-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Requests
When invoking an Elasticsearch endpoint via a service of a client, every request goes through the same method: client.PerformRequest(...)
. Here's what you need to know about requests in Elastic.
First, PerformRequest
picks a node/connection for your request. This happens in a round-robin fashion. In a nutshell, it starts with the first node of your cluster, then picks the next node for the next request, and so on, until it hits the last node, then picks the first again. This simple process ensures that all of your nodes are used in a "fair" manner.
Assume one of your nodes goes down in the middle of a request: The HTTP request will fail. If you configured Elastic to use retries, it just tries again, on a different node. If there is no other node available, there's nothing Elastic can do: Your request will fail and you should be prepared for that. In fact: You should be prepared for errors at any time!
Notice that Elastic will automatically mark nodes as "dead" when they fail after the configured number of retries. Elastic will not use "dead" connections in subsequent requests. However, it will eventually mark them as "alive" in a health check.
Nodes that successfully executed a request are automatically marked as "healthy".
You can use client.SetRetrier(...)
to specify a custom retry and backoff algorithm.