Architecture
KafScale brokers are stateless pods on Kubernetes. Metadata lives in etcd, while immutable log segments live in S3. Clients speak the Kafka protocol to brokers; brokers flush segments to S3 and serve reads with caching.
Platform overview
Architecture overview
Produce flow
Write path
Producers send records to brokers. Brokers validate, batch, and assign offsets. When the buffer reaches 4MB or 500ms, it’s sealed and flushed to S3 as an immutable segment.
Fetch flow
Read path
Consumers request data from brokers. Brokers resolve the segment offset, check the LRU cache, and fetch from S3 on cache miss. Read-ahead prefetches likely-needed segments.
Segment format
Field
Size
Description
Magic Number
4 bytes
0x4B414653 ("KAFS")
Version
2 bytes
Format version (currently 1)
Flags
2 bytes
Compression codec, etc.
Base Offset
8 bytes
First offset in segment
Message Count
4 bytes
Number of messages
Created Timestamp
8 bytes
Unix milliseconds
Message Batches
variable
Kafka-compatible RecordBatch format
CRC32
4 bytes
Checksum of all batches
Footer Magic
4 bytes
0x454E4421 ("END!")
Key design decisions
| Decision | Rationale |
|---|---|
| S3 as source of truth | 11 9’s durability, infinite capacity, $0.023/GB |
| Stateless brokers | Any pod serves any partition; HPA scales 0→N |
| etcd for metadata | Leverages existing K8s etcd or dedicated cluster |
| ~500ms latency | Acceptable trade-off for ETL, logs, async events |
| No transactions | Simplifies architecture for 80% use case |
| 4MB segments | Balances S3 PUT costs vs. flush latency |