Video in progress

How do you plan the capacity of a new Kafka cluster?

I calculate disk, network and broker count from the incoming traffic, replication factor, retention and the number of consumers, then check that the remaining brokers can carry the load when one is lost. Often the bottleneck is the network, not the disk.

📖 Answer

Let me work through an example. Ingress: 100 MB/s at peak (compressed), RF=3, retention 7 days, and each topic is read by an average of 3 consumer groups.

Disk: 100 MB/s × 86400 × 7 × 3 ≈ 181 TB. Average traffic will be below the peak, but I leave headroom: disks shouldn't go above 60-70%. With 6 brokers, that's ~40 TB each.

Network (inbound to the brokers): 100 MB/s from producers + 200 MB/s replication = 300 MB/s total, ~50 MB/s per broker across 6. Network (outbound): consumers 3 × 100 = 300 MB/s + replication 200 MB/s = 500 MB/s, ~85 MB/s per broker. A 10 Gbit card (~1.2 GB/s) is enough, but cross-AZ traffic costs money; count that separately in the cloud. Follower fetching (client.rack) lets consumers read from a replica in their own zone and cuts this cost.

Failure margin: if one broker dies, its load is spread over the other 5, and when it comes back it has to catch up on replicas, which is extra traffic. I aim to stay under 60% even in the N-1 state.

Memory: the heap doesn't need to be big (6-8 GB); the rest is page cache. If consumers read the "tail", they never go to disk. If many consumers re-read old data, disk IO jumps sharply; I account for that as a scenario too.

Partitions: keep the number of leaders and replicas balanced on each broker; Cruise Control automates this.

The calculation is a starting point. Then you test with kafka-producer-perf-test and a real load profile, and re-evaluate every 3-6 months. If you have tiered storage, the disk math changes sharply: locally only the last few hours.