When I am programming to connect and use Elasticsearch in Python, is the Context thread safe? i.e. do I need one instance per thread or can I use a static Context for all threads?
For that matter is the elasticsearch client thread safe? Can I have one instance for all my threads?
https://elasticsearch-py.readthedocs.io/en/7.x/
Thread safety
The client is thread safe and can be used in a multi threaded environment. Best practice is to create a single global instance of the client and use it throughout your application. If your application is long-running consider turning on Sniffing to make sure the client is up to date on the cluster location.
By default we allow urllib3
to open up to 10 connections to each node, if your application calls for more parallelism, use the maxsize
parameter to raise the limit:
Thank you
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.