-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][client] Add maxConnectionsPerHost and connectionMaxIdleSeconds to PulsarAdminBuilder #22541
Conversation
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
...ient-admin/src/main/java/org/apache/pulsar/client/admin/internal/PulsarAdminBuilderImpl.java
Show resolved
Hide resolved
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. |
… 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
...ent-admin/src/main/java/org/apache/pulsar/client/admin/internal/http/AsyncHttpConnector.java
Fixed
Show fixed
Hide fixed
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #22541 +/- ##
============================================
+ Coverage 73.57% 74.56% +0.98%
- Complexity 32624 33586 +962
============================================
Files 1877 1919 +42
Lines 139502 144229 +4727
Branches 15299 15774 +475
============================================
+ Hits 102638 107542 +4904
+ Misses 28908 28448 -460
- Partials 7956 8239 +283
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…nds to PulsarAdminBuilder (apache#22541) (cherry picked from commit 3e7dbb4) (cherry picked from commit 4c480fd)
…nds to PulsarAdminBuilder (apache#22541) (cherry picked from commit 3e7dbb4) (cherry picked from commit 4c480fd)
…nds to PulsarAdminBuilder (apache#22541)
…nds to PulsarAdminBuilder (apache#22541)
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 secondsjersey.version
to 2.42 since there's a change included that enables cancelling operationsDocumentation
doc
doc-required
doc-not-needed
doc-complete