Postfix Connection Cache


Introduction

This document describes the Postfix connection cache implementation, which is available with Postfix version 2.2 and later.

Topics covered in this document:

What SMTP connection caching can do for you

With SMTP connection caching, Postfix can deliver multiple messages over the same SMTP connection. By default, Postfix 2.2 reuses an SMTP connection automatically when a destination has high volume of mail in the active queue.

SMTP Connection caching is a performance feature. Whether or not it actually improves performance depends on the conditions:

For other potential issues with SMTP connection caching, see the discussion of limitations at the end of this document.

Connection cache implementation

For an overview of how Postfix delivers mail, see the Postfix architecture OVERVIEW document.

The Postfix connection cache is shared among Postfix mail delivering processes. This maximizes the opportunity to reuse an open connection. Other MTAs such as Sendmail or exim have a non-shared connection cache. Here, a connection can be reused only by the mail delivering process that creates the connection. To get the same performance improvement as with a shared connection cache, non-shared connections need to be kept open for a longer time.

Internet <--
smtp(8)
 
<->
scache(8)
 
<->
smtp(8)
 
--> Internet

The scache(8) server, introduced with Postfix version 2.2, maintains the shared connection cache. With Postfix version 2.2, only the smtp(8) client has support to access this cache.

When SMTP connection caching is enabled (see next section), the smtp(8) client does not disconnect after a mail transaction, but gives the connection to the scache(8) server which keeps the connection open for a limited amount of time.

After handing over the open connection to the scache(8) server, the smtp(8) client continues with some other mail delivery request. Meanwhile, any smtp(8) client process can ask the scache(8) server for that cached connection and reuse it for mail delivery.

The connection cache can be searched by destination domain name (the right-hand side of the recipient address) and by the IP address of the host at the other end of the connection. This allows Postfix to reuse a connection even when the remote host is mail server for domains with different names.

Connection cache configuration

The Postfix smtp(8) client supports two connection caching strategies:

Connection cache safety mechanisms

Connection caching must be used wisely. It is anti-social to keep an unused SMTP connection open for a significant amount of time, and it is unwise to send huge numbers of messages through the same connection. In order to avoid problems with SMTP connection caching, Postfix implements the following safety mechanisms:

Connection cache limitations

Postfix SMTP connection caching conflicts with certain applications:

Connection cache statistics

The scache(8) connection cache server logs statistics about the peak cache size and the cache hit rates. This information is logged every connection_cache_status_update_time seconds, when the process terminates after the maximal idle time is exceeded, or when Postfix is reloaded.

Valid HTML 4.01! traduction par Xavier Guimard - Retour au menu