Does es node prioritize local shard for searching?

Hi,

I use es cluster to serve a small index (<1G) for searching and aggregation and so only 1 shard is assigned and 1 replica. As 1 node does not able to serve all the request fast enough so the cluster scale to 10 nodes.

I increase the number of replica to 9 so that the total replica is (1+9) so that every node have the copy of the single shard.

I put a load balancer in front of all the nodes so that the http request is distributed across the nodes.

I would like to ask the following:

  1. Is it a general good practice for my case?

  2. Is it a good practice to increase the number of replica so that every node have a local copy of the shard in order to increase the performance?

  3. When the node receive a request, does it prefer to use the shard available in local before reaching to other nodes? should i use preference=_local to force the node to uses its local shard from the documentation[1]?

[1] Search shard routing | Elasticsearch Guide [8.6] | Elastic

Welcome to our community! :smiley:

  1. Does it work? If so then yes
  2. For your use case, yes
  3. It will pick the primary of any one of your replicas at random. You might be better off using preference as you mention

Yes. I see nothing wrong with this approach as long as clients use long running connections and the load balancer distributes load evenly.

Yes. If you have a small data set that fits in the OS page cache and a high number of concurrent requests this is great.

I believe the default is adaptive selection, which may not favour the local shard. As this setting exists I would use it, at least as long as the load is evenly distributed by the load balancer.

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