Scrivio Interview library
DesignAdvanced6 min read · updated 13 November 2026

Three consumer groups with very different jobs must keep up with one of the busiest topics in a cluster spread over three availability zones.

Design the consumer side for a topic carrying 1.5 GB/s of compressed data read by three consumer groups (a real-time enrichment service, a lake loader and a search indexer) in a three-zone cluster. How many consumers per group, which fetch settings, and which limits will you hit first?

Try it yourself

Consumer group: who reads which partition

Change the number of partitions and consumers, and see who owns what, who is idle, and where ordering holds.

Read this example as text

Who reads which partition

  1. 3 partitions, 2 consumers. C0 reads P0, P1; C1 reads P2.
  2. 4 partitions, 2 consumers. C0 reads P0, P1; C1 reads P2, P3.
  3. 3 partitions, 3 consumers. C0 reads P0; C1 reads P1; C2 reads P2.
  4. 6 partitions, 4 consumers. C0 reads P0, P1; C1 reads P2, P3; C2 reads P4; C3 reads P5.
  5. 2 partitions, 4 consumers. C0 reads P0; C1 reads P1; C2 is idle; C3 is idle.

A partition has exactly one reader in the group. A consumer beyond the number of partitions is idle.

Six records with 3 partitions and 2 consumers

  1. Record A1. Key A goes to P0, read by C0.
  2. Record B1. Key B goes to P1, read by C0.
  3. Record A2. Key A goes to P0, read by C0.
  4. Record C1. Key C goes to P2, read by C1.
  5. Record B2. Key B goes to P1, read by C0.
  6. Record A3. Key A goes to P0, read by C0.

A1, A2 and A3 sit in one partition and are read in that order. Nothing orders a record in one partition against a record in another.

What this example leaves out
  • One topic, and Kafka's range assignor, the first in the default list. Other assignors spread partitions differently.
  • A, B and C stand for key hashes 0, 1 and 2. The real client hashes the key bytes; the rule shown, same key to the same partition, is the same.
  • A rebalance is shown as instant. In a real group, consumers stop briefly while partitions move.

Size each group from measured per-consumer throughput, usually limited by decompression, deserialisation and the sink: at 50 MB/s per consumer, 1.5 GB/s needs about 30 consumers per group and at least that many partitions, more for catch-up headroom. Three groups read 4.5 GB/s from brokers on top of produce and replication traffic, so broker network is the first limit; follower fetching with client.rack spreads reads and avoids cross-zone transfer. Tune the real-time group for latency and the lake loader and indexer for large fetches, put byte-rate quotas on the bulk groups, and plan capacity so each group can clear a one-hour backlog of about 5.4 TB.

Why this question is asked

A topic at 1.5 GB/s is big enough that every per-byte cost becomes a capacity question: client CPU, broker network cards and cross-zone transfer bills. Interviewers ask this design question to see whether we reason from numbers, notice that every consumer group multiplies broker reads, and protect a latency-sensitive group from bulk readers. In this answer, we will recap the constraints, size the groups, account for broker load and zones, choose fetch settings per group, add quotas, and plan for catch-up.

1A Quick Recap of the Constraints

A consumer group spreads a topic's partitions over its members, and each partition is read by one member, so a group can never use more consumers than there are partitions. Every group reads the full topic independently, so three groups mean three full copies of the read traffic. And in a three-zone cluster, each partition's leader lives in one zone, so by default two thirds of consumers read from a leader in another zone, paying cross-zone latency and, in most clouds, a transfer charge per gigabyte.

2Sizing Each Group

The number of consumers comes from measured throughput per consumer, not from the topic rate alone. For compressed data, a consumer's throughput is usually limited by CPU for decompression and deserialisation, and by the sink it writes to. Suppose a load test shows 50 MB/s of compressed input per consumer for each of the three jobs.

Java
topic rate (compressed) 1.5 GB/s = 1,500 MB/s
measured per consumer 50 MB/s
consumers per group, steady 1,500 / 50 = 30
with 2x catch-up headroom 60 consumers
partitions at least 60; for example 96, so groups can grow
broker egress for consumers 3 groups x 1.5 GB/s = 4.5 GB/s

Notice that partitions are the ceiling on parallelism, so we choose them for the headroom we want, not the steady state. 96 partitions let any group scale to 96 consumers. Each group can also measure differently: the indexer may manage only 30 MB/s per consumer if the search cluster is slow, which would mean 50 consumers in steady state.

3Broker Load and the Three Zones

Add up the broker traffic. Producers write 1.5 GB/s. With replication factor 3, followers copy another 3 GB/s between brokers. The three groups read 4.5 GB/s. That is 9 GB/s of traffic, most of it outgoing from brokers, and this is usually the first limit we hit: broker network interfaces, before disks or CPU.

Follower fetching helps twice. With the broker setting replica.selector.class=org.apache.kafka.common.replica.RackAwareReplicaSelector, each broker's broker.rack set to its zone, and each consumer's client.rack set to its own zone, consumers read from a replica in their own zone instead of always from the leader. Reads spread over all three replicas rather than piling on leaders, and cross-zone transfer for consumers drops to almost nothing, which at 4.5 GB/s is a large monthly cost. The trade-off is slightly higher end-to-end latency, because a follower serves data only once it has replicated it.

Step throughTraffic on the cluster
  1. Producers1.5 GB/s into leaders
  2. Replication3 GB/s leader to followers (RF 3)
  3. Real-time enrichment group1.5 GB/s, same-zone replicas via client.rack
  4. Lake loader group1.5 GB/s, quota-limited during catch-up
  5. Search indexer group1.5 GB/s, quota-limited during catch-up

5 layers, from the top down. Step through them one at a time.

9 GB/s in total: broker network is the first ceiling, so reads are spread over replicas and zones.

4Fetch Settings per Group

The groups want different things. The real-time enrichment service cares about latency, so it keeps fetch.min.bytes small (the default 1 byte, or a few KB) and fetch.max.wait.ms short, around 100 ms, and keeps max.partition.fetch.bytes near the 1 MB default. The lake loader and the indexer batch their writes anyway, so they ask for big responses: fetch.min.bytes of about 1 MB, fetch.max.wait.ms of 500 ms, and max.partition.fetch.bytes of a few MB, which cuts the number of fetch requests and broker CPU per byte.

Bigger fetches cost memory, roughly partitions per consumer times max.partition.fetch.bytes in the worst case, so with about three partitions per consumer a few MB per partition is safe.

Fetch settings by group
SettingReal-time enrichmentLake loader and indexer
fetch.min.bytes1 byte to a few KBabout 1 MB
fetch.max.wait.msabout 100 ms500 ms
max.partition.fetch.bytes1 MB (default)4 MB to 8 MB
client.rackown zoneown zone
Quotanoneconsumer byte-rate quota

5Quotas and Catch-Up

After an outage, the bulk groups will try to read as fast as possible. Without limits, the lake loader and indexer catching up at 3 GB/s each could saturate broker networks and push the real-time group's latency up exactly when the business is recovering. Consumer byte-rate quotas, set per client id or user with kafka-configs.sh, cap each bulk group's read rate, for example at 2.5 GB/s per group, leaving room for the real-time group.

Now the catch-up arithmetic. A one-hour outage leaves 1.5 GB/s times 3,600 s, about 5.4 TB, per group to clear. If a group can read at twice the normal rate, 3 GB/s, its surplus over the incoming 1.5 GB/s is 1.5 GB/s, so clearing 5.4 TB takes another hour. If that is too slow, the group needs more headroom, and the brokers need the network capacity to serve it. Topic retention must comfortably exceed the longest outage we plan for, so the backlog is still there to read.

6Follow-up questions

Which limit will we hit first?

Usually broker network egress, because reads multiply with each group and replication doubles the write traffic. Next comes consumer CPU for decompression and deserialisation, then the sinks: the search cluster's indexing rate often limits the indexer before Kafka does. Measuring each in a load test tells us the actual order for our hardware.

Should the real-time group also use follower fetching?

Usually yes, for cost and to spread load, but followers serve records only after they have replicated them, adding a little latency. If the real-time group has a very tight latency target, we can let it read from leaders and keep follower fetching for the bulk groups.

7Conclusion

In this answer, we sized three consumer groups for a 1.5 GB/s topic from measured per-consumer throughput: about 30 consumers per group at 50 MB/s, with partitions chosen for catch-up headroom. Three groups mean 4.5 GB/s of reads on top of produce and replication, so broker network is the first limit, and follower fetching with client.rack spreads reads and avoids cross-zone transfer. The real-time group is tuned for latency and the bulk groups for large fetches, quotas keep catch-up from starving the real-time group, and a one-hour outage means about 5.4 TB per group to clear.

What to say in the interviewAbout 80 seconds aloud

Open with

I would size from measurement, not from the topic rate. In a load test I measure what one consumer can do for each job, because decompression, deserialisation and the sink usually limit it.

Then, if they want more

Say it is 50 megabytes a second; then 1.5 gigabytes a second needs 30 consumers per group, and I want twice that for catch-up, so at least 60 partitions, probably 96 so groups can grow. Then broker load: three groups read 4.5 gigabytes a second, on top of 1.5 in and 3 more for replication at factor three.

Broker network is the first wall. I would enable follower fetching: rack-aware replica selector on the brokers, broker.rack per zone, client.rack on each consumer, so reads come from a same-zone replica, which spreads load and removes most cross-zone transfer.

Fetch settings differ by group: the real-time group keeps fetch.min.bytes tiny and fetch.max.wait.ms around 100 milliseconds, while the lake loader and indexer use about a megabyte minimum, 500 milliseconds, and a few megabytes per partition. I would put byte-rate quotas on the two bulk groups so their catch-up after an outage cannot starve the real-time group.

And I would plan catch-up explicitly: one hour down is about 5.4 terabytes per group, and at twice normal speed that takes another hour to clear.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design the consumer side for a topic carrying 1.5 GB/s of compressed data read by three...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-clients-in-depth/295daee1bc/