A key-based distribution strategy assigns each message to a partition according to its key. Messages sharing a key remain in the same partition, preserving their relative order while allowing different keys to be processed across partitions. section 4.2.1
Product-price updates
Produce records such as `coffee pads:10`, `cola:2`, and `energy drink:3` with key parsing enabled. Consume them with key printing enabled to verify that repeated keys, such as `coffee pads`, stay together even though records appear in a different overall order. section 4.2.1
Plan for distribution before choosing keys:
- Prefer many keys, such as customer IDs, when traffic is broadly distributed. section 4.2.1
- Watch for a few high-traffic keys, because they can overload individual partitions and brokers. section 4.2.1
