New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][client] Add maxConnectionsPerHost and connectionMaxIdleSeconds to PulsarAdminBuilder #22541
base: master
Are you sure you want to change the base?
[improve][client] Add maxConnectionsPerHost and connectionMaxIdleSeconds to PulsarAdminBuilder #22541
Conversation
… to PulsarAdminBuilder - also modify the default connectionMaxIdleSeconds from 60 seconds to 25 seconds - some firewalls/NATs have a timeout of 30 seconds and that's why 25 seconds is a better default - common firewall/NAT idle timeout is 60 seconds and since the check isn't absolute, a better default is 25 seconds to ensure that connections don't die because of firewall/NAT timeouts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of minor suggestions
pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/PulsarAdminBuilder.java
Outdated
Show resolved
Hide resolved
@@ -47,6 +47,7 @@ public PulsarAdmin build() throws PulsarClientException { | |||
|
|||
public PulsarAdminBuilderImpl() { | |||
this.conf = new ClientConfigurationData(); | |||
this.conf.setConnectionsPerBroker(16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't the default be part of ClientConfigurationData
constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't the default be part of
ClientConfigurationData
constructor?
Not really. ClientConfigurationData is designed for PulsarClient, but it's also used in PulsarAdmin client. The current PulsarAdminBuilderImpl is a bit of a hack around ClientConfigurationData.
the
UPDATE: it's necessary to set |
There's a problem with backpressure handling with async requests in the Pulsar code base. The namespace unloading is a good example: pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java Lines 829 to 841 in d7d5452
All bundles in the namespace are unloaded at once without limiting concurrency. a snippet from my email in that thread:
The solution for the namespace unloading issue is to have a way to limit the outstanding CompletableFutures that are in progress and use that as a way to "backpressure" the sending of new requests. The current solution of sending out all requests and then waiting for the results is a problematic solution since it doesn't use any sort of feedback from the system to adjust the speed. In other words, there's currently no proper backpressure solution for async Pulsar Admin calls within Pulsar broker. I'll experiment with some ways to add backpressure to cases where a large amount of async calls are triggered and then results are waited. |
Another location without proper backpressure is namespace deletion: pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java Lines 282 to 293 in d7d5452
|
example of creating partitions: pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java Lines 162 to 171 in 50121e7
This would need backpressure too. Let's say if you create a 100 partition topic, the broker might open 100 HTTP connections to create the topic partitions concurrently. This is problematic when the brokers are under heavy load. |
Looks like https://github.com/spotify/completable-futures/blob/master/src/main/java/com/spotify/futures/ConcurrencyReducer.java could be a useful solution to leverage. |
Noticed that there's a solution to run 1-by-1 using pulsar/pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java Lines 179 to 210 in ed59967
|
Another challenge is to cancel work that is queued in the system, but not waited by any clients. |
Fixes #22041
Motivation
See #22041 . Currently, when using the asynchronous interfaces of the Pulsar Admin client, there's no backpressure by the client itself and the client will keep on opening new connections to the broker to fulfill the in-progress requests.
Eventually, the broker will hit the
maxHttpServerConnections
limit, which is 2048.It's better to limit the number of connections from a single client. This PR sets the limit to 16 connections per host.
The limit isn't called
connectionsPerBroker
since admin operations usually target a cluster address.Modification
maxConnectionsPerHost
andconnectionMaxIdleSeconds
to PulsarAdminBuilderconnectionMaxIdleSeconds
from 60 seconds to 25 secondsDocumentation
doc
doc-required
doc-not-needed
doc-complete