How to reduce the memory consumption of Apache?

0 like 0 dislike
There is a dedicated server on CentOS 5.3 i386 2GB RAM. Soft:
mysql.i386 5.1.36-1.el5.remi

In the top of the picture is often like this:
29689 apache 17 0 250m 28m 189m D 34 9.4 0:12.28 httpd
29472 apache 16 0 175m 240m 23m S 7 8.7 0:35.23 httpd
29473 apache 16 0 242m 186m 34m 9.2 0 S 6:26.83 httpd

Accordingly, if the load increases, Apache, or stop time to process requests or the system goes into swap (depending on MaxClients):
Now in the config file of Apache:

ListenBacklog 1024
StartServers 3
MinSpareServers 3
MaxSpareServers 5
ServerLimit 15
MaxClients 15
MaxRequestsPerChild 500

Loaded modules:
LoadModule authn_file_module modules/
LoadModule authn_anon_module modules/
LoadModule authn_default_module modules/
LoadModule authn_alias_module modules/
LoadModule authz_host_module modules/
LoadModule authz_user_module modules/
LoadModule authz_default_module modules/
LoadModule auth_basic_module modules/
LoadModule file_cache_module modules/
LoadModule cache_module modules/
LoadModule include_module modules/
LoadModule filter_module modules/
LoadModule deflate_module modules/
LoadModule log_config_module modules/
LoadModule logio_module modules/
LoadModule env_module modules/
LoadModule mime_magic_module modules/
LoadModule expires_module modules/
LoadModule headers_module modules/
LoadModule unique_id_module modules/
LoadModule setenvif_module modules/
LoadModule version_module modules/
LoadModule mime_module modules/
LoadModule status_module modules/
LoadModule autoindex_module modules/
LoadModule info_module modules/
LoadModule cgi_module modules/
LoadModule vhost_alias_module modules/
LoadModule negotiation_module modules/
LoadModule dir_module modules/
LoadModule alias_module modules/
LoadModule rewrite_module modules/
LoadModule php5_module modules/
Rpaf_module LoadModule modules/

Actually the question is how to make Apache consume so much memory per process?
by | 7 views

7 Answers

0 like 0 dislike
Was in one project we have a similar problem. Only we had mod_perl.
Apache weighed too much.
So, we took the whole load Perl code in Apache in advance direct to the root process. By specifying something like PerlRequire /path/to/script/with/all/ in the config of Apache.
And since Apache spawns a fork, most occupied our Perl application memory is only used once, not once for each Apache process.
So, if You have the application approved php'also lives in the memory of the Apache dig in this side.
0 like 0 dislike
We have reduced the memory consumed by Apache, through its demolition and replacement on nginx
0 like 0 dislike
Nginx frontend for static recoil is already enough reduces the memory consumption of Apache (on my VPS it turned out reduced more than two times).
0 like 0 dislike
Apparently carried out by workername code big and thick. Optimize your web application. Well, unused modules do not load.
0 like 0 dislike
First, put freedom nginx is quite simple, really...
Here is a pretty old recording, but the essence does not change, only the fresher of stable nginx build with sorrow
0 like 0 dislike
Find which script eats so much.
If it is rarely caused by a single script, then you can force stop the biggest Apache in the end of the script call the php function apache_child_terminate.
If scripts are invoked frequently redirect in nginx to a separate copy of Apache with a reduced number of MaxClients.
0 like 0 dislike
KeepAlive Off make, static hang on, nginx a little more than a whole, and the maximum number of processes Express 3-5 the Apache.
Atom 1.6 this config gave me 20 random pages with Drupal in second, having eaten about 400 MB of memory. But then, of course, need percent good — dedicated core, and not a scrap of OpenVZ or a Xen'.

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
110,608 questions
257,186 answers
28,862 users