使用下面脚本压测:
siege -q -c1000 -r100 -lsiege.log -b http://127.0.0.1:8081/hello_world
然后mochiweb启动选项:
1使用选项:
{acceptor_pool_size, 200}
压测结果:
$siege -q -c1000 -r100 -lsiege.log -b http://127.0.0.1:8081/hello_worldTransactions: 100000 hitsAvailability: 100.00 %Elapsed time: 6.69 secsData transferred: 1.24 MBResponse time: 0.04 secsTransaction rate: 14947.68 trans/secThroughput: 0.19 MB/secConcurrency: 565.82Successful transactions: 100000Failed transactions: 0Longest transaction: 3.31Shortest transaction: 0.00
2.使用选项:
{acceptor_pool_size, 20}
输出结果:
$siege -q -c1000 -r100 -lsiege.log -b http://127.0.0.1:8081/hello_worldTransactions: 100000 hitsAvailability: 100.00 %Elapsed time: 7.36 secsData transferred: 1.24 MBResponse time: 0.03 secsTransaction rate: 13586.96 trans/secThroughput: 0.17 MB/secConcurrency: 473.18Successful transactions: 100000Failed transactions: 0Longest transaction: 7.04Shortest transaction: 0.00
可以看到次数相同,但响应时间是20个连接池的较快,但其他数值是200个连接池的较好。显然,20 - 200间个某个特殊值可能会达到最优,因为这里面的差距没有1个数量级。