mod_deflate optimization
Hi,
I'm trying to optimize speed by using mod_deflate
on a particular personal server. It runs Apache httpd 2.0.52+ and
PHP Version 5.1.6, with eaccellerator 0.9.5, on CentOS 4.5
with Linux 2.6.9-023stab033.6 SMP kernel.
It serves 5 websites, combined they get about 1 real human
to visit each second in total (excluding redirected hits,
blocked spammers/IPs/robots/spiders).
One of the sites is behind SSL, for squirrelmail webmail.
Most filetypes it serves are php (flatfile non-mysql weblogs),
a few text and .htm* files, very small cgi-scripts here and there
and a couple of imagefiles, avi's and mp3's, but not very much.
(Bandwidth/traffic are no problem factors for this server, it
runs with a 100 mbit NIC to the net, and I can use it wide-open.)
Currently it uses about 220 MB of DDR3, and I have at least
another 128 MB of RAM left, the Quad Core CPU also has room left.
From the current httpd.conf :
# gzip for mod_deflate:
#<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI
\.(?:gif|jpe?g|png|wav|mp3|ogg|bmp|avi|mpg)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
DeflateCompressionLevel 5
DeflateMemLevel 9
DeflateWindowSize 14
#</Location>
#AddOutputFilterByType DEFLATE text/html text/plain text/xml
When I uncomment the Location tags, Apache won't start.
Haven't figured out why, but doesn't seem to matter,
since I'm running it for all the sites anyway.
Does it also work for the SSL content ?
This httpd.conf has had a pretty long life, so I forgot
much of what I've changed over the years. But I was
wondering how I could better load speeds for php webpages
using mod_deflate, and also, handy pointers on how to best
measure this perhaps, although I don't have very much
time to spend on that. If any of you sees really strange
or bad general config values, please say so.
Here are some other more or less crucial values from the same conf:
Timeout 180
KeepAlive On
MaxKeepAliveRequests 80
KeepAliveTimeout 20
<IfModule prefork.c>
StartServers 9
MinSpareServers 6
MaxSpareServers 18
ServerLimit 250
MaxClients 250
MaxRequestsPerChild 0
</IfModule>
<IfModule worker.c>
StartServers 4
MaxClients 132
MinSpareThreads 18
MaxSpareThreads 70
ThreadsPerChild 24
MaxRequestsPerChild 0
</IfModule>
LoadModule access_module modules/mod_access.so
LoadModule auth_module modules/mod_auth.so
LoadModule auth_anon_module modules/mod_auth_anon.so
LoadModule auth_dbm_module modules/mod_auth_dbm.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule ldap_module modules/mod_ldap.so
#LoadModule auth_ldap_module modules/mod_auth_ldap.so
#LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule cern_meta_module modules/mod_cern_meta.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 asis_module modules/mod_asis.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 imap_module modules/mod_imap.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
CheckSpelling on
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.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
# added april 2007:
LoadFile /usr/lib/libxml2.so
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule security2_module modules/mod_security2.so
#LoadModule evasive20_module modules/mod_evasive20.so
Those last ones I'm still experimenting with.
For now I use mod_security with only very basic defaults.
This server doesn't really suffer from DDoS attacks often.
Any advice or improvements highly appreciated!
Regards,
Julius
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: mod_deflate optimization
Actually, when I try to use itlike this:
<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI\.(?:gif|jpe?g|png|wav|mp3|ogg|bmp|avi|mpg)$
no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
DeflateCompressionLevel 5
DeflateMemLevel 9
DeflateWindowSize 14
</Location>
I get:
"DeflateCompressionLevel not allowed here"
and httpd won't start.
Anyone care to explain what kind of permissions are involved here?
Should I point <Location /> to only the webdir I want to use deflate
for, and if so, how do I make it allowed there?
Thanks
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Re: mod_deflate optimization
On 09/07/07, Julius Thyssen <jultus [at] gmail.com> wrote:
> Actually, when I try to use itlike this:
>
> <Location />
>
> SetOutputFilter DEFLATE
> BrowserMatch ^Mozilla/4 gzip-only-text/html
> BrowserMatch ^Mozilla/4\.0[678] no-gzip
> BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
> SetEnvIfNoCase Request_URI\.(?:gif|jpe?g|png|wav|mp3|ogg|bmp|avi|mpg)$
> no-gzip dont-vary
> Header append Vary User-Agent env=!dont-vary
> DeflateCompressionLevel 5
> DeflateMemLevel 9
> DeflateWindowSize 14
>
> </Location>
>
> I get:
>
> "DeflateCompressionLevel not allowed here"
>
> and httpd won't start.
>
> Anyone care to explain what kind of permissions are involved here?
> Should I point <Location /> to only the webdir I want to use deflate
> for, and if so, how do I make it allowed there?
See the docs for that directive which include:
Context: server config, virtual host
Meaning that this directive can be set in the main server context, or
<VirtualHost, but not in a container like <Location or <Directory.
As for your original post, if you don't have an issue with bandwidth
but otherwise want to speep up your site, are you sure adding the
overhead of compression is wise?
Also, I expect your SetOutputFilter is too general and may end up
having apache try in vain to compress image files.
--
noodl
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Re: mod_deflate optimization
On 7/9/07, Vincent Bray <noodlet [at] gmail.com> wrote:
> See the docs for that directive which include:
>
> Context: server config, virtual host
>
> Meaning that this directive can be set in the main server context, or
> <VirtualHost, but not in a container like <Location or <Directory.
http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
shows an example almost identical to what I'm using,
with <Location tags. Not very indicative of your advice,
I would say. ;-)
> As for your original post, if you don't have an issue with bandwidth
> but otherwise want to speep up your site, are you sure adding the
> overhead of compression is wise?
I don't remember, but someone on the web, long ago,
advised me to use mod_deflate just to speed things up.
This may be versions ago, but I'm switching it off right now.
I see I'm also loading
mod_cache
mod_disk_cache
mod_mem_cache
Is there any way to make more use of these?
Less disk-reads, more memory caching perhaps
could speed up page-loading for my server.
But I just read another post in this list,
claiming the linux kernel already mem-caches everything.
Thanks for any and all advice.
Julius
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Re: mod_deflate optimization
On 09/07/07, Julius Thyssen <jultus [at] gmail.com> wrote:
> http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
> shows an example almost identical to what I'm using,
> with <Location tags. Not very indicative of your advice,
> I would say. ;-)
That example doesn't include DeflateCompressionLevel :-)
> I don't remember, but someone on the web, long ago,
> advised me to use mod_deflate just to speed things up.
> This may be versions ago, but I'm switching it off right now.
It might well do, but it's a tradeoff between slightly increased CPU
usage and smaller responses to the client. Clients on slow connections
will likely see an increased responsiveness on your site.
> I see I'm also loading
> mod_cache
> mod_disk_cache
> mod_mem_cache
>
> Is there any way to make more use of these?
> Less disk-reads, more memory caching perhaps
> could speed up page-loading for my server.
> But I just read another post in this list,
> claiming the linux kernel already mem-caches everything.
See:
http://httpd.apache.org/docs/2.2/caching.html
http://www.mnot.net/cache_docs/
mod_cache implements a http cache so requires that your php pages send
appropriate headers to indicate cacheability and time-to-live. It'll
certainly be a good speed increase, but only for those pages which can
be cached, eg those which are identical regardless of the client over
a period of time. Anything that requires a login generally can't be
cached in this manner. For that scenario there are caching engine
specific to the php module which allow it to speed up script parsing
etc.
Of course you shouldn't attempt to optimise your server without having
some kind of benchmark to tell you if your changes are having any
effect. Apache bundles one such tool, the 'ab' command, and there are
several others available on the 'net.
--
noodl
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org