Jump to content

Apache high swap memory usage


Recommended Posts

Posted

Hi Everyone,
I'm moving a 600K post board over to IPB Wednesday. Since we're sending out an email to all of our users, I decided to do a load test on the new board this evening, simulating 50 concurrent users.

For some reason, Apache started eating up a lot of virtual memory (swap), even though there was plenty of physical memory available.

The server is a 4xcore Xeon, with 4GB memory running CentOS 64-bit. About 60% of the physical memory was consumed, the CPU was 80% idle, and 500MB of virtual memory was used.

Since I intend many more users to be accessing this when we launch the new board, can you tell me how i can better utilize the physical memory in the server?

My apache settings are below:


# 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 15
MinSpareServers 15
MaxSpareServers 50
ServerLimit 500
MaxClients 500
MaxRequestsPerChild 4000
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>


Thanks!
John

Posted

First, if all you are running is IPB I'd ditch Apache and go with a much lighter web server like nginx and setup PHP as fastCGI pools. This will drastically reduce your memory footprint and give you much better future scaling.

Even with Apache in the picture those memory figures are very high for what you have running. Have you tuned the OS itself? Turned off unnecessary daemons (like X, sasl* stuff if you aren't running a local mailhost, gpm, netfs stuff if you aren't mounting network filesystems, etc)? Next examine your apache config itself. Do you have modules enabled that you don't need (webdav, authx stuff, etc)? Same with PHP, do you have a bunch of extensions loaded into PHP that you don't need? All of these can contribute to the overall memory footprint of Apache.

The other thing to note is that swap usage can be normal under a linux system. The 2.6 kernels are designed to swap out memory to disk if it hasn't been accessed in some time to free up more RAM for buffers and running application. This is tunable via /proc/sys/vm/swappiness but you'll want to do some googling to understand what this setting does and what you should tune it to.

Also, are you sure that the system is actively swapping and it wasn't just stuff that got swapped out as per the tuning parameter I mentioned above? Run 'vmstat 2' for example and see if the swap stats are actually increasing (swpd, si, so for example). If vmstat is not available you may need to install the 'procps' package (though this should be installed already). If you run your tests and no active swapping takes place then it's probably old unused memory that got swapped out. If swapping is actively taking place then you need to reducing your overall footprint.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...