2

我目前正在运行一个 Web 应用程序,该应用程序会看到几个(约 15 个)用户每天登录一次,然后将 Web 应用程序保持打开状态,它每 5 分钟自动刷新一次新内容。每个用户倾向于将其打开大约 15-18 小时。

然而,当用户达到临界质量(~30-40)时,一切都开始显着减慢,并且 HTTPD 进程开始在内存使用中膨胀。我添加了一个每小时重新启动一次 apache 的 cron 作业,但这只会有所帮助。所有内容都是动态生成的和新的观看时间,因此缓存页面不是一种选择。

我已经开始尝试使用 Timeout、MaxRequest 和 KeepAlive 选项,但任何指导都将不胜感激,因为我过去总是将这些设置为默认值。

这就是我所拥有的。任何 apache 天才都对如何针对上述情况优化此配置有想法?我认为长时间超时很好,因为加载时间有时会变得非常高。

# Timeout: The number of seconds before receives and sends time out.

Timeout 200

# 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 60

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers       16
MinSpareServers    10
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>
4

1 回答 1

2

这可能是进入ServerFault的一个好问题。

您的服务器可能正在交换(缺少 RAM)。

你的MaxClients指令应该是这样的:

MaxClients ≈ (RAM - size_all_other_processes)/(size_apache_process)

您可以查看几篇解释如何微调 apache 的文章

cron-restarting是不行的!一个好主意。也许一天一次。但不要试图以这种方式解决这个问题。

希望能帮助到你!

于 2010-08-04T20:21:22.277 回答