KatInterview

Design a Centralized Log Aggregation Platform

System DesignModel answer
HardModel answerSystem Designloggingobservabilitydistributed-systems

Last updated

Design a high-throughput internal logging platform that ingests, indexes, and retains logs from thousands of services with near-real-time search and strict tenant isolation.

The Problem

Your organization runs thousands of services across virtual machines, containers, and serverless functions. Right now every team manages logs differently — some stream to local files, some push to ad-hoc dashboards, and on-call engineers spend the first ten minutes of every incident just finding the right logs. You've been asked to design an internal, self-hosted log aggregation platform that every team can ship logs to and query from.

Think of it as the platform behind tools like the ELK stack, Splunk, or Datadog Logs — but you own the infrastructure.

What the system needs to do

  • Ingest log events from a wide variety of sources: different languages, different runtimes, different environments. Agents on hosts, sidecars in containers, and SDK-level emitters in serverless functions all need to get data in.
  • Search and filter logs interactively: by service name, host, severity, time range, and free-text message content. Engineers debugging an incident need answers in seconds, not minutes.
  • Enforce retention tiers: for example, logs are fully searchable for 7 days, archived but retrievable for 90 days, then permanently deleted. Teams should be able to configure their own retention windows within platform limits.
  • Absorb bursty write load: during incidents, retry storms, or deployment failures, write volume can spike dramatically. The system must not drop data under these conditions.
  • Isolate tenants: different teams share the same platform, but one team's spike must not degrade another team's query experience or ingest reliability. Tenant data must be logically (and where required, physically) separated.

Constraints and scale assumptions

Nail down your numbers early — they drive every architecture decision.

  • Around 10,000 hosts, each emitting roughly 100 events/second at baseline. That's on the order of 1 million events/second steady-state, spiking to 5–10 million events/second during major incidents.
  • Average event size after enrichment: ~1 KB. That's roughly 1 GB/s ingest, or ~86 TB/day of raw log data.
  • Ingest-to-searchable latency: a few seconds end-to-end is acceptable.
  • Query latency: sub-second to a few seconds for a filtered query over the hot (fully searchable) window.
  • Logs are append-only and immutable. There are no per-record updates or deletes — only bulk expiry when a retention window closes.
  • At-least-once delivery is acceptable. Small windows of duplication and minor out-of-order events are tolerable; data loss is not.

What you're expected to cover

Walk through the full design. A strong answer will address:

  1. Requirements — Functional and non-functional, with explicit non-goals (e.g., metrics, traces, alerting engine).
  2. Scale sizing — Back-of-envelope math that turns the numbers above into concrete storage, throughput, and partitioning requirements.
  3. Architecture — End-to-end data path from agent to queryable store. Name each stage, describe its role, and justify why it belongs there.
  4. Data model and indexing — What a canonical log event looks like, how you index it for fast filtered and full-text search, and how you prevent indexing pathologies like cardinality explosions.
  5. Partitioning and scaling — How you shard the ingestion pipeline and the storage layer, and how you handle hot-partition and query fan-out problems.
  6. Reliability and delivery semantics — How the system behaves when agents crash, brokers lose a node, or the search cluster is slow. Where exactly do you make durability guarantees?
  7. Multi-tenancy and security — How tenant isolation is enforced, how quotas and rate limits work, and how PII is handled.
  8. Cost and operational trade-offs — Storage tiering strategy, the cost/latency/durability knobs you'd expose, and what you'd instrument to know the system is healthy.

Clarifying questions you should raise

Before diving into architecture, a strong candidate asks:

  • What is the burst multiplier we need to absorb without dropping events?
  • Is full-text search on message bodies a hard requirement, or are structured field filters sufficient? (This changes the hot-store technology choice significantly.)
  • What are the compliance requirements — PII redaction, data residency, immutability for audit logs?
  • How many tenants, and how skewed is their volume distribution? A few high-volume teams or hundreds of roughly equal ones?
  • Is exactly-once delivery required anywhere, or is at-least-once with idempotent reads acceptable throughout?
  • Is the budget posture cost-optimized (aggressive tiering, sampling) or latency-optimized (long hot window)?

Hints

Hint 1

Start with the durable buffer between ingest and storage — it's the single component that decouples write spikes from the search cluster and is the foundation of your reliability story. Justify your choice of partition key and explain its ordering trade-off.

Hint 2

Think carefully about what 86 TB/day means for your hot store. A 7-day hot window is ~600 TB. Time-bucketed indices let you enforce retention by dropping an entire index rather than running deletes — that's both operationally simpler and dramatically cheaper.

Hint 3

Multi-tenancy is not just a query filter. You need server-side tenant resolution (agents cannot self-declare their own tenant), per-tenant write quotas enforced before the broker, and a mandatory tenant filter injected at query time. Trace through what happens when a tenant exceeds their quota.