[Proxy] Use shared internal and external executor for broker clients #13834
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Pulsar Proxy will create a new Pulsar Client instance for each and every proxied connection.
Currently 2 threads will be created for every Pulsar Client instance for the internal/IO and external/listener executors. This causes a lot of overhead and inefficiency in the Pulsar Proxy.
In the current solution, it's already possible to share the EventLoopGroup and HashedWheelTimer instances. Support for sharing the timer was added by #9802.
A recently merged PR, #12037, added support for sharing the the internal/IO and external/listener executors in PulsarClientImpl instances. This feature has been used in this PR to share the executors across all PulsarClientImpl instances created in the Pulsar Proxy.
Modifications
brokerClientNumIOThreads
which can be used to configure the number of threads for the internal/IO executor. It defaults to 2 * number of available processors.