apache:architecture
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| apache:architecture [2014/05/24 20:34] – [optimize load module apache] admin | apache:architecture [2022/10/29 16:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Apache Architecture ====== | ||
| + | refer: http:// | ||
| + | MPM(Multi Processing Module) | ||
| + | ===== MPM Prefork Architecture ===== | ||
| + | Basic configuration: | ||
| + | * StartServers: | ||
| + | * MinSpareServers: | ||
| + | * MaxSpareServers: | ||
| + | * MaxClients: | ||
| + | {{: | ||
| + | Config example:< | ||
| + | < | ||
| + | StartServers | ||
| + | MinSpareServers | ||
| + | MaxSpareServers | ||
| + | MaxClients | ||
| + | MaxRequestsPerChild | ||
| + | </ | ||
| + | check config: | ||
| + | * check number of httpd process with none client request:< | ||
| + | ps -eaf | grep httpd | ||
| + | </ | ||
| + | root 1629 | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | </ | ||
| + | * run load test with 20 concurrecy requests to server:< | ||
| + | ab -n 200 -c 20 http:// | ||
| + | </ | ||
| + | ps -eaf | grep httpd | ||
| + | root 1013 | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | </ | ||
| + | ===== MPM worker Architecture ===== | ||
| + | * StartServers: | ||
| + | * MinSpareThreads: | ||
| + | * MaxSpareThreads: | ||
| + | * ThreadsPerChild: | ||
| + | {{: | ||
| + | ===== Debug architecture of apache ===== | ||
| + | ==== Get current MPM is running: MPM Prefork or MPM worker ==== | ||
| + | <code bash> | ||
| + | apachectl -V | ||
| + | Server version: Apache/ | ||
| + | Server built: | ||
| + | Server' | ||
| + | Server loaded: | ||
| + | Compiled using: APR 1.3.9, APR-Util 1.3.9 | ||
| + | Architecture: | ||
| + | Server MPM: | ||
| + | threaded: | ||
| + | forked: | ||
| + | Server compiled with.... | ||
| + | -D APACHE_MPM_DIR=" | ||
| + | ........................... | ||
| + | </ | ||
| + | ==== compiled modules in MPM Prefork(httpd) and MPM worker(httpd.worker) ==== | ||
| + | * httpd -V< | ||
| + | Server version: Apache/ | ||
| + | Server built: | ||
| + | Server' | ||
| + | Server loaded: | ||
| + | Compiled using: APR 1.3.9, APR-Util 1.3.9 | ||
| + | Architecture: | ||
| + | Server MPM: | ||
| + | threaded: | ||
| + | forked: | ||
| + | Server compiled with.... | ||
| + | -D APACHE_MPM_DIR=" | ||
| + | -D APR_HAS_SENDFILE | ||
| + | -D APR_HAS_MMAP | ||
| + | -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) | ||
| + | -D APR_USE_SYSVSEM_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=128 | ||
| + | -D HTTPD_ROOT="/ | ||
| + | -D SUEXEC_BIN="/ | ||
| + | -D DEFAULT_PIDLOG=" | ||
| + | -D DEFAULT_SCOREBOARD=" | ||
| + | -D DEFAULT_LOCKFILE=" | ||
| + | -D DEFAULT_ERRORLOG=" | ||
| + | -D AP_TYPES_CONFIG_FILE=" | ||
| + | -D SERVER_CONFIG_FILE=" | ||
| + | </ | ||
| + | * httpd.worker -V<code bash> | ||
| + | Server version: Apache/ | ||
| + | Server built: | ||
| + | Server' | ||
| + | Server loaded: | ||
| + | Compiled using: APR 1.3.9, APR-Util 1.3.9 | ||
| + | Architecture: | ||
| + | Server MPM: | ||
| + | threaded: | ||
| + | forked: | ||
| + | Server compiled with.... | ||
| + | -D APACHE_MPM_DIR=" | ||
| + | -D APR_HAS_SENDFILE | ||
| + | -D APR_HAS_MMAP | ||
| + | -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) | ||
| + | -D APR_USE_SYSVSEM_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=128 | ||
| + | -D HTTPD_ROOT="/ | ||
| + | -D SUEXEC_BIN="/ | ||
| + | -D DEFAULT_SCOREBOARD=" | ||
| + | -D DEFAULT_ERRORLOG=" | ||
| + | -D AP_TYPES_CONFIG_FILE=" | ||
| + | -D SERVER_CONFIG_FILE=" | ||
| + | </ | ||
| + | * Difference between "httpd -V" and " | ||
| + | * httpd -V< | ||
| + | Server MPM: | ||
| + | threaded: | ||
| + | forked: | ||
| + | Server compiled with.... | ||
| + | -D APACHE_MPM_DIR=" | ||
| + | </ | ||
| + | * httpd.worker -V< | ||
| + | Server MPM: | ||
| + | threaded: | ||
| + | forked: | ||
| + | Server compiled with.... | ||
| + | -D APACHE_MPM_DIR=" | ||
| + | </ | ||
| + | * httpd -l< | ||
| + | Compiled in modules: | ||
| + | core.c | ||
| + | prefork.c | ||
| + | http_core.c | ||
| + | mod_so.c | ||
| + | </ | ||
| + | * httpd.worker -l< | ||
| + | Compiled in modules: | ||
| + | core.c | ||
| + | worker.c | ||
| + | http_core.c | ||
| + | mod_so.c | ||
| + | </ | ||
| + | ==== Debug processes and used memory, cpu ==== | ||
| + | * netstat -anp | grep 80 | grep LISTEN< | ||
| + | tcp 0 0 :::80 ::: | ||
| + | => http listen on port 80 with PID(ProcessID) 5141 | ||
| + | </ | ||
| + | * ps -eaf | grep 5141< | ||
| + | ps -eaf | grep 5141 | ||
| + | UID PID PPID C STIME TTY TIME CMD | ||
| + | root 5141 | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | </ | ||
| + | * ps -aux | grep / | ||
| + | ps -aux | grep / | ||
| + | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
| + | root 5141 0.0 1.9 254904 | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | apache | ||
| + | </ | ||
| + | * pmap -x 6726 | sort -nk +2<code bash> | ||
| + | pmap -x 6812 | sort -nk +2 | ||
| + | 00007fcacac95000 | ||
| + | 00007fcacb4a8000 | ||
| + | 00007fcacc0c1000 | ||
| + | 00007fcacccd7000 | ||
| + | 00007fcacd559000 | ||
| + | 00007fcacdb06000 | ||
| + | 00007fcace4db000 | ||
| + | 00007fcad1562000 | ||
| + | 00007fcac723b000 | ||
| + | 00007fcad17b6000 | ||
| + | </ | ||
| + | ===== Optimize apache and PHP config ===== | ||
| + | ==== optimize load module apache ==== | ||
| + | Config Optimize load modules for httpd with Explain directives with these modules: | ||
| + | <code bash> | ||
| + | LoadModule authz_host_module modules/ | ||
| + | LoadModule access_compat_module modules/ | ||
| + | LoadModule log_config_module modules/ | ||
| + | LoadModule expires_module modules/ | ||
| + | LoadModule deflate_module modules/ | ||
| + | LoadModule headers_module modules/ | ||
| + | LoadModule env_module modules/ | ||
| + | LoadModule setenvif_module modules/ | ||
| + | LoadModule mime_module modules/ | ||
| + | LoadModule autoindex_module modules/ | ||
| + | LoadModule negotiation_module modules/ | ||
| + | LoadModule dir_module modules/ | ||
| + | LoadModule alias_module modules/ | ||
| + | LoadModule rewrite_module modules/ | ||
| + | </ | ||
| + | ==== optimize load module php ==== | ||
| + | ===== Custom Config for Apache ===== | ||
| + | ==== Config disable warning log from browser ==== | ||
| + | With this config, the log will display in PHP error log but they don't display in browser side\\\ | ||
| + | Update httpd.conf | ||
| + | <code php> | ||
| + | < | ||
| + | php_admin_flag display_errors off | ||
| + | </ | ||
| + | </ | ||
