Flaminel
Posts: 4
Joined: Thu Jun 04, 2020 4:13 pm

Performance drop while using docker containers + MySQL problem

Thu Jun 04, 2020 6:49 pm

I'm working on a personal project which was started a few years ago on my windows laptop, then tried to move it to different free web host providers. For easy access and ease of use, I've always used MySQL for my database.
Not so long ago I bought a Raspberry Pi 4 4GB wanting to host my project on it. The problem I face now is that MySQL is not available on Debian anymore and MariaDB is not cutting it for me. I've tried MariaDB and it failed, mostly timing out on queries that have no problem using MySQL. I don't care that MariaDB is forked from MySQL before Oracle takeover and I certainly do not cut corners and replace my database provider because of Debian. The two databases are more and more different with every release.
The problem is that I can not find a viable workaround. I've found docker images containing MySQL as a first try at a workaround. The server works ok, but the problem is that the Raspberry becomes unusable when any docker container is running. I can't remote with xrdp into it anymore. Even on ssh it stutters a lot when writing commands. I've installed RPi-Monitor and it does not seem like the containers are doing anything to the resources, so I got no idea where this is coming from. I'm running Raspbian on a 120GB Kingston SSD without an SD card, so storage speed should not be a problem.
Does anyone know how I can solve the performance problem when running docker containers? Or, even better, does anyone know any other workaround for this MySQL problem?

Thanks! :D
Last edited by Flaminel on Fri Jun 05, 2020 10:15 am, edited 1 time in total.

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Performance drop while using docker containers

Thu Jun 04, 2020 7:57 pm

"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

W. H. Heydt
Posts: 12654
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Performance drop while using docker containers

Thu Jun 04, 2020 11:40 pm

From what I've read about containers, a drop in performance would be expected. They add overhead.

Flaminel
Posts: 4
Joined: Thu Jun 04, 2020 4:13 pm

Re: Performance drop while using docker containers

Fri Jun 05, 2020 5:49 am

epoch1970 wrote:
Thu Jun 04, 2020 7:57 pm
This?
https://dev.mysql.com/downloads/repo/apt/
I've tried, but I get this

Code: Select all

N: Skipping acquire of configured file 'mysql-apt-config/binary-armhf/Packages' as repository 'http://repo.mysql.com/apt/debian buster InRelease' doesn't support architecture 'armhf'
N: Skipping acquire of configured file 'mysql-8.0/binary-armhf/Packages' as repository 'http://repo.mysql.com/apt/debian buster InRelease' doesn't support architecture 'armhf'
N: Skipping acquire of configured file 'mysql-tools/binary-armhf/Packages' as repository 'http://repo.mysql.com/apt/debian buster InRelease' doesn't support architecture 'armhf'
W. H. Heydt wrote: From what I've read about containers, a drop in performance would be expected. They add overhead.
I get that something should happen when running containers, but not to the point where even ssh becomes unusable because of constantly freezing. Also, RPi-Monitor shows normal stats while running containers, which means there might be something else.

Flaminel
Posts: 4
Joined: Thu Jun 04, 2020 4:13 pm

Re: Performance drop while using docker containers + MySQL problem

Sat Jun 06, 2020 1:06 pm

Isn't there anyone using docker on RPi that can share his experience? Maybe I'm doing something wrong, or maybe there really is something wrong. Or anyone bypassing the MySQL repository problem?

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Performance drop while using docker containers + MySQL problem

Sat Jun 06, 2020 3:10 pm

I don't think Docker adds much CPU overhead on Rpi (or anywhere), but DBs aren't my turf so I can't say for sure.

However docker interacts with filtering (iptables) on the host quite a lot. If the problems you describe are experienced from a remote host, I would look into the iptables setup and networking setup on the Pi.
For example, first time you run Docker it looks for networks that are in use locally and chooses a free network for its default bridge network. I think its default choice is 172.17/16. That happens to be a network I use, so according to how the Pi was connected initially when docker was installed, I may have to edit /etc/docker/daemon.json and create a "bip" entry that doesn't break routing...
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Flaminel
Posts: 4
Joined: Thu Jun 04, 2020 4:13 pm

Re: Performance drop while using docker containers + MySQL problem

Sat Jun 06, 2020 6:32 pm

epoch1970 wrote:
Sat Jun 06, 2020 3:10 pm
I don't think Docker adds much CPU overhead on Rpi (or anywhere), but DBs aren't my turf so I can't say for sure.

However docker interacts with filtering (iptables) on the host quite a lot. If the problems you describe are experienced from a remote host, I would look into the iptables setup and networking setup on the Pi.
For example, first time you run Docker it looks for networks that are in use locally and chooses a free network for its default bridge network. I think its default choice is 172.17/16. That happens to be a network I use, so according to how the Pi was connected initially when docker was installed, I may have to edit /etc/docker/daemon.json and create a "bip" entry that doesn't break routing...
I'm not quite familiar with Linux, so I don't really know what those iptables do just yet. I've found that docker has a lot of configuration there though. This is the result of "sudo iptables -L":

Code: Select all

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy DROP)
target     prot opt source               destination
DOCKER-USER  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain DOCKER (1 references)
target     prot opt source               destination

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-USER (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere
I spent some time trying to edit the docker service to start with the "--iptables=false" option, but I can't seem to find where it's started from. There's no physical docker.service in /etc/systemd/system/, but there are some files in /etc/init and /etc/init.d/. I've tried editing them to concatenate that option, but no luck so far. Also, there's also no `daemon.json` in the docker folder.

Edit: I've found the docker.service file and added "--iptables=false", but there are still some persistent iptables configurations. Doesn't seem to do anything for that performance problem though.

Return to “Troubleshooting”