Skip to content

Reduce producer lookups and connections in partitioned producers #11496

Closed

Description

@Vanlightly

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

  1. added
    type/enhancement
    on Jul 29, 2021
  2. equanz commented on Aug 4, 2021

    @equanz
    Contributor

    I have published similar solution in the PIP-79. If so, could you please review or discuss it in the PR?

  3. Vanlightly commented on Aug 5, 2021

    @Vanlightly
    ContributorAuthor

    @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.

  4. added a commit that references this issue on Aug 16, 2021
    9577b84
  5. added a commit that references this issue on Sep 10, 2021
    649e15a
  6. added a commit that references this issue on Mar 18, 2022
    ad6c2bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions