Friday, March 30, 2007

Improving Performance with RoundCube Webmail

There are many contenders in the market of web-based email clients, few distinguish themselves as much as Roundcube . Although I harbor within myself a profound loathing for any product whose sole star feature is the fact that it uses AJAX, Roundcube has done a great job of using it in such a way that truly streamlines performance and also makes setup a breeze. A similar product by AfterLogic called "MailBee" also markets itself on its AJAX mechanisms however is in my opinion quite a let down in both performance and usability for the 199$ basic edition price tag. Zimbra webmail is also AJAX based however requires at least 1 GB available memory just for the development installation , production requires in upwards of 2GB.

The only issue I found with Roundcube was the performance factor. Here I have gathered together and outlined several tips that helped me get the most out of this webmail suite.

Note to ISPConfig Users: I found that it was best to install roundcube manually and create a manual virtual hosts entry. Otherwise, the database will not be properly configured and virtusertable will not properly be used. Resulting in an inability to save identity information effectively

1. Configuration

Assuming you are installing Roundcube on a different machine as the webserver.

$rcmail_config['enable_caching'] = TRUE;
$rcmail_config['skip_deleted'] = FALSE;

Otherwise it would be best to leave caching off, caching stores all emails in the DB - is best for few accounts and those having difficulty with IMAP connections. - by MarcB

2. Caching Images

Although I haven't personally tried this, here is a patch to place in your images/.htaccess to speed up the loading of images - by seansean

Index: roundcubemail/skins/default/images/.htaccess
--- roundcubemail/skins/default/images/.htaccess (revision 0)
+++ roundcubemail/skins/default/images/.htaccess (revision 0)
@@ -0,0 +1,5 @@
+### activate mod_expires
+ExpiresActive On
+### Expire .gif's 1 day from when they're accessed
+ExpiresByType image/gif A86400
+ExpiresByType image/png A86400
\ No newline at end of file

Although I can't remember where I heard this, but its been said that you can convert the png's to gif files and then save them in gif format as PNG's. Doesn't sound right, but apparently leads to huge speed improvements by bypassing PNG loading

3. Code Optimization

There is a client side optimization and a server side optimization. For the server side , you would use an opcode cache - there is a tutorial for xCache and a tutorial for APC on Ubuntu. If you decide to install APC from source I will say that if you have php5 to run phpize5 instead of phpize and pass php-config5 instead of php-config to ./configure for a modest performance boost.

Javascript Optimization

The total JS for roundcube is absolutely scary - and honestly is my biggest criticism of the package. Although its interface animations and AJAX implementation patterns are implemented quite gracefully, the code and methods used to achieve that effect are another story. The total JS for roundcube is 156kb. You can cut that down to 96KB by using an Javascript Optimization/Compresion utility. I used Dojo ShrinkSafe. Once you get the final file (after adding the app.js, common.js and googiespell.js). You will have to edit some of the source to use the new file (I added common.js last so the result was common.compressed.js). Put this file in lib/js

You can run from the webmail root

grep -R "app.js" .

to find all references to app.js, likewise with common.js
in program/include/ change the lines




And finally find all references to googiespell.js using the same command as above and comment them out as it has now been included in common.compressed.js

4. Optimize Apache

If you are running apache, you may want to optimize your server configuration, and also a2enmod (enable the modules) mod_deflate and mod_cache.

5. Optimize your Mail Domain Setup

This got me. Even with all the above modifications , I was still getting 50 seconds to login. I eventually figured it out though, I had given RC the address of my mail server - and I wondered why I couldn't just say localhost to skip name resolution. Then it hit me. Name Resolution. Please ensure that in your /etc/hosts (c:\windows\system32\drivers\etc\hosts) that along with localhost.localdomain

That there is also an entry for whatever mail server you are accessing with RC. localhost.localdomain

Upon changing that, the login time went from 50.35 seconds to 1.7 seconds

Good Luck


instoremarketer said...

You might want to take a look at imapproxy - its in debian and ubuntu and should help with roundcube performance.

edwaa said...

Could you comment more on name resolution? If you have entries in BIND for AND in your /etc/hosts file which one will be used?

Mike said...

Imapproxy is definitely useful - even if your webmail and imap are on the same machine. It avoids hitting the authentication system time and time again as well.

Mod Expires made a big performance improvement for those with slower connections (e.g. Dialup / high latency like satellite). One of the issues with the interfaces is it includes a lot of little images, javascripts, css, etc. Even if these are cached by default the browser will check to see if that is up to date or not - and that latency multiplied by so many little downloads is a big delay.

Anonymous said...

When the Wow Gold wolf finally found the wow gold cheap hole in the chimney he crawled cheap wow gold down and KERSPLASH right into that kettle of water and that was cheapest wow gold the end of his troubles with the big bad wolf.

The next day the Buy Wow Goldlittle pig invited hisbuy gold wow mother over . She said "You see it is just as Cheapest wow goldI told you. The way to get along in the world is to do world of warcraft gold things as well as you can." Fortunately for that little pig, he buy cheap wow gold learned that lesson. And he just wow gold lived happily ever after!.

Michael said...

Tuxedo webmail (a Roundcube-based project) already addresses a lot of these issues and offers a really cool interface.

There's a free demo at

What do you think?

David said...

Tuxedo was lookng promising until it asked for $189!

I don't mind paying for software but that is more than my willingness to pay.

The DNS change worked a treat for me too.

I changed:

$rcmail_config['default_host'] = 'localhost';


$rcmail_config['default_host'] = '';

It is on around like 67.

This DRAMATICALLY improved performance.
I also turned off caching like you mentioned as my web server and mail server are on the same machine.

Thanks alot for these tips!! :)

Mandy Oviatt said...

Roundcube is pretty decent.
I use it myself when I check my webmail

Round Cube said...

RoundcubeSkins.Com COLORFUL skins for Roundcube Webmail Client !!! Roundcube our skins are compatible for 0.8.x, 0.9.0 and Soon we will be coming up with all our roundcubeskins compatible with 1.0 beta release of roundcube webmail. So keep visiting our site for updates!!