The Payment Pipeline and Its Partition Count

Design a fintech payment pipeline handling 500,000 events/sec at peak. Every decision — partition count, replication factor, acks, consumer config, exactly-once scope, failover behavior — must be justified. Work through each section before checking the reference.

Scenario and Requirements

Topic Partition Count

DimensionAnswer
Partition count32–64 partitions
RationaleEach partition can handle ~10–50 MB/s or ~10k–50k msg/s. At 500k msg/s peak, need at minimum 10–50 partitions. Round up to power of 2, add 20% headroom → 32–64.
Consumer parallelismOne consumer per partition per group at most. 32 partitions allows up to 32 consumer instances in each group.
Risk of too manyEvery partition costs the cluster something: open files on disk, and an entry the controller (ZooKeeper or KRaft) has to track. When a broker dies, a new leader must be picked for each of its partitions — so more partitions means a longer outage while that happens.
Rough safe limit per broker: 2,000–4,000 with ZooKeeper; 10,000+ with KRaft.
Risk of too fewTwo hard caps you can't get past later without repartitioning:
1. Consumers: each partition goes to only one consumer in a group, so 32 partitions = at most 32 busy consumers. Adding a 33rd does nothing.
2. Throughput: think of each partition as one checkout lane. One lane has a fixed speed (say 20 MB/s), and the topic's total speed is all lanes added up: 10 partitions × 20 MB/s = 200 MB/s max. Adding brokers doesn't help, because Kafka never splits a partition across brokers, so the new brokers just sit idle for this topic. The only way to go faster is more partitions.

ceil(max(peak_throughput / per_partition_throughput, peak_throughput / per_consumer_throughput)) → round up to power of 2 → add 20% headroom

The second term matters when consumers are slower than the broker — often the case. See Throughput Limits: Partitions, Brokers and Fan-Out.