KatInterview

Build a Fleet-Wide Log Search Platform at 100K Lines/Second

System DesignModel answer
MediumModel answerSystem Designsystem-designlog-pipelinekafka

Last updated

Design a platform that collects logs from many microservices, keeps them for 30 days, and supports fast searches by service, time window, and text or regex pattern.

Design a Fleet-Wide Log Search Platform

Your company runs hundreds of microservices, and engineers currently SSH into hosts to read logs. Design a central platform that gathers logs from every service and lets engineers search them quickly.

Functional requirements

  • Collection: services (directly or through a host agent) send log lines to the platform through a shared interface.
  • Search: users can filter by service name and time range, and match on keywords or regular expressions.
  • Retention: every log line stays searchable for 30 days, then is removed.

Non-functional requirements

  • Throughput: sustain 100,000 log lines per second.
  • Query speed: searches should return within a few seconds.
  • No loss after acknowledgment: once the collection endpoint confirms a log line, it must never be lost.

What to cover

  • Capacity estimates (volume per day, storage for the retention window).
  • The write path from service to durable storage, including the API contract.
  • Storage layout and schema.
  • Indexing approach and why you chose it over alternatives.
  • The read path for a search query.
  • How the system behaves during traffic bursts and when downstream components fail.
  • Trade-offs and what you would improve with more time.

Hints

Hint 1

Start with numbers: lines per second times average line size gives bytes per second, per day, and over 30 days. Notice that writes vastly outnumber reads, and ask how that should shape your indexing choice.

Hint 2

Compare indexing every word (inverted index) with indexing only a few low-cardinality labels such as service and level, then scanning matching data on demand. Think about index size, write cost, and how each handles regex.

Hint 3

For durability, decide exactly when the ingestion endpoint may say 'accepted', and make downstream consumers safe to retry. For bursts, think about a replicated log or queue that decouples producers from the storage writers.

Hint 4

Retention is easiest when stored data is immutable and organized by time. Consider how that makes deletion a simple lifecycle rule rather than a compaction job.