New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
[SOLVED] Apache Ram usage increasing with time
Hello,
I have a Ramnode 512 MB server. I've set up CF image hosting script earlier today. Since then, the ram usage of Apache has been increasing slowly without anything done on the server. There are no traffic or anything. Now apache 2 is consuming 231 MB ram(increasing slowly) with 10 process running. Server's total ram usage is 273 MB.
Could you guys please suggest me some fix? I'm running Ubuntu 12.04 64 bit.
Thanked by 1Nick_A
Comments
Debian 6 32 bits.
Check if it destroys the image variables.
You can lsof -p your Apache process to find out which files it has open.
I had the same problem before and a quick fix to it was to run a bash script to reload Apache every 30 mins.
I ran this command and got this. I don't know what to pick from this
lsof: no process ID specified
lsof 4.81
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abhlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]]
[-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.
@chinmoy
lsof -p [YOUR-APACHE-PID-NUMBER-HERE]
That's normal for apache. Try switching to nginx
Guys, this is by far the most used web server you're talking about!!! Saying that this is normal or you need to restart the service every x time, just doesn't make sense.
@chinmoy What php handler are you using?
If you're using mod_php, try switching to suphp, fcgid or php-fpm
What is your configuration for keepalive, StartServers, MinSpareServers, MaxSpareServers in httpd.conf ?
I say --- try Nginx.
I've never liked configs for Apache and it by default it is ho-hum performance with higher than necessary RAM consumption.
try lowering the KeepAlive timeout, if you have it enabled. I had mine set to 30 and always saw high RAM usage, lowering it to 5-10 seconds reduced the usage drastically.
Seconded. While nginx or other webservers might be better, Apache -should- run fine with appropriate tweaks.
Just turn down the number of worker processes it's spawning - 10 is excessive.
But I agree, NGINX is far superior. I haven't used apache in years.
Thanks for the reply everyone. I tweaked Timeout, KeepAlive, MaxKeepAliveRequests and KeepAliveTimeout. Now apache is using only 35 MB ram with 5 processes.
If you really want to be friendly to your server, put Nginx infront of Apache, and make sure that all your images are served by Nginx.
Nginx really excels at serving up static files with minimal memory overhead - Since that's the majority of traffic you'll be getting to your site it's well worth the few minutes it takes to set it up
Thanks Is it possible to be done on a live site? Any recommended tutorials?
Sure is! All it requires is a single change to the Apache config file (moving it off port 80), installing Nginx (apt-get/yum install nginx) and making them talk to each-other.
Here's a nice example tutorial to read through.
Once you read through the config file, it does 'make sense', sort of.
Interestingly this is the preferred method for setting up websites for a number of places, including AppFog, although whenever possible I tend to stick to an nginx-only environment :P
We had a similar issue to yours when we moved servers last year (8 GB RAM for an eCommerce website, and Apache would find ways to eat all RAM and swap available). When we looked into it further, we found modsecurity to be the culprit. Apparently, in some instances when using the default config and logging to file, memory leaks may occur. Not sure if this has been fixed, or even if this may be contributing to your issue, but I figured I'd toss it out there.