http压测nginx在Docker中的性能损失
1。 宿主机测试nginx版本[yeqiang@harbor wrk]$ /usr/local/nginx/sbin/nginx-Vnginx version: nginx/1.18.0built by gcc 9.2.1 20190827 (Red Hat 9.2.1-1) (GCC)configure arguments:配置:主要调整了CPU亲和配置,宿主服务器6核CPU,配置5个工作进程另
1。 宿主机测试
nginx版本
[yeqiang@harbor wrk]$ /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 9.2.1 20190827 (Red Hat 9.2.1-1) (GCC)
configure arguments:
配置:主要调整了CPU亲和配置,宿主服务器6核CPU,配置5个工作进程另外一个核留给压测客户端
#user nobody;
worker_processes 5;
worker_cpu_affinity auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65s;
server {
listen 81;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location = /50x.html {
root html;
}
}
}
wrk压测
(说明:实测wrk压测能力比apache bench约强30%,项目地址:https://github.com/wg/wrk)
benchmark.bin制作方法
[yeqiang@harbor wrk]$ sudo dd if=/dev/urandom of=/usr/local/nginx/html/benchmark.bin bs=4K count=1
[sudo] password for yeqiang:
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 0.000378936 s, 10.8 MB/s
[yeqiang@harbor wrk]$ ll /usr/local/nginx/html/benchmark.bin
-rw-r--r-- 1 root root 4096 2020-10-26 15:03:44 /usr/local/nginx/html/benchmark.bin
wrk版本
[yeqiang@harbor wrk]$ ./wrk --version
wrk 4.1.0-4-g0896020 [epoll] Copyright (C) 2012 Will Glozer
压测结果
[yeqiang@harbor wrk]$ ./wrk -t4 -c160 -d30s http://localhost:81/benchmark.bin
Running 30s test @ http://localhost:81/benchmark.bin
4 threads and 160 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 803.72us 1.16ms 21.36ms 91.92%
Req/Sec 65.30k 8.20k 102.88k 72.50%
7812697 requests in 30.09s, 31.66GB read
Requests/sec: 259640.68
Transfer/sec: 1.05GB
此时CPU表现,只有3.3id(空闲),基本接近极限
2。 Docker容器内Nginx http压测
[yeqiang@harbor wrk]$ docker run --rm -it -p 81:81 centos /bin/bash
[root@c6f0d2296598 /]#
wrk测试结果
yeqiang@harbor wrk]$ ./wrk -t4 -c160 -d30s http://localhost:81/benchmark.bin
Running 30s test @ http://localhost:81/benchmark.bin
4 threads and 160 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.58ms 1.04ms 51.48ms 83.58%
Req/Sec 25.33k 2.66k 38.80k 71.33%
3028759 requests in 30.07s, 12.27GB read
Requests/sec: 100719.32
Transfer/sec: 417.92MB
wrk压测性能表现不足宿主服务器一半
此时CPU表现(注意docker-proxy CPU使用率偏高!)
总结:
根据以往的测试:
Docker UnixBench测试https://hknaruto.blog.csdn.net/article/details/109244148
iperf测试https://hknaruto.blog.csdn.net/article/details/109288085
及本次http性能测试,可以看到Docker部署服务,最大的性能损失在于网络,docker-proxy转发性能表现一般。但实际一般项目也不会达到这种水平的负载量,宿主机器测试时,本地网卡lo的流量已达11000Mbps,超过万兆网口的物理限制。
其次性能损失在于文件系统IO
更多推荐
所有评论(0)