I currently have a REST API written in Flask that connects to a MariaDB server. I'm thinking about replacing the server with a Galera cluster to improve availability and ensure continuity in case one of the nodes goes down. What I'm having trouble understanding is how client applications connect to the cluster itself. As I'm currently only using a single database server, I can connect using the following code:

engine = create_engine('mysql://username:password@hostaddress/database_name)

If I were to have three nodes in the cluster with the addresses, and how would I connect the application to the cluster? I assume that it would be possible to replace the current hostname value with one of the node IPs e.g. but I'd imagine that if I did that and that node went down, the application would no longer be able to connect to the cluster because it's specifically trying to connect to that one node. How can I ensure that the application continues to function if a node fails?

I'm still new to the idea of Galera cluster so apologies if I've misunderstood something about how it works. Any advice would be much appreciated.

1 Answer 1


You'll have to look up on the documentation of your database connector. Normally (e.g. in Java world) you can specify comma-separated list of nodes instead of a single host.

For instance, check the documentation on Failover at: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html

Alternatively you can run a separate load-balancer server "in front of" the cluster nodes and just point the client to the load-balancer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.