Skip to content
Advertisement

Connection pooling in java using HttpClient [closed]

  • How can I create a pool of connections using HttpClient?
  • I have to make frequent connections to the same server. Is it worth creating such a pool?
  • Is it possible to keep HTTP connections live and use them for various requests, and if yes how can I do so?

Advertisement

Answer

[assuming Java, and Apache’s HttpClient]

Use a ThreadSafeClientConnManager. Pass a single global instance to the constructor of every HttpClient instance. I don’t think there’s any point in pooling the HttpClients themselves.

Advertisement