Knowledgebase

Apache's going crazy with memory usage

Posted by lifetalk, 08-03-2010, 02:48 PM
So, I have the latest version of php/apache installed and everything was going fine. I just ran 'top' today and I saw that my memory usage had hiked to a whopping 15.xGB and I just had 100mb or so of free memory. I've noticed that I have multiple httpd processes running, and each process was using about an average 200MB of memory. I must have had quite a lot of processes running for them to use up almost all my memory. Now, I run a site where I stream data to the user. The data is not streamed directly. It's streamed through PHP. Would that be the cause of httpd processes bloating? And if so, does anyone have a recommendation here as to how I could optimize or reduce the memory usage?

Posted by mehboobashraf, 08-03-2010, 03:07 PM
How many users are online at a time?

Posted by ClaudiuPopescu, 08-03-2010, 03:16 PM
For starters could you post the result of: ps axf

Posted by lifetalk, 08-03-2010, 03:21 PM
mehboobashraf I'm not quite sure. But, top says 600 processes total (out of which only a few are running, the rest sleeping). And, I'm on a 1gbps port and its average utilization at any given time of the day is ~100mbps. I also have this apache's server status mod switched on. It's processing about anywhere between 4-10 requests per second. @ClaudiuPopescu I just rebooted the server a while back, so the memory usage is considerably lower. Would it help if I set the maxrequestsperchild directive to something lower? It's 4000 right now.

Posted by ClaudiuPopescu, 08-03-2010, 03:31 PM
If it's not too much to ask, do you have a phpinfo link? A safe way would be to save the phpinfo output and post it onto a different web site, this way your server would be protected.

Posted by lifetalk, 08-03-2010, 03:35 PM
Alright. Just saved it and you can have a look at it here:

Posted by xeonfan, 08-03-2010, 03:45 PM
looks like too many connections to your apache. also please remove that php.ini from where you uploaded, it already shows what the other person wanted you to hide. have you run top from ssh, what is the load like ? have you checked how many open connections you have to apache. The memory usage may appear as most used as most of memory may be cached by os to perform smooth operation. if the load is not high and server runs smooth you should only look to throttle connection per IP. I am not expert, just my 2 cent, if the server is managed one, you can ask your provider to dig into it for you and help you tweak the server.

Posted by ClaudiuPopescu, 08-03-2010, 04:18 PM
It would be best to remove that post and edit your dropbox link here. You did forgot to remove the domain pointing to your server. And since you are streaming using php, that's the cause of your problem. A php script will start a new httpd service eating up memory. You could try switching to FCGI as PHP Handler. But what I don't understand is why are you concerned at this time if your server is running just fine? You should be concerned if the memory is 100% used and your server starts using Swap. If the load is not too high you should be just fine.

Posted by lifetalk, 08-03-2010, 04:24 PM
Removed the file, thanks for the warning I've run top, yes. The loads are minimal, actually. I have a 24 core system (dual xeon x5650) so my load averages are about 2 - 6. CPU is mostly 95% idle. But the memory consumption bothers me. I guess it could be the fact that memory's being cached. Server's unmanaged It's just that I've never come across this issue ever before. As posted above, I removed that file. I cannot edit my prior post, but I guess it's relatively safe because I've removed it. Thanks My swap is actually not being used at all. But yeah, the memory usage still did seem like a cause of concern. And to top that, the ssh response was slightly sluggish. Maybe that could be cause of concern? Otherwise my CPU usage is fairly minimal. Like i said above, I have a powerful CPU so the load averages are still low compared to that. I have been thinking, though, to switch to a dual server setup. 2 Corei7's with 10GB memory each as opposed to a single system with dual xeon 5650. Would you recommend that?

Posted by ClaudiuPopescu, 08-03-2010, 04:30 PM
I'd recommend optimizing your scripts / server configuration. Maybe you will evolve in the near future and due to the bad php coding and server configuration it will cost you a lot of money monthly for a bigger server or more servers.

Posted by keserhosting, 08-04-2010, 06:57 PM
To check the current memory usage you can use, run free -m



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Dreamweaver CS3 (Views: 637)
how stop spam? (Views: 599)


Language:

Client Login

Email

Password

Remember Me

Search