Liferay Enterprise Search

[LES] How to use a load balancer with Elasticsearch?

Environment

  • Liferay DXP 7.0-7.2
  • Elasticsearch 6.x. 7.x

Question

Are there any guidelines for using Elasticsearch* with a load balancer like F5?

Answer

For load balancing, there are a few out of the box solutions available without having to use an external load balancer.

  • Elasticsearch includes a lightweight load balancer, we call it a coordinating node. It is a separate ES node that will join the cluster. It does not store any data, but it is aware of the cluster state and will automatically direct requests to the appropriate node(s) that store the data being requested. Once it receives the result set, it will reduce it and send it back to the requestor. Learn more about configuring load balancing with coordinating nodes for Kibana
  • If you are using the .NET client, you can use one of the available ConnectionPool types. For example, within your application code, you can define a SniffingConnectionPool when you establish the ES connection. The .NET client will sniff the cluster state to determine the list of available nodes and round-robin requests automatically between them.
  • If you are using the NEST client, you can similarly pass in the appropriate IConnectionPool type to your ConnectionSettings to achieve the same. This is a straightforward way to implement load balancing in Elasticsearch. 

That said, using a load balancer with the HTTP or Transport Client should not be a problem, but there are a few things to keep in mind.

  • The HTTP client and Transport Client connect to a single Elasticsearch node or a list of nodes using round-robin. That node will then coordinate the operation with the correct data node.  Most operations will be 2 hop, which means it doesn't matter which node you initially connect to. In your load balancer scenario, this is good. Simply give the IP or name of your load balancer to the client.
  • With TLS security, if Elasticsearch is behind a load balancer you have 2 options:
    • Include the load balancer's DNS name in the SAN (Subject Alternative Name) of each node's certificate and pass-through TCP port 9200/9300
    • Terminate SSL on the load balancer like a proxy, and use the Load Balancer's certificate
  • When using the Transport Client, do not enable sniffing (See the docs), which will result in the Transport client attempting direct connections to each node

* Elastic, Elasticsearch, and X-Pack are trademarks of Elasticsearch BV, registered in the U.S. and in other countries.

On this page