Question

I am currently running a web app that sees several (~15) users logging in once each day, and then leaving the web app open where it automatically refreshes with new content every 5 minutes. Each user tends to have it open for about 15-18 hours.

However at critical mass (~30-40) users everything starts to slow down dramatically and the HTTPD process start to balloon in memory usage. I have added a cron job that restarts apache once an hour, but that only helps somewhat. All the content is dynamically generated and new wach time, so caching pages isn't an option.

I have started to play around with the Timeout,MaxRequest and KeepAlive options, but any guidance would be greatly appreciated, as I have always left these on defaults in the past.

Here's what i have. Any apache geniuses have ideas on how to optimize this config for above scenario? I figured a long timeout is good because the load times can sometimes get VERY high.

# Timeout: The number of seconds before receives and sends time out.

Timeout 200

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.

KeepAlive On

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.

KeepAliveTimeout 60

# 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       16
MinSpareServers    10
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>
Was it helpful?

Solution

This is probably a good question to go into ServerFault.

Your server is probably swapping (lack of RAM).

Your MaxClients directive should be something like:

MaxClients ≈ (RAM - size_all_other_processes)/(size_apache_process)

You can look into several articles that explain how to fine-tune apache.

Cron-restarting is not! a good ideia. Maybe once a day. But don't try to solve this problem that way.

Hope it helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top