How to optimize performance for a docker container? How to optimize performance for a docker container? docker docker

How to optimize performance for a docker container?


The container appears to be slower because you are going through an extra network layer.

In that case, instead of connecting directly to Redis, to connect to the Docker userland proxy, which itself connects back to the container (and instead of going over a local interface, this connection goes over a veth interface).

This adds a little bit of latency (not measurable compared to, e.g, a 10ms webpage generation; but 50µs is still faster than 150µs, if you see what I mean).

If you want to do a more "apples to apples" comparison, you could:

  • run redis-benchmark inside the container (to connect directly to Redis from within the container);
  • run redis-benchmark on another machine (but keep in mind that you will still have an extra network layer for the port translation mechanism);
  • run redis-benchmark on another machine and use a mechanism like pipework to give the container a macvlan interface with (almost) zero overhead.


The extra network layer of the container is the performance bottleneck in your scenario, and communicating from docker-to-docker will not help too much (some optimizations apply, but then also some extra overhead has to be confronted).

Also, running redis-benchmark in the same container as redis server will give you host-level performance but this is not the use case you are looking for, probably you would like to know the performance that can be provided by a dockerized redis server.

We, at Torusware, have done some tests to assess the overhead of dockerized applications and we have realized that the network layer of the container is limiting the performance.

In fact, running a dockerized redis-benchmark and a dockerized redis server in the same host, only achieves 38k GET and 46k SET requests per second.

We have a solution for accelerating this scenario, in a non intrusive way (no change neither in Docker nor the applications). It is our product Speedus Plug&Run, a high-performance socket library.

By using the Redis+Speedus Lite docker (available in the Docker registry for free), you will be able to reduce significantly the peak times (worst case scenario), from almost 1 second to below 1 millisecond.

Furthermore, Redis+Speedus Lite multiplies the performance by 2.5X for SET (from 46k TPS to 113k TPS) and multiplies by 3X for GET (from 39k TPS to 121k TPS).

Check this post in our blog for further details.

But if you really look for extreme performance, our Speedus Extreme Performance version will make your redis servers run really fast. Thanks to our technology, a dockerized redis server can provide other dockerized applications with 717k SET requests and 415k GET requests per second!

Check details in this post.