Customer transport client with an elastic search. Singleton vs One new instance for each call vs Connection Pool (if any)

I connect to elastic search using the Elastic Search Transport Client. There are two approaches that I have tried

1) Singleton client, common to the entire application. Response time between 1-2 sec.

2) A new client instance for each Elastic Search call takes about 7 seconds to respond. To be specific, there are 5 classes that need to connect an ES cluster, and this approach creates a new transport client for each class.

Is 1) a good approach to search elastic search, since it is usually not recommended to have a singleton db connection object?

Is there any pooling mechanism for Elastic Search, for example, do we have DBCP for relational databases?

+4
source share
2 answers

It should not be a single-user client (by "singleton" I mean an instance that can only be initialized once). You can save the state of the client instance and pass it as a parameter between your application modules. thus, you will not limit your application to only one client resource.

, ,

0

All Articles