Nginx performance issues in docker container

I am using ApacheBench (ab) to measure the performance of two nginx on Linux. They have the same configuration file. The only difference is that one of nginx works in the docker container.

Nginx on the host system:

Running: ab -n 50000 -c 1000 http://172.17.0.2:7082/

Concurrency Level:      1000
Time taken for tests:   9.376 seconds
Complete requests:      50000
Failed requests:        0
Total transferred:      8050000 bytes
HTML transferred:       250000 bytes
Requests per second:    5332.94 [#/sec] (mean)
Time per request:       187.514 [ms] (mean)
Time per request:       0.188 [ms] (mean, across all concurrent requests)
Transfer rate:          838.48 [Kbytes/sec] received

Nginx in docker container:

Running: ab -n 50000 -c 1000 http://172.17.0.2:6066/

Concurrency Level:      1000
Time taken for tests:   31.274 seconds
Complete requests:      50000
Failed requests:        0
Total transferred:      8050000 bytes
HTML transferred:       250000 bytes
Requests per second:    1598.76 [#/sec] (mean)
Time per request:       625.484 [ms] (mean)
Time per request:       0.625 [ms] (mean, across all concurrent requests)
Transfer rate:          251.37 [Kbytes/sec] received

Just wondering why the container has such poor performance.

nginx.conf:

worker_processes  auto;
worker_rlimit_nofile 10240;

events {
    use epoll;
    multi_accept on;
    worker_connections  4096;
}

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

    sendfile        on;
    keepalive_timeout  10;

    client_header_timeout 10;
    client_body_timeout 10;

    send_timeout 10;

    tcp_nopush on;
    tcp_nodelay on;

    server {
        listen       80;
        server_name  localhost;
        location / {
            return 200 'hello';
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
+4
source share
2 answers

How do you manage the container? Does Docker use the default bridge network? If so, try running the tests with --net=hostand see what the results look like.

+3
source

@Andrian Mouat , .

Docker:

:

bridge , host , , docker.

, , , -.


Flame Graphs:

--net=host, , . :

  • 30 : sudo perf record -F 99 -a -g -- sleep 30
  • ab : ab -n 50000 -c 1000 http://my-host-ip/ ( )

, - : www.brendangregg.com/

-p 80:80:

nginx:

docker nginx flame graph publish port zoomed



--net=host:

nginx:

docker nginx flame graph net host zoomed

+1

Source: https://habr.com/ru/post/1694215/


All Articles