Mysql – the most effective way to cluster MySQL for the requirements

MySQL

Basically I have 3 edge servers and 3 application servers. The edge servers are running nginx and load balance between the application servers. The application servers are running Virtualmin GPL with PHP applications deployed. All are running CentOS 5.7

At the moment MySQL is running on one of the edge servers, and is the single point of failure – I'm looking to cluster it between the application servers, but I'm just not sure what the best thing would be to do. I was thinking of running MySQL load balancers on 2 of the edge servers, then the MySQL instances on all 3 of the application servers and the MySQL cluster management server on one of the edge servers.

Does anyone have any other ideas? The problem with the aforementioned setup is the apps will be connecting to the edge servers for MySQL which could affect performance.

As I'm the developer of most of the apps I can rewrite the database abstraction in such a way it could switch load balancers (like round-robin DNS) if one was unavailable. I have some WordPress stuff that isn't mission critical, but my site powercuts.info is the biggest and gets the most traffic, I want to make sure it performs well.

Thank you

Best Answer

It depends on how you use your database. If it is read-heavy but with few writes (like a blog or a news paper) you could have one mysql for writes and two for reads. You would set up so the write server is a replication master and the two for reads are slaves.

All application servers needs to know about both the write server and one of the read servers, that way when you balance the loads to application servers you automatically balance the reads between the mysql servers. It's also easy to add another mysql+application server once the need is bigger.

If you on the other hand have a write heavy site (I can't even find an example) you need to do some research on sharding. It's normally not recommended unless you really need it.