zsyzhou 发表于 2018-11-26 12:09:05

apache最大连接数性能测试

apache最大连接数性能测试
这天工作没什么事情,翻开看资料,再次学习一下apache的性能优化,以下就说说我的设置及测试。
先说一下我的测试机硬件及软件配置环境,
硬件:一台比较古老的机器,cpu: P42.0 ,内存256,其他的就不多说了。
软件:linux as 4 , apache2.0.59
先说一下这次安装及配置就是测试apache的性能,如果你打算看其他方面的,那就不要看了,因为偶也没有写,嘿嘿嘿。。。。。。http://blog.51cto.com/editor/icons/etc_16.gif
./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-so
说明;
的引入是MPM,多道处理模块),,2.xmpmt_os2和MPM
CGI版本中的threadpool的变体
prefork平台上缺省的 Apache 1.3本身并没有使用到线程,1.3用单独的子进程来处理不同的请求,进程之间是彼此独立的,这也使其成为最稳定的prefork编译和“httpd -l”,应该会看到httpd.conf
StartServers 5
MaxClients 150
prefork个子进程后,为了满足……个,直到满足prefork
设置了最大的空闲进程数,如果空闲进程数大于这个值,kill小,MinSpareServers+1和 MaxRequestsPerChild个请求后将自动销毁。0
可防止意外的内存泄漏;  ◆ 是这些指令中最为重要的一个,设定的是Apache是远远不够的,如果请求总数已达到这个值(可通过HTTP默认的限制不能大于256将无法起动。事实上,Apache 1.3前手工修改源代码树下的 256这行。把4000即可。在ServerLimitApache。下面是测试的
MaxSpareServers 15
MaxRequestsPerChild 10000
的最大值是server/mpm/prefork/prefork.c
worker2.x 模型。由于使用线程来处理,所以可以处理相对海量的请求,而系统资源的开销要小于基于进程的服务器。但是,MPM的发展趋势。
后,进行make install中有以下配置段:
MinSpareThreads 25
MaxRequestsPerChild 0
的工作原理是,由主控制进程生成ThreadsPerChild 和MaxClients
和75。这两个参数对worker MPMThreadsPerChild,如果负载较大, ThreadLimit20000中的以下两行:#define DEFAULT_THREAD_LIMIT 64
和configure改成所希望的值。注意,不要把这两个值设得太高而超过系统的处理能力,从而导致因 Worker值决定的,应该大于等于如果负载很大,现有的子进程数不能满足时,主控进程会派生新的子进程。默认最大的子进程总数是ServerLimit)中的以下两行:#define DEFAULT_SERVER_LIMIT 16
以上内容我也是从我以前文档里cp的,也许有点过时,对于初次学习还是有帮助的。HOHOHO http://blog.51cto.com/editor/icons/etc_19.gif
修改文件为;/root/httpd-2.0.59/server/mpm/worker/worker.c
#define DEFAULT_THREAD_LIMIT 100

StartServers      10
MaxClients          900
ServerLimit         50
MinSpareThreads   25
MaxSpareThreads   75
ThreadsPerChild   90
ThreadLimit      100
MaxRequestsPerChild0

ab是Apache超文本传输协议(HTTP)的性能测试工具。 其设计意图是描绘当前所安装的Apache的执行性能, 主要是显示你安装的Apache每秒可以处理多少个请求
-n requests
在测试会话中所执行的请求个数。
表示同时处理1000个请求并运行100次

Server Software:      Apache/2.0.59
测试机apache版本号
Server Hostname:      192.168.1.226
测试机主机名
Server Port:            80
测试机端口
Document Path:          /
测试机目录
Document Length:      1456 bytes
文档大小
Concurrency Level:      100
并发数
Time taken for tests:   1.305834 seconds
整个测试持续的时间
Complete requests:      1000
完成请求的数量
Failed requests:      0
失败请求数量
Write errors:         0
错误请求数量
Total transferred:      1924263 bytes
整个测试的网络传输量
HTML transferred:       1489488 bytes
整个测试html页面的网络传输量
Requests per second:    765.79 [#/sec] (mean)
关注1:每秒事务数
Time per request:       130.583 (mean)
关注2:平均事务响应时间
Time per request:       1.306 (mean, across all concurrent requests)
每个请求实际运行时间的平均值
Transfer rate:          1438.93 received
平均每秒网络上的流量
Connection Times (ms)
            minmean[+/-sd] median   max
Connect:       17   4517.1   47      92
Processing:    21   7658.7   61   585
Waiting:      1   5624.0   52   116
Total:         6412157.5    119   610
网络上消耗时间的分解
Percentage of the requests served within a certain time (ms)
50%    119
66%    122
75%    125
80%    132
90%    139
95%    172
98%    325
99%    465
100%    610 (longest request)
整个场景的响应情况,只重50%的用户响应时间小于119豪秒,66%的用户响应时间小于122豪秒。。。。。。
在测试一个
ab -n 10000 -c 1000 http://192.168.1.226/
请求处理10000个并行运行1000次
Document Path:          /
Document Length:      1456 bytes
Concurrency Level:      1000
Time taken for tests:   27.371944 seconds
Complete requests:      10000
Failed requests:      0
Write errors:         0
Total transferred:      18958599 bytes
HTML transferred:       14675024 bytes
Requests per second:    365.34 [#/sec] (mean)
Time per request:       2737.194 (mean)
Time per request:       2.737 (mean, across all concurrent requests)
Transfer rate:          676.39 received
Connection Times (ms)
            minmean[+/-sd] median   max
Connect:      1252 1416.5      9   20999
Processing:    13464 841.6    254   15626
Waiting:      3439 849.1    227   15624
Total:         28717 1909.5    283   21692
Percentage of the requests served within a certain time (ms)
50%    283
66%    403
75%    650
80%    663
90%    688
95%   1672
98%   6693
99%   9689
100%21692 (longest request)
呵呵。。好了。到此写完,有哪里不对也给我提个醒。相互学习才能进步。http://blog.51cto.com/editor/icons/etc_17.gif



页: [1]
查看完整版本: apache最大连接数性能测试