Engineering/WEB & WAS

[Apache] MPM 설정 (Prefork, Worker, Event)

[앙금빵] 2021. 11. 28.

MPM Module 특징

 

Prefork MPM 처리방식

(좌) Prefork (우) Worker MPM 처리방식


소스 컴파일 설치방식

  • 2.4.x 버전 기준으로 소스 컴파일 설치시 Default로 MPM이 event 설정된다.
  • 다른 모드로 설정하고 싶다면 컴파일 시 --with-mpm=prefork 혹은 --with-mpm=worker 추가를 진행해야 한다.
  • (예시) prefork MPM Apache 설치
# apache prefork 컴파일
./configure --prefix=/usr/local/apache2.4 \
--enable-modules=most --enable-mods-shared=all --enable-so \
--with-apr=/usr/local/src/apr-1.7.0 \
--with-apr-util=/usr/local/src/apr-util-1.6.1 \
--with-pcre=/usr/local/src/pcre-8.45 \
--with-mpm=prefork

# mpm 방식 확인
[root@test bin]# ./httpd -V
Server version: Apache/2.4.51 (Unix)
Server built:   Nov 24 2021 05:34:36
Server's Module Magic Number: 20120211:118
Server loaded:  APR 1.7.0, APR-UTIL 1.6.1
Compiled using: APR 1.7.0, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_PROC_PTHREAD_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/usr/local/apache2.4"
 -D SUEXEC_BIN="/usr/local/apache2.4/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

바이너리(YUM) 방식

바이너리 설치(YUM) 으로 Apache를 설치를 했다면 Default MPM이 prefork 로 설정된다.

 

Apache MPM 변경 (YUM 설치)

MPM prefork 방식을 event 방식으로 바꾸어 보자

# 설치된 아파치 MPM 정보확인
[root@test ~]# apachectl -V | grep MPM
Server MPM:     prefork

# apache 종료
[root@test ~]# apachectl stop

# mpm 모듈 변경
[root@test ~]# vim /etc/httpd/conf.modules.d/00-mpm.conf

# 변경 전
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
# LoadModule mpm_event_module modules/mod_mpm_event.so

# 변경 후
# LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule mpm_event_module modules/mod_mpm_event.so

00-mpm.conf 설정

Module 변경 확인

# 아파치 시작
[root@test ~]# apachectl start

# 아파치 MPM 모듈 확인
[root@test ~]# apachectl -V | grep MPM
Server MPM:     event

참조


공식 홈페이지 (ENG)
https://httpd.apache.org/docs/2.4/mod/event.html

공식 홈페이지 (KOR)
https://runebook.dev/ko/docs/apache_http_server/mod/event

apache 2.4 (event-mpm), nginx 1.4 비교 테스트
https://aonenetworks.tistory.com/390

Apache MPM - Multiple Request Processing Module
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=kkson50&logNo=221099080215

Apache MPM 유형 설명 - prefork, worker, event
https://mytory.net/2021/05/06/apache-mpm.html

Apache MPM(Multi Processing Module) 이란?
https://s-jg.tistory.com/27

 

댓글