[dev] Horde imap client performance

Michael M Slusarz slusarz at horde.org
Thu Jul 14 17:25:26 UTC 2011


Quoting Ruu Gulin <ruu.gulin at gmail.com>:

> Hi,
>
> I'm trying to use the Horde Imap Client Module in a webapplication to fetch
> emails. It works very well and fast with a local test server ( ~0.1s for
> login+fetch envelope), but it's much slower using a remote imap server.

This sounds like an issue with your network connection then, or at  
least with PHP's socket connection.  If it is working fine when  
network latency is eliminated, then it would not seem to be an issue  
with the Horde Imap code per se.

And it shouldn't be an issue with pipelining commands, since we  
optimize the search and send it out in a single command.  And the PHP  
imap functions will generally send a bunch of additional commands  
which make it even less efficient.

> Of course this is expected, but i'm suprised about the difference to the PHP
> imap extension. Horde Imap takes ~3s for every single request, while the imap
> extension needs less than 0.5s. So I think i might be doing  
> something wrong with
> the Horde Imap Client but can't find the reason for this (I tried different
> remote imap servers and another webserver with the same result). Does anyone
> have an idea what could cause such slow requests?

No.  You might try creating a debug log of the IMAP traffic to debug  
further - you can look at the timestamps to track the command  
performance.

> The Horde Framework (4) runs on Apache/Php 5.3 with eAccelerator.  
> The test was
> just a simple fetch query:
>
> $imap = Horde_Imap_Client::factory(...);
> $imap->login();
> $query = new Horde_Imap_Client_Fetch_Query();
> $query->envelope();
> $result = $imap->fetch("INBOX",$query);

Are you meaning to download the envelope data of ALL messages?  What  
php imap commands are you using?

> Another thing I noticed is, unlike all other parts of the mails, the  
> envelope is
> not decoded with Horde_MIME::decode(), so it needs to be done later.  
> Is there a
> reason why the decoding of the envelope to utf-8 shouldn't be done  
> in Socket.php?

First, it wouldn't be done in Socket.php - it would be done in the  
Envelope data object.
Second, one issue is that some IMAP servers will return the envelope  
data already decoded into UTF-8 (it is not entirely clear whether this  
is proper according to the RFC).  Thus, we can't guarantee the return  
value.
Third, there has to be a way to get the raw return value.

A solution would be to add additional properties to the envelope  
object that will contain values guaranteed to be decoded (e.g.  
subject_decoded, from_decoded).

michael

___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the dev mailing list