LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 02-11-2010, 09:31 AM   #1
rhodri
LQ Newbie
 
Registered: Jun 2008
Posts: 2

Rep: Reputation: 0
Apache crashing VPS - need to reduce memory usage


I have a VPS running a web application served using Apache, that on average deals with 20-50 requests per second. It's usually above this point (50 requests per second) that the amount of memory that Apache uses is too high for the VPS and errors start occuring - web pages crash and VPS falls over for a minute or two before going back to normal levels.

I believe that MaxClients is the best way to reduce the amount of RAM that Apache uses and I am planning to reduce MaxClients from 256 (default value) to around 100. Each Apache process uses ~15MB and the server has 1900MB of ram in total - the server does nothing else other than run Apache and a few crons.

Current setting are:

Code:
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 3

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

I tried reducing MaxClients before which lead to massive slowness, so I need some other options as well.

Does my suggestion of reducing MaxClients to ~100 seems sensible? What are my options if the server experiences slowness again - optimise the application? What's the best way to reduce memory usage - move images to another web server?

Any suggestions gratefully received!
 
Old 02-11-2010, 09:37 AM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
You might want to turn on server status and evaluate how many connections you're typically handling at any given time. Perhaps 100 is a bit light due to various reasons, but you need to look more closely at the information you have available before you can really make that decision.

Last edited by rweaver; 02-11-2010 at 09:40 AM.
 
Old 02-15-2010, 03:00 AM   #3
rhodri
LQ Newbie
 
Registered: Jun 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rweaver View Post
You might want to turn on server status and evaluate how many connections you're typically handling at any given time. Perhaps 100 is a bit light due to various reasons, but you need to look more closely at the information you have available before you can really make that decision.
Thanks for the suggestion - mod_status didn't occur to me, it'll be really helpful to know what Apache is doing at the point of crashing. I'll hold off making any changes for now and gather more information.
 
  


Reply

Tags
apache, memory management, vps


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Tips to reduce memory usage on Firefox | Linux LXer Syndicated Linux News 0 01-24-2010 03:01 PM
Does /dev/shm reduce memory available for non-shared memory segments? mightyscotchpine Linux - Server 1 09-22-2009 06:58 PM
memory usage (apache related?) stonecrest Linux - General 3 08-10-2005 05:52 AM
Apache, PHP, Mysql memory usage MikeyCarter Linux - Software 0 09-24-2003 12:37 PM
Limiting the total amount of memory usage by apache. SplashHost.com Linux - General 8 08-30-2002 09:56 AM


All times are GMT -5. The time now is 05:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration