One customer generates a third of your traffic and you key by customer. How do you keep the partition from falling behind?
Sketch your own answer first, then compare it with the one below.
A strong answer
A key maps to one partition and a partition has one reader in the group, so neither more partitions nor more consumers helps a single key. The options all trade order for balance.
Add a salt to the key for the big customer, such as a small random suffix, so its traffic spreads over several partitions. Order then holds only within each suffix. Or split by a finer key, like the customer plus the entity inside it. Or make that consumer faster by batching, or by moving heavy work to a separate pool.
Ask what ordering the customer really needs. It is often per entity and not per customer. And measure first rather than assume the cause.
Sources
- Jay Kreps, Neha Narkhede, Jun Rao (2011). Kafka: a distributed messaging system for log processing.
- Martin Kleppmann (2017). Designing Data-Intensive Applications.