Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upis ElasticClient thread safe? (connection pooling) #385
Comments
|
We are currently using it as a singleton object. I think all that ElasticClient does is create an org.elasticsearch.client.transport.TransportClient. It seems that he keeps a pool of threads for sending the requests over the cluster; so i don't think its a good idea to call it every time when making a request. |
|
@janghwan Definitely cache it. The reason is an Elasticsearch client is a clever beast. It pings the cluster to become cluster-aware so it can route queries to the right nodes. Each time you create one there's this small overhead. In addition to the internal thread pools it creates (about 30 threads). |
Is that good example of it or ?
|
Hi guys.
I wonder what's the best usage of
ElasticClientIs it okay - in terms of performance - to call
ElasticClient.remote()every time I need a client?Or should I cache a singleton object and share among threads?