WAL-Backed Batched Log-Writing System
Design a partitioned network service that acknowledges log batches through a replicated write-ahead log and asynchronously publishes immutable storage segments.
Problem statement
For this exercise, assume producers send opaque records to a regional, multi-tenant log-writing service. Streams and partitions are pre-provisioned. A producer appends an ordered batch of at most 1,000 records and 1 MiB to one partition, supplying a producer ID and request ID. The partition assigns one contiguous offset range and reports committed only after the append is durably present in a quorum of a three-replica write-ahead log across availability zones. A retry of the same producer and request ID with the same payload must return the original offset range; reusing that identity with different bytes is a conflict. Ordering is defined within a partition, not across partitions. Background workers batch committed WAL entries into immutable segments of at most 128 MiB in object storage, atomically publish segment manifests, and truncate WAL data only after the corresponding segment and manifest are durable. Every acknowledged record must survive leader or process failure; an unacknowledged request may already be committed, so clients can retry or query its status. Assume 100,000 records per second per region, 500-byte average records, 100 millisecond p95 append acknowledgement, 99.95 percent monthly write availability, and seven days of segment retention. Apply bounded backpressure when replication, local WAL capacity, or segment publication falls behind. Consumer delivery, search, indexing, record interpretation, cross-region replication, and exactly-once downstream effects are outside scope.
What to build
- A producer can append a bounded ordered batch to one stream partition and receive its contiguous offset range after quorum WAL commit.
- A producer can safely retry an uncertain append or query its request identity and converge on the sole committed offset range.
- The service batches committed WAL entries into immutable durable segments and publishes one authoritative partition manifest without losing acknowledged records.
- The service recovers committed partition state after failure and applies explicit bounded backpressure before WAL or replication safety is exhausted.
At scale
- For this exercise, support 100,000 opaque records per second per region with an average record size of 500 bytes.
- For this exercise, one append contains at most 1,000 records and 1 MiB, while one immutable storage segment contains at most 128 MiB.
- For this exercise, target 100 milliseconds p95 for quorum-committed append acknowledgement and 99.95 percent monthly write availability.
- For this exercise, use three availability-zone replicas per partition and retain published segments for seven days.