Performance issues running a database in a docker

2019-07-06 09:33发布

问题:

Has anyone noticed any performance issues running a database (MySQL or Postgres) in a docker container, I'm told that severe performance degradation occurs.

Please advise.

回答1:

Docker itself imposes very little overhead, it's just isolating the process from other processes on the host. However, there are lots of things you can do to degrade the performance of a container:

  1. Run it inside Windows/MacOS while only giving the embedded VM a fraction of the memory/CPU of the parent OS.
  2. Restrict CPU or memory resources inside the container.
  3. Launch a lot of containers on your host. Docker isn't magic, if 10 instances of Java each using 2 gigs of ram bring the host to a crawl outside of container, they won't run any better inside of containers.
  4. Networking complications. Each container is by default spun up on an isolated network bridge, where IO may take a little longer with the extra hops. And if your DNS isn't properly configured, you may see extra delays from failed lookups.
  5. Bare metal requirements like direct disk access aren't allowed by default in Docker. You can give access to specific devices, but otherwise the containerized version of the app is isolated intentionally.
  6. Data in volumes may reside in a less efficient location. By default it's your /var/lib/docker filesystem, but you could easily point this to an NFS mount where the performance would be even worse.
  7. Misconfigured DB, e.g. forgetting to create an index.

In short, the container is unlikely to be the issue itself, but make sure you're doing an apples to apples comparison.



回答2:

We see no performance penalty when running SQL Server in WinDocks Windows containers.

The container instance performs just as any SQL Server instance on a shared host.

Disclosure: I am the Co-Founder of WinDocks