Skip to content

Interview PrepCase studies · Advanced

Platform Designs ​

31. How would you design a centralized logging system? ​

The short answer

Every service writes structured JSON logs to stdout. An agent on each node, such as Fluent Bit, Vector or the OpenTelemetry Collector, tails them, adds metadata like service, pod and region, and sends batches to a buffer, usually Kafka, so spikes and storage outages do not lose logs. Indexers consume from the buffer and write to a searchable store, such as Elasticsearch, OpenSearch or Loki, split into time-based indices with hot, warm and cold tiers and retention by log type. A query UI searches by trace ID, service, level and text. Redact secrets at the source and control who can read which logs.

servicesJSON to stdoutnode agentenrich, batchKafkabufferindexershot store7 days, fastcold, object storage90 days, cheapquery UI, alerts
Collect, buffer, index, age out. The buffer keeps logs safe during spikes or when the store is slow. Recent logs stay in fast storage for investigations; older ones move to cheap storage for compliance.

Estimates: 500 services, 2 million log lines per second at 500 bytes ≈ 1 GB per second ≈ 86 TB a day raw. Compression of 5 to 10 times and sampling of noisy debug logs bring it down a lot, and retention tiers decide the cost.

Deep diveDesign
Volume and costSample debug logs; drop health-check noise at the agent; short hot retention
SearchIndex common fields such as service, level and trace ID; full-text only where needed
CorrelationTrace ID on every line (correlation IDs)
Back-pressureAgents buffer to disk; Kafka absorbs bursts
SecurityRedaction at the source; access per team; audit logs kept separately (audit logging)

32. How would you design a monitoring system? ​

The short answer

Services expose metrics, counters, gauges and histograms with labels such as service and route, which are scraped by Prometheus-style collectors or pushed through the OpenTelemetry Collector into a time-series database built for many writes and range queries. Recording rules precompute common aggregates. An alerting engine evaluates rules, especially SLO burn-rate rules, every minute and routes alerts by severity and owner to paging, chat or tickets, with grouping and silences. Dashboards show golden signals. Watch label cardinality: a label such as user ID can create millions of series and break the system.

PartDesign
CollectionPull scraping every 15 to 30 seconds; push for short-lived jobs
StorageTime-series database; downsample old data, such as 1-minute points after 30 days
ScaleShard by metric or tenant; long-term storage in object storage
AlertsSLO burn rates on user-facing symptoms; each with an owner and runbook (alerting)
RoutingCritical to paging, warnings to chat, the rest to tickets; deduplicate and group
Meta-monitoringA separate, simple check that the monitoring system itself is alive

Cardinality, with numbers. A metric labelled by 50 routes, 5 status codes and 20 instances is 5,000 series, which is fine. Add a user_id label with a million users and it becomes 5 billion series, which no system will hold. Put per-user detail in logs or traces, not metric labels.

33. How would you design distributed caching? ​

The short answer

Layer it: a CDN for public responses, a small in-process cache for the hottest keys, and a shared Redis cluster with replicas as the main cache, using cache-aside with TTLs and invalidation driven by database change events. Design keys with versions and tenant IDs, protect the database from stampedes with single-flight rebuilds and jittered TTLs, handle hot keys with local copies, and treat the cache as optional, with timeouts and a fallback when Redis is unavailable. Measure hit rate, latency and evictions.

The complete design, with a diagram and the numbers that justify it, is in designing distributed caching. The building blocks are cache-aside, TTLs, Redis Cluster and stampedes.

34. How would you design a backend that handles millions of requests reliably? ​

The short answer

Start with the numbers: a million requests a day is about 12 per second; a million per minute is about 17,000 per second, which needs real scale. Either way the shape is the same: stateless services autoscaled across zones behind load balancers; a CDN and caches absorbing most reads; a well-indexed database with replicas, partitioned only when writes demand it; queues for slow and bursty work; timeouts, retries with budgets, circuit breakers and rate limits everywhere; idempotent writes; safe deploys with rollback; and SLO-based monitoring. Reliability comes from removing single points of failure and planning for each dependency failing.

LayerAt 17,000 requests per second
EdgeCDN serving most public reads; WAF and rate limits
API20 to 40 stateless instances across 3 zones, autoscaled on CPU and latency
CacheRedis cluster; 90%+ hit rate keeps the database near 1,700 per second
DatabasePrimary plus replicas; reads on replicas; pooled connections through PgBouncer
AsyncQueues for notifications, exports, search indexing
ResilienceTimeouts, breakers, bulkheads, load shedding (resilience)
OperationsCanary deploys, error-budget alerts, runbooks, game days

The single-region version for one million requests a day is worked through in handling a million requests a day.

Combine chapters into one PDF

Pick the chapters you want. They print in the order you pick them.

Interview Prep
System Design
The method
Case studies
Auth designs
Scenarios
Other topics
Nothing picked yet