How to setup compression for high volume zabbix server

Jephe Wu - http://linuxtechres.blogspot.com 

Environment: CentOS 5 64bit, zabbix server with very large items.
Objective: make 'latest data' with group and host set to 'all' page loading faster.


Steps:
1. make sure deflate_module is enabled in apache configuration

LoadModule deflate_module modules/mod_deflate.so

2. filtered by type
for example:

<Location />
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css
</Location>


Note: you can use Lynx or similar to do a headers dump on the file and it will tell you want the mime type is,

e.g.:

$ lynx -head -dump http://www.example.com/js/jquery-1.2.6.min.js
HTTP/1.1 200 OK
Date: Wed, 25 Jun 2008 03:25:53 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Wed, 25 Jun 2008 03:24:47 GMT
ETag: "38016-d9de-37f45dc0"
Accept-Ranges: bytes
Content-Length: 55774
Connection: close
Content-Type: application/x-javascript

<Location />
    AddOutputFilterByType DEFLATE application/x-javascript
</Location>

--------------------
3. example settings
root@zabbixserver01:/var/log/httpd/ # more /etc/httpd/conf.d/deflate.conf
<IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/xml
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/x-javascript
        DeflateCompressionLevel 9
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Don't compress images
    SetEnvIfNoCase Request_URI \
    \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
       
    DeflateFilterNote Input instream
        DeflateFilterNote Output outstream
        DeflateFilterNote Ratio ratio
        LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
    CustomLog logs/deflate_log deflate
</IfModule>


4. References
a. Apache mod_deflate example:
http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

b. http://www.linuxjournal.com/article/6802?page=0,1

c. use php zlib compress by modifying php.ini

PHP with the --with-zlib configure option and then reconfiguring the php.ini file.

Below is what the output buffer method looks like:

output_buffering = On
output_handler = ob_gzhandler
zlib.output_compression = Off


The ZLIB method uses:

output_buffering = Off
output_handler =
zlib.output_compression = On