我在 ubuntu 上有一个带有 apache/php 的专用服务器,为我的 Wordpress 博客提供每天大约 10K+ 的综合浏览量。我在 APC 上安装了 W3TC 插件。
但是服务器时不时地停止响应或变慢,我必须重新启动 apache 才能恢复它。
这是我的配置我做错了什么?
ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
TimeOut 40
KeepAlive on
MaxKeepAliveRequests 200
KeepAliveTimeout 2
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 8
ServerLimit 80
MaxClients 80
MaxRequestsPerChild 1000
</IfModule>
<IfModule mpm_worker_module>
StartServers 3
MinSpareServers 3
MaxSpareServers 3
ServerLimit 80
MaxClients 80
MaxRequestsPerChild 1000
</IfModule>
<IfModule mpm_event_module>
StartServers 3
MinSpareServers 3
MaxSpareServers 3
ServerLimit 80
MaxClients 80
MaxRequestsPerChild 1000
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP} …Run Code Online (Sandbox Code Playgroud) 我正在尝试优化我们的 Web 服务器以处理尽可能多的连接。我阅读了很多帖子和 Apache 笔记。我试图了解我应该为 选择哪个值MaxRequestsPerChild。
起初,我尝试将其设置为 4,000,但服务器在处理许多请求时遇到困难,因此我开始提高它。目前我的设置是:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 40000
</IfModule>
Run Code Online (Sandbox Code Playgroud)
将 设置MaxRequestsPerChild为 40,000 后,服务器设法在不使用更多内存/CPU 的情况下处理更多连接。
谁能告诉我这个值是太高了还是可以有这么高的值?
谢谢!
操作系统信息:
[root@web06 ~]# uname -a
Linux web 2.6.18-164.el5PAE #1 SMP Thu Sep 3 04:10:44 EDT 2009 i686 i686 i386 GNU/Linux
[root@web06 ~]# free
total used free shared buffers cached
Mem: 3814660 3502968 311692 0 144368 2970468
-/+ buffers/cache: 388132 3426528
Swap: 5210104 0 5210104
Run Code Online (Sandbox Code Playgroud) 我读了很多帖子说我不应该使用worker MPMwithPHP。
我的问题是这是否仍然有效,还是worker MPM不建议使用 。
我问这个的原因是因为我看到工作 MPM 确实支持 PHP,我认为甚至有一个为此目的的包 php-zts
我在linuxatemyram 上阅读了有关 Linux 和缓存内存的信息,但有一些对我来说没有意义的东西,如果服务器的负载甚至很低,而不是释放一些缓存内存,它开始使用交换,这会使服务器变慢..
即使是现在,当服务器负载达到load average: 0.00, 0.00, 0.00一定程度时,一些内存会被交换,而超过 85% 的内存被用于交换。
我读过类似的问题,例如this和this,但有人提到不应该发生交换。同样,直到 3 周前,只有一小部分内存被缓存占用,我们没有更改任何可能影响缓存内存的内容。
你能告诉我这个值是否仍然可以,还是我有问题?
谢谢!
[root@web01 ~]# cat /proc/meminfo
MemTotal: 5183448 kB
MemFree: 249260 kB
Buffers: 330848 kB
Cached: 4317828 kB
SwapCached: 92 kB
Active: 2883596 kB
Inactive: 1882468 kB
HighTotal: 4315324 kB
HighFree: 63516 kB
LowTotal: 868124 kB
LowFree: 185744 kB
SwapTotal: 5799928 kB
SwapFree: 5799796 kB
Dirty: 368 kB
Writeback: 0 kB
AnonPages: 117356 kB
Mapped: 21076 kB
Slab: …Run Code Online (Sandbox Code Playgroud) apache-2.2 ×3
linux ×2
cache ×1
memory ×1
mpm-prefork ×1
mpm-worker ×1
optimization ×1
php ×1
php5 ×1
scalability ×1
swap ×1
wordpress ×1