I can not seem to find any info related to the connection pooling of the java rest client. I found several articles about transport client but nothing about the rest.
We have a proxy server in front of ES cluster transforming requests. The version of the ES client is 5.2.2 and ES cluster is 2.4.4 . We are close to migrate the cluster to 5.2.2.
There was a new client built for every request. I changed that to a singleton RestClient. Is this the best approach? In fact method RestClose.close() never gets called. We call synchronous performRequest method.
Thanks any hints,
I believe pooling it is better. Internally it uses an async client that starts a few threads and stuff. If you find contention on those threads you can configure the client differently when you build it, I believe.
Reusing a single instance of RestClient is the way to go, also calling close it important when the application gets stopped. This is mentioned in our docs here: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_initialization.html.
The connection pooling is done internally in the underlying apache async http client. We increase by default the maxConnPerRoute to 10 and maxConnTotal to 30. That is just a guess on our end. You can always set your own values by providing a custom HttpClientConfigCallback that sets them using RestClientBuilder#setHttpClientConfigCallback.
Thank you very much. I have implemented ServletContextListener that takes care of the client and sniffer close() calls during redeploy.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.