Docker presents new levels of portability and ease of use when it comes to deploying systems. We have for some time now released Dockerfiles and scripts for MySQL products, and are not surprised by it steadily gaining traction in the development community.
- Docker Mysql Slow Query Log
- Docker Mysql Slow Release
- Docker Mysql Slow Mac
- Docker Mysql Slow Log
- Docker Mysql Too Slow
- Docker Mysql Slow
The typical concern that users have with any level of abstraction, is if there is a measurable level of overhead in doing so. We have conducted our own performance tests to understand the characteristics more closely, and in this post I will go into some detail as to what we have observed.
So Docker simulates your actual application environment versus running Apache, PHP, and MySQL locally on macOS would have. What's not nice about this, is the same thing that's not nice about Docker. In this example we have a Go and MySQL service. Go depends on MySQL. MySQL is slow in accepting connections. We will use our script in Go to force it to wait for MySQL to accept connections first. Once MySQL says it is ready then we will bring up the Go service. Re: SOLVED Very slow Docker MySQL container What storage driver are you using (see 'docker info')? If you are using devicemapper, which is the default unless you have an AUFS enabled kernel or a btrfs partition, I'd suggest creating a btrfs partition for /var/lib/docker and trying again. Analyzing MySQL Queries The slow query logs will show you a list of queries that have been identified as slow, based on the given values in the system variables as mentioned earlier. The slow queries definition might differ in different cases since there are certain occasions that even a 10 second query is acceptable and still not slow.
We’ve primarily focused on I/O and network overhead and compared the results to a stock instance of MySQL. Specifically we wanted to compare the performance between Docker’s different storage options and also how much overhead Docker’s bridged network brought into the picture. The tests have been run on a Oracle Server X5-2, with 2x Xeon E5-2660 v3 (40 hardware threads) and 256GB RAM using Docker version 1.11.2 on Ubuntu 16.04.
Docker has three different ways of providing persistent storage.
- The default is by using data volumes. This writes data to a directory on the host system using Docker’s internal volume management.
- The second way is by specifying a directory on the host system that will be mounted into a specified location inside the container.
- A third way is by creating a data volume container. Basically, this lets you create a shared container whose data volumes can be used by other containers.
Docker images are made up of a set of layers stacked on top of each other, where each layer represent file system differences. Docker’s storage drivers are responsible for stacking the image layers and creating a single unified view of the image. However, data volumes and host directories bypass Docker’s storage driver and should therefore run at near-native speeds. For our tests, we’ve used the AUFS storage driver as it’s the most widely used driver.
For measuring network overhead, we’ve conducted tests using Docker’s host and bridge networks, specified by --net=host or --net=bridged respectively when creating your container. Bridged networking is the default when creating containers. Host networking on the other hand adds a container on the host’s network stack, and should thus avoid the overhead typically imposed by the bridged network.
For these tests, we used a custom configuration file. We first deliberately set the buffer pool size to around 10% of the total database size in order to increase I/O-bound load. The database size was 2358MB, so we set our buffer pool size to 256MB. We then increased the buffer size to 16384MB to see what happens when Docker isn’t bound by I/O load. Specifying a custom configuration file for MySQL with Docker is relatively straight-forward. The easiest way to go about this is by mounting your config file into /etc/my.cnf on your container. This is done by passing -v/path/to/host/my.cnf:/etc/my.cnf to Docker when creating the container. You could also manually modify the container and commit your changes back into a new image, but this is somewhat impractical as you’ll have to do this procedure each time you update MySQL.
We’ve conducted tests using sysbench. We ran the following command in order to set up our databases for testing.