Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with OpenID
Advertise on LowEndTalk.com

In this Discussion

[SOLVED] Apache Ram usage increasing with time

[SOLVED] Apache Ram usage increasing with time

chinmoychinmoy Member
edited October 2012 in Help

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.

I don't know nothing about linux and networking :(

Tagged:
Thanked by 1Nick_A

Comments

  • @chinmoy said: Could you guys please suggest me some fix? I'm running Ubuntu 12.04 64 bit.

    Debian 6 32 bits.

    @chinmoy said: CF image hosting script

    Check if it destroys the image variables.

    Thanked by 1chinmoy
  • You can lsof -p your Apache process to find out which files it has open.

    Thanked by 1chinmoy
  • I had the same problem before and a quick fix to it was to run a bash script to reload Apache every 30 mins.

    vpsdash.com - Tips and tricks in life, information and technology news to get things done

    Thanked by 1chinmoy
  • @jhadley said: You can lsof -p your Apache process to find out which files it has open.

    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.

    I don't know nothing about linux and networking :(

  • @chinmoy

    lsof -p [YOUR-APACHE-PID-NUMBER-HERE]

    Thanked by 1chinmoy
  • That's normal for apache. Try switching to nginx ;)

    Thanked by 2tux chinmoy
  • 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 ?

    Thanked by 2Nick_A chinmoy
  • 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.

    Thanked by 2tux chinmoy
  • 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.

    Thanked by 1chinmoy
  • @camarg said: 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.

    Seconded. While nginx or other webservers might be better, Apache -should- run fine with appropriate tweaks.

    RamNode: High Performance SSD and SSD-Cached VPS
    New York - Atlanta - Seattle - Netherlands - IPv6 - DDoS Protection - AS3842
    Thanked by 1chinmoy
  • serverbearserverbear Member
    edited October 2012

    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.

    ServerBear - Easy UnixBench/dd/IOPS/FIO (NEW) & Network Benchmarks | Example Report | Compare Low End Boxes
    Gleam - Run kick-ass viral competitions & rewards to grow your userbase. Free until Sept.
    Thanked by 1chinmoy
  • Thanks for the reply everyone. I tweaked Timeout, KeepAlive, MaxKeepAliveRequests and KeepAliveTimeout. Now apache is using only 35 MB ram with 5 processes. :)

    I don't know nothing about linux and networking :(

  • 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 :)

    Thanked by 1chinmoy
  • @ElliotJ said: f 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?

    I don't know nothing about linux and networking :(

  • ElliotJElliotJ Member
    edited October 2012

    @chinmoy said: 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.

    DevOp based out of Chicago Somewhat knowledgeable about php.
    Thanked by 1chinmoy
Sign In or Register to comment.