Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to elasticsearch cluster in NEST

Let's assume I have several elasticsearch machines in a cluster: 192.168.1.1, 192.168.1.2 and 192.168.1.3

Any of the machines can go down. It doesn't look like NEST supports providing a range of IPs to try to connect.

So how do I make sure I connect to any of the available machines from Nest? Just try to open connection to one, if TryConnect didn't work, try another?

like image 863
Sumrak Avatar asked Mar 24 '23 05:03

Sumrak


1 Answers

You can run a local ES instance at your application server (eg your web server) and config it to work as a load balancer:

  • Set node.client: true (or node.master: false and node.data: false) for this local ES config to make it a load balancer. This mean ES will not become master nor contains data
  • Config it to join the cluster (your 3 nodes don't need to know this ES)
  • Config NEST to use local ES as your search server

Then this ES become a part of your cluster, and will distribute your requests to suitable nodes

If you don't want "load balancer", then you have to manually checking on client side to determine which node is alive.

like image 117
Duc.Duong Avatar answered Apr 01 '23 22:04

Duc.Duong