在一个项目中,我们需要服务一个小的静态 xml 文件 ~40k / s。
所有传入的请求都从 HAProxy 发送到服务器。但是,没有一个请求是持久的。
问题在于,在使用非持久请求进行基准测试时,nginx 实例的上限为 19 114 req/s。启用持久连接后,性能会提高近一个数量级,达到 168 867 req/s。结果与 G-wan 相似。
在对非持久请求进行基准测试时,CPU 使用率最低。
我可以做些什么来提高非持久连接和 nginx 的性能?
[root@spare01 lighttpd-weighttp-c24b505]# ./weighttp -n 1000000 -c 100 -t 16 "http://192.168.1.40/feed.txt"
finished in 52 sec, 315 millisec and 603 microsec, 19114 req/s, 5413 kbyte/s
requests: 1000000 total, 1000000 started, 1000000 done, 1000000 succeeded, 0 failed, 0 errored
status codes: 1000000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 290000000 bytes total, 231000000 bytes http, 59000000 bytes data
[root@spare01 lighttpd-weighttp-c24b505]# ./weighttp -n 1000000 -c 100 -t 16 -k "http://192.168.1.40/feed.txt"
finished in 5 sec, 921 millisec and 791 microsec, 168867 req/s, 48640 kbyte/s
requests: 1000000 total, 1000000 started, 1000000 done, 1000000 succeeded, 0 failed, 0 errored
status codes: 1000000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 294950245 bytes total, 235950245 bytes http, 59000000 bytes data