SquirrelMail  
Donations
News
About
Support
Screen shots
Download
Plugins
Documentation
Sponsors
Bounties



SquirrelMail Administrator's Manual: Optimizing SquirrelMail Next Previous Contents

6. Optimizing SquirrelMail

This chapter should explain what can help in speeding up your SquirrelMail installation and improve its performance.

6.1 Examining the whole chain

SquirrelMail is far from a stand alone product. The performance of a webmail system depends on a lot of factors. It makes sense to look at each of these factors. You should think about the following:

  • Webserver. There's a lot of documentation about tuning Apache for example.
  • PHP. Using PHP as a module is a lot faster than the CGI version.
  • IMAP server. This starts with the choice of software. Different servers can have radical performance differences.
  • Authentication backend. Some backends have slow responses. Caching solutions are available.
  • Mail storage backend (mbox, maildir, database).
  • SquirrelMail itself.

6.2 PHP extensions

You can install or enable some PHP extensions which will make SquirrelMail functionality run faster. SquirrelMail uses gettext functions for translations. If PHP gettext extension is not present, the interface switches to slower internal gettext implementation.

If you use CRAM-MD5 or DIGEST-MD5 authentication methods, SquirrelMail can use PHP mhash functions. If PHP mhash extension is not present, interface uses own hmac_md5 implementation.

In some cases SquirrelMail can take advantage of PHP recode or iconv functions. These functions can be used to speedup decoding of CJK charsets.

6.3 IMAP server extensions

Sorting

If the IMAP server supports the IMAP extension SORT (most mainstream servers do) enable this feature in SquirrelMail's configuration. In general, always enable this option if your server supports it since it's way faster than sorting in SquirrelMail, and may prevent problems for end users with very large mailboxes. When not using server-side sorting, these end users may get an empty page upon viewing the large mailbox, because the PHP sorting times out. It'll vary by machine speed, but it has been reported that when viewing a folder containing circa 17,000 mails, the initial viewing delays can decrease from around 35 seconds to 4 seconds.

The only case when server-side sorting causes problems in SquirrelMail is when the IMAP server doesn't support the character set used by the translation selected in SquirrelMail. SquirrelMail can use more than 15 character sets in server-side sorting and threading commands. Courier IMAP server only supports them when compiled with the --enable-unicode option. Cyrus IMAP (v.2.2.12) doesn't support some of the multibyte character sets used by SquirrelMail.

Threading

SquirrelMail also allows using server-side threading if the IMAP server supports it. This option offers the end users to view the message list in a thread view. Threaded sorting requires more system resources and you should enable it only if you want to provide such an option to end users.

Enabling the extensions

To find out if the IMAP server supports server-side sorting and threading, telnet to it and ask:

> telnet imapserver.example.com imap
* OK

1 capability
* CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN STARTTLS
1 OK CAPABILITY completed

The SORT and THREAD capabilities indicates that this server supports these extensions. Next step is to configure SquirrelMail to use them.

Using config/conf.pl:

4. General Options
    10. Allow server thread sort:   false
    11. Allow server-side sorting:  false

Editing config/config.php:

$allow_thread_sort = false;
$allow_server_sort = false;

Sorting and threading since 1.5.1

SquirrelMail 1.5.1 introduces some changes when it comes to sorting and threading. Sorting and threading is used by default, if the IMAP server supports it (according to the IMAP server's CAPABILITY response). It is, however, possible to manually override that, thus disabling them, in SquirrelMail's configuration.

Using config/conf.pl:

4. General Options
    10. Disable server thread sort:   false
    11. Disable server-side sorting:  false

Editing config/config.php:

$disable_thread_sort = false;
$disable_server_sort = false;

Even with server-side sorting disabled, PHP sorting is faster thanks to the rewritten sorting code.

6.4 Mailbox format

The default Unix mailbox format is slower than other formats and can increase server loads when used with bigger mail folders. If you use UW IMAP server, you should try switching to mbx mailbox format. Maildir mailboxes have higher bottlenecks than formats that store entire mail folder in one file.

6.5 Use server side filtering

Mail filtering, i.e. deleting mails or putting them in selected folders based on criteria, isn't a must have mail system feature, but it sure is one of those nice to have features that the end users might require.

To avoid negative performance impact as much as possible, systems providing mail filtering should do so by using a server side application. The SquirrelMail package includes the Filter plugin, but it should be the last resort when other means of filtering can't be provided. The plugin is implemented in PHP and works only when users actively log in to their mail accounts, making the display of the folders slower (typically when logging in, and especially for accounts with a large amount of mail) or, at worst, produce errors thus preventing the use of some accounts completely. Server side filtering, performed by applications such as Procmail, Maildrop, or any application using Sieve; provide more options, work even when users do not actively log into their accounts, and are much faster and more efficient.

SquirrelMail frontends for server side filtering applications are found at the Filters & Spam section of the plugin pages.

6.6 Use an IMAP proxy

A caching IMAP proxy server can vastly improve SquirrelMail performance by cutting down on the number of times you have to create a new connection to the IMAP server. It keeps server connections alive for reuse avoiding a new IMAP connection for each SquirrelMail transaction. Install the proxy at the web server, configure SquirrelMail to connect to the proxy (localhost), and configure the proxy to connect to the IMAP server. A side benefit is your logs aren't full of IMAP logins.

IMAP Proxy is a caching IMAP proxy server known to be working well in various SquirrelMail installations. The latest version allows log levels to be configured at runtime from the configuration file. It's free, open source software and runs on various platforms.

6.7 PHP cache

A PHP cache is a tool that might speed up PHP scripts. The general idea is to check if a PHP script is modified since it was cached, and use the cached copy if it wasn't. If the script is new or modifed, it's compiled and cached. The benefit is that using precomplied, cached copies of the script are quicker then compiling the script every time it's requested. Here are some examples of products to try:

Alternative PHP Cache is a "free, open, and robust framework for caching and optimizing PHP intermediate code". It's released under the PHP License.

eAccelerator is a fork of the old, discontinued Turck MMCache for PHP project. It's described as a "free open-source PHP accelerator, optimizer, encoder and dynamic content cache", and is released under the GNU LGPL.

PHP Accelerator is an "easily installed PHP Zend engine extension that provides a PHP cache, and is capable of delivering a substantial acceleration of PHP scripts without requiring any script changes, loss of dynamic content, or other application compromises". There is no official license for PHPA, and it's free for use.

Zend Optimizer is a "free application that runs the files encoded by the Zend Guard, while enhancing the performance of PHP applications." It's released under the Zend License Agreement.

6.8 Decreasing the bandwidth

Sometimes the speed of the server is perceived to be terribly slow, but it is the cause of the modem speed or bandwidth at some intermediate server. To cut down on the amount of traffic generated from the server, you could compress web pages or condense them by removing excess garbage. Keep in mind that this will put a little more load on your server, but it is practically nothing when compared to your IMAP server and SquirrelMail.

Compression

These solutions only compress the output to clients that support it, so you don't need to worry about corrupting data to some older browsers by enabling any of the options listed below. They are listed in order of preference.

Only implement one or else you might get some weird problems.

  • Configure the web server to compress the web pages (and maybe images). The module mod_deflate is part of Apache since 2.0 and there's also a third party module for Apache called mod_gzip.
  • PHP can also compress all PHP pages sent out by setting the output_handler to ob_gzhandler, or enable zlib.output_compression in php.ini.
  • SquirrelMail has the Gzip Compressed Output plugin that enables compression of output in the same way that PHP does (see above), but only for SquirrelMail.

Condensation

This refers to cleaning the HTML and removing unnecessary garbage in an effort to send as little to the client without actually changing the structure of the web page. Usually white space (extra spaces and new lines) are condensed into one, comments are removed, and sometimes HTML tags will be changed to be more efficient.

Unfortunately the SquirrelMail Project Team doesn't know of a semi-standard module or PHP extension that does this, but we'd like to be informed if you find one.


Next Previous Contents
© 1999-2016 by The SquirrelMail Project Team