apache进程和pageloads / views / hits之间的关系

当我运行ps aux命令时,我看到/usr/sbin/apache2 -k start (在Ubuntu机器上)和/usr/sbin/httpd -k start (在Centos中)有很多条目。 我已经从某个地方看过,这些条目中的每一个都是一个apache进程,它是事先创build的,以便为将来的服务器请求做好准备。

所以,据我所知,这些apache进程中的每一个都是为http请求提供服务,并在作业完成后closures,其他进程将被创build以为将来的其他请求做好准备。

我不清楚的是,每个Apache进程将服务页面载入或命中? (由于每个页面载入可能有几十个命中)。

我在问这个问题,因为我看到了两种不同的Ubuntu和Centos行为。 我对Ubuntu更加熟悉,当我有很多命中不存在的页面时,我的Ubuntu机器从未遇到过高负载问题(当我说不存在的页面时,这意味着文件不存在于服务器中,不会被.htaccess文件重写成一个php文件)

但是,最近我必须pipe理一个Centos服务器。 我看到一些不好的机器人只是在1-2秒内将20-30次命中到不存在的页面上,每次发生的时候,平均负载都会很高,而且我也看到很多/usr/sbin/httpd -k startps aux命令/usr/sbin/httpd -k startinput。

所以我猜Centos会为每个命中使用一个httpd进程,而在ubuntu中,每个apache进程都可以用于多个命中。 这是正确的猜测吗? 如果这是正确的,我认为与Ubuntu相比,Centos是非常低效的。

任何人都可以澄清这些点,以便我可以看到我失踪?

非常感谢你!

更新1

我也看到了另一个区别:当我从ubuntu机器打开一个url时,一个/usr/bin/php5-cgi进程被创build,并且这个进程仍然在那里很长时间(小时),即使pageload在1- 2秒。 所以我想这个PHP进程是持有一些caching信息,以便它可以用于服务下一个页面请求(我没有看到一个新的/usr/bin/php5-cgi进程,当我继续浏览到另一个页面)

但在Centos机器上,当我访问一个页面,如果我很幸运,我可以看到一个/opt/cpanel/ea-php56/root/usr/bin/php-cgi进程,并且这个进程在1-2秒后立即消失

更新2

这里是/etc/apache2/apache2.conf(Ubuntu)的内容

 # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See http://httpd.apache.org/docs/2.4/ for detailed information about # the directives and /usr/share/doc/apache2/README.Debian about Debian specific # hints. # # # Summary of how the Apache 2 configuration works in Debian: # The Apache 2 web server configuration in Debian is quite different to # upstream's suggested way to configure the web server. This is because Debian's # default Apache2 installation attempts to make adding and removing modules, # virtual hosts, and extra configuration directives as flexible as possible, in # order to make automating the changes and administering the server as easy as # possible. # It is split into several files forming the configuration hierarchy outlined # below, all located in the /etc/apache2/ directory: # # /etc/apache2/ # |-- apache2.conf # | `-- ports.conf # |-- mods-enabled # | |-- *.load # | `-- *.conf # |-- conf-enabled # | `-- *.conf # `-- sites-enabled # `-- *.conf # # # * apache2.conf is the main configuration file (this file). It puts the pieces # together by including all remaining configuration files when starting up the # web server. # # * ports.conf is always included from the main configuration file. It is # supposed to determine listening ports for incoming connections which can be # customized anytime. # # * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ # directories contain particular configuration snippets which manage modules, # global configuration fragments, or virtual host configurations, # respectively. # # They are activated by symlinking available configuration files from their # respective *-available/ counterparts. These should be managed by using our # helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See # their respective man pages for detailed information. # # * The binary is called apache2. Due to the use of environment variables, in # the default configuration, apache2 needs to be started/stopped with # /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not # work with the default configuration. # Global configuration # # # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # NOTE! If you intend to place this on an NFS (or otherwise network) # mounted filesystem then please read the Mutex documentation (available # at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>); # you will save yourself a lot of trouble. # # Do NOT add a slash at the end of the directory path. # #ServerRoot "/etc/apache2" # # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. # Mutex file:${APACHE_LOCK_DIR} default # # PidFile: The file in which the server should record its process # identification number when it starts. # This needs to be set in /etc/apache2/envvars # PidFile ${APACHE_PID_FILE} # # Timeout: The number of seconds before receives and sends time out. # Timeout 300 # # KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to "Off" to deactivate. # KeepAlive On # # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # We recommend you leave this number high, for maximum performance. # MaxKeepAliveRequests 100 # # KeepAliveTimeout: Number of seconds to wait for the next request from the # same client on the same connection. # KeepAliveTimeout 5 # These need to be set in /etc/apache2/envvars User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP} # # HostnameLookups: Log the names of clients or just their IP addresses # eg, www.apache.org (on) or 204.62.129.132 (off). # The default is off because it'd be overall better for the net if people # had to knowingly turn this feature on, since enabling it means that # each client request will result in AT LEAST one lookup request to the # nameserver. # HostnameLookups Off # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a <VirtualHost> # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here. # ErrorLog ${APACHE_LOG_DIR}/error.log # # LogLevel: Control the severity of messages logged to the error_log. # Available values: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the log level for particular modules, eg # "LogLevel info ssl:warn" # LogLevel warn # Include module configuration: IncludeOptional mods-enabled/*.load IncludeOptional mods-enabled/*.conf # Include list of ports to listen on Include ports.conf # Sets the default security model of the Apache2 HTTPD server. It does # not allow access to the root filesystem outside of /usr/share and /var/www. # The former is used by web applications packaged in Debian, # the latter may be used for local directories served by the web server. If # your system is serving content from a sub-directory in /srv you must allow # access here, or in any related virtual host. <Directory /> Options FollowSymLinks AllowOverride None Require all denied </Directory> <Directory /usr/share> AllowOverride None Require all granted </Directory> <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> #<Directory /srv/> # Options Indexes FollowSymLinks # AllowOverride None # Require all granted #</Directory> # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess # # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <FilesMatch "^\.ht"> Require all denied </FilesMatch> # # The following directives define some format nicknames for use with # a CustomLog directive. # # These deviate from the Common Log Format definitions in that they use %O # (the actual bytes sent including headers) instead of %b (the size of the # requested file), because the latter makes it impossible to detect partial # requests. # # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. # Use mod_remoteip instead. # LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent # Include of directories ignores editors' and dpkg's backup files, # see README.Debian for details. # Include generic snippets of statements IncludeOptional conf-enabled/*.conf # Include the virtual host configurations: IncludeOptional sites-enabled/*.conf SSLProtocol ALL -SSLv2 SSLCipherSuite ECDHE-RSA-AES256-SHA384:AES256-SHA256:AES256-SHA256:RC4:HIGH:MEDIUM:+TLSv1:+TLSv1.1:+TLSv1.2:!MD5:!ADH:!aNULL:!eNULL:!NULL:!DH:!ADH:!EDH:!AESGCM # vim: syntax=apache ts=4 sw=4 sts=4 sr noet Include /etc/phpmyadmin/apache.conf 

这里是/etc/httpd/conf/httpd.conf(Centos)的一部分(其他部分是虚拟主机的域名,我认为它没有任何有用的信息)

 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # DO NOT EDIT. AUTOMATICALLY GENERATED. USE INCLUDE FILES IF YOU NEED TO MAKE A CHANGE # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # Direct modifications to the Apache configuration file WILL be lost upon subsequent # regeneration of this configuration file, or an Apache update. # # To have your modifications retained, you should create/edit administrator-specific # include files: # # /etc/apache2/conf.d/includes/pre_main_global.conf # /etc/apache2/conf.d/includes/pre_virtualhost_global.conf # /etc/apache2/conf.d/includes/post_virtualhost_global.conf # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ################################################## ################################################## # # cPanel & WHM controlled Apache configuration # ################################################## ################################################## Include "/etc/apache2/conf.modules.d/*.conf" # Administrator locations for safely altering httpd.conf Include "/etc/apache2/conf.d/includes/pre_main_global.conf" # These are hard-coded values that are required by cPanel & WHM PidFile /run/apache2/httpd.pid User nobody Group nobody ExtendedStatus On LogLevel warn # You can change this by using WHM, and navigating to the 'Basic cPanel & WHM Setup' -> 'Contact Information' interface. ServerAdmin [email protected] # You can change this by using WHM, and navigating to the 'Networking Setup' => 'Change Hostname' interface. ServerName sv1.howhubs.com # You can change this by using WHM, and navigating to the 'Apache Configuration' -> 'Global Configuration' interface. TraceEnable Off ServerSignature Off ServerTokens ProductOnly FileETag None <Directory "/"> AllowOverride None Options </Directory> StartServers 5 <IfModule prefork.c> MinSpareServers 5 MaxSpareServers 10 </IfModule> ServerLimit 256 MaxRequestWorkers 150 MaxConnectionsPerChild 10000 KeepAlive On KeepAliveTimeout 5 MaxKeepAliveRequests 100 Timeout 300 <IfModule rewrite_module> # Global DCV Exclude RewriteEngine on RewriteCond %{REQUEST_URI} ^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ [OR] RewriteCond %{REQUEST_URI} ^/[0-9]+\..+\.cpaneldcv$ # Exclude proxy subdomains as we need rewrites to capture the DCV requests RewriteCond %{HTTP_HOST} !^(?:autoconfig|autodiscover|cpanel|cpcalendars|cpcontacts|webdisk|webmail|whm)\. RewriteRule ^ - [END] </IfModule> # You can change this by using WHM, and navigating to the 'Apache Configuration' -> 'DirectoryIndex Priority' interface. <IfModule dir_module> DirectoryIndex index.php index.php5 index.php4 index.php3 index.perl index.pl index.plx index.ppl index.cgi index.jsp index.jp index.phtml index.shtml index.xhtml index.html index.htm index.wml Default.html Default.htm default.html default.htm home.html home.htm index.js </IfModule> # You can change this by using WHM, and navigating to the 'Apache Configuration' -> 'Memory Usage Restrictions' interface. # This setting is required by cPanel & WHM in order to provide access to a default webpage when none exists <Directory "/var/www/html"> Options All AllowOverride None Require all granted </Directory> # Required cPanel security policy: Disallow remote access to .htaccess, .htpasswd, .user.ini, and php.ini files <Files ~ "^error_log$"> Order allow,deny Deny from all Satisfy All </Files> <FilesMatch "^(\.ht(access|passwds?)|\.user\.ini|php\.ini)$"> Require all denied </FilesMatch> <IfModule alias_module> ScriptAliasMatch ^/?controlpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi ScriptAliasMatch ^/?kpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi ScriptAliasMatch ^/?securecontrolpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi ScriptAliasMatch ^/?securecpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi ScriptAliasMatch ^/?securewhm/?$ /usr/local/cpanel/cgi-sys/swhmredirect.cgi ScriptAliasMatch ^/?webmail$ /usr/local/cpanel/cgi-sys/wredirect.cgi ScriptAliasMatch ^/?webmail/ /usr/local/cpanel/cgi-sys/wredirect.cgi ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi Alias /bandwidth /usr/local/bandmin/htdocs/ Alias /img-sys /usr/local/cpanel/img-sys/ Alias /java-sys /usr/local/cpanel/java-sys/ Alias /mailman/archives /usr/local/cpanel/3rdparty/mailman/archives/public/ Alias /pipermail /usr/local/cpanel/3rdparty/mailman/archives/public/ Alias /sys_cpanel /usr/local/cpanel/sys_cpanel/ ScriptAlias /cgi-sys /usr/local/cpanel/cgi-sys/ ScriptAlias /mailman /usr/local/cpanel/3rdparty/mailman/cgi-bin/ </IfModule> # This can be configured in the cPanel 'Leech Protection' interface. <IfModule rewrite_module> RewriteEngine on RewriteMap LeechProtect prg:/usr/local/cpanel/bin/leechprotect Mutex file:/run/apache2 rewrite-map </IfModule> <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml AddType application/x-tar .tgz AddType text/vnd.wap.wml .wml AddType image/vnd.wap.wbmp .wbmp AddType text/vnd.wap.wmlscript .wmls AddType application/vnd.wap.wmlc .wmlc AddType application/vnd.wap.wmlscriptc .wmlsc # These extensions are used to redirect incoming requests to WHM AddHandler cgi-script .cgi .pl .plx .ppl .perl # This is used for custom error documents AddHandler server-parsed .shtml </IfModule> # You can change this by using WHM, and updating the 'Tweak Settings' -> 'System' -> 'Allow server-info' option. <IfModule status_module> # This is used by the WHM 'Apache Status' application <Location /whm-server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 ::1 </Location> </IfModule> # Required cPanel security policy: disable userdir when mod_ruid2 or mpm_itk or mod_passenger are loaded <IfModule userdir_module> UserDir public_html <IfModule ruid2_module> UserDir disabled </IfModule> <IfModule mpm_itk.c> UserDir disabled </IfModule> <IfModule mod_passenger.c> UserDir disabled </IfModule> </IfModule> <IfModule log_config_module> LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent # NOTE: "combined" and "common" are required by WHM LogFormat "%h %l %u %t \"%r\" %>s %b" common LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined # access_log format can be set in WHM under 'Basic cPanel & WHM Setup' CustomLog logs/access_log combined </IfModule> # The Listen port can be updated using 'Tweak Settings' -> 'System', # However, if you have any Apache Reserved IPs, then this Tweak setting will # be ignored. Instead, each IP on your system (excluding Apache Reserved IPs) # will be listed here. Listen 0.0.0.0:80 Listen [::]:80 <IfModule ssl_module> # cipher and protocol directives can be set in WHM under 'Apache Configuration' -> 'Global Configuration' SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS SSLProtocol All -SSLv2 -SSLv3 SSLPassPhraseDialog builtin <IfModule socache_shmcb_module> SSLUseStapling on SSLStaplingCache shmcb:/run/apache2/stapling_cache_shmcb(256000) # Prevent browsers from failing if an OCSP server is temporarily broken. SSLStaplingReturnResponderErrors off SSLStaplingErrorCacheTimeout 60 SSLStaplingFakeTryLater off SSLStaplingResponderTimeout 3 SSLSessionCache shmcb:/run/apache2/ssl_gcache_data_shmcb(1024000) </IfModule> <IfModule !socache_shmcb_module> SSLSessionCache dbm:/run/apache2/ssl_gcache_data_dbm </IfModule> SSLSessionCacheTimeout 300 Mutex file:/run/apache2 ssl-cache SSLRandomSeed startup builtin SSLRandomSeed connect builtin # The Listen port can be updated using 'Tweak Settings' -> 'System', # However, if you have any Apache Reserved IPs, then this Tweak setting will # be ignored. Instead, each IP on your system (excluding Apache Reserved IPs) # will be listed here. Listen 0.0.0.0:443 Listen [::]:443 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl </IfModule> Include "/etc/apache2/conf.d/*.conf" Include "/etc/apache2/conf.d/includes/account_suspensions.conf" Include "/etc/apache2/conf.d/includes/errordocument.conf" # Administrator locations for safely globally altering all virtualhost configurations Include "/etc/apache2/conf.d/includes/pre_virtualhost_global.conf" ProxyPass /___proxy_subdomain_ws_cpanel ws://127.0.0.1:2082 max=1 retry=0 ProxyPass /___proxy_subdomain_ws_whm ws://127.0.0.1:2086 max=1 retry=0 ProxyPass /___proxy_subdomain_ws_webmail ws://127.0.0.1:2095 max=1 retry=0