How to reduce the memory consumption of Apache?

0 like 0 dislike
7 views
There is a dedicated server on CentOS 5.3 i386 2GB RAM. Soft:
2.2.3-43.el5.centos.3
5.2.14-1.el5.remi
php-eaccelerator.i386
mysql.i386 5.1.36-1.el5.remi

In the top of the picture is often like this:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
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/mod_authn_file.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule cache_module modules/mod_cache.so
LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule mime_module modules/mod_mime.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module modules/libphp5.so
Rpaf_module LoadModule modules/mod_rpaf-2.0.so


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.
\r
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/includes.pl in the config of Apache.
\r
And since Apache spawns a fork, most occupied our Perl application memory is only used once, not once for each Apache process.
\r
So, if You have the application approved php'also lives in the memory of the Apache dig in this side.
by
0 like 0 dislike
We have reduced the memory consumed by Apache, through its demolition and replacement on nginx
by
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).
by
0 like 0 dislike
Apparently carried out by workername code big and thick. Optimize your web application. Well, unused modules do not load.
by
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
\rwww.odmin4eg.ru/2008/nginx-na-ubuntu-prosto/
by
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.
by
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.
\r
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'.
by

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
0 comments
28,862 users