我怎样才能prevent吨Apache进程,当我启动Apache和程序杀死我的机器产卵? [英] How can I prevent tons of apache processes spawning when I start apache and proceeding to kill my machine?

查看:136
本文介绍了我怎样才能prevent吨Apache进程,当我启动Apache和程序杀死我的机器产卵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Debian的机器上的高流量的应用程序和Apache已经开始代理奇怪。

I have a highly trafficked application on one debian machine and apache has started acting strange.

我每次启动Apache,Apache的吨过程中被催生,应用程序不会加载所有,并很快在整个机器死机,必须开机循环重启。

Every time I start apache, tons of apache processes are spawned, the app doesn't load at all, and very quickly the whole machine freezes and must be powercycled to reboot.

下面是我得到顶部开始后立即阿帕奇:

Here is what I get for top immediately after starting apache:


top -   20:14:44    up         1:16,      2 users,    load average: 0.48, 0.10, 0.03
Tasks:  330 total,  5 running, 325 sleeping,   0 stopped,   0 zombie
Cpu(s): 12.0%us,    21.4%sy,   0.0%ni,        65.7%id,   0.2%wa,  0.1%hi,  0.7%si,  0.0%st
Mem:    8179920k    total,     404984k used,  7774936k free,    60716k buffers
Swap:   2097136k    total,     0k used,       2097136k free,    43424k cached


10251 www-data  15   0  467m 8100 4016 S    6  0.1   0:00.04 apache2
10262 www-data  15   0  467m 8092 4012 S    6  0.1   0:00.05 apache2
10360 www-data  15   0  468m 8296 4016 S    6  0.1   0:00.05 apache2
10428 www-data  15   0  468m 8272 3992 S    6  0.1   0:00.05 apache2
10241 www-data  15   0  467m 8256 4012 S    4  0.1   0:00.03 apache2
10259 www-data  15   0  467m 8092 4012 S    4  0.1   0:00.04 apache2
10274 www-data  15   0  467m 8056 4012 S    4  0.1   0:00.03 apache2
10291 www-data  15   0  468m 8292 4012 S    4  0.1   0:00.03 apache2
10293 www-data  15   0  468m 8292 4012 S    4  0.1   0:00.03 apache2
10308 www-data  15   0  468m 8296 4016 S    4  0.1   0:00.02 apache2
10317 www-data  15   0  468m 8292 4012 S    4  0.1   0:00.02 apache2
10320 www-data  15   0  468m 8292 4012 S    4  0.1   0:00.04 apache2
10325 www-data  15   0  468m 8292 4012 S    4  0.1   0:00.04 apache2

和等..更多Apache2的流程。

And so forth.. with more apache2 processes.

不到一分钟后不到,你可以看到下面的负荷已经从0.48到2.17。如果我没有在这一点上停止Apache,负荷继续上升在几分钟以内,直到机模具。

Less than a minute later, you can see below that the load has gone from 0.48 to 2.17. If I do not stop apache at this point, the load continues to rise over a few minutes or less until the machine dies.


top -    20:15:34 up 1:17,       2 users,  load average: 2.17, 0.62, 0.21
Tasks:   1850 total,  5 running, 1845 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,      2.1%sy,    0.0%ni, 96.4%id,  0.0%wa,  0.1%hi,  1.0%si,  0.0%st
Mem:     8179920k     total,     1938524k used,  6241396k free,    60860k buffers
Swap:    2097136k     total,     0k used,  2097136k free,    44196k cached

我们有我们列入白名单,我们知道被允许打我们的网站地址的防火墙。

We have a firewall where we whitelist the addresses we know are allowed to hit our site.

什么问题可能是任何想法是非常欢迎的。

Any ideas about what the problem might be are very welcome.

谢谢!

推荐答案

您可能已经做出配置Apache使用远远超过所有您的RAM的错误。这是一个容易犯的错误。

You have probably made the error of configuring Apache to use far more than all of your ram. This is an easy mistake to make.

我假设你使用的是prefork Apache和一个进程的应用服务器(如PHP或mod_perl的)。在这种模式下,你将最终获得一个最大的(MaxClients的*每个流程应用程序的最大内存使用)使用的内存。如果没有近那么多,它的时间减少一个,另一个或两者兼而有之。

I am assuming you are using a Prefork Apache, and an in-process application server (such as PHP or mod_perl). In this model, you will end up with a maximum of (MaxClients * max memory usage of your application per process) memory used. If you don't have nearly that much, it's time to decrease one, the other or both.

在一般情况下,这意味着减少MaxClients的到你的服务器有足够的RAM应付的地步。

In the general case, this means decreasing MaxClients to the point where your server has enough ram to cope.

通常用于MaxClients的(150是典型的)不适合温和机器上运行一个进程重量级应用服务器,如果您使用的是prefork模式的默认值(大多数应用服务器或者不支持,或不鼓励,使用螺纹模型)。

The default values typically used for MaxClients (150 is typical) are not suitable for running an in-process heavyweight application server on a modest machine if you are using the Prefork model (Most application servers either don't support, or discourage, the use of threaded models).

然而,减少MaxClients的最终会导致应用程序变得不可用,特别是如果你有持久连接上和端的超时时间太长。流程它们只是保持连接活着(状态K在服务器状态)仍然使用了大量的内存,这可能是一个问题 - 要尽量减少keepalive超时,或者完全关闭它。

However, decreasing MaxClients will eventually cause the application to become unavailable, particularly if you have keepalives on and the keepalive timeout too long. Processes which are just keeping a connection alive (state K in server-status) still use a lot of RAM, and that may be a problem - try to minimise keepalive timeout, or turn it off altogether.

您需要密切关注服务器状态(由mod_status的提供)。

You need to keep an eye on server-status (as provided by mod_status).

当然,如果你了解的后果,你只应做任何更改的。三思而后行,更改配置一次。如果你一定要考一个类似规范非生产机器上模拟负载的变化ANY能力这样做。

Of course you should only make ANY of these changes if you understand the consequences. Think twice, change the config once. If you have ANY ability to test the changes with simulated load on a similar spec non-production machine, do so.

这篇关于我怎样才能prevent吨Apache进程,当我启动Apache和程序杀死我的机器产卵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