0

I have MySQL (5.7) running in a Docker (18.03.1-ce) container and I'm benchmarking it using Sysbench (1.0.15). When I run Docker with --cpus=1 to limit the cpu utilization of the container, I get poor performance in terms of Transactions Per Second (TPS) and Latency (P99).

docker run --cpus=1 -it --rm mysqldemo

Result: TPS=490 and Latency(P99)=41ms

Now, if I increase the number of cpus to 2 the results get MUCH better.

docker run --cpus=2 -it --rm mysqldemo

Result: TPS=865 and Latency(P99)=1.5ms

Note, this performance boost is NOT simply a result of having more cores because in Sysbench I set the threads to 1. In both runs everything is the same except for the cpus limit.

So, I'm wondering if Docker has some sort of overhead that causes --cpus=1 performance to be poor.

Shadow
  • 33,525
  • 10
  • 51
  • 64
Justin Elkow
  • 2,833
  • 6
  • 28
  • 60
  • 2
    Does this question translate to "If I restrict my VM to just one core it runs slower than if I allow it to use two?" because if so I'm really confused. Yes, two cores should be faster than one. MySQL won't have to compete against the kernel for cycles. – tadman Jul 27 '18 at 20:49
  • You configured your benchmarking tool to be one thread, how about the configuration of the database? Did you check the CPU utilization of the processes inside the mysql container while running the benchmark? – BMitch Jul 27 '18 at 20:51
  • No @tadman, this is more than just an adding more available CPUs issue. I can show more threads & cores. You will see it is not linear, which leads me to believe that Docker has some CPU overhead. – Justin Elkow Jul 27 '18 at 21:11
  • Remember, in Docker there's a container with the kernel and whatever user processes that are constrained to whatever resource limits you apply. One core means one core, period, for both kernel and `mysqld`. Without more data I can only really speculate, but with two cores you'd get better latency because the user process can hand off to the kernel running concurrently instantly instead of waiting for a context switch each time. – tadman Jul 27 '18 at 21:12

0 Answers0