Skip to content

Conversation

domodwyer
Copy link
Contributor

@domodwyer domodwyer commented Aug 11, 2022

This exposes a method that can be used to drive leader discovery before the first call to produce() on a PartitionClient. This allows us to "pre-warm" the cached broker connection to the leader and avoid doing it when we send through the first write.

Ideally we would do this automatically when initialising the PartitionClient, but that would be a breaking change as the constructor would need to become async - happy to change it if a breaking change is acceptable 👍

I wasn't really sure how to test this 🤷


  • feat: support pre-warming PartitionClient (b612f08)

    Adds a refresh_leader() method to force the PartitionClient through the 
    discovery process.
    
    This will ensure a cached connection to the leader is (likely) already 
    established by the time the first produce() call is issued, preventing the
    first produce() calls (multiple of which may be queued up on the discovery
    mutex) from experiencing excessively high latency.
    
  • refactor: pre-warm PartitionClient connection (387a96d)

    Change the Client::partition_client() constructor to always perform leader
    detection and establish a connection to the broker immediately, instead of
    differing the work until the first produce() call.
    
    This eliminates the unusually high latency of the first produce() call.
    
    BREAKING CHANGE: PartitionClient constructor is now async
    
  • refactor: retry failed leader discovery (e060f60)

    Adds a retry loop (w/ backoff) over the leader discover when initialising a
    PartitionClient.
    

Adds a refresh_leader() method to force the PartitionClient through the
discovery process.

This will ensure a cached connection to the leader is (likely) already
established by the time the first produce() call is issued, preventing
the first produce() calls (multiple of which may be queued up on the
discovery mutex) from experiencing excessively high latency.
@domodwyer domodwyer requested a review from crepererum August 11, 2022 13:39
@domodwyer domodwyer self-assigned this Aug 11, 2022
Change the Client::partition_client() constructor to always perform
leader detection and establish a connection to the broker immediately,
instead of differing the work until the first produce() call.

This eliminates the unusually high latency of the first produce() call.

BREAKING CHANGE: PartitionClient constructor is now async
@domodwyer
Copy link
Contributor Author

I have made the breaking change proposed in the description - now all users will have a fully-primed PartitionClient without any extra hops 👍

Adds a retry loop (w/ backoff) over the leader discover when
initialising a PartitionClient.
@domodwyer domodwyer merged commit cb9195a into main Aug 11, 2022
@domodwyer domodwyer deleted the dom/pre-warm branch August 11, 2022 15:21
domodwyer added a commit that referenced this pull request Aug 11, 2022
PR #165 added leader discovery at initialisation time and intended to
also cache the broker connection but called the wrong func.

This commit calls get() which establishes & caches the broker
connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants