zl程序教程

您现在的位置是:首页 >  工具

当前栏目

运维基础之Docker(6)性能

2023-09-14 09:00:07 时间

The general result is that Docker is nearly identical to Native performance and faster than KVM in every category.

1 CPU

2 Memory

 

3 Network

 

Docker’s use of bridging and NAT noticeably increases the transmit path length; vhost-net is fairly efficient at transmitting but has high overhead on the receive side. Containers that do not use NAT have identical performance to native Linux.

 

NAT, as used in Docker, doubles latency in this test. KVM adds 30µs of overhead to each transaction compared to the non-virtualized network stack, an increase of 80%.

 

4 Disk

 

 

 

 

5 Other

5.1 redis

 

5.2 mysql

 

 

 

可见除了Network之外,docker非常接近native,
带宽测试:nuttcp (http://www.nuttcp.net/)
延迟测试:netperf (http://netperf.org/netperf/)
而docker network中常用的host和bridge差别也很大,对nginx压测数据如下:

1)native

# ./http_load -p 10 -s 10 urls/raw_nginx.urls
274791 fetches, 10 max parallel, 1.78339e+08 bytes, in 10.0001 seconds
649 mean bytes/connection
27478.9 fetches/sec, 1.78338e+07 bytes/sec
msecs/connect: 0.0345773 mean, 0.445 max, 0.011 min
msecs/first-response: 0.310406 mean, 1.026 max, 0.088 min
HTTP response codes:
code 200 -- 274791

2)docker network-host

# ./http_load -p 10 -s 10 urls/docker_host_nginx.urls
202773 fetches, 10 max parallel, 1.316e+08 bytes, in 10 seconds
649 mean bytes/connection
20277.3 fetches/sec, 1.31599e+07 bytes/sec
msecs/connect: 0.0426044 mean, 0.897 max, 0.013 min
msecs/first-response: 0.423675 mean, 1.401 max, 0.076 min
HTTP response codes:
code 200 -- 202773

3)docker network-bridge

# ./http_load -p 10 -s 10 urls/docker_bridge_nginx.urls
80282 fetches, 10 max parallel, 5.2103e+07 bytes, in 10 seconds
649 mean bytes/connection
8028.2 fetches/sec, 5.2103e+06 bytes/sec
msecs/connect: 0.0522431 mean, 0.489 max, 0.014 min
msecs/first-response: 1.17323 mean, 10.748 max, 0.122 min
HTTP response codes:
code 200 -- 80282

几种部署的nginx结果如下:使用native可以达到27k的tps,使用docker network-host可以达到20k的tps(下降24%),使用docker network-bridge(默认)可以达到8k的tps(下降70%);

 

参考:

docker network

https://docs.docker.com/network/

 

An Updated Performance Comparison of Virtual Machines and Linux Containers

https://domino.research.ibm.com/library/cyberdig.nsf/papers/0929052195DD819C85257D2300681E7B/$File/rc25482.pdf