0

How to configure an application with a MySQL NDB cluster database so as the High availability as well the load balancing can be catered altogether. We can have these two capabilities separately by configuring the database connection url appropriately as below as I know.

For High Availability [1]

jdbc:mysql://[primary host][:port],[secondary host 1][:port][,[secondary host 2][:port]]...[/[database]]» [?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]

For Load balancing [2]

jdbc:mysql:loadbalance://[host1][:port],[host2][:port][,[host3][:port]]...[/[database]] » [?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]

The query is how to achieve both these capabilities with mysql ndb cluster if that is possible.

[1] - https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-config-failover.html

[2] - https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-usagenotes-j2ee-concepts-managing-load-balanced-connections.html

Samitha Chathuranga
  • 1,689
  • 5
  • 30
  • 57

1 Answers1

0

For MySQL NDB Cluster the high availability is in the data nodes. So you can use the load balancing setup and still get high availability.

With the high availability you will only use one MySQL server at a time, this will work fine with MySQL NDB Cluster as well, but in NDB you can have any number of MySQL servers in load balancing and they will see each others updates immediately. So load balancing setup is the preferred one for NDB.

  • With NDB cluster, we point mysql nodes from our applications. We do not point data nodes. So we cannot say that high availability is achieved if we configure our application as Load balanced pointing to Mysql nodes. If a mysql node is down, there is no HA. Application will not work as the Mysql node is down. Because data nodes are separate and our applications do not connect with them directly. So IMHO we cannot consider that HA is achieved with a setup connected to a NDB cluster, eventhough the HA is implemented within mysql cluster. WDYT ? – Samitha Chathuranga Feb 23 '18 at 06:37
  • Not sure I understand your reasoning, if the MySQL server is down it will not participate in the load balancing, in that case the alive MySQL server is always choosen. So you get both HA and load balancing with NDB in this case. – Mikael Ronström Feb 24 '18 at 16:05
  • I argue on your statement, "For MySQL NDB Cluster the high availability is in the data nodes." What I say is that in the setup if there is only one MySql server node, and multiple data nodes, there is no HA. We can't say that HA is achieved by having multiple data nodes. HA is achieved actually by having multiple MySQL nodes. – Samitha Chathuranga Mar 01 '18 at 06:01
  • This is quite correct that you don't get HA with a single MySQL Server. But the original question on using JDBC with loadbalance or list of MySQL Servers both require at least 2 MySQL Servers to be of any use. So if you have 2 MySQL servers and use load balancing config with JDBC, you will get HA since JDBC will use round robin when there are two live MySQL Servers and will use the single surviving MySQL server when only of the MySQL Servers is up – Mikael Ronström Mar 02 '18 at 12:37