Answer the question
In order to leave comments, you need to log in
Httpd starts eating memory... and hangs up?
There is one site, average attendance. It spins on a VPS with two gigs of memory (plus two - swap) under Fedora (I don't remember which version). It worked great until last weekend. For some reason, Apache began to devour all the memory without a trace, then devoured the swap, after which the server literally lay down. However, sometimes he went to bed earlier, with a message from the oom killer in the logs.
Following a lot of advice on the net, I set up nginx static output, added memory to eAccelerator, slightly reconfigured MySQL, and tracked the most frequently requested files (these turned out to be three scripts requested by Ajax; I just added shared memory caching to them).
A piece of httpd.conf:
KeepAlive Off<br/>
RLimitMEM 67108864 # 64 мегабайта я поставил уже под конец, потому что ограничение в гигабайт не помогало<br/>
RLimitCPU 20<br/>
# Честно говоря, не знаю, который из MPM используется, менял сразу оба. Но вроде не особо много стоит<br/>
<IfModule prefork.c><br/>
StartServers 2<br/>
MinSpareServers 2<br/>
MaxSpareServers 8<br/>
ServerLimit 50<br/>
MaxClients 30<br/>
MaxRequestsPerChild 50<br/>
</IfModule><br/>
<IfModule worker.c><br/>
StartServers 2<br/>
MaxClients 50<br/>
MinSpareThreads 5<br/>
MaxSpareThreads 30<br/>
ThreadsPerChild 15<br/>
MaxRequestsPerChild 50<br/>
</IfModule><br/>
Listen 127.0.0.1:8101 # Для nginx<br/>
HostnameLookups Off<br/>
[mysqld]<br/>
datadir=/var/lib/mysql<br/>
socket=/var/lib/mysql/mysql.sock<br/>
user=mysql<br/>
<br/>
low-priority-updates=yes<br/>
skip-external-locking=yes<br/>
skip-name-resolve=yes<br/>
skip-networking=yes<br/>
<br/>
bind-address=127.0.0.1<br/>
max_connections = 128<br/>
thread_cache_size = 16<br/>
query_cache_size = 64M<br/>
query_cache_type = ON<br/>
<br/>
symbolic-links=0<br/>
user nginx;<br/>
worker_processes 2;<br/>
worker_priority -1;<br/>
events {<br/>
worker_connections 1024;<br/>
use epoll;<br/>
}<br/>
<br/>
http {<br/>
include /etc/nginx/mime.types;<br/>
default_type application/octet-stream;<br/>
log_format main '$remote_addr - $remote_user [$time_local] "$request" '<br/>
'$status $body_bytes_sent "$http_referer" '<br/>
'"$http_user_agent" "$http_x_forwarded_for"';<br/>
access_log /var/log/nginx/access.log main;<br/>
sendfile on;<br/>
keepalive_timeout 65;<br/>
server_names_hash_bucket_size 64;<br/>
include /etc/nginx/conf.d/*.conf;<br/>
}<br/>
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {<br/>
root /var/www/indee;<br/>
access_log off;<br/>
expires 1d;<br/>
add_header Last-Modified: $date_gmt;<br/>
}<br/>
<br/>
location ~ /\.ht {<br/>
deny all;<br/>
}<br/>
<br/>
location / {<br/>
proxy_pass <a href="http://127.0.0.1">127.0.0.1</a>:8101/;<br/>
proxy_redirect off;<br/>
<br/>
proxy_set_header Host $host;<br/>
proxy_set_header X-Real-IP $remote_addr;<br/>
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br/>
<br/>
client_max_body_size 10m;<br/>
client_body_buffer_size 128k;<br/>
<br/>
proxy_connect_timeout 90;<br/>
proxy_send_timeout 90;<br/>
proxy_read_timeout 90;<br/>
<br/>
proxy_buffer_size 4k;<br/>
proxy_buffers 4 32k;<br/>
proxy_busy_buffers_size 64k;<br/>
proxy_temp_file_write_size 64k;<br/>
}<br/>
Server version: Apache/2.2.3<br/>
Server built: Jan 31 2011 17:50:30
nginx: nginx version: nginx/1.0.0
PHP 5.3.6 (cli) (built: Apr 19 2011 13:21:12) <br/>
Copyright © 1997-2011 The PHP Group<br/>
Zend Engine v2.3.0, Copyright © 1998-2011 Zend Technologies<br/>
with eAccelerator v0.9.6-svn358-dev, Copyright © 2004-2007 eAccelerator, by eAccelerator
mysqld_multi version 2.16 by Jani Tolonen
Answer the question
In order to leave comments, you need to log in
Start with status and info for apache. Look aside:
SetHandler server-status
SetHandler server-info
Next look in which mode: if prefork, then this is most likely the rampant reproduction of children. If the worker somewhere wants a lot of memory and does not release it. As an option - a bug in Apache or a module. But most likely - a buggy script.
Monitor the state of apache and use it and the logs to reproduce and localize the problem.
The first is the analysis of request logs - look for what is repeated every time memory leaks and check.
The second is to turn off in turn and watch.
But in general, the question is from the category “X does not work. What can we do to make it work?”
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question