Consulting djbware Publications

10. Clustering, mini-qmail, QMQ, and Tapping

In this chapter some ideas are laid out how to setup s/qmail for larger sites and high mail volumes (> 100,000 mails/day). Distinguished domain specific settings given the hosting of serveral domains and clustering is also discussed.

Finally, the optional 'tapping' feature of s/qmail is introduced, since this might be a legal requirement.

  1. Bird's View on Clustering
  2. The Concept of Mini-qmail
  3. The Idea of Qmail-Multiple-Queues (QMQ)
  4. Controlling domain-specific Delivery and Email Tapping

10.1. Bird's View on Clustering

The main and single-instance setup of s/qmail is given in the 'big picture':

Figure: The s/qmail 'Big Picture' with one singel s/qmail instance serving as hub for SMTP and POP3 connections.

Here, several 'mini-qmail' Internet receiving instance of qmail can be setup while on is particular instance is in place to be responsible and to queue the ingress (incoming) and outgress (outgoing) email traffic. This setup might not be optimal for large sites:

A multi-tier architecture is needed to overcome those shortcomings and is available now at your fingertips.

10.2. The Concept of mini-qmail

Daniel J. Bernstein described the idea of 'mini-qmail' here: mini-qmail. However, at that point, the assumption is made, that qmail feeds local users. This assumption is only partially valid today:

Figure: Setup of 'mini-qmail' receiving mails from the Internet (ingress)
and delivering those to a central but redundant qmail system by means of qmail-qmqpc and qmail-qmqpd
on the receiving system while making use of tcpserver and its feature to control incoming connections via a cdb.

10.2.1 Setup of mini-qmail

Setting up a mini-qmail requires the following steps.

10.2.2 Advantages of mini-qmail

This setup has several advantages and can be expanded to even larger custers:

10.3. Idea of Qmail-Multiple-Queues (QMQ)

The idea for QMQ was raised while trying to improve reliable delivery to distinct downstream domains even in the case of general attack to the main receiving system.

One major load any qmail system is the us of an anti-virus scanner. Such a tool usually requires significant system resources and in particular I/O. s/qmail/ provides several means to include such a AV systems; but the principle problem still exists.

While adjusting qmail for the German government, it turned out, that different needs for such AV systems need to be accustomed; in particular what is called 'multi-tenancy'.

QMQ is the approach to provide this for downstream (responsible) domains without inflicting services for others. QMP (Qmail-Multiple-Queues) is thus the opposite of a 'mini-qmail': For one major qmail (receiving) instance, serveral egress instances are raised with individual queues and delivery schemes.

Figure: Setup of 'QMP' with several downstream instances - typically on the same MTA.

Which advantages can be expected with serveral Queues?

In a QMQ s/qmail system, typically one MTA is setup for several (small) s/qmail instances; however now with several queues for dedicated domains.

Those QMQ instances provide the following features:

10.3.1 Setup of QMQ

Within s/qmail the following means are available to setup distinct queuing:

Once you have made of sketch of your desired delivery scheme, this will potentially include:

These settings need to be reflected in conf-qmq which provides the initial default dummy settings:

# conf-qmq environment settings # Here, you may change some global settings # Example for multiple s/qmail directories: # 01:instance1 02:instance2 10:INTERNET 98:SPAM 99:BACKUP # Use meaningful names for 'instance1' etc.; they will be used in 'me' export SERVICE_BASEDIR="/service" # must exist; could be dummy for systemd # export SKELETON_CONCURRENCYREMOTE="120" export SKELETON_QUEUELIFETIME="1440" # 24 Hours export SKELETON_PORT="1000" # high ports for QMQ export SKELETON_ME=`hostname`

At that point, lets assume, all other s/qmail settings work out. The QMQ setup can be done anytime later!

The next steps are the following:

  1. Move to the scripts directory and do a make. At that point, all scripts will be provissioned with your given setup.
  2. Call the generated multi-queue script!
  3. It will tell you to use the steps build, conf or all. Proceed as required.

Now, the s/qmail installation starts for the given QMQ instances and perhaps populate ('conf') those with a minimal setup.

This does not impact your running system. The QMQ instances are raised in your given high-level prefix (typically 'var) at conf-qmail with queues setup at conf-queue (if different). Futher, the /service might be populated.
All this can be purged or modified on demand.

Though QMQ (along with s/qmail) takes advantage of DJB's supervise, any other tool can be used; though of course requiring additional attention.

Now it is time, to investigate the raised QMQ instances. Those instances are minimalistic, just have the directories and binaries required to serve the domainstream (egress) MTA together with the queue. There are serveral things to check:

10.3.2 Provisioning Domains in QMQ

10.3.3 Special and Dorming Domains

10.4. Controlling domain-specific Delivery and Email Tapping

10.4.1 Controlling

10.4.2 Tapping

10.4.3 Quotas