# Percona XtraDB Cluster: Automatic Failover Between Nodes in Java Spring Boot Application

**URL:** <https://forums.percona.com/t/percona-xtradb-cluster-automatic-failover-between-nodes-in-java-spring-boot-application/26475>\
**Category:** Percona XtraDB Cluster\
**Created:** [November 10, 2023, 12:12pm UTC](https://forums.percona.com/t/percona-xtradb-cluster-automatic-failover-between-nodes-in-java-spring-boot-application/26475 "2023-11-10T12:12:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muhammad\_Umar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/muhammad_umar/32/13704_2.png) [@Muhammad\_Umar](https://forums.percona.com/u/Muhammad_Umar)\
**Post date:** [November 10, 2023, 12:12pm UTC](https://forums.percona.com/t/percona-xtradb-cluster-automatic-failover-between-nodes-in-java-spring-boot-application/26475/1 "2023-11-10T12:12:01Z")

</div>

I’ve set up a Percona XtraDB Cluster with two nodes, and my Java Spring Boot application is currently communicating with node1. The challenge is that when node1 goes down, the application doesn’t seamlessly switch to node2.

Do I need to make specific configurations in my Spring Boot application or the Percona XtraDB Cluster to enable automatic failover?

I want the application to intelligently switch to node2 if node1 becomes unavailable, without manual intervention. Any insights or guidance on the necessary settings or configurations would be highly appreciated.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [November 10, 2023, 6:42pm UTC](https://forums.percona.com/t/percona-xtradb-cluster-automatic-failover-between-nodes-in-java-spring-boot-application/26475/2 "2023-11-10T18:42:44Z")

</div>

Hi @Muhammad_Umar,  
If you only have 2 nodes, then when node1 goes down, you now have a split-brain situation and node2 will refuse to answer any questions. You need a minimum of 3 nodes to survive having 1 node going away.  
As for the Java side, you need to configure the connection string such that it picks node1 by default and chooses node2 if node1 goes away.

---

<div class="post-metadata">

**Author:** ![Michael\_Coburn](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/michael_coburn/32/18_2.png) [@Michael\_Coburn](https://forums.percona.com/u/Michael_Coburn)\
**Post date:** [November 12, 2023, 9:08pm UTC](https://forums.percona.com/t/percona-xtradb-cluster-automatic-failover-between-nodes-in-java-spring-boot-application/26475/3 "2023-11-12T21:08:44Z")

</div>

> [@Muhammad\_Umar](#):
>
> Do I need to make specific configurations in my Spring Boot application or the Percona XtraDB Cluster to enable automatic failover?

You would need another service in order to load balance the query traffic among the remaining Percona XtraDB Cluster members. See the Percona Docs for how to set up query routing using ProxySQL:

> **[Percona XtraDB Cluster - Load balance with ProxySQL](https://docs.percona.com/percona-xtradb-cluster/8.0/load-balance-proxysql.html)**
>
> ProxySQL is a high-performance SQL proxy. ProxySQL runs as a daemon watched by
> a monitoring process. The process monitors the daemon and restarts it in case
> of a crash to minimize downtime.

Another helpful blog post

> **[ProxySQL Native Support for Percona XtraDB Cluster (PXC)](https://www.percona.com/blog/proxysql-native-support-for-percona-xtradb-cluster-pxc/)**
>
> ProxySQL 2.0 provides native support for Galera cluster. Marco Tusa sets up ProxySQL Galera native integration and highlights things you should be aware of.
