I\'m using ApacheBench (ab) to measure the performance of two nginx on Linux. They have same config file. The Only difference is one of nginx is running in a docker containe
How are you running the container? Is it using the default Docker bridge network? If so, try running the tests with --net=host
and see what the results look like.
I'd like to add to @Andrian Mouat's answer, something I've just found in the docs.
It is written in the Docker run reference:
NETWORK: HOST
Compared to the default
bridge
mode, thehost
mode gives significantly better networking performance since it uses the host’s native networking stack whereas the bridge has to go through one level of virtualization through the docker daemon.It is recommended to run containers in this mode when their networking performance is critical, for example, a production Load Balancer or a High Performance Web Server.
When using the host’s native networking stack with --net=host
, there are fewer system calls and this is clearly depicted in the following Flame Graphs. Details:
sudo perf record -F 99 -a -g -- sleep 30
ab -n 50000 -c 1000 http://my-host-ip/
(takes place while capturing)For more info on Flame Graphs, check Brendan Gregg's website: www.brendangregg.com/
-p 80:80
:Full picture here
Zoomed to nginx
part:
--net=host
:Full picture here
Zoomed to nginx
part: