AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[mpm-prefork](server)

Martin Hope
Rahul
Asked: 2020-08-26 03:02:29 +0800 CST

apache2 服务器中的零空闲工作人员导致性能问题

  • 1

我有一个基于 php 以及 apache2 和 mysql 的 SAAS 产品,它已经托管在 AWS 上。我的生产在高峰时间非常慢,当我检查服务器状态时,它说空闲工作人员为 0(零)我正在使用 mpm-prefork

Current Time: Monday, 24-Aug-2020 19:36:32 UTC
Restart Time: Friday, 14-Aug-2020 06:03:27 UTC
Parent Server Config. Generation: 12
Parent Server MPM Generation: 11
Server uptime: 10 days 13 hours 33 minutes 5 seconds
Server load: 1.17 1.07 0.95
Total accesses: 28851443 - Total Traffic: 824.8 GB
CPU Usage: u289.99 s50.68 cu0 cs0 - .0373% CPU load
31.6 requests/sec - 0.9 MB/second - 30.0 kB/request
256 requests currently being processed, 0 idle workers

以下是我的 mpm-prefork.conf 设置文件

<IfModule mpm_prefork_module>
        StartServers                     5
        MinSpareServers           5
        MaxSpareServers          10
        MaxRequestWorkers         450
        MaxConnectionsPerChild   0
</IfModule>

ubuntu20.04 上的 TOP 命令给了我这个:

top - 20:03:58 up 143 days, 11:16,  1 user,  load average: 0.48, 0.71, 0.83
Tasks: 369 total,   3 running, 317 sleeping,   0 stopped,   0 zombie
%Cpu(s): 15.9 us,  3.2 sy,  0.0 ni, 79.9 id,  0.0 wa,  0.0 hi,  1.0 si,  0.0 st
KiB Mem :  7865072 total,  1023492 free,  2752320 used,  4089260 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  4755856 avail Mem

根据详细信息,我可以看到 1 GB 内存仍然是免费的。那么零闲置工人呢?另外,为什么当我将 MaxRequestWorkers 设置为 450 时,只有 256 个请求的空闲工作人员为零。机器中的最大 RAM 为 8GB

apache-2.4 mpm-prefork
  • 2 个回答
  • 857 Views
Martin Hope
Mr P
Asked: 2017-02-25 11:00:43 +0800 CST

centos 7中的apache不以mpm事件开头

  • 0

嗨,我尝试从 prefork 切换到 apache MPM 事件,如下所示:

 vim /etc/httpd/conf.modules.d/00-mpm.conf

# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines:

# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#
#LoadModule mpm_event_module modules/mod_mpm_event.so

切换到

# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines:

# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#

LoadModule mpm_event_module modules/mod_mpm_event.so

并且 apache 不会启动:

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

以下是相关日志(重启失败后我切换回并重新启动):

Feb 25 05:48:19 hostname9727 httpd[20029]: [Sat Feb 25 05:48:19.831460 2017] [:crit] [pid 20029:tid 139667929794688] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.
Feb 25 05:48:19 hostname9727 httpd[20029]: AH00013: Pre-configuration failed
Feb 25 05:48:19 hostname9727 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Feb 25 05:48:19 hostname9727 kill[20031]: kill: cannot find process ""
Feb 25 05:48:19 hostname9727 systemd[1]: httpd.service: control process exited, code=exited status=1
Feb 25 05:48:19 hostname9727 systemd[1]: Failed to start The Apache HTTP Server.
Feb 25 05:48:19 hostname9727 systemd[1]: Unit httpd.service entered failed state.
Feb 25 05:48:19 hostname9727 systemd[1]: httpd.service failed.

systemctl status httpd.service 和 journalctl -xe 没有相关日志(没有来自同一日期的日志)。

编辑

这是我的httpd.conf:

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. [email protected]
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride all
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ".ht*">
    Require all denied
</Files>

#
# 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 "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to 
    # exist in your server's namespace, but do not anymore. The client 
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts. 
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the 
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it, 
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted 
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
<FilesMatch "\.ph(p[2-6]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

#eran

#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/root/wwwroot/classes/"
Alias /awstatscss "/root/wwwroot/css/"
Alias /awstatsicons "/root/wwwroot/icon/"
ScriptAlias /awstats/ "/root/wwwroot/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/root/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

我认为我应该改变:

LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
<FilesMatch "\.ph(p[2-6]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

至:

#LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

<FilesMatch "\.ph(p[2-6]?|tml)$">
    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
DirectoryIndex /index.php index.php
</FilesMatch>
apache-2.4 mpm-worker mpm-prefork
  • 1 个回答
  • 7185 Views
Martin Hope
user3162662
Asked: 2016-12-02 22:04:06 +0800 CST

Windows Server 2008 R2 上的 WINNT Apache MPM“ThreadsPerChild”配置

  • 1

当我将 ThreadPerChild 设置为 200 时出现错误并且无法启动 Apache,尽管我仍有 60% 的可用 RAM。服务器是具有 4GB RAM 的 Windows Server 2008 R2。在这种情况下如何为 apache 使用更多 RAM?

我的 Apache MPM 配置:

# WinNT MPM
# ThreadsPerChild: constant number of worker threads in the server process
# MaxRequestsPerChild: maximum  number of requests a server process serves
# Win32DisableAcceptEx: Use accept() rather than AcceptEx() to accept network connections
<IfModule mpm_winnt_module>
   ThreadStackSize 8388608
    ThreadsPerChild      170
    MaxRequestsPerChild    0
    #Win32DisableAcceptEx
</IfModule>

我在 apache 的 error_log 中得到了什么:

[Thu Dec 01 18:23:04.459113 2016] [mpm_winnt:notice] [pid 3396:tid 288] AH00354: Child: 启动 200 个工作线程。

[Thu Dec 01 18:23:04.459113 2016] [mpm_winnt:crit] [pid 3396:tid 288] (OS 8)没有足够的存储空间来处理这个命令。:AH00355:孩子:CreateThread 失败。无法创建所有工作线程。在使用 ThreadsPerChild 配置指令请求的 200 个线程中创建了 190 个。

[Thu Dec 01 18:23:04.474714 2016] [mpm_winnt:notice] [pid 3644:tid 380] AH00422: Parent: Received shutdown signal --

编辑:2016 年 12 月 9 日:

按照此页面https://support.microsoft.com/en-us/kb/106167将注册表中的 IRPStackSize 更改为 20 和 25。仍然无法启动 Apache 服务器。

谢谢。

amazon-ec2 apache2 windows-server-2008-r2 mpm-prefork
  • 2 个回答
  • 12314 Views
Martin Hope
Isidius
Asked: 2016-08-27 03:11:36 +0800 CST

防止Apache2在错误日志中写入启动信息

  • 0

Apache2 总是将启动信息写入错误日志。请参阅以下输出:

[Fri Aug 26 12:57:54.298895 2016] [ssl:warn] [pid 4287] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Fri Aug 26 12:57:54.326885 2016] [mpm_prefork:notice] [pid 4287] AH00163: Apache/2.4.10 (Linux/SUSE) OpenSSL/1.0.1k-fips PHP/5.6.1 configured -- resuming normal operations
[Fri Aug 26 12:57:54.326943 2016] [core:notice] [pid 4287] AH00094: Command line: '/usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -D CACTI -D SYSTEMD -D FOREGROUND'

我如何配置 apache2 来阻止它,因为它让webmin感到困惑,它认为虽然它成功启动了,但它没有..

我在任何配置文件中都没有设置

LogLevel debug|trace
startup apache-2.4 apache2 mpm-prefork
  • 3 个回答
  • 1012 Views
Martin Hope
MitchellK
Asked: 2016-05-27 01:56:58 +0800 CST

Apache 不断恢复到 mpm_prefork (Apache 2.4.7 / Ubuntu 14.04.2)

  • 0

我已经有这个问题超过一年了,每次 Ubuntu 有安全更新并且我必须重新启动服务器时,Apache 2.4 决定开始使用 mpm_prefork 工作程序,尽管我已将 mpm_event 设置为 / 中的启用模块etc/apache2/mods 启用。

我什至在 /etc/apache2/mods-available 中编辑 mpm_prefork.conf 文件并注释掉它加载模块的位置,但今天早上重新启动后,apache 根本不会启动,因为它坚持使用 Prefork 启动.

这是我的 /etc/apache2/mods-enabled/ 目录列表

access_compat.load
actions.conf
actions.load
alias.conf
alias.load
auth_basic.load
authn_core.load
authn_file.load
authz_core.load
authz_host.load
authz_user.load
autoindex.conf
autoindex.load
deflate.conf
deflate.load
dir.conf
dir.load
env.load
evasive.conf
evasive.load
expires.load
fastcgi.conf
fastcgi.load
filter.load
headers.load
mime.conf
mime.load
mpm_event.conf
mpm_event.load
negotiation.conf
negotiation.load
pagespeed.conf
pagespeed.load
rewrite.load
setenvif.conf
setenvif.load
socache_shmcb.load
spamhaus.conf
spamhaus.load
ssl.conf
ssl.load
status.conf
status.load

我通过运行 apache2 -l 检查它是否已编译到 Apache 中,这是输出

Compiled in modules:
  core.c
  mod_so.c
  mod_watchdog.c
  http_core.c
  mod_log_config.c
  mod_logio.c
  mod_version.c
  mod_unixd.c

最后 a2query -M 的结果是

sudo a2query -M
event

但是,如果我现在重新启动,Apache 会在启动时死机,因为它需要 mpm_prefork 模块,正如我所说,我已经通过在其 .conf 文件中注释掉它来禁用它以防止它加载,这不是解决我的问题的方法。

老实说,我对 Apache 2.4 一直在自己决定加载 mpm_prefork 的地方感到困惑。

这也是我没有注释的 apache2.conf 文件

# Global configuration
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 40
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostNameLookups Off
ErrorLog ${APACHE_LOG_DIR}/apache-error.log
LogLevel warn
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
SetEnvIf Remote_Addr "::1" loopback
CustomLog ${APACHE_LOG_DIR}/apache-access.log combined env=!loopback

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


<Directory />
    Options -Indexes +FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options -Indexes +FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/html/opcache/>
    Options -Indexes +FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%V %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
LogFormat "%h %l %u %t \"%r\" %>s %O %b %D \"%{Referer}i\" \"%{User-Agent}i\"" custom


