My VM is Ubuntu 18.04 and I install 2 instances of MySQL 5.7.
The first is installed in the localhost (port 3306), the second is installed via docker-compose (port 57306). The configurations cnf (which is from the default install of the localhost version) are all the same.
The Docker version only get 1700 Transactions vs the localhost version with 4100 Transactions.
My question is, why the docker version is a lot slower, the configs are all the same, what could be the problems?
I test the localhost (port 3306) using sysbench with this command:
# prepare
sysbench --table_size=1000000 --db-driver=mysql --mysql-db=sysbench --mysql-user=root --mysql-password=<pass> /usr/share/sysbench/oltp_read_only.lua prepare
# run
sysbench --table_size=1000000 --db-driver=mysql --mysql-db=sysbench --mysql-user=root --mysql-password=<pass> --time=60 --max-requests=0 --threads=8 /usr/share/sysbench/oltp_read_only.lua run
and I got 4100 Transactions
SQL statistics:
queries performed:
read: 3444602
write: 0
other: 492086
total: 3936688
transactions: 246043 (4100.43 per sec.)
queries: 3936688 (65606.81 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 60.0025s
total number of events: 246043
Latency (ms):
min: 0.88
avg: 1.95
max: 19.27
95th percentile: 3.13
sum: 479541.05
Threads fairness:
events (avg/stddev): 30755.3750/971.95
execution time (avg/stddev): 59.9426/0.00
Next I deploy the docker version using this docker-compose.yml
file in port 57306
version: "3"
services:
mysql57:
build: ./bin/mysql57
container_name: 'mysql-5.7'
restart: 'unless-stopped'
ports:
- "57306:3306"
volumes:
- ./config/mysql57:/etc/mysql
- ./data/mysql57:/var/lib/mysql
- ./logs/mysql57:/var/log/mysql
environment:
MYSQL_ROOT_PASSWORD: <pass>
entrypoint: ""
command: bash -c "chown -R mysql:mysql /var/log/mysql && exec /entrypoint.sh mysqld"
The folder ./config/mysql57
is copied from the localhost configuration (/etc/mysql)
then I use this sysbench command
#prepare
sysbench --table_size=1000000 --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=57306 --mysql-db=sysbench --mysql-user=root --mysql-password=<pass> /usr/share/sysbench/oltp_read_only.lua prepare
#run
sysbench --table_size=1000000 --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=57306 --mysql-db=sysbench --mysql-user=root --mysql-password=<pass> --time=60 --max-requests=0 --threads=8 /usr/share/sysbench/oltp_read_only.lua run
I expect at least the transaction is near 4100 like above, but here it's only 1700
SQL statistics:
queries performed:
read: 1431402
write: 0
other: 204486
total: 1635888
transactions: 102243 (1703.87 per sec.)
queries: 1635888 (27261.87 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 60.0047s
total number of events: 102243
Latency (ms):
min: 3.01
avg: 4.69
max: 14.64
95th percentile: 5.99
sum: 479794.64
Threads fairness:
events (avg/stddev): 12780.3750/11.56
execution time (avg/stddev): 59.9743/0.00