Speed up Zabbix UI with xcache

I recently posted a quick way to speed up your Zabbix UI by enabling compression in Apache httpd. Check out that post here. Today we’ll take it a step further by installing and configuring xcache. These 2 posts will help you improve your Zabbix front end performance.

Xcache is a PHP opcode cacher, which will pre-compile PHP scripts and then caching the compiled script in RAM. The results should be fast page generation time as well as reduced server load.

You can install from source or RPM packages, depending on your distro.

Install from source

I grabbed the XCache source package to manually compile from

 wget http://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2.0.0.tar.gz

Unzip the file and check out the INSTALL file in the xcache-2.0.0 directory

 tar -xvpf xcache-2.0.0.tar.gz

Compilation and installation is pretty straight forward

 $ phpize --clean && phpize
 $ ./configure --enable-xcache
 $ make
 $ su
 $ make install

Once XCache binaries have been compiled and installed, you need to configure your PHP to enable this new module.

# su
 # cat xcache-2.0.0/xcache.ini >> /etc/php.ini
 # vi /etc/php.ini

Make sure the path to the xcache.so module in php.ini is pointing at the right place or you will get errors once you restart Apache httpd.

My xcache.so was in /usr/lib64/php/modules/xcache.so so I modified this entry in /etc/php.ini

 zend_extension = /usr/lib64/php/modules/xcache.so

Once you have saved your changes to php.ini, restart Apache and verify xcache has loaded

php -i | grep xcache

If you don’t see an error, xcache is working.

Install from RPM on RHEL/CentOS 6.5

yum install php-xcache xcache-admin

To verify xcache was loaded properly run:

php -i | grep xcache

If you don’t see an error, xcache is working.

XCache admin configuration

XCache has a web based administration portal that shows useful metrics on XCache activities.

If you installed from source, you will have to copy the admin files from the xcache source directory into your web server document root, or similar location.

cp -R xcache-2.0.0/admin /var/www/html/

If you installed from packages, modify the [xcache.admin] attributes in /etc/php.d/xcache.ini

After copying the files, I added a Location directive to httpd.conf to limit access to the admin.

<Location /admin>
    Order deny,allow
    Deny from all
    Allow from 192.168
</Location>

XCache admin requires authentication by default.  Credentials should be modified in the php.ini file under [xcache.admin]

[xcache.admin]
xcache.admin.enable_auth = On
xcache.admin.user = "mOo"
;xcache.admin.pass = md5($your_password)
xcache.admin.pass = "<md5 password>"

Generate md5sum of password

echo -n "secreatpassword" | md5sum

OR XCache admin has a page that will create an md5 hash of your password under

http://<ip address>/admin/mkpassword.php

Bring up this page, enter a desired password, and hit submit query.  Copy the resulting hash into the php.ini file.

Restart Apache httpd and test your access to the admin.

http://<ip address>/admin

Now you have a working XCache and admin.  You should see improved Zabbix UI page load times.  I didn’t see as large of an improvement implementing XCache as I did after I implemented mod_deflate, but the stats in the XCache admin do show significant caching and file size reduction.  I count this as a win.

Let me know your results.


2 Comments on “Speed up Zabbix UI with xcache”

  1. Shyamal says:

    We have a small internal setup using a Virtualbox VM for Zabbix Server. UI performance has noticeably improved after both deflate and xcache enabling.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s