Httpd服务入门知识-Httpd服务常见配置案例之MPM( Multi-Processing Module)多路处理模块

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

   

一.MPM( Multi-Processing Module)多路处理模块

  MPM( Multi-Processing Module)多路处理模块分为:"prefork, worker, event",接下来我们查看一下如何配置吧。

1>.prefork的配置

StartServers 
  启动服务时默认会启动8个进程
MinSpareServers
  最少空闲的进程数默认为5,当响应请求时就不需要在浪费创建进程的时间啦,而是直接让空闲进程去响应,因此咱们可以指定最少的进程数。
MaxSpareServers
  最大进程空闲数默认为20,当所有的进程都处理完请求后,可能会有很多进程空闲,此时会释放部分进程,因此咱们可以指定最多的空闲进程数。
ServerLimit
  最多开启的进程数默认为256 最多进程数的最大值为20000
MaxRequestsPerChild
  每个子进程最多处理默认为4000个请求,即子进程最多能处理的请求数量为4000 。在处理MaxRequestsPerChild个请求之后,子进程将会被父进程终止,这时候子进程占用的内存就会释放(为0时永远不释放),在重新开启新的子进程来响应。

2>.worker的配置

ServerLimit
  最多开启的进程数默认为16 最多进程数的最大值为20000 StartServers
 启动服务时默认会启动2个进程
MaxRequestWorkers
  每个子线程最多处理的请求数默认为150.
MinSpareThreads
  最小空闲的线程数默认是25. MaxSpareThreads
  最大空闲的线程数默认是75. ThreadsPerChild
  每个子进程最多开放的线程数默认为25.

二.切换使用的MPM

1>.查看默认的多路处理模块

