Forum Moderators: phranque

Message Too Old, No Replies

tuning apache: less module to load

httpd.conf tuning

         

xnavigator

5:55 pm on Jan 23, 2008 (gmt 0)

10+ Year Member



My server is experiencing difficulties ( in ssh many times bash tell me fork: cannote allocate memory ..... )

I'm trying to tuning apache, I have already commented the customlog, for the access_log
now I want to disable some module, now apache loads all this modules:

LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.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 ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.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 actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so

Which can I disable?
(I use only mod_rewrite that I know :) )

thanks to all
(sorry for my english ^^ )

Brett_Tabke

6:15 pm on Jan 23, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



just because they are called and initialized, doesn't mean they actually use that many resources. Most of the modules are not that much code and do little to impact apache (mostly indirectly).

xnavigator

9:25 pm on Jan 23, 2008 (gmt 0)

10+ Year Member



Thank you for reply.
Can you advise me what should I do?

Sometime when I try to connect to SSH server return that error, too

fork:cannote allocate memory

And every 30min~ mysql crash, I see the mysqld.log (/var/log/mysqld.log)


[ERROR] mysqld: Got error 12 from select
..
[ERROR] Error in accept: Too many open files in system
..
[ERROR] Can't start server: can't create PID file: Too many open files in system
..
[ERROR] Can't create interrupt-thread (error 12, errno: 12)

primary mysql write the "Too many open files in system" error..

I'm Desperate...

Thanks to all

Frank_Rizzo

10:45 pm on Jan 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a lot you can optimise in apache - not just rem out the modules.

Modules
-------
First guess which ones you probably don't need and put a # in front of them. e.g. if you think you are not using proxy

#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so

Now restart apache and make sure all is fine

Next try the ones you are not to sure about. But first read about them on the http / apache site. Again rem them out, restart test

Timeout / Keep Alive / Servers / Max Clients
--------------------
Probably best if you read one of the optimisation guides on this. But one tip - don't just change the figures and restart. Make sure you make notes on each change and date it!

#Changed 23/01/08 from 15 to 5
KeepAliveTimeout 5

Language Files / icons
------------------------
Maybe not much of a saving but it's sure to help a bit. Remove the Addlanguage settings for all but languages you know will visit your site or remove the ones you are not too bothered about.

Remove the /icons if you do not allow directory browsing

disk / memory cache
-------------------
This can be enabled and tuned.

<IfModule mod_cache.c>
<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 32000
MCacheMaxObjectCount 1640
MCacheMinObjectSize 256
MCacheMaxObjectSize 128000
</IfModule>
</IfModule>

MySql
----------

This needs to be looked at too. Some sites give too much memory to mysql for caching but this then just reduced the server file caching pool and you run out of memory.

Add more memory
----------------
Of course, the easiest thing to do is to add more memory. If this is your own dedicated server ram is now dirt cheap ($30 a Gb). If this is shared hosting insist your webhoster give you more allocation.

[edited by: Frank_Rizzo at 10:46 pm (utc) on Jan. 23, 2008]

xnavigator

11:10 pm on Jan 23, 2008 (gmt 0)

10+ Year Member



thanks for the reply.

first of all, I have try to launch the command: ulimit -aH:


core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 55296
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

I have see that open files is = 1024..
Perhaps this can be the problem (for mysql too)?

Frank_Rizzo

1:43 pm on Jan 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Need more info here. Is this a dedicated or shared server?

Is the open files error specific to mysql or the file system?

Try

cat /proc/sys/fs/file-max

Google for

"MySQL performance tuning primer script"

and download and run the tuning-primer.sh file

this will give you a lot of info on how mysql is using memory. You'll also see your mysql open files limit.

xnavigator

3:36 pm on Jan 24, 2008 (gmt 0)

10+ Year Member



I have exec the "ulimit -n 2048" and I restarted mysql
now It seems that there aren't problems

thank

xnavigator

12:41 am on Jan 29, 2008 (gmt 0)

10+ Year Member



Hi,

I have inserted the line:


* soft nofile 4096

in etc/security/limits.conf, but when I do in ssh: ulimit -aH, open file is always 1024

How can I "restart" the limits.conf?

very thanks!