What is the right way to do load balancer of EventStore

Hi all,
Our team want to improve application’s availability by balance the load to different instances of EventStore cluster. our application use secure tcp connections to persist events into EventStore using single instance of IEventStoreConnection.

It seems we have two approaches to do the load balance.

  1. EventStore.ClientAPI
 var clusterSettings = ClusterSettings
                      .Create()
                      .DiscoverClusterViaGossipSeeds()
                      .SetGossipSeedEndPoints(gossipSeeds);

 var connectionSettingsBuilder = ConnectionSettings
                     .Create()
                     .PerformOnAnyNode()

By setting the gossip seed of EventStore cluster, ClientAPI will be able to discover the health status of each EventStore instance and choose the best one to accept coming tcp request. Even if one of the instance is in the status of outage, application can still write events.

  1. EventStore cluster behind load balancer (f5)

By creating a pool contains all the listening secure tcp port of each EventStore instance, Application will only talk to f5. f5 will be responsible for managing the health status by telnet secure tcp port of each instance.

On this case, It would be much easier to add new EventStore instance into cluster without changing all the application configurations.

We would like to know which approach is recommended to do the load balance? Is there any risk for the second approach?

We are looking forward for your suggestions and advice.
Thanks

There is no need for anything if you’re already passing in the cluster settings to the client - the .NET client API is cluster aware and will do the right thing.

James is right, but for completeness, there’s are other options:

You can use DNS for cluster discovery rather than pre-defined gossip seeds. If you go this route, clients simply make DNS lookup calls. You can add, remove or move ES nodes at will.

Note that this implies you have a supervisor process that registers the A record when ES starts and removes the A record when ES stops. This pairing is sometimes called a sidecar pattern. AFAIK, you have to write the sidecar yourself (no off-the-shelf tool exists) but it’s not hard to do.

You could also use HAProxy in the more or less the way you use an F5.