apache worker 模块 线程连接数简单介绍
来源:互联网 发布:淘宝可以买轮椅吗 编辑:程序博客网 时间:2024/05/16 05:34
所使用httpd版本为:httpd2.2.8
配置安装:
./configure --prefix=/usr/local/apaache2/ --with-mpm=worker
make && make install
查看pmp httpd -l
修改配置文件 apache安装目录/conf/httpd.conf文件
支持网页查看status
添加如下配置
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from nothing
Allow from all
</Location>
并开启mpm配置、
修改worker moudle时的配置参数
位于apache安装目录/conf/extra/httpd-mpm.conf 文件
vi /usr/local/apaache2/conf/extra/httpd-mpm.conf
线程数 默认为50个
① 默认配置为:
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
startServers :初始化时开启的进程MinSpareThreads :最小的空闲线程
MaxSpareThreads:最大的空闲线程数
ThreadsPerChild: 每个进程下产生的线程数
查看
所以线程数为 2*25=50
即1(requess currently )+ 49 (idle workers)
②修改 将startservers 改为3.
<IfModule mpm_worker_module>
StartServers 3
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
此时线程数为 3*25=75
③ 将startservers 修改为4
<IfModule mpm_worker_module>
StartServers 4
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
此时线程数还是75
原因:因为最大线程数限制为75个。虽然设定开始进程为4.但是当启动完3个进程时(3*25)已经达到最大线程数限定(75),所以第4个进程就起不来了
④startservers改为3,ThreadsPerChild为30
<IfModule mpm_worker_module>
StartServers 3
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 30
MaxRequestsPerChild 0
</IfModule>
此时的线程数为60,分析:当启动2个进程时,线程数为60(2*30),当启动第三个进程时线程数要为90(3*30)超过了最大线程数为75的限制所以第三个进程起不来。即为60.
如果此时用ab命令对其进行压力测试时,
/usr/local/apaache2/bin/ab -c 1000 -n 10000 http://192.168.1.65/
会发现最大能达到150个(74+76)如下图。
分析:当多用户连接的时候,Apache会根据连接数来开启进程,每个进程会启用各自启动线程。这时,有可能会超过MaxSpreThreads 线程的限制,
但是会受到MaxClients 的限制,即最多启动线程为150个。
另外,配置参数时 MaxClients最好与ThreadsPerChild 的设置成整数倍,这样大用户并发访问时 能到达Maxclients的设置。
如下配置
<IfModule mpm_worker_module>
StartServers 3
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 40
MaxRequestsPerChild 0
</IfModule>
开始时是为40个线程
对其进行压力测试
/usr/local/apaache2/bin/ab -c 1000 -n 10000 http://192.168.1.65/
发现最大也只能到120个线程。
另外,这样设置的时候
apache会对你提醒的
0 0
- apache worker 模块 线程连接数简单介绍
- apache的prefork和worker模块
- Apache 多路复用模块(MPMs) - Prefork, Worker, Event
- Apache 多路复用模块(MPMs) - Prefork, Worker, Event
- apache常用模块介绍
- Apache 模块介绍
- apache常用模块介绍
- 08-Apache模块介绍
- apache2.2支持worker,rewrite模块,支持线程
- Apache连接数设置
- 查看Apache 连接数
- apache连接数限制
- Apache连接数设置
- Apache 连接数优化
- apache 连接数
- Apache连接数设置
- apache连接数配置
- Apache的工作模式prefork & worker简单分析
- 芯客-互联网硬件化的最强支柱
- 在linux下出现cannot restore segment prot after reloc: Permission denied
- android nfc中MifareClassic格式的读写
- 结构型模式-外观
- nyoj题目67:三角形面积
- apache worker 模块 线程连接数简单介绍
- 线程死锁
- android L 启动流程
- A*算法理论与实践
- 基于.NET的大型Web站点StackOverflow架构分析
- KDD 2014 “A Dirichlet Multinomial Mixture Model-based Approach for Short Text Clustering” 的主要思想
- 开源框架研究----Otto源代码分析
- 云计算学习笔记(一):云计算基础
- CodeForces 97B Superset