我的机子配置 2G内存
1:安装好apache和nginx。它们共用80端口(哈哈,当然修改端口是很简单的),apache安装在 /opt/httpd目录下,nginx安装在/opt/nginx中。
2:安装好webbench(很简单,下载解压后,进入目录,make ,make install即可进行安装),用于压力测试。
3:cd /opt/httpd/bin
./apachectl start
netstat -antl | grep 80 //用以确认该服务是否真正启动!以下是测试部分:
[root@*bin]# webbench -c 5000 -t 60 http://127.0.0.1/apache_pb.png Webbench - Simple Web Benchmark 1.5 Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software. Benchmarking: GET http://127.0.0.1/apache_pb.png 5000 clients, running 60 sec. Speed=208453 pages/min, 5741557 bytes/sec. Requests: 208279 susceed, 174 failed. |
很直观的一点就是说有174个响应失败。
4:为了测试的准确性,我
cp /opt/httpd/htdocs/apache_pb.png /opt/nginx/html/ //复制文件 |
[[email protected] bin]# pkill httpd //将服务kill掉 [[email protected] bin]# netstat -antl | grep 80 //确认apache是否被kill [[email protected] bin]# /opt/nginx/sbin/nginx //启动nginx [[email protected] bin]# netstat -antl | grep 80 //确认是否正常启动 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN //压力测试: [*]# webbench -c 5000 -t 60 http://127.0.0.1/apache_pb.png Webbench - Simple Web Benchmark 1.5 Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software. Benchmarking: GET http://127.0.0.1/apache_pb.png 5000 clients, running 60 sec. Speed=325235 pages/min, 8656698 bytes/sec. Requests: 325235 susceed, 0 failed. [[email protected] bin]# |