注意docker在加载时停止响应。以下是重现此问题的步骤:
docker-machine create -d virtualbox web
docker-machine ip web
192.168.99.253
eval $(docker-machine env web)
docker run --name app -d -p 3000:3000 ragesh / hello-express
ab -n 100000 -c 100 http://192.168.99.253:3000/
Server Hostname: 192.168.99.253
Server Port: 3000
Document Path: /
Document Length: 207 bytes
Concurrency Level: 100
Time taken for tests: 145.726 seconds
Complete requests: 100000
Failed requests: 0
Total transferred: 38900000 bytes
HTML transferred: 20700000 bytes
Requests per second: 686.22 [#/sec] (mean)
Time per request: 145.726 [ms] (mean)
Time per request: 1.457 [ms] (mean, across all concurrent requests)
Transfer rate: 260.68 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 15
Processing: 32 145 14.1 140 237
Waiting: 32 145 14.1 140 237
Total: 36 146 14.1 140 237
Percentage of the requests served within a certain time (ms)
50% 140
66% 146
75% 151
80% 155
90% 165
95% 173
98% 185
99% 196
100% 237 (longest request)
一切看起来都很好 - 甚至是100000。
docker-machine create -d virtualbox router
eval $(docker-machine env router)
vi nginx.conf
upstream web {
server 192.168.99.253:3000;
}
server {
listen 80;
location / {
proxy_pass http://web;
}
}
docker run --name router -p 80:80 -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro -d nginx
docker-machine ip router
192.168.99.252
ab -n 10000 -c 100 http://192.168.99.252:80/
Server Software: nginx/1.9.14
Server Hostname: 192.168.99.252
Server Port: 80
Document Path: /
Document Length: 207 bytes
Concurrency Level: 100
Time taken for tests: 32.631 seconds
Complete requests: 5957
Failed requests: 0
Total transferred: 2448327 bytes
HTML transferred: 1233099 bytes
Requests per second: 182.56 [#/sec] (mean)
Time per request: 547.773 [ms] (mean)
Time per request: 5.478 [ms] (mean, across all concurrent requests)
Transfer rate: 73.27 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 52.6 0 3048
Processing: 2 168 56.2 164 3002
Waiting: 2 168 56.2 163 3002
Total: 2 169 97.7 164 5032
Percentage of the requests served within a certain time (ms)
50% 164
66% 171
75% 176
80% 178
90% 185
95% 192
98% 199
99% 209
100% 5032 (longest request)
预计每秒请求数将下降,但除非下降得如此之大。并运行ab几次,经常出现连接错误。
我做错了吗?