MySQL Proxy for sharding
April 18, 2008 3 Comments
I have been reading about various experiments using MySQL Proxy to handle sharding (and by extension scaling) for application by rewriting SQL queries as they come through and directing them to the appropriate shards.
The most visible project seems to be HScale, which is well worth looking at and reading about.
The premise is very compelling, which is to remove the issue of sharding from the application layer, moving it into the database layer. This makes the application less complex because it no longer needs to deal with sharding (though it could be argued that sharding, if correctly done, has very little ‘imprint’ on the application.)
I think this project has promise but there are some questions that needs to be addressed before it is really ready to be used in a production setting:
- First is that the MySQL Proxy introduces a single point of failure. If it fails, the application stops. At the very least, there needs to be a number of proxies and the application needs to be able to detect when one has failed and switch over to another one. I suspect you could get around that issue with a load balancer.
- Second sharding does not mean that your application automatically becomes fault tolerant. If you have more machines, the odds of one failing go up, so the proxy needs to be able to handle failing over from a failing server to a backup server.
Both of those are difficult problems to deal with, and like a lot of software projects it is the 20% that is going to take 80% of the time.