My nginx configuration seems to offer extremely poor performance through a docker network, while the host machine (a dedicated server) has great specs (104 threads, 245gb DDR4, SSD).

When benchmarking using wrk to serve a static HTML file (1mb) from outside the host, I'm getting around 10 req/s.

Running 30s test @ http://x/static.html
  40 threads and 80 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.62s     2.37s   13.20s    67.02%
    Req/Sec     0.46      1.40    10.00     90.74%
  382 requests in 30.09s, 393.63MB read
Requests/sec:     12.69
Transfer/sec:     13.08MB

When connecting from a container in the same docker network, I'm getting a decent 500 req/sec.

I'm not seeing any significant CPU load on the host, nor in docker stats. Not a lot of disk IO either, and there is still a massive amount of memory available.

One thing I've read as a solution is to run the nginx instance on the host network, but as I have multiple nginx instances running on the same host (with an equal amount of PHP FPM instances), I would not like to run them all in host mode and have to deal with all the ports that need to be assigned. I'm also using the docker container names to reach FPM within the same docker (bridge) network.

Nginx configs:

server {
    listen 80;
    server_name x;

    root /app/web;
    index app.php;

    location / {
        try_files $uri $uri/ /app.php?$args;
user  nginx;

worker_processes auto;

worker_rlimit_nofile 100000;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections 4000;
    multi_accept        on;
    use                 epoll;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$host" "$request" "$scheme" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" -- $request_time';

    access_log  /var/log/nginx/access.log  main;

    #gzip            on;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    server_tokens off;

    # allow long domain names
    server_names_hash_bucket_size 128;

    proxy_buffering                 off;
    proxy_buffer_size  128k;
    proxy_buffers 100  128k;

    include /etc/nginx/sites-enabled/*;

    keepalive_requests 100000;

What could I do to discover/profile the bottleneck? And are there any options getting decent performance using docker bridge networks?

1 Answer 1


Do you need PHP - and PHP-FPM? Your question speaks about profiling using a static HTML file. The response will clearly be different for static vs dynamic PHP.
If you are only interested in static HTML - you could run the NGINX in a container and expose port 80. That would provide a better comparison with your "connect within the docker network". You could put the static file(s) on a docker volume for the container if you don't want to copy them in.
If you need PHP - then loading this into a docker container alongside nginx would still offer you more control than accepting the common denominator of the host machine.
Let us know what happens...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .