User Tools

Site Tools


apache:architecture

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
apache:architecture [2014/09/20 14:27] – [MPM Prefork Architecture] adminapache:architecture [2022/10/29 16:15] (current) – external edit 127.0.0.1
Line 7: Line 7:
   * MinSpareServers: minimum number of server processes which are kept spare   * MinSpareServers: minimum number of server processes which are kept spare
   * MaxSpareServers: maximum **number of server processes which are kept spare**   * MaxSpareServers: maximum **number of server processes which are kept spare**
-  * MaxClients:  maximum number of server processes allowed to start => Limist number of httpd created and processing the request+  * MaxClients:  maximum number of server processes allowed to start => Limist number of httpd created and processing the request. For example: MaxClients 10, And clients send **100 concurrency requests to server**, The server only **create max 10 server process httpd** for processing, and **99 remain requests will waiting in the queues**
 {{:apache:preforkmodel.png|}} {{:apache:preforkmodel.png|}}
 Config example:<code> Config example:<code>
 <IfModule mpm_prefork_module> <IfModule mpm_prefork_module>
-    StartServers          2 +    StartServers          6 
-    MinSpareServers       2 +    MinSpareServers       6 
-    MaxSpareServers      5 +    MaxSpareServers      12 
-    MaxClients          10+    MaxClients          12
     MaxRequestsPerChild   0     MaxRequestsPerChild   0
-</IfModule> +</IfModule></code> 
-</code>+check config: 
 +  * check number of httpd process with none client request:<code bash> 
 +ps -eaf | grep httpd 
 +</code>output:<code> 
 +root      1629      0 20:56 ?        00:00:00 /usr/local/apache/bin/httpd 
 +apache    1631  1629  0 20:56 ?        00:00:00 /usr/local/apache/bin/httpd 
 +apache    1632  1629  0 20:56 ?        00:00:00 /usr/local/apache/bin/httpd 
 +apache    1633  1629  0 20:56 ?        00:00:00 /usr/local/apache/bin/httpd 
 +apache    1634  1629  0 20:56 ?        00:00:00 /usr/local/apache/bin/httpd 
 +apache    1635  1629  0 20:56 ?        00:00:00 /usr/local/apache/bin/httpd 
 +apache    1636  1629  0 20:56 ?        00:00:00 /usr/local/apache/bin/httpd 
 +</code> => 7 processes = MinSpareServers + 1 
 +  * run load test with 20 concurrecy requests to server:<code bash> 
 +ab -n 200 -c 20 http://shop.babies.vn/ 
 +</code> And check number of httpd processes:<code> 
 +ps -eaf | grep httpd 
 +root      1013      0 19:50 ?        00:00:00 /usr/local/apache/bin/httpd 
 +apache    1144  1013  0 20:10 ?        00:00:09 /usr/local/apache/bin/httpd 
 +apache    1210  1013  1 20:29 ?        00:00:05 /usr/local/apache/bin/httpd 
 +apache    1216  1013  2 20:30 ?        00:00:05 /usr/local/apache/bin/httpd 
 +apache    1219  1013  2 20:30 ?        00:00:06 /usr/local/apache/bin/httpd 
 +apache    1220  1013  2 20:30 ?        00:00:05 /usr/local/apache/bin/httpd 
 +apache    1226  1013  8 20:33 ?        00:00:06 /usr/local/apache/bin/httpd 
 +apache    1227  1013  8 20:33 ?        00:00:06 /usr/local/apache/bin/httpd 
 +apache    1228  1013  8 20:33 ?        00:00:06 /usr/local/apache/bin/httpd 
 +apache    1229  1013  7 20:33 ?        00:00:05 /usr/local/apache/bin/httpd 
 +apache    1230  1013  6 20:33 ?        00:00:04 /usr/local/apache/bin/httpd 
 +apache    1231  1013  8 20:33 ?        00:00:05 /usr/local/apache/bin/httpd 
 +apache    1288  1013  8 20:34 ?        00:00:03 /usr/local/apache/bin/httpd 
 +</code> => max httpd processes = 13 = maxClients + 1
 ===== MPM worker Architecture ===== ===== MPM worker Architecture =====
   * StartServers: initial number of server processes to start   * StartServers: initial number of server processes to start
Line 154: Line 183:
 apache    5360  0.1  7.6 283964 38312 ?      15:59   0:00 /usr/sbin/httpd apache    5360  0.1  7.6 283964 38312 ?      15:59   0:00 /usr/sbin/httpd
 </code>With VSZ is Virtual Memory Size(address space allocated) , and RSS is Resident Set Size (physically resident memory) </code>With VSZ is Virtual Memory Size(address space allocated) , and RSS is Resident Set Size (physically resident memory)
-  * pmap -x 6726 | sort -ak +2<code bash>+  * pmap -x 6726 | sort -nk +2<code bash>
 pmap -x 6812 | sort -nk +2 pmap -x 6812 | sort -nk +2
 00007fcacac95000    2048             0 -----  mod_mime_magic.so 00007fcacac95000    2048             0 -----  mod_mime_magic.so
Line 169: Line 198:
 ===== Optimize apache and PHP config ===== ===== Optimize apache and PHP config =====
 ==== optimize load module apache ==== ==== optimize load module apache ====
-Config load modules below: +Config Optimize load modules for httpd with Explain directives with these modules:
-<code bash> +
-LoadModule authz_host_module modules/mod_authz_host.so +
-LoadModule log_config_module modules/mod_log_config.so +
-LoadModule expires_module modules/mod_expires.so +
-LoadModule deflate_module modules/mod_deflate.so +
-LoadModule headers_module modules/mod_headers.so +
-LoadModule env_module modules/mod_env.so +
-LoadModule setenvif_module modules/mod_setenvif.so +
-LoadModule mime_module modules/mod_mime.so +
-LoadModule autoindex_module modules/mod_autoindex.so +
-LoadModule negotiation_module modules/mod_negotiation.so +
-LoadModule dir_module modules/mod_dir.so +
-LoadModule alias_module modules/mod_alias.so +
-LoadModule rewrite_module modules/mod_rewrite.so +
-</code> +
-Explain directives with these modules: +
 <code bash> <code bash>
 LoadModule authz_host_module modules/mod_authz_host.so#Order LoadModule authz_host_module modules/mod_authz_host.so#Order
 +LoadModule access_compat_module modules/mod_access_compat.so#Require
 LoadModule log_config_module modules/mod_log_config.so#LogFormat,TransferLog LoadModule log_config_module modules/mod_log_config.so#LogFormat,TransferLog
 LoadModule expires_module modules/mod_expires.so LoadModule expires_module modules/mod_expires.so
Line 203: Line 216:
 </code> </code>
 ==== optimize load module php ==== ==== 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>
 +<IfModule mod_php5.c>
 +    php_admin_flag display_errors off
 +</IfModule>
 +</code>
 +
apache/architecture.1411223260.txt.gz · Last modified: 2022/10/29 16:15 (external edit)