Delay for elasticsearch connection

Hi.
I have a java class that includes many methods. each method first connect to elasticsearch and does operations on indices and finally close the connection.
When the program is running i have a long delay for connecting to elasticsearch for every methodes.I want to know that how solve this problem. (why this problem is occurred, too)
Please help me.

What kind of client are you using to connect to elasticsearch?

Transport? Rest?

Transport

Just create one instance of the Transport client for the whole application and reuse that instance any time you need. It's thread safe.

thanks dadoonet.
But in my application these methods should be connect to elasticserach simultaneously and do operations on indices, that's mean multi threads connect to elasticsearch at the same time and i have long delay for connecting to elasticsearch for every thread.
What can be done to solve this problem?

What can be done to solve this problem?

Follow my advice.

Share your Transport Client within your application please.
You don't need to create multiple instances.

Should i use a singleton instance of transport client for multiple threads? Please exactly help me how share transport client within my application by an example?
thanks.

Should i use a singleton instance of transport client for multiple threads?

Yes.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.