`

Nginx和Apache简单的并发压力测试

阅读更多
同样的环境,大小差不了几个字节的页面,

Nginx的worker_connections  1024;

Apache的MaxClients          150,worker模式;


照理说压Nginx如果用1024个并发压效果是最好的,同样压apache并发150的话效果也是最好的。


Nginx的测试结果:
[root@localhost nginx-0.7.19]# ab -t 60 -c 1024 http://192.168.1.101:8080/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Completed 40000 requests Completed 45000 requests Finished 50000 requests Server Software: nginx/0.7.19 Server Hostname: 192.168.1.101 Server Port: 8080 Document Path: / Document Length: 151 bytes Concurrency Level: 1024 Time taken for tests: 28.791802 seconds Complete requests: 50000 Failed requests: 0 Write errors: 0 Total transferred: 18100000 bytes HTML transferred: 7550000 bytes Requests per second: 1736.61 [#/sec] (mean) Time per request: 589.656 [ms] (mean) Time per request: 0.576 [ms] (mean, across all concurrent requests) Transfer rate: 613.89 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 19.0 0 2998 Processing: 33 531 448.3 458 3452 Waiting: 10 298 457.2 237 3415 Total: 33 531 448.7 458 3452 Percentage of the requests served within a certain time (ms) 50% 458 66% 466 75% 478 80% 483 90% 502 95% 599 98% 3409 99% 3428 100% 3452 (longest request)


Nginx5000个请求只花费了28秒就搞定。


Apache的测试结果:
[root@localhost nginx-0.7.19]# ab -t 60 -c 150 http://192.168.1.101/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Finished 39842 requests Server Software: Apache/2.2.10 Server Hostname: 192.168.1.101 Server Port: 80 Document Path: / Document Length: 44 bytes Concurrency Level: 150 Time taken for tests: 60.74169 seconds Complete requests: 39842 Failed requests: 0 Write errors: 0 Total transferred: 11953500 bytes HTML transferred: 1753180 bytes Requests per second: 663.21 [#/sec] (mean) Time per request: 226.172 [ms] (mean) Time per request: 1.508 [ms] (mean, across all concurrent requests) Transfer rate: 194.31 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 47.5 0 3000 Processing: 62 223 696.2 111 12013 Waiting: 0 156 605.3 58 9025 Total: 62 224 701.2 111 12013 Percentage of the requests served within a certain time (ms) 50% 111 66% 119 75% 125 80% 129 90% 159 95% 191 98% 3011 99% 3017 100% 12013 (longest request)


Apache一分钟只搞定了4000个请求。


再试试,Nginx的并发150时候的速度:
[root@localhost nginx-0.7.19]# ab -t 60 -c 150 http://192.168.1.101:8080/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Completed 40000 requests Completed 45000 requests Finished 50000 requests Server Software: nginx/0.7.19 Server Hostname: 192.168.1.101 Server Port: 8080 Document Path: / Document Length: 151 bytes Concurrency Level: 150 Time taken for tests: 27.603372 seconds Complete requests: 50000 Failed requests: 0 Write errors: 0 Total transferred: 18100000 bytes HTML transferred: 7550000 bytes Requests per second: 1811.37 [#/sec] (mean) Time per request: 82.810 [ms] (mean) Time per request: 0.552 [ms] (mean, across all concurrent requests) Transfer rate: 640.32 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 19.0 0 2998 Processing: 3 81 222.2 63 3066 Waiting: 0 47 216.0 31 3021 Total: 3 81 223.0 63 3066 Percentage of the requests served within a certain time (ms) 50% 63 66% 64 75% 65 80% 66 90% 70 95% 75 98% 86 99% 91 100% 3066 (longest request)


此次和上次Nginx1024个并发相比快了一秒钟,27秒搞定50000个请求


再试试,Apache的并发1024时候的速度:

我估计会被压死,先把帖子发出去,没压死再修改。。。
[root@localhost nginx-0.7.19]# ab -t 60 -c 1024 http://192.168.1.101/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Finished 2737 requests Server Software: Apache/2.2.10 Server Hostname: 192.168.1.101 Server Port: 80 Document Path: / Document Length: 44 bytes Concurrency Level: 1024 Time taken for tests: 75.767759 seconds Complete requests: 2737 Failed requests: 0 Write errors: 0 Total transferred: 821100 bytes HTML transferred: 120428 bytes Requests per second: 36.12 [#/sec] (mean) Time per request: 28347.164 [ms] (mean) Time per request: 27.683 [ms] (mean, across all concurrent requests) Transfer rate: 10.57 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 20 248.8 0 3002 Processing: 15158 20495 5117.8 18237 36418 Waiting: 23 9583 5978.2 9136 21205 Total: 15158 20516 5119.1 18238 39402 Percentage of the requests served within a certain time (ms) 50% 18238 66% 21138 75% 21187 80% 21197 90% 24196 95% 36319 98% 36415 99% 36417 100% 39402 (longest request)


居然没有死机! 结论:在我本机当前环境下,Nginx处理高并发小请求的速度要快于Apache。


开始用nginx的时候大家都说它比apache快很多,所以纯跑一下http看谁处理短连接更快,没有关注apache是否比nginx更稳定。
现在用nginx在生产上的项目并不多,apache还是主流,就是因为apache的稳定大家都信任,而nginx还没经受过长时间的考验。

你说的没错,apache很稳定!
分享到:
评论

相关推荐

    Nginx:取代apache的高性能服务器

    Nginx选择了epoll和kqueue作为网络I/O模型,在高连接并发的情况下,Nginx是Apache服务器不错的替代品,它能够支持高达50 000个并发连接数的响应,运行稳定,且内存、CPU等系统资源消耗非常低。, 本书主要分为4个部分...

    nginx高并发原理

    如何设计高并发网站?nginx高并发原理以及nginx vs Apache.

    Apache ab并发负载压力测试实现方法

    Apache的ab命令模拟多线程并发请求,测试服务器负载压力,也可以测试nginx、lighthttp、IIS等其它Web服务器的压力

    php+mysql+nginx安装与常遇到的错误.doc

    根据我的测试结果,Nginx 0.8.15 + PHP 5.2.10 (FastCGI) 可以承受3万以上的并发连接数,相当于同等环境下Apache的10倍。 具体可参考 张宴《Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6...

    实战Nginx:取代Apache的高性能Web服务器 中文版

    nginx选择了epoll和kqueue作为网络i/o模型,在高连接并发的情况下,内存、cpu等系统资源消耗非常低,运行稳定。  本书系统地介绍了nginx与php、ruby、python结合的使用方法,nginx作为反向代理与负载均衡的配置与...

    实战Nginx:取代Apache的高性能Web服务器

    Nginx选择了epoll和kqueue作为网络I/O模型,在高连接并发的情况下,Nginx是Apache服务器不错的替代品,它能够支持高达50000个并发连接数的响应,运行稳定,且内存、CPU等系统资源消耗非常低。  本书主要分为4个部分...

    nginx基础实例培训视频.zip

    目录网盘文件永久链接 01-nginx介绍及编译安装 02-nginx信号量 03-nginx虚拟主机配置 04-nginx日志管理 ...20-ab压力测试及nginx性能统计模块 21-nginx单机1W并发优化 22-服务器集群搭建 23-集群性能测试

    ab压力测试的安装、使用、破2万并发测试

    它的测试目标是基于URL的,因此,它既可以用来测试Apache的负载压力,也可以测试Nginx、Lighthttp、Tomcat、IIS等其它Web服务器的压力。 ab命令对发出负载的计算机要求很低,它既不会占用很高CPU,也不会占用很多

    nginx与apache限制ip并发访问 限制ip连接的设置方法

    nginx nginx限制ip并发数,也是说限制同一个ip同时连接服务器的数量 1.添加limit_zone 这个变量只能在http使用 vi /usr/local/nginx/conf/nginx.conf limit_zone one $binary_remote_addr 10m; 2.添加limit_conn 这...

    Nginx 1.22.0 Linux 版本,解压安装。

    在连接高并发的情况下,Nginx是Apache服务不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一。能够支持高达 50,000 个并发连接数的响应,感谢Nginx为我们选择了 epoll and kqueue作为开发...

    Nginx:影响高并发性能优化的主要参数配置(含Nginx运维标准文件)

    Nginx 是一个高性能的HTTP和反向代理web服务器,在连接高并发的情况下,Nginx是Apache服务不错的替代品。 日常的运维工作中,我们经常会用到nginx服务,也时常会碰到nginx因高并发导致的性能瓶颈问题。 今天,我来...

    实战nginx:取代Apache的高性能web服务器

    在高连接并发的情况下,Nginx是Apache服务器不错的替代品: Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一. 能够支持高达 50,000 个并发连接数的响应, 感谢Nginx为我们选择了 epoll and kqueue 作为...

    实战Nginx.取代Apache的高性能Web服务器.2010 pdf

    Nginx选择了epoll和kqueue作为网络I/O模型,在高连接并发的情况下,Nginx是Apache服务器不错的替代品,它能够支持高达50 000个并发连接数的响应,运行稳定,且内存、CPU等系统资源消耗非常低。  本书主要分为4个...

    Nginx 1.22.0 Windows版本,解压安装。

    在连接高并发的情况下,Nginx是Apache服务不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一。能够支持高达 50,000 个并发连接数的响应,感谢Nginx为我们选择了 epoll and kqueue作为开发...

    实战Nginx_取代Apache的高性能Web服务器].张宴.扫描版

    Nginx选择了epoll和kqueue作为网络I/O模型,在高连接并发的情况下,内存、 CPU等系统资源消耗非常低,运行稳定。  本书系统地介绍了Nginx与PHP、RUBY、Python结合的使用方法,Nginx作为反向代理与负载均衡的配置与...

    配置ab来为Nginx服务器做压力测试的方法

     但是,在压力测试中存在一个共性,那就是压力测试的结果与实际负载结果不会完全相同,就算压力测试工作做的再好,也不能保证100%和线上性能指标相同。面对这些问题,我们只能尽量去想方设法去模拟。所以,压力测试...

Global site tag (gtag.js) - Google Analytics