Increase Web Client Performance with Memcache

Memcache is a protocol to access a simple key-value store, that is memory-backed, over a network socket. The memcached server does not perform any form of access control and is optimal for certain caches used in the Kolab web client (and associated HTTP-based access interfaces), by avoiding superfluous login, access control, and other such software policy considerations, as well as disk I/O.

This article outlines the installation and configuration of a single memcached server for use with the Roundcube web client for Kolab.

WARNING: This procedure will cause all existing sessions to be rendered invalid, and all of the users that are currently active will effectively be logged out with an “invalid session” error message.

CentOS 7 and Red Hat Enterprise Linux 7 (Maipo)

On the designated memcached server, install the memcached package, included in your standard distribution repositories;

# yum -y install memcached

You may want to edit /etc/sysconfig/memcached and increase MAXCONN as well as CACHESIZE (in megabytes).

If you do increase MAXCONN, to allow more connections to memcached, to over 1024, you must also supply a file /etc/systemd/system/memcached.service.d/limits.conf with the following contents (and a matching number):


Ensure the memcached service is started and will be started upon system start;

# systemctl enable memcached
# systemctl start memcached

On the web server, install the php-pecl-memcache package;

# yum -y install php-pecl-memcache

Check /etc/php.d/memcache.ini for the session.save_path setting, which should reflect the address on which your memcached server is available;

; Use memcache as a session handler

; Defines a comma separated of server urls to use for session storage

Note that this article does not include firewall considerations, but it should be obvious that your memcached server should be available to the most limited number of clients.

Restart your web server for the new PHP extension to become available;

# systemctl restart httpd

To configure the web client (and associated web- and HTTP-based applications), edit /etc/roundcubemail/ and ensure the following setting is available:

$config['memcache_hosts'] = Array('');

Now, the following storage engines can be changed to use memcached:

  • $config['session_storage'] = 'memcache';

    This setting controls where sessions are saved. Normally, PHP saves session information to the local filesystem (single-system limitation), and the web client instead by default uses the database. Using memcached will prevent the associated disk I/O from occurring.

  • $config['imap_cache'] = 'memcache';

    The IMAP cache is used for lists of folders, access control parameters, subscription metadata and folder annotations. Especially for larger numbers of folders, or folders that change frequently (such as high-traffic mail folders), changing the storage engine for this cache to use memcached will improve performance.

  • $config['ldap_cache'] = 'memcache';

    While the LDAP cache is used less frequently, and less extensively, it is the last of possible optimization steps for as far as using memcached for these sorts of caches is concerned.

Posted in Guides and tagged , , , , , , , , , , , , , , .