I’m using a Golang psql client to connect to a cockroachdb cluster. What is the best practice to connect to the cluster? Should the client keep a list of IPs of the nodes in the cluster and connect to any one of them? Should the failover logic be built on the client side? For example, if the client connect to a fixed IP in the cluster then it needs to connect to a different IP upon failure?
I had a similar problem, and I was told that I could either use a PSQL client that would allow to Round Robin over multiple nodes or the best method suggested by CRDB itself would be to use a load balancer over the crdb nodes (Please refer : https://www.cockroachlabs.com/docs/stable/manual-deployment.html#step-5-set-up-haproxy-load-balancers)
Thanks a lot! Probably another solution will be a ‘client only’ load balancing such as Cassandra client library. But of course this requires a specially built client driver for cockroach db.
We are using haproxy on each client host, which works fantastically.