Skip to content

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

@lhotari

Description

@lhotari

Search before asking

  • I searched in the issues and found nothing similar.

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:

DefaultAsyncHttpClientConfig.Builder confBuilder = new DefaultAsyncHttpClientConfig.Builder();
confBuilder.setUseProxyProperties(true);
confBuilder.setFollowRedirect(true);
confBuilder.setRequestTimeout(conf.getRequestTimeoutMs());
confBuilder.setConnectTimeout(connectTimeoutMs);
confBuilder.setReadTimeout(readTimeoutMs);
confBuilder.setUserAgent(String.format("Pulsar-Java-v%s", PulsarVersion.getVersion()));
confBuilder.setRequestTimeout(requestTimeoutMs);
confBuilder.setIoThreadsCount(conf.getNumIoThreads());
confBuilder.setKeepAliveStrategy(new DefaultKeepAliveStrategy() {

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?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions