KatInterview

Build a Weighted Traffic Splitter for Multi-Backend Log Pipelines

System DesignModel answer
MediumModel answerSystem Designsystem-designkafkaload-balancing

Last updated

Design a scalable service that takes logs from many services and splits them across storage backends by live-adjustable percentages, surviving backend outages without losing data.

Scenario

Many microservices emit logs continuously. Your job is to design a platform that receives these logs and forwards each one to one of several storage destinations, such as object storage buckets, search clusters, or local disks. The share of traffic each destination receives is controlled by operator-defined percentages that are set per source service. For example, 70% of Service A's logs go to Cluster X and 30% go to Cluster Y.

Functional requirements

  • Live reconfiguration: Operators can change the percentages while the system is running, with no downtime and no restart.
  • Even spread: Load is distributed so that no single destination, or node inside a destination, becomes a hotspot.
  • Resilience to outages: If a destination cannot be reached, its logs are buffered or redirected to a healthy destination. No data may be lost.

Non-functional requirements

  • Throughput: 100,000 events per second on each node.
  • Latency: Ingestion completes in under 50 ms.
  • Scalability: Capacity grows horizontally as log volume grows.

What to deliver

  1. A high-level architecture covering how logs are received, routed, and persisted.
  2. Your choice of storage for the routing percentages, with justification.
  3. How the system handles a slow or unavailable destination (backpressure and outages).
  4. The API used to manage routing rules.

State any assumptions you make (event size, delivery guarantee, ordering, and what exactly the latency target measures), and size the system with a quick back-of-envelope estimate.

Hints

Hint 1

Pin down what the 50 ms target actually covers. A durable acknowledgement to the sender is achievable; being searchable in a downstream store is not. This decides where a durable log or queue must sit in the design.

Hint 2

Separate the pipeline into stages joined by a durable, replayable buffer: receive, route, then write to each destination. Give each destination its own queue so a slow one cannot stall the others.

Hint 3

The routing config is tiny and read constantly, but must change instantly. Think about a consistent store with a push/watch mechanism, and about routers that keep serving their last known config if that store goes down.

Hint 4

At-least-once delivery means duplicates. Plan for idempotent writes using a stable event ID or deterministic object names. Also decide, per rule, whether an outage should lead to waiting (buffering) or to reweighting across healthy destinations.