IncludeOptional conf-enabled/*.conf

IncludeOptional sites-enabled/*.conf
httpd.conf apache-2.4 mpm-prefork
  • 1 个回答
  • 2145 Views
Martin Hope
WooDzu
Asked: 2012-05-20 05:29:00 +0800 CST

专用服务器上的单个 CMS 站点 [重复]

  • -3
这个问题在这里已经有了答案:
10 年前关闭。

可能重复:
您能帮我进行容量规划吗?

我们即将推出一个巨大的网站,预计会有巨大的流量,尤其是在最初的几周内。这将是一个基于 Joomla CMS 的社区网站。我们预计每天有 2 万到 5 万次独立访问。通常页面会进行 25-35 次 mysql 查询,但有些甚至有 140 次,其中最大内存使用量约为 20-25MB。

请你看看这个配置并提出一些意见和建议。我已经使用ab -n 500 -c 10对此进行了测试,但我担心的是这不是真正的基准测试。

  • 2 x Intel X5650 处理器(共 24 核)
  • 12 个 2.66 GHz 超线程内核
  • 32GB
  • CentOS 6.2 在 Virtuosso 层,cPanel
  • 带有 mod_suhoshin、mod_fcgid、APC 的 PHP 5.3.10
<IfModule prefork.c>
    StartServers     5
    MinSpareServers   5
    MaxSpareServers   10
    ServerLimit      48
    MaxClients       44
    MaxRequestsPerChild  10000
</IfModule>
Timeout 300
KeepAlive Off

<IfModule mod_fcgid.c>
    FcgidMaxRequestLen 1073741824
    FcgidMaxRequestsPerProcess 1000
    FcgidMaxProcesses 1000
</IfModule>
apache-2.2 dedicated-server mod-fcgid mpm-prefork
  • 1 个回答
  • 158 Views
Martin Hope
Rodrigo Sieiro
Asked: 2010-04-19 09:06:17 +0800 CST

Apache 到达 MaxClients 并锁定服务器

  • 9

我目前有一个 Apache2 服务器在 OpenVZ VPS 上运行,mpm-prefork具有mod_php512M 真实/1024M 可爆 RAM(无交换)。运行一些测试后,我发现 Apache 获得的最大进程大小是 23M,所以我设置MaxClients为 25(23M x 25 = 575 MB,对我来说还可以)。我决定在我的服务器上运行一些负载测试,结果让我很困惑。

我ab在我的台式机上使用从 wordpress 博客请求主页。

当我运行ab24 个并发连接时,一切似乎都很好。当然,CPU 上升,可用 RAM 下降,结果是每个请求大约需要 2-3 秒的响应时间。

但是如果我运行ab25 个并发连接(我的服务器限制),Apache 会在几秒钟后挂起。它开始处理请求,然后停止响应,CPU 回到 100% 空闲并ab超时。Apache 日志说它达到了MaxClients.

发生这种情况时,Apache 将自己锁定在 25 个正在运行的进程中(如果我检查服务器状态,它们都处于“W”状态)并且只有在TimeOut设置后进程开始终止并且服务器再次开始响应(在我的情况下它已设置至 45)。

我的问题:这是预期的行为吗?为什么 Apache 在到达时就死掉了MaxClients?如果它适用于 24 个连接,那么它不应该适用于 25 个连接,只是需要更多的时间来响应每个请求并将其余的排队?

ab对我来说,任何运行的孩子都可以通过设置与服务器的并发连接单独杀死网络服务器,这听起来有点奇怪MaxClients。

apache-2.2 timeout openvz mpm-prefork
  • 2 个回答
  • 14029 Views
Martin Hope
beny
Asked: 2010-02-10 07:04:57 +0800 CST

apache 关闭,因为达到 MaxClients

  • 3

有一个严重的问题。我有运行 Apache 的虚拟服务器和两个有很多访问者的 Web 项目(大约每秒 5 次点击)。我的服务器开始自行关闭。在错误日志中我发现了这个问题

[error] server reached MaxClients setting, consider raising the MaxClients setting
[notice] caught SIGTERM, shutting down

所以我寻找解决方案来提高这些数字。我发现这个数字在 apache 配置中分为两个部分。和

/usr/sbin/httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

我发现我的服务器正在使用 prefork。所以我再次寻找合适的值并尝试了这些

<IfModule prefork.c>
    StartServers       8
    MinSpareServers    5
    MaxSpareServers   20
    ServerLimit     1024
    MaxClients      1024
    MaxRequestsPerChild  4000
</IfModule>

但即使使用这些值,服务器仍会关闭。任何人都可以指导我去哪里看,读什么,或者为服务器的正常稳定运行设置什么?伙计们,我将不胜感激。

服务器运行Linux CentOS 5.4

谢谢贝尼

apache-2.2 mpm-prefork
  • 3 个回答
  • 10386 Views
Martin Hope
Aron Rotteveel
Asked: 2009-07-25 00:47:30 +0800 CST

安装哪个:Apache Worker 还是 Prefork?每个的(缺点)优点是什么?

  • 56

根据对Prefork和Worker MPM 的描述,似乎 prefork 类型有些过时,但我真的找不到这两种类型的适当比较。

我想知道的:

  • 两个版本有什么区别?
  • 每种服务器类型的(缺点)优点是什么?
  • 是否有根据条件选择哪种类型的基本准则?
  • 两者之间有什么大的性能差异吗?
apache-2.2 mpm-worker mpm-prefork
  • 5 个回答
  • 57903 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve