如何对 apache/nginx 设置进行基准测试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2528266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to benchmark apache/nginx setup
提问by Saif Bechan
I am planning to setup nginx as reverse proxy. I will have apache to deliver my dynamic content, and nginx will deliver the static content.
我打算将 nginx 设置为反向代理。我将让 apache 来传送我的动态内容,而 nginx 将传送静态内容。
My configuration i have now is just Apache with fastCGI. This gives me no configuration problems and runs great.
我现在的配置只是带有 fastCGI 的 Apache。这给我没有配置问题并且运行良好。
After I have set up nginx I want to run some benchmarks to see if I really got some performance increases, else i will switch back.
在我设置了 nginx 之后,我想运行一些基准测试,看看我是否真的得到了一些性能提升,否则我会切换回来。
Does anyone know how I can benchmark this type of setup? Or maybe someone did this already and have some canned results, I will be glad to hear them.
有谁知道我如何对这种类型的设置进行基准测试?或者,也许有人已经这样做了并取得了一些预想的结果,我会很高兴听到他们的消息。
PS.I know this is more a serverfault type of question, but i have seen numerous posts about apache and nginx so i thought i give it a try
附注。我知道这更像是一个服务器故障类型的问题,但我看过很多关于 apache 和 nginx 的帖子,所以我想我试一试
回答by cliff.wells
A few things:
一些东西:
Don't use ab. It's single-threaded and you will probably end up benchmarking ab rather than your HTTP server.
Don't run whatever stress tool you use on the same system as the server. The HTTP server will be competing with the tool for CPU and other resources. Plus localhost's idealized version of a network doesn't tell the whole picture (see point 4).
Pay attention to memory and CPU utilization during the tests. So many people never consider this factor. Even if both setups perform equally, if one uses a fraction of the RAM/CPU, then you have a winner.
RPS isn't the only meaningful metric. Things like slow clients (3G smartphones, congested networks, slow PC's) can have a distinctly negative impact on threaded servers. The idealized lab setup (localhost or isolated switch) won't reflect this.
Your FCGI script will be the bottleneck for either server. I'd suggest using a tool that can pull multiple resources (ideally an entire page, including static content) so you can get a complete picture of page load times.
不要使用 ab。它是单线程的,你可能最终会测试 ab 而不是你的 HTTP 服务器。
不要在与服务器相同的系统上运行您使用的任何压力工具。HTTP 服务器将与该工具竞争 CPU 和其他资源。加上 localhost 理想化的网络版本并不能说明全部情况(参见第 4 点)。
在测试过程中注意内存和 CPU 利用率。所以很多人从来没有考虑过这个因素。即使两种设置的性能相同,如果其中一个使用了 RAM/CPU 的一小部分,那么您就是赢家。
RPS 并不是唯一有意义的指标。诸如慢速客户端(3G 智能手机、拥挤的网络、慢速 PC)之类的事情会对线程服务器产生明显的负面影响。理想化的实验室设置(本地主机或隔离交换机)不会反映这一点。
您的 FCGI 脚本将成为任一服务器的瓶颈。我建议使用可以提取多个资源(最好是整个页面,包括静态内容)的工具,以便您可以全面了解页面加载时间。
You might consider using one of the "cloud-based" testing tools, such as browsermob.com or loadimpact.com.
您可以考虑使用“基于云的”测试工具之一,例如 browsermob.com 或 loadimpact.com。
回答by mighq
http://curl-loader.sourceforge.net/
http://curl-loader.sourceforge.net/
a bit harder to config, but works great
配置有点困难,但效果很好