[root@node101.yinzhengjie.org.cn ~]# cat /etc/httpd/conf.modules.d/-mpm.conf                   #启用要启用的MPM相关的LoadModule指令即可
# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines: # 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 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN *: *:*
LISTEN ::: :::*
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps auxf | grep apache
root 0.0 0.0 pts/ S+ : : | \_ grep --color=auto apache
apache 0.0 0.0 ? S : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? S : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? S : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? S : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? S : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? S : : \_ /usr/sbin/httpd -DFOREGROUND
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# pstree -p | grep httpd
|-httpd()-+-httpd()
| |-httpd()
| |-httpd()
| |-httpd()
| |-httpd()
| `-httpd()
[root@node101.yinzhengjie.org.cn ~]#

2>.切换至worker模块

[root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf.modules.d/-mpm.conf        #默认使用的就是prefock处理模块
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# vim /etc/httpd/conf.modules.d/-mpm.conf
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf.modules.d/-mpm.conf        #将默认的模块注释掉,切换成worker处理模块
LoadModule mpm_worker_module modules/mod_mpm_worker.so
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# systemctl reload httpd
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN *: *:*
LISTEN ::: :::*
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps auxf | grep apache
root 0.0 0.0 pts/ S+ : : | \_ grep --color=auto apache
apache 0.0 0.0 ? S : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? Sl : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? Sl : : \_ /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.0 ? Sl : : \_ /usr/sbin/httpd -DFOREGROUND
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# pstree -p | grep http                          #不难发现有主进程多出来多个子进程,而子进程有分裂出多个线程
|-httpd()-+-httpd()
| |-httpd()-+-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | `-{httpd}()
| |-httpd()-+-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | |-{httpd}()
| | `-{httpd}()
| `-httpd()-+-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| |-{httpd}()
| `-{httpd}()
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# httpd -M | grep worker                      #我们发现worker模块已被加载啦~
mpm_worker_module (shared)
[root@node101.yinzhengjie.org.cn ~]#

三.模块加载

1>.查看静态编译的模块

[root@node101.yinzhengjie.org.cn ~]# httpd -l
Compiled in modules:
core.c
mod_so.c
http_core.c
[root@node101.yinzhengjie.org.cn ~]#

2>.查看静态编译及动态装载的模块

[root@node101.yinzhengjie.org.cn ~]# httpd -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
allowmethods_module (shared)
auth_basic_module (shared)
auth_digest_module (shared)
authn_anon_module (shared)
authn_core_module (shared)
authn_dbd_module (shared)
authn_dbm_module (shared)
authn_file_module (shared)
authn_socache_module (shared)
authz_core_module (shared)
authz_dbd_module (shared)
authz_dbm_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_owner_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cache_module (shared)
cache_disk_module (shared)
data_module (shared)
dbd_module (shared)
deflate_module (shared)
dir_module (shared)
dumpio_module (shared)
echo_module (shared)
env_module (shared)
expires_module (shared)
ext_filter_module (shared)
filter_module (shared)
headers_module (shared)
include_module (shared)
info_module (shared)
log_config_module (shared)
logio_module (shared)
mime_magic_module (shared)
mime_module (shared)
negotiation_module (shared)
remoteip_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
slotmem_plain_module (shared)
slotmem_shm_module (shared)
socache_dbm_module (shared)
socache_memcache_module (shared)
socache_shmcb_module (shared)
status_module (shared)
substitute_module (shared)
suexec_module (shared)
unique_id_module (shared)
unixd_module (shared)
userdir_module (shared)
version_module (shared)
vhost_alias_module (shared)
dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)
lua_module (shared)
mpm_worker_module (shared)
proxy_module (shared)
lbmethod_bybusyness_module (shared)
lbmethod_byrequests_module (shared)
lbmethod_bytraffic_module (shared)
lbmethod_heartbeat_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_connect_module (shared)
proxy_express_module (shared)
proxy_fcgi_module (shared)
proxy_fdpass_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_scgi_module (shared)
proxy_wstunnel_module (shared)
systemd_module (shared)
cgid_module (shared)
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# httpd -M

3>.动态模块路径

[root@node101.yinzhengjie.org.cn ~]# ll /usr/lib64/httpd/modules/
total
-rwxr-xr-x root root Aug : mod_access_compat.so
-rwxr-xr-x root root Aug : mod_actions.so
-rwxr-xr-x root root Aug : mod_alias.so
-rwxr-xr-x root root Aug : mod_allowmethods.so
-rwxr-xr-x root root Aug : mod_asis.so
-rwxr-xr-x root root Aug : mod_auth_basic.so
-rwxr-xr-x root root Aug : mod_auth_digest.so
-rwxr-xr-x root root Aug : mod_authn_anon.so
-rwxr-xr-x root root Aug : mod_authn_core.so
-rwxr-xr-x root root Aug : mod_authn_dbd.so
-rwxr-xr-x root root Aug : mod_authn_dbm.so
-rwxr-xr-x root root Aug : mod_authn_file.so
-rwxr-xr-x root root Aug : mod_authn_socache.so
-rwxr-xr-x root root Aug : mod_authz_core.so
-rwxr-xr-x root root Aug : mod_authz_dbd.so
-rwxr-xr-x root root Aug : mod_authz_dbm.so
-rwxr-xr-x root root Aug : mod_authz_groupfile.so
-rwxr-xr-x root root Aug : mod_authz_host.so
-rwxr-xr-x root root Aug : mod_authz_owner.so
-rwxr-xr-x root root Aug : mod_authz_user.so
-rwxr-xr-x root root Aug : mod_autoindex.so
-rwxr-xr-x root root Aug : mod_buffer.so
-rwxr-xr-x root root Aug : mod_cache_disk.so
-rwxr-xr-x root root Aug : mod_cache.so
-rwxr-xr-x root root Aug : mod_cache_socache.so
-rwxr-xr-x root root Aug : mod_cgid.so
-rwxr-xr-x root root Aug : mod_cgi.so
-rwxr-xr-x root root Aug : mod_charset_lite.so
-rwxr-xr-x root root Aug : mod_data.so
-rwxr-xr-x root root Aug : mod_dav_fs.so
-rwxr-xr-x root root Aug : mod_dav_lock.so
-rwxr-xr-x root root Aug : mod_dav.so
-rwxr-xr-x root root Aug : mod_dbd.so
-rwxr-xr-x root root Aug : mod_deflate.so
-rwxr-xr-x root root Aug : mod_dialup.so
-rwxr-xr-x root root Aug : mod_dir.so
-rwxr-xr-x root root Aug : mod_dumpio.so
-rwxr-xr-x root root Aug : mod_echo.so
-rwxr-xr-x root root Aug : mod_env.so
-rwxr-xr-x root root Aug : mod_expires.so
-rwxr-xr-x root root Aug : mod_ext_filter.so
-rwxr-xr-x root root Aug : mod_file_cache.so
-rwxr-xr-x root root Aug : mod_filter.so
-rwxr-xr-x root root Aug : mod_headers.so
-rwxr-xr-x root root Aug : mod_heartbeat.so
-rwxr-xr-x root root Aug : mod_heartmonitor.so
-rwxr-xr-x root root Aug : mod_include.so
-rwxr-xr-x root root Aug : mod_info.so
-rwxr-xr-x root root Aug : mod_lbmethod_bybusyness.so
-rwxr-xr-x root root Aug : mod_lbmethod_byrequests.so
-rwxr-xr-x root root Aug : mod_lbmethod_bytraffic.so
-rwxr-xr-x root root Aug : mod_lbmethod_heartbeat.so
-rwxr-xr-x root root Aug : mod_log_config.so
-rwxr-xr-x root root Aug : mod_log_debug.so
-rwxr-xr-x root root Aug : mod_log_forensic.so
-rwxr-xr-x root root Aug : mod_logio.so
-rwxr-xr-x root root Aug : mod_lua.so
-rwxr-xr-x root root Aug : mod_macro.so
-rwxr-xr-x root root Aug : mod_mime_magic.so
-rwxr-xr-x root root Aug : mod_mime.so
-rwxr-xr-x root root Aug : mod_mpm_event.so
-rwxr-xr-x root root Aug : mod_mpm_prefork.so
-rwxr-xr-x root root Aug : mod_mpm_worker.so
-rwxr-xr-x root root Aug : mod_negotiation.so
-rwxr-xr-x root root Aug : mod_proxy_ajp.so
-rwxr-xr-x root root Aug : mod_proxy_balancer.so
-rwxr-xr-x root root Aug : mod_proxy_connect.so
-rwxr-xr-x root root Aug : mod_proxy_express.so
-rwxr-xr-x root root Aug : mod_proxy_fcgi.so
-rwxr-xr-x root root Aug : mod_proxy_fdpass.so
-rwxr-xr-x root root Aug : mod_proxy_ftp.so
-rwxr-xr-x root root Aug : mod_proxy_http.so
-rwxr-xr-x root root Aug : mod_proxy_scgi.so
-rwxr-xr-x root root Aug : mod_proxy.so
-rwxr-xr-x root root Aug : mod_proxy_wstunnel.so
-rwxr-xr-x root root Aug : mod_ratelimit.so
-rwxr-xr-x root root Aug : mod_reflector.so
-rwxr-xr-x root root Aug : mod_remoteip.so
-rwxr-xr-x root root Aug : mod_reqtimeout.so
-rwxr-xr-x root root Aug : mod_request.so
-rwxr-xr-x root root Aug : mod_rewrite.so
-rwxr-xr-x root root Aug : mod_sed.so
-rwxr-xr-x root root Aug : mod_setenvif.so
-rwxr-xr-x root root Aug : mod_slotmem_plain.so
-rwxr-xr-x root root Aug : mod_slotmem_shm.so
-rwxr-xr-x root root Aug : mod_socache_dbm.so
-rwxr-xr-x root root Aug : mod_socache_memcache.so
-rwxr-xr-x root root Aug : mod_socache_shmcb.so
-rwxr-xr-x root root Aug : mod_speling.so
-rwxr-xr-x root root Aug : mod_status.so
-rwxr-xr-x root root Aug : mod_substitute.so
-rwxr-xr-x root root Aug : mod_suexec.so
-rwxr-xr-x root root Aug : mod_systemd.so
-rwxr-xr-x root root Aug : mod_unique_id.so
-rwxr-xr-x root root Aug : mod_unixd.so
-rwxr-xr-x root root Aug : mod_userdir.so
-rwxr-xr-x root root Aug : mod_usertrack.so
-rwxr-xr-x root root Aug : mod_version.so
-rwxr-xr-x root root Aug : mod_vhost_alias.so
-rwxr-xr-x root root Aug : mod_watchdog.so
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /usr/lib64/httpd/modules/ | wc -l [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll /usr/lib64/httpd/modules/               #动态模块加载:不需重启即生效

Httpd服务入门知识-Httpd服务常见配置案例之MPM( Multi-Processing Module)多路处理模块的更多相关文章

  1. Httpd服务入门知识-Httpd服务常见配置案例之虚拟主机

    Httpd服务入门知识-Httpd服务常见配置案例之虚拟主机 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.虚拟主机实现方案 1>.Apache httpd 有三种实现虚 ...

  2. Httpd服务入门知识-Httpd服务常见配置案例之Apache的工作做状态status页面

    Httpd服务入门知识-Httpd服务常见配置案例之Apache的工作做状态status页面 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.status功能概述 status页 ...

  3. Httpd服务入门知识-Httpd服务常见配置案例之ServerSignature指令选项

    Httpd服务入门知识-Httpd服务常见配置案例之ServerSignature指令选项 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.ServerSignature指令概述 ...

  4. Httpd服务入门知识-Httpd服务常见配置案例之实现用户家目录的http共享

    Httpd服务入门知识-Httpd服务常见配置案例之实现用户家目录的http共享 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.实现用户家目录的http共享前提 在配置家目录共 ...

  5. Httpd服务入门知识-Httpd服务常见配置案例之定义路径别名

    Httpd服务入门知识-Httpd服务常见配置案例之定义路径别名 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.   一.创建测试数据 [root@node101.yinzhengj ...

  6. Httpd服务入门知识-Httpd服务常见配置案例之设定默认字符集

    Httpd服务入门知识-Httpd服务常见配置案例之设定默认字符集 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.查看生产环境中使用的字符集案例 1>.查看腾讯设置的默认 ...

  7. Httpd服务入门知识-Httpd服务常见配置案例之日志设定

    Httpd服务入门知识-Httpd服务常见配置案例之日志设定 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.日志类型 [root@node101.yinzhengjie.org ...

  8. Httpd服务入门知识-Httpd服务常见配置案例之基于客户端来源地址实现访问控制

    Httpd服务入门知识-Httpd服务常见配置案例之基于客户端来源地址实现访问控制 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Options  1>.OPTIONS指 ...

  9. Httpd服务入门知识-Httpd服务常见配置案例之基于用户账号实现访问控制

    Httpd服务入门知识-Httpd服务常见配置案例之基于用户账号实现访问控制 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.基于用户的访问控制概述 认证质询: WWW-Auth ...

随机推荐

  1. Makefile之编译运行连接库方法

    LIBS+= -L $$PWD/../HKUnifyCamera_one/Debug -lHKUnifyCamera -luuid -Wl,-rpath=$$PWD/../HKUnifyCamera_ ...

  2. map函数怎么用咧↓↓↓

    Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作! 1. map最基本的构造函数:    map<st ...

  3. C++ 重写虚函数的代码使用注意点+全部知识点+全部例子实现

    h-------------------------- #ifndef VIRTUALFUNCTION_H #define VIRTUALFUNCTION_H /* * 派生类中覆盖虚函数的使用知识点 ...

  4. Redis与Mysql双写一致性方案解析

    一 前言 首先,缓存由于其高并发和高性能的特性,已经在项目中被广泛使用.在读取缓存方面,大家没啥疑问,都是按照下图的流程来进行业务操作 但是在更新缓存方面,对于更新完数据库,是更新缓存呢,还是删除缓存 ...

  5. Log4j Threshold指定输出等级&&Append指定是否追加内容

    Threshold指定输出等级 有时候我们需要把一些报错ERROR日志单独存到指定文件 ,这时候,Threshold属性就派上用场了: Threshold属性可以指定日志level Log4j根据日志 ...

  6. 让sentinel-dashboard支持nacos

    以sentinel-1.7.0为例 下载源码,idea打开. 找到sentinel-dashboard这个项目 在该项目下的pom.xml文件中找到: <!-- for Nacos rule p ...

  7. 《Linux就该这么学》培训笔记_ch14_使用DHCP动态管理主机地址

    <Linux就该这么学>培训笔记_ch14_使用DHCP动态管理主机地址 文章最后会post上书本的笔记照片. 文章主要内容: 动态主机地址管理协议 部署dhcpd服务程序 自动管理IP地 ...

  8. Springboot Actuator之九:actuator jmx endpoint

    1.配置 endpoints.jmx.domain: myapp endpoints.jmx.uniqueNames: true endpoints.auditevents.enabled: true ...

  9. Visual Studio 重命名项目名

    1. 打开VS Studio,重命名项目 2. 重命名对应的项目文件夹,并重命名项目文件夹下的这两个文件名: 3. 用记事本打开解决方案,修改对应的项目名字和路径 未完 ...... 点击访问原文(进 ...

  10. json文件 乱码问题 根本解决办法

    1 工具→自定义:2 点击 命令 标签:3 在上方单选区选中 菜单栏,下拉列表选 文件:4 点击 添加命令5 在类别中,找到文件,在右侧找到高级保存选项,确定6 然后可以通过下移调整该选项在文件菜单中 ...