apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
13.97k stars 3.54k forks source link

Set limits for number of opened HTTP connections for Pulsar Admin client #22041

Open lhotari opened 5 months ago

lhotari commented 5 months ago

Search before asking

Motivation

The Pulsar Admin client uses connection pooling (keep alive) without limiting the number of connections. When HTTP calls get queued up on the brokers for some reason, the client will keep on opening more connections.

Solution

The AsyncHttpClient used in pulsar-admin-client should be configured to limit the number of connections. This could happen somewhere here: https://github.com/apache/pulsar/blob/e3debb9ad867cb9b977e8bb1b21aab66387b3c5d/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/http/AsyncHttpConnector.java#L99-L108 setMaxConnections and setMaxConnectionsPerHost would have to be configured. In addition, it would be useful to use setPooledConnectionIdleTimeout to set the timeout to 25 seconds so that pooled connections don't exceed timeouts in typical firewall configurations. The default of 60 seconds conflicts with many firewall idle connection defaults.

Alternatives

No response

Anything else?

No response

Are you willing to submit a PR?

lhotari commented 5 months ago

UPDATE: It turns out that HTTP connection pooling is already configured, but there's no limit of the number of pooled connections.

nodece commented 5 months ago

Reference: https://github.com/AsyncHttpClient/async-http-client/blob/async-http-client-project-2.12.3/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties