ElasticSearch NEST Elastic Client Lifetime

In an ASP.NET application. What would be the recommended use of the ElasticClient: once per application, once per request, or just create and destroy as needed?

What are the implications for caching, warming up, ...?

Is there some piece of documentation that goes into this? I have read several statements on the internet that the cache file belongs to the AppDomain, but I would like to know more details about this NEST area.


source to share

1 answer

The client is stateless, so whether you register it as a singleton or instantiate a new object is optional.

The only big one , but for this rule is when you enter IConnectionPool

it has some internal state associated with known nodes and should register as single.

All bits of caching per application (static) no matter how you register, instantiate clients.



All Articles