Nginx IMAP/POP3 Proxy Connection Pooling

We’re going to be using nginx to do imap and pop3 proxying. As some of
you know, we are the the mercy of the mail client as to the number of
connections that we will see from a user’s client. In extreme cases, if
a user has 40 Folders, their client will create 1 connection for each
folder. In this situation, we’ll see 10s of connections for just 1
user.

I couldn’t find any config settings to setup server-side (backend)
connection pools. I’d love to set up nginx so that I get 1000s of
incoming/client connections, but only a fraction of that to the backend
mail servers. My goal is to avoid the 1:1 ration of connections.

Any help is greatly appreciated!
-James

Posted at Nginx Forum:

Hello!

On Thu, Feb 17, 2011 at 12:14:13PM -0500, JamesR wrote:

We’re going to be using nginx to do imap and pop3 proxying. As some of
you know, we are the the mercy of the mail client as to the number of
connections that we will see from a user’s client. In extreme cases, if
a user has 40 Folders, their client will create 1 connection for each
folder. In this situation, we’ll see 10s of connections for just 1
user.

Actually, you should say “thanks” to the protocols, not to the
mail clients.

I couldn’t find any config settings to setup server-side (backend)
connection pools. I’d love to set up nginx so that I get 1000s of
incoming/client connections, but only a fraction of that to the backend
mail servers. My goal is to avoid the 1:1 ration of connections.

The problem is that imap is statefull protocol, so this is not
really possible. At least not without re-implementing large parts
of real imap server in nginx and using backends as some sort of
storage (periodically polling for changes on backends and so on,
including requirement for backends to support RFC4551 to make sure
re-sync won’t consume to many resources).

Maxim D.