P
P
Pavel Belyaev2020-09-13 00:43:13
PHP
Pavel Belyaev, 2020-09-13 00:43:13

Mysql + PHP docker speed?

Hello everyone, there is such a problem, MySQL in docker is slower than on hardware, at first it sinned on the network, I thought that the application from the container with delays communicates with another container or with the host, but the point was that the host had version 8.0, on it drawdown is faster on 5.7, and even faster on MariaDB.
At least when the load is not highload - 8.0 is either equal to or behind 5.7. But now is not about that.

First I installed php and mariadb on the hardware, about 2.9 seconds the execution time for 260 requests + some small processing ...
I installed PHP in the docker, left mariadb on the host, PHP on the docker, well, about 3.0-3.1 seconds, quite an acceptable overhead.

But when I run MariaDB in the docker, the speed drops, the time is about 3.9-4 seconds.
Interestingly, yesterday I did docker exec -it sh... in the PHP container container. I installed MariaDB of the same version, launched it, and the same as in the neighboring container.

I tried, as with the standard volume, and forwarding the local folder -v to the container, nothing changes, there is either some difference when mysqld starts in the docker, and the system service on the host or some settings do not cling or under alpine and ubuntu the assemblies do not the best. I read it on the Internet, some also write that in the docker, the peak speeds of the database sag.

Nobody faced?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kuzyaev, 2020-09-14
@kuzyaev

Here you need to conduct more detailed testing.
In this case, you need to look at how you connect to mysql.
After all, if we put mysql-server on the host and connect via localhost (we will lose some of the time searching for the ip address), if we specify 127.0.0.1, then the work will be faster.
Same thing with docker. When specifying mysql as the connection address, it will look for its ip address (you can try to specify it manually when connecting).
---
According to my assumptions, this increased time = search for the ip address of the mysql server.

P
Pavel Belyaev, 2020-09-14
@PavelBelyaev

I found tests from perkona, there really is such a network overhead, even if everything is on the same computer ... My tests, of course, impose more computational performance, and probably I don’t have so much work with the database as processing, generating all sorts of xml ... If only I only worked with the base, then most likely I got as much as a threefold slowdown... https://www.percona.com/blog/2016/02/05/measuring-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question