Running multiple instances on the same hardware

Written by

in

Currently, we have one database cluster with 15 different schemas – these schemas could be either schemas that contain “real” data or just schemas with metadata.

I guess the next evolutionary step of our database stack would be to split up the database cluster vertically along these schemas. All the data schemas should be moved to standalone mysql instances and the metadata schemas should be put next to them. This also could be a good project to prepare to move a certain part of the database for example to a cloud provider while other parts are still kept on bare metal.

I started wondering what could be the best way to split MySQL instances on a single machine. I have the following ideas:

  • Hack init scripts to start different instances on different ports (and log directories, data directories, config files too)
  • Use mysqld_multi
  • Use MySQL Sandbox
  • Use docker

The first one doesn’t look good to me because that could make any of the upgrades hell. The rpm package will probably rewrite my init script every time, so I have to fix this manually from time to time. It’s simply a NO GO.

It just looks like mysqld_multi is designed for this purpose. It has good documentation, there are blog posts about them. It is worth checking out.

MySQL Sandbox is also a project aimed at running multiple instances on the same hardware, but from reading its documentation, it is designed more for testing and checking out features than for production use.

Docker seems the sexiest and neat from all of the above, but I don’t know how much overhead it will generate either in network usage or in any other resource usage. It has a great advantage that docker allows you to map resources for containers – like CPUs -, which could be useful, however, I don’t know how I could map the data directories for containers – must they be included inside, or could they be left on a host? (EDIT: Volume plugin)

I’ll start my experiments and tests, and I will blog about them here.