欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

nginx win32 版本静态文件测试 (Windows环境)

程序员文章站 2022-05-11 21:37:39
下载了 nginx for win32 的官方版本 nginx 0.7.53 进行了试用以及压力测试。 安装使用方式很简单,直接贴官方的方式: win32 binaries...
下载了 nginx for win32 的官方版本 nginx 0.7.53

进行了试用以及压力测试。

安装使用方式很简单,直接贴官方的方式:
win32 binaries

as of 0.7.52, nginx is now available as an official windows binary.

installation:

cd c:\
unzip nginx-0.7.52.zip
ren nginx-0.7.52 nginx
cd nginx
start nginx

control:
nginx -s [ stop | quit | reopen | reload ]

for problems look in c:\nginx\logs\error.log or in eventlog.

但要说明一下的,之前有第三方编译的 nginx for windows 版本,是可以加载到 windows 服务中运行的。但在这个官方版本下该方法行不通。所以建议暂时手动启动,或者新建一个计划任务开机启动。

然后迫不及待进行压力测试。我们使用的工具是 apache 的 ab , 测试的是纯静态页面。就是 nginx 一装好后默认的 :
welcome to nginx!

测试命令:./ab -c 100 -n 10000 http://192.168.3.50:8888/
操作系统:windows server 2003 r2
硬件配置:xeon 2.8g x2 1g ram
测试结果:

server software: nginx/0.7.53
server hostname: 192.168.3.50
server port: 8888

document path: /
document length: 151 bytes

concurrency level: 100
time taken for tests: 107.329 seconds
complete requests: 10000 (100%处理请求,没有丢失)
failed requests: 0
write errors: 0
total transferred: 3620000 bytes
html transferred: 1510000 bytes
requests per second: 93.17 [#/sec] (mean) 每秒处理请求 93.17 个
time per request: 1073.293 [ms] (mean)
time per request: 10.733 [ms] (mean, across all concurrent requests)
transfer rate: 32.94 [kbytes/sec] received

connection times (ms)
min mean[+/-sd] median max
connect: 0 13 44.3 2 550
processing: 180 1059 350.5 1065 2665
waiting: 178 1053 352.3 1058 2664
total: 194 1071 351.9 1074 2668

percentage of the requests served within a certain time (ms)
50% 1074
66% 1162
75% 1215
80% 1288
90% 1547
95% 1694
98% 1853
99% 1946
100% 2668 (longest request)
################

由测试结果所得,nginx for windows 100 个线程每秒只能处理 93 个请求。
如果再启动多一个 ab 来压,加起来就有200个线程,ab结果相当。各端每秒处理93个请求。
但如果你再启动第三ab 进行 100 个线程压力,正在进行的2个ab 其中一个就会被服务端拒绝。

来回尝试修改nginx的worker_processes 参数无果,修改了 win2003 的并发线程也无果….难道 nginx 在windows下就只能有这么点能耐??回头要再详细找找原因。

另外还有一个问题,当压力测试完毕了,在 windows 中查看进程会发现 nginx 还占着 2~30 的cpu。
在命令行下 nginx -s stop 也无法停止。必须 结束进程…..

################

初步尝试就这几点,希望是我个别的问题,有机会的朋友也不妨试试。

配置 pd930 cpu,2g 内存,测试结果如下:

c:\>ab -n 10000 -c 100 http://192.168.1.8/
this is apachebench, version 2.3 <$revision: 655654 $>
copyright 1996 adam twiss, zeus technology ltd, http://www.zeustech.net/
licensed to the apache software foundation, http://www.apache.org/

benchmarking 192.168.1.8 (be patient)
completed 1000 requests
completed 2000 requests
completed 3000 requests
completed 4000 requests
completed 5000 requests
completed 6000 requests
completed 7000 requests
completed 8000 requests
completed 9000 requests
completed 10000 requests
finished 10000 requests

server software: nginx/0.7.52
server hostname: 192.168.1.8
server port: 80

document path: /
document length: 151 bytes

concurrency level: 100
time taken for tests: 5.109 seconds
complete requests: 10000
failed requests: 0
write errors: 0
total transferred: 3620000 bytes
html transferred: 1510000 bytes
requests per second: 1957.19 [#/sec] (mean)
time per request: 51.094 [ms] (mean)
time per request: 0.511 [ms] (mean, across all concurrent requests)
transfer rate: 691.90 [kbytes/sec] received

connection times (ms)
min mean[+/-sd] median max
connect: 0 0 2.4 0 16
processing: 16 50 13.3 47 78
waiting: 0 34 14.4 31 78
total: 16 51 13.3 47 78

percentage of the requests served within a certain time (ms)
50% 47
66% 63
75% 63
80% 63
90% 63
95% 63
98% 63
99% 78
100% 78 (longest request)