Repository navigation
Description
Is your enhancement request related to a problem? Please describe.
Producers that send messages to partitioned topics start a producer per partition, even when using single partition routing. For topics that have the combination of a large number of producers and a large number of partitions, this can put strain on the brokers. With say 1000 partitions and single partition routing with non-keyed messages, 999 topic owner lookups and producer registrations are performed that could be avoided.
Describe the solution you'd like
Option 1 - Strict Single Partition Routing
The problem is that we have no way of knowing which partitions will be involved upon producer creation, even when using Single Partition routing. The problem with this is that the user code can still use keyed messages which may then involve more than one partition.
Solution: offer a strict single partition routing mode where we guarantee that all messages will only be sent to a single partition, keyed or not. This would allow us to only start a single producer on the creation of the partitioned producer.
Option 2 - Lazy Producer Start
Allow for producers in the partitioned producer class to be started lazily, upon the first message being sent to their particular partition. This would be controlled via a new producer configuration as this behaviour only benefits those who:
- have topic with a large number of partitions in a topic
- single partition routing is used
- messages are non-keyed
- potentially have a large number of producers to the topic
Messages will be buffered while the connection to the topic owner is carried out.
The downside is that there will be extra latency on the first messages being published. The send timeout timer is only started once the producer is connected so this means that timeouts should not trigger. Only if the send timeout is set very low and the number of pending messages is high might we typically see send timeouts because of this change.
Describe alternatives you've considered
Just option 1 and 2.
I have an implementation of lazy producer start for the C++ client in case option 2 is preferred. I can contribute the work to both Java and C++ clients whether it is ultimately option 1 or 2 that we select.
Activity
equanz commentedon Aug 4, 2021
I have published similar solution in the PIP-79. If so, could you please review or discuss it in the PR?
Vanlightly commentedon Aug 5, 2021
@equanz I have created an MR with my C++ changes, which are very similar to your Java client changes and fall nicely inside your PIP (its a subset of the PIP). Some differences, such as allowing lazy producers to be configurable, and how the lazy start is kicked off.
[Issue 11496][C++] Allow partitioned producers to start lazily (#11570)
[Issue 11496][C++] Allow partitioned producers to start lazily (#11570)
[Issue 11496][C++] Allow partitioned producers to start lazily (apach…