Copartitioning arranges input topics for reliable stream joins: every topic uses the same partition count, key distribution strategy, and partitioning logic. Records with the join key then reach partitions with the same index and are processed by the same Kafka Streams task. section 8.3.6
Orders and payments
To join orders with payments, both topics must use the same number of partitions and the same key, such as orderId. If payments use paymentId, selectKey can change the payment key to orderId before joining. section 8.3.6
Design checks for copartitioned topics:
- Match the partition count across all input topics. section 8.3.6
- Use the join attribute as the key and apply the same partitioner. section 8.3.6
- Treat key-distribution correctness as an application responsibility because Kafka Streams does not validate it at runtime. section 8.3.6
Figure 8.14 When the Payments and Orders topics are joined, they must have the same number of input partitions and the same key (orderId).
Shows the aligned partition counts and shared orderId key required when joining Payments and Orders. section 8.3.6

