System design · 5 of 16
Mid
Senior
- Monitoring and alerting for 100 servicesSRE · Platform · DevOps
- Secrets management platformDevOps · Platform · SRE
- Multi-region active-active serviceSRE · Platform
- Distributed job scheduler (cron at scale)SRE · Platform
- Internal developer platform (IDP)Platform
- Multi-tenant Kubernetes platformPlatform · DevOps · SRE
- GitOps for a fleet of 100 clustersPlatform · DevOps
- ML training platform and feature storeMLOps · Platform
- LLM inference platformMLOps · Platform · SRE
MID · 12 MIN · SRE · DEVOPS · PLATFORM
Centralized logging pipeline
Agents on every node, a Kafka buffer, processing that redacts and routes, hot search for days and cheap archives for months.
- Peak load
- 100 MB/s ingest
- Availability target
- 99.9% (ingest)
- RTO: back up within
- 1 hour (search)
- RPO: data you can lose
- < 1 min
← Swipe sideways to see the whole diagram →
The question
"Design a logging system that collects logs from thousands of containers, lets engineers search recent logs quickly, and keeps older logs cheaply."
Requirements
- Collect stdout and log files from every pod and server.
- Search the last 7-14 days in seconds; keep 1 year for audits.
- Never lose logs during spikes or when the search cluster is slow.
- Remove secrets and personal data before storing.
Quick numbers
| Item | Assumption | Result |
|---|---|---|
| Ingest | 2 TB per day | ~25 MB/s average, ~100 MB/s peak |
| Hot storage | 14 days, 1 replica, compressed ~3x | ~19 TB |
| Archive | 1 year in S3, compressed ~8x | ~90 TB, cheap |
How it works
- A Fluent Bit DaemonSet on each node tails container logs, adds Kubernetes labels (namespace, pod, app) and batches them.
- Batches go to Kafka, a buffer that absorbs spikes and lets the search cluster fall behind without losing data.
- Processors (Logstash, Vector or Fluentd) parse JSON, redact secrets and emails, drop debug noise, and route by team.
- Recent logs go to OpenSearch (hot, searchable). All logs also go to S3 in compressed files, queryable with Athena when needed.
- Index lifecycle policies roll indexes daily and delete them after 14 days.
Think of it like: a post office. Agents are the post boxes, Kafka is the sorting warehouse that never turns letters away, processors stamp and sort them, OpenSearch is the front desk for recent mail, and S3 is the long-term archive.
Key decisions
| Decision | Choice | Why |
|---|---|---|
| Buffer | Kafka | decouples producers from storage; replays after failures |
| Structure | JSON logs with standard fields | fast, reliable search and dashboards |
| Hot vs cold | 14 days searchable, 1 year archive | balances speed and cost |
| Cheaper option | Loki instead of OpenSearch | indexes labels only; much cheaper, slower full-text search |
What breaks and how it heals
- Search cluster down: Kafka keeps data (set retention to 1-3 days); consumers catch up after.
- Log spike from a crash loop: per-namespace rate limits in the agent so one app can't flood everyone.
- Agent falls behind: monitor its buffer and dropped-records metrics.
High availability and disaster recovery
| Target | Number | How it is met |
|---|---|---|
| Ingest availability | 99.9% | agents buffer up to ~1-2 GB per node on disk if Kafka is unreachable |
| Kafka broker fails | no loss | replication factor 3, min.insync.replicas=2, brokers in 3 AZs |
| Search cluster down for 3 days | no loss | Kafka keeps 72 hours of logs; processors catch up afterwards |
| Search cluster lost | RTO ~1 hour | 3 dedicated master nodes, 1 replica per shard across AZs, hourly snapshots to S3 |
| Data loss (RPO) | under 1 minute | only what sits in an agent's memory buffer on a node that dies |
| Audit archive | can't be deleted early | S3 Object Lock (write once, read many) for 1 year |
What interviewers listen for
- A buffer between collection and storage, and back-pressure handling.
- Hot/cold tiers with real cost numbers.
- Redaction of secrets and PII, and per-tenant limits.