Quantcast
Channel: Eureka! » Apache
Viewing all articles
Browse latest Browse all 12

Ubuntu – Limit the RAM consumption by Apache

$
0
0

When i am trying to setup a new server, most of the time i just used the default settings of Apache. But sometimes if the server is not equipped with enough RAM, the Apache service may consume all the server resources causing server failure. Here is an example for limited the resource comsumption by Apache.

I have a Rackspace server with only 1GB RAM running Ubuntu 10.04. The following setting is part of the original /etc/apache2/apache2.conf

...
<IfModule mpm_prefork_module>
  StartServers          5
  MinSpareServers       5
  MaxSpareServers      10
  MaxClients          150
  MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
  StartServers          2
  MinSpareThreads      25
  MaxSpareThreads      75
  ThreadLimit          64
  ThreadsPerChild      25
  MaxClients          150
  MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_event_module>
  StartServers          2
  MaxClients          150
  MinSpareThreads      25
  MaxSpareThreads      75
  ThreadLimit          64
  ThreadsPerChild      25
  MaxRequestsPerChild   0
</IfModule>
...

 

Restart the Apache with the following new configuration, it should consume less server resources.

<IfModule mpm_prefork_module>
  StartServers          5
  MinSpareServers       1
  MaxSpareServers       2
  MaxClients           20
  MaxRequestsPerChild 100
</IfModule>
<IfModule mpm_worker_module>
  StartServers          2
  MinSpareThreads      10
  MaxSpareThreads      30
  ThreadLimit          64
  ThreadsPerChild      10
  MaxClients           20
  MaxRequestsPerChild 100
</IfModule>
<IfModule mpm_event_module>
  StartServers          2
  MaxClients           20
  MinSpareThreads      10
  MaxSpareThreads      30
  ThreadLimit          64
  ThreadsPerChild      10
  MaxRequestsPerChild 100
</IfModule>

 

Please note that this is only an example for reference only, it does not guarantee it could optimize the Apache service on your server since performance tuning is always a big question.

Reference: Ubuntu Forums – Apache is running multiple processes and it’s eating RAM


Filed under: Apache, Linux Tagged: Apache, Linux, Ubuntu

Viewing all articles
Browse latest Browse all 12

Trending Articles