免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 9127 | 回复: 3
打印 上一主题 下一主题

[Web] 关于apache最大并发数的一些疑问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-02-23 10:36 |只看该作者 |倒序浏览
20可用积分
环境:
vmware5.5 centos 5.2 Apache/2.2.10
由于是实验环境,无应用,只有一个index.html

疑问1:使用了limitipconn_module来限制同一IP的并发连接,设置如下:
ExtendedStatus On
<IfModule limitipconn_module>
<Location />
MaxConnPerIP 3
NoIPLimit image/*
</Location>
</IfModule>
使用迅雷测试下载一个电影文件,默认的5个线程中只有3个线程在读取数据,经多次测试无误。这应该能说明上述的设置上有效的吧?
能不能用ab来测试同一IP的并发连接数呢?下面是我的设想,不知道科学与否,还请指正:
在上述设置下,同一IP的最大并发连接数为3,我若使用如下指令:ab -n 50 -c 10 127.0.0.1/index.html,每次并发量为10,则是不是应该有7个连接被拒绝呢?得到如下结果:
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 127.0.0.1 (be patient).....done

Server Software:        Apache
Server Hostname:        127.0.0.1
Server Port:            80
Document Path:          /index.html
Document Length:        44 bytes
Concurrency Level:      10
Time taken for tests:   0.103 seconds
Complete requests:      50
Failed requests:        35
   (Connect: 0, Receive: 0, Length: 35, Exceptions: 0)
Write errors:           0
Non-2xx responses:      35
Total transferred:      26384 bytes
HTML transferred:       16734 bytes
Requests per second:    487.28 [#/sec] (mean)
Time per request:       20.522 [ms] (mean)
Time per request:       2.052 [ms] (mean, across all concurrent requests)
Transfer rate:          251.10 [Kbytes/sec] received
若依据上述结果,则access_log中会有连接三个200和连续七个503的记录。
上述ab测试是基于这种测试方法正确的假设之上的,事实上我在后来的测试过程中也多次出现过以上的结果,但每次测试的结果并不完全一样,有时候被拒的包会较多,有时候较少,还会如下结果出现:
Server Software:        Apache
Server Hostname:        127.0.0.1
Server Port:            80
Document Path:          /index.html
Document Length:        44 bytes
Concurrency Level:      10
Time taken for tests:   0.113 seconds
Complete requests:      50
Failed requests:        0
Write errors:           0
Total transferred:      14000 bytes
HTML transferred:       2200 bytes
Requests per second:    442.83 [#/sec] (mean)
Time per request:       22.582 [ms] (mean)
Time per request:       2.258 [ms] (mean, across all concurrent requests)
Transfer rate:          121.09 [Kbytes/sec] received
根据以上情况,我的疑问是:
a、以我上述的方法测试同一IP最大并发连接数的方法是否科学?为什么?
b、ab测试的结果为什么会出现这种不稳定的情况?
疑问2:关于prefork模式下最大并发数的问题:
关闭limitipconn_module,MPM配置如下:
<IfModule mpm_prefork_module>
    StartServers          8
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
在此配置下,apache的最大并发数应该为150吧?那么我用ab或webbench测试151的并发正常来说是不是应该会报错呢?但测试结果却不是如此:
[root@centos ~]# ab -n 300 -c 151 http://127.0.0.1/index.html
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 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Finished 300 requests

Server Software:        Apache
Server Hostname:        127.0.0.1
Server Port:            80
Document Path:          /index.html
Document Length:        44 bytes
Concurrency Level:      151
Time taken for tests:   0.404 seconds
Complete requests:      300
Failed requests:        0
Write errors:           0
Total transferred:      84000 bytes
HTML transferred:       13200 bytes
Requests per second:    743.47 [#/sec] (mean)
Time per request:       203.102 [ms] (mean)
Time per request:       1.345 [ms] (mean, across all concurrent requests)
Transfer rate:          203.29 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   29  28.3     11      92
Processing:    33  123  50.4    134     304
Waiting:       18  119  51.0    130     302
Total:         46  153  60.5    147     393
Percentage of the requests served within a certain time (ms)
  50%    147
  66%    154
  75%    159
  80%    171
  90%    215
  95%    236
  98%    389
  99%    392
100%    393 (longest request)
[root@centos ~]# ab -n 700 -c 257 http://127.0.0.1/index.html
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 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Finished 700 requests

Server Software:        Apache
Server Hostname:        127.0.0.1
Server Port:            80
Document Path:          /index.html
Document Length:        44 bytes
Concurrency Level:      257
Time taken for tests:   1.308 seconds
Complete requests:      700
Failed requests:        0
Write errors:           0
Total transferred:      196560 bytes
HTML transferred:       30888 bytes
Requests per second:    535.05 [#/sec] (mean)
Time per request:       480.330 [ms] (mean)
Time per request:       1.869 [ms] (mean, across all concurrent requests)
Transfer rate:          146.72 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   22  28.6      8     105
Processing:    33  292 375.7    144    1198
Waiting:       23  288 377.4    140    1197
Total:         36  314 400.9    150    1303
Percentage of the requests served within a certain time (ms)
  50%    150
  66%    155
  75%    160
  80%    177
  90%   1218
  95%   1260
  98%   1286
  99%   1295
100%   1303 (longest request)
[root@centos ~]# webbench -c 257 -t 10 http://127.0.0.1/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://127.0.0.1/index.html
257 clients, running 10 sec.
Speed=85380 pages/min, 398412 bytes/sec.
Requests: 14230 susceed, 0 failed.
根据上述情况的疑问如下:
a、 根据上述配置,正常情况下最大并发是150,是不是这样?若不是,为什么?
b、ab或webbench能不能用来测试apache的最大并发数,数据是否准确?我的使用方法是否有误?


多谢!!

论坛徽章:
0
2 [报告]
发表于 2009-02-26 11:54 |只看该作者
神啊,救救我吧!

论坛徽章:
0
3 [报告]
发表于 2009-02-26 14:43 |只看该作者
正常情况下最大并发是150 正常是这样的,是指同时并发连接数。
用ab来测并发数并不准确。

论坛徽章:
0
4 [报告]
发表于 2009-03-04 23:53 |只看该作者
原帖由 我是DBA 于 2009-2-26 14:43 发表
正常情况下最大并发是150 正常是这样的,是指同时并发连接数。
用ab来测并发数并不准确。


为什么用ab不能准确测试呢?
还有就是webbench能准确测试吗?

还请赐教!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP