Experimenting where to put MySQL

At MobileXCo, our ‘app’ consists of 5 Laravel apps plus their supporting services like MySQL, Redis, ElasticSearch and we have them all in a single Vagrant instance. VMs aren’t ‘cool’ anymore, but our production infrastructure is VM based (EC2) and onboarding developers is pretty easy as its just ‘vagrant up’.

That said, as an experiment I moved where MySQL lived a couple places to see if I could simplify the VM by not having it in there. After all, we use RDS to host our database in production, so why not externalize that from development as well?

First, the baseline of having everything in the VM

Time: 19.69 seconds, Memory: 94.25 MB 

This maths out to about .75s per test. Not too too shabby.

Next up was reaching out of the VM to the Host (macOS 10.15.4).

Time: 28.1 seconds, Memory: 94.25 MB

Which is 1.08s per test which is on the border of consideration for running the server on the Host — if setup wasn’t as trivial as it is in the VM. (Which is fully configured via the Puppet Provisioner using the same scripts as production. Well, with a couple minor tweaks through environment checks.)

Lastly, I spent an couple hours teaching myself about docker-compose and ran MySQL in a container using the mysql:5.7 image. (And if I’m am going to be honest, this really was an excuse to do said learning.) Port 33306 on the Host forwarded to port 3306 on the Container so really this is Guest -> Host -> Container, but

Time: 1.02 minutes, Memory: 94.25 MB

That’s … erm, not awesome at 2.38s.

This can’t be a unique configuration and I find it hard to believe that such a performance discrepancy would not have been addressed which makes me think there is some networking tuning options I don’t know about. If anyone has any ideas on how to tweak things, let me know and I’ll re-run the experiment.

Post a Comment

Your email is never published nor shared. Required fields are marked *