配置Httpd事件处理模块

1.概述多处理模块(MPM)
模块名称模块说明
core始终可用的Apache HTTP服务器核心特性
mpm_common由多个多处理模块(MPM)实现的指令集合
eventworker MPM的一种变体,其目标是仅为活动处理的连接使用线程,对于Linux,建议使用2.6内核,还必须确保您的的版本glibc已编译为支持EPoll
mpm_netware多处理模块实现了专为Novell NetWare优化的线程web服务器
mpmt_os2混合多进程,多线程MPM为OS/2
prefork实现一个非线程的、预分叉的web服务器
mpm_winnt多处理模块为Windows NT优化
worker多处理模块实现了一个混合的多线程多进程web服务器

2.配置httpd的event事件处理模块

参考官方event事件处理模块的文档:请点击这里

#查看配置httpd事件处理模块的目录
vi  /etc/httpd/conf/httpd.conf 
......
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf
......
#配置event事件处理模块
vi  /etc/httpd/conf.modules.d/00-mpm.conf 
# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#
LoadModule mpm_event_module modules/mod_mpm_event.so

<IfModule event.c>
 StartServers 8
 ServerLimit 20000
 AsyncRequestWorkerFactor 20000
 MaxRequestWorkers 20000
</IfModule>

#检查httpd配置是否有误
httpd -t

#重启httpd服务
systemctl restart httpd
参数名称参数说明
StartServers默认启动httpd进程数,默认8个进程
ServerLimit设置httpd服务器最大的进程数
AsyncRequestWorkerFactor限制每个进程的并发连接,默认数值为2
MaxRequestWorkers最大并发进程数

可以通过两种方式计算并发连接的绝对最大数量:

max_connections(最大连接数)= (ThreadsPerChild + (AsyncRequestWorkerFactor * idle_workers ))* ServerLimit

max_connections (最大连接数)= (AsyncRequestWorkerFactor + 1 )* MaxRequestWorkers

3.在另一台主机上进行压力测试
ab -n 100000 -c 1020 http://172.25.0.110/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.25.0.110 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        Apache/2.4.6
Server Hostname:        172.25.0.110
Server Port:            80

Document Path:          /
Document Length:        4247 bytes

Concurrency Level:      1020
Time taken for tests:   37.888 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      454500000 bytes
HTML transferred:       424700000 bytes
Requests per second:    2639.38 [#/sec] (mean)
Time per request:       386.455 [ms] (mean)
Time per request:       0.379 [ms] (mean, across all concurrent requests)
Transfer rate:          11714.81 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  128 541.9     21   15064
Processing:     1  131 1111.4     53   37758
Waiting:        1  120 1111.3     43   37758
Total:          1  259 1234.8     86   37810

Percentage of the requests served within a certain time (ms)
  50%     86
  66%    117
  75%    149
  80%    180
  90%    400
  95%   1069
  98%   1262
  99%   3071
 100%  37810 (longest request)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

路来了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值