
Apache httpd는 다양한 환경에서 동작할 수 있도록 설계되어 있다.
Apache는 모듈화된 설계를 웹서버의 기본적인 부분에 탑재하여 다양한 운영체제, 환경을 지원할 수 있다는 것이 특징이다.서버는 시스템의 네트웍 포트에 연결하고, 요청을 받아들이며, 받아들인 요청을 처리하기위해 자식들에게 분배하는 다중처리 모듈 (Multi-Processing Modules, MPMs)을 선택할 수 있다.
00. Apache 설치를 위한 기본 설정
- 50MB 이상의 설치 공간
- ANSI 컴파일러 (GCC 등)
- perl
- expat-devel
- pcre-devel
- openssl-devel
01. Apache 설치
01) Apache MPM 방식
Apache에서 동작하는 MPM방식은 주로 세 가지가 있다. (prefork, worker, event)
① prefork (Implements a non-threaded, pre-forking web server)
– 자식 프로세스를 미리 준비해두는 방식
– 자식 프로세스는 최대 1024개
– 하나의 자식 프로세스당 1개의 스레드 연결
– 스레드간 메모리 공유를 하지 않아 독립적사용으로 안정적이나 메모리를 많이 사용함
# /usr/local/apache/conf/extra/httpd-mpm.conf <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxRequestWorkers 300 ServerLimit 300 MaxConnectionsPerChild 0 </IfModule> |
– StartServer : 기본 자식 프로세스 개수
– MinSpareServers, MaxSpareServers : 최소 개수 / 부하 증가에 따라 증가
– MaxRequestWorkers, ServerLimit : 최대 요청 가능한 Worker, 구성 가능한 Child Process
– MaxReqeustPerChild : 클라이언트들의 요청 개수를 제한 (0 인 경우 무한대)
② worker (Multi-Processing Module implementing a hybrid multi-threaded multi-process web server)
– 프로세스당 여러개의 스레드 연결
– 스레드간 메모리를 공유하여 메모리 사용량이 비교적 적음
– 통신량이 많은 서버에 적합
# /usr/local/apache/conf/extra/httpd-mpm.conf <IfModule mpm_worker_module> StartServers 3 MaxClients 150 MinSpareThreads 75 MaxSpareThreads 250 ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0 </IfModule> |
– StartServers(Default 3) : 시작시에 생성되는 서버 프로세스의 개수
– ServerLimit (default : 16) : 구성 가능한 child 프로세스의 제한
– MaxClient (default : ServerLimit * ThreadsPerChild) : 동시 처리 최대 커넥션 수, MaxClients 수치를 초과한 후 온 요청들은 대기
– MinSpareThreads(default 75) : 최소 thread 개수
– MaxSpareThreads(default 250) : 최대 thread개수
– ThreadPerChild : 개별 자식 프로세스가 지속적으로 가질 수 있는 Thread의 개수.
– MaxRequestPerChild : 자식 프로세스가 서비스할 수 있는 최대 요청 개수
③ event (A variant of the worker MPM with the goal of consuming threads only for connections with active processing)
– 아파치 2.4.x 버전부터 생성된 방식
– worker 방식을 기반으로 함
– keepalive 시에 클라이언트로부터 요청을 기다리고 있는 자식 프로세스 또는 스레드 전체를 유지하게 되는 문제를 해결하기 위하여 리스닝 소켓과 기타 모든 소켓을 처리하는 각 프로세스를 위한 전용 리스너 스레드 사용
<event 방식>
# /usr/local/apache/conf/extra/httpd-mpm.conf <IfModule mpm_event_module> StartServers 3 MinSpareThreads 75 MaxSpareThreads 250 ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0 </IfModule> |
④ 기타 용도
mpm_netware (Multi-Processing Module implementing an exclusively threaded web server optimized for Novell NetWare)
mpmt_os2 (Hybrid multi-process, multi-threaded MPM for OS/2)
mpm_winnt (Multi-Processing Module optimized for Windows NT)
prefork | worker | event | |
Memory | 많이 소모 | 비교적 적음 | 비교적 적음 |
방식 | 사전에 자식 프로세스 생성, 프로세스당 1개 쓰레드 | 프로세스 당 여러 쓰레드 연결 | 프로세스 당 여러 쓰레드 연결 |
메모리 사용 | 독립적 사용 | 메모리 공유 | 메모리 공유 |
기타 | event driven 지원 (요청을 받는 쓰레드를 별도로 관리) |
'IT > MW' 카테고리의 다른 글
08. Application Server, Servlet Container (0) | 2020.06.16 |
---|---|
07. Apache vs Nginx (0) | 2020.06.16 |
03. SSL/TLS, HTTPS (0) | 2020.06.07 |
02. WEB Server (0) | 2020.06.06 |
01. 미들웨어 (Middleware) (0) | 2020.06.05 |