1*da7d7b9cSGregory Neil Shapiro# Copyright (c) 2001-2003, 2014 Proofpoint, Inc. and its suppliers. 240266059SGregory Neil Shapiro# All rights reserved. 340266059SGregory Neil Shapiro# 440266059SGregory Neil Shapiro# By using this file, you agree to the terms and conditions set 540266059SGregory Neil Shapiro# forth in the LICENSE file which can be found at the top level of 640266059SGregory Neil Shapiro# the sendmail distribution. 740266059SGregory Neil Shapiro# 84313cc83SGregory Neil Shapiro# $Id: TUNING,v 1.22 2013-11-22 20:51:54 ca Exp $ 940266059SGregory Neil Shapiro# 1040266059SGregory Neil Shapiro 1140266059SGregory Neil Shapiro******************************************** 1240266059SGregory Neil Shapiro** This is a DRAFT, comments are welcome! ** 1340266059SGregory Neil Shapiro******************************************** 1440266059SGregory Neil Shapiro 1540266059SGregory Neil Shapiro 1640266059SGregory Neil ShapiroIf the default configuration of sendmail does not achieve the 1740266059SGregory Neil Shapirorequired performance, there are several configuration options that 1840266059SGregory Neil Shapirocan be changed to accomplish higher performance. However, before 1940266059SGregory Neil Shapirothose options are changed it is necessary to understand why the 2040266059SGregory Neil Shapiroperformance is not as good as desired. This may also involve hardware 2140266059SGregory Neil Shapiroand software (OS) configurations which are not extensively explored 2240266059SGregory Neil Shapiroin this document. We assume that your system is not limited by 2340266059SGregory Neil Shapironetwork bandwidth because optimizing for this situation is beyond 2440266059SGregory Neil Shapirothe scope of this guide. In almost all other cases performance will 2540266059SGregory Neil Shapirobe limited by disk I/O. 2640266059SGregory Neil Shapiro 2740266059SGregory Neil Shapiro 2840266059SGregory Neil ShapiroThis text assumes that all options which are mentioned here are 2940266059SGregory Neil Shapirofamiliar to the reader, they are explained in the Sendmail Installation 3040266059SGregory Neil Shapiroand Operations Guide; doc/op/op.txt. 3140266059SGregory Neil Shapiro 3240266059SGregory Neil ShapiroThere are basically three different scenarios which are treated 3340266059SGregory Neil Shapiroin the following: 3440266059SGregory Neil Shapiro* Mailing Lists and Large Aliases (1-n Mailing) 3540266059SGregory Neil Shapiro* 1-1 Mass Mailing 3640266059SGregory Neil Shapiro* High Volume Mail 3740266059SGregory Neil Shapiro 3840266059SGregory Neil ShapiroDepending on your requirements, these may need different options 3940266059SGregory Neil Shapiroto optimize sendmail for the particular purpose. It is also possible 4040266059SGregory Neil Shapiroto configure sendmail to achieve good performance in all cases, but 4140266059SGregory Neil Shapiroit will not be optimal for any specific purpose. For example, it 42d0cef73dSGregory Neil Shapirois non-trivial to combine low latency (fast delivery of incoming 4340266059SGregory Neil Shapiromail) with high overall throughput. 4440266059SGregory Neil Shapiro 4540266059SGregory Neil ShapiroBefore we explore the different scenarios, a basic discussion about 4640266059SGregory Neil Shapirodisk I/O, delivery modes, and queue control is required. 4740266059SGregory Neil Shapiro 4840266059SGregory Neil Shapiro 4940266059SGregory Neil Shapiro* Disk I/O 5040266059SGregory Neil Shapiro----------------------------------------------- 5140266059SGregory Neil Shapiro 52d0cef73dSGregory Neil ShapiroIn general mail will be written to disk before a delivery attempt 5340266059SGregory Neil Shapirois made. This is required for reliability and should only be changed 5440266059SGregory Neil Shapiroin a few specific cases that are mentioned later on. To achieve 5540266059SGregory Neil Shapirobetter disk I/O performance the queue directories can be spread 5640266059SGregory Neil Shapiroover several disks to distribute the load. This is some basic tuning 5740266059SGregory Neil Shapirothat should be done in all cases where the I/O speed of a single 5840266059SGregory Neil Shapirodisk is exceeded, which is true for almost every high-volume 5940266059SGregory Neil Shapirosituation except if a special disk subsystem with large (NV)RAM 6040266059SGregory Neil Shapirobuffer is used. 6140266059SGregory Neil Shapiro 6240266059SGregory Neil ShapiroDepending on your OS there might be ways to speed up I/O, e.g., 6340266059SGregory Neil Shapirousing softupdates or turning on the noatime mount option. If this 6440266059SGregory Neil Shapirois done make sure the filesystem is still reliable, i.e., if fsync() 6540266059SGregory Neil Shapiroreturns without an error, the file has really been committed to 6640266059SGregory Neil Shapirodisk. 6740266059SGregory Neil Shapiro 6840266059SGregory Neil Shapiro 6940266059SGregory Neil Shapiro* Queueing Strategies and DeliveryMode 7040266059SGregory Neil Shapiro----------------------------------------------- 7140266059SGregory Neil Shapiro 7240266059SGregory Neil ShapiroThere are basically three delivery modes: 7340266059SGregory Neil Shapiro 7440266059SGregory Neil Shapirobackground: incoming mail will be immediately delivered by a new process 7540266059SGregory Neil Shapirointeractive: incoming mail will be immediately delivered by the same process 7640266059SGregory Neil Shapiroqueue: incoming mail will be queued and delivered by a queue runner later on 7740266059SGregory Neil Shapiro 7840266059SGregory Neil ShapiroThe first offers the lowest latency without the disadvantage of the 79d0cef73dSGregory Neil Shapirosecond, which keeps the connection from the sender open until the 8040266059SGregory Neil Shapirodelivery to the next hop succeeded or failed. However, it does not 8140266059SGregory Neil Shapiroallow for a good control over the number of delivery processes other 8240266059SGregory Neil Shapirothan limiting the total number of direct children of the daemon 8340266059SGregory Neil Shapiroprocesses (MaxChildren) or by load control options (RefuseLA, 8440266059SGregory Neil ShapiroDelayLA). Moreover, it can't make as good use as 'queue' mode can 8540266059SGregory Neil Shapirofor connection caching. 8640266059SGregory Neil Shapiro 8740266059SGregory Neil ShapiroInteractive DeliveryMode should only be used in rare cases, e.g., 8840266059SGregory Neil Shapiroif the delivery time to the next hop is a known quantity or if the 8940266059SGregory Neil Shapirosender is under local control and it does not matter if it has to 9040266059SGregory Neil Shapirowait for delivery. 9140266059SGregory Neil Shapiro 9240266059SGregory Neil ShapiroQueueing up e-mail before delivery is done by a queue runner allows 9340266059SGregory Neil Shapirothe best load control but does not achieve as low latency as the 9440266059SGregory Neil Shapiroother two modes. However, this mode is probably also best for 9540266059SGregory Neil Shapiroconcurrent delivery since the number of queue runners can be specified 9640266059SGregory Neil Shapiroon a queue group basis. Persistent queue runners (-qp) can be used 9740266059SGregory Neil Shapiroto minimize the overhead for creating processes because they just 98d0cef73dSGregory Neil Shapirosleep for the specified interval (which should be short) instead of 9940266059SGregory Neil Shapiroexiting after a queue run. 10040266059SGregory Neil Shapiro 10140266059SGregory Neil Shapiro 10240266059SGregory Neil Shapiro* Queue Groups 10340266059SGregory Neil Shapiro----------------------------------------------- 10440266059SGregory Neil Shapiro 10540266059SGregory Neil ShapiroIn most situations disk I/O is a bottleneck which can be mitigated 10640266059SGregory Neil Shapiroby spreading the load over several disks. This can easily be achieved 10740266059SGregory Neil Shapirowith different queue directories. sendmail 8.12 introduces queue 10840266059SGregory Neil Shapirogroups which are collections of queue directories with similar 10940266059SGregory Neil Shapiroproperties, i.e., number of processes to run the queues in the 11040266059SGregory Neil Shapirogroup, maximum number of recipients within an e-mail (envelope), 11140266059SGregory Neil Shapiroetc. Queue groups allow control over the behaviour of different 11240266059SGregory Neil Shapiroqueues. Depending on the setup, it is usually possible to have 11340266059SGregory Neil Shapiroseveral queue runners delivering mails concurrently which should 11440266059SGregory Neil Shapiroincrease throughput. The number of queue runners can be controlled 11540266059SGregory Neil Shapiroper queue group (Runner=) and overall (MaxQueueChildren). 11640266059SGregory Neil Shapiro 11740266059SGregory Neil Shapiro 11840266059SGregory Neil Shapiro* DNS Lookups 11940266059SGregory Neil Shapiro----------------------------------------------- 12040266059SGregory Neil Shapiro 12140266059SGregory Neil Shapirosendmail performs by default host name canonifications by using 12240266059SGregory Neil Shapirohost name lookups. This process is meant to replace unqualified 12340266059SGregory Neil Shapirohost name with qualified host names, and CNAMEs with the non-aliased 12440266059SGregory Neil Shapironame. However, these lookups can take a while for large address 12540266059SGregory Neil Shapirolists, e.g., mailing lists. If you can assure by other means that 12640266059SGregory Neil Shapirohost names are canonical, you should use 12740266059SGregory Neil Shapiro 12840266059SGregory Neil Shapiro FEATURE(`nocanonify', `canonify_hosts') 12940266059SGregory Neil Shapiro 13040266059SGregory Neil Shapiroin your .mc file. For further information on this feature and 13140266059SGregory Neil Shapiroadditional options see cf/README. If sendmail is invoked directly 13240266059SGregory Neil Shapiroto send e-mail then either the -G option should be used or 13340266059SGregory Neil Shapiro 13440266059SGregory Neil Shapiro define(`confDIRECT_SUBMISSION_MODIFIERS', `C') 13540266059SGregory Neil Shapiro 13640266059SGregory Neil Shapiroshould be added to the .mc file. 13740266059SGregory Neil Shapiro 138*da7d7b9cSGregory Neil ShapiroNote: starting with 8.15, sendmail will not ignore temporary map 139*da7d7b9cSGregory Neil Shapirolookup failures during header rewriting, which means that DNS lookup 140*da7d7b9cSGregory Neil Shapiroproblems even for headers will cause messages to stay in the queue. 141*da7d7b9cSGregory Neil ShapiroHence it is strongly suggested to use the nocanonify feature; 142*da7d7b9cSGregory Neil Shapiroat least turning it on for the MTA, but maybe disabling it for the 143*da7d7b9cSGregory Neil ShapiroMSA, i.e., use Modifiers for DaemonPortOptions accordingly. 144*da7d7b9cSGregory Neil ShapiroAs a last resort, it is possible to override the host map to ignore 145*da7d7b9cSGregory Neil Shapirotemporary failures, e.g., 146*da7d7b9cSGregory Neil ShapiroKhost host -t 147*da7d7b9cSGregory Neil ShapiroHowever, this can cause inconsistent header rewriting. 148*da7d7b9cSGregory Neil Shapiro 14940266059SGregory Neil Shapiro 15040266059SGregory Neil Shapiro* Mailing Lists and Large Aliases (1-n Mailing) 15140266059SGregory Neil Shapiro----------------------------------------------- 15240266059SGregory Neil Shapiro 153d0cef73dSGregory Neil ShapiroBefore 8.12 sendmail would deliver an e-mail sequentially to all its 15440266059SGregory Neil Shapirorecipients. For mailing lists or large aliases the overall delivery 155605302a5SGregory Neil Shapirotime can be substantial, especially if some of the recipients are 156605302a5SGregory Neil Shapirolocated at hosts that are slow to accept e-mail. Some mailing list 157605302a5SGregory Neil Shapirosoftware therefore "split" up e-mails into smaller pieces with 158605302a5SGregory Neil Shapirofewer recipients. sendmail 8.12 can do this itself, either across 159605302a5SGregory Neil Shapiroqueue groups or within a queue directory. The latter is controlled 160605302a5SGregory Neil Shapiroby the 'r=' field of a queue group declaration. 16140266059SGregory Neil Shapiro 162d0cef73dSGregory Neil ShapiroLet's assume a simple example: a mailing list where most of the 163d0cef73dSGregory Neil Shapirorecipients are at three domains: the local one (local.domain) and 164d0cef73dSGregory Neil Shapirotwo remotes (one.domain, two.domain) and the rest is splittered 16540266059SGregory Neil Shapiroover several other domains. For this case it is useful to specify 16640266059SGregory Neil Shapirothree queue groups: 16740266059SGregory Neil Shapiro 16840266059SGregory Neil ShapiroQUEUE_GROUP(`local', `P=/var/spool/mqueue/local, F=f, R=2, I=1m')dnl 16940266059SGregory Neil ShapiroQUEUE_GROUP(`one', `P=/var/spool/mqueue/one, F=f, r=50, R=3')dnl 17040266059SGregory Neil ShapiroQUEUE_GROUP(`two', `P=/var/spool/mqueue/two, F=f, r=30, R=4')dnl 17140266059SGregory Neil ShapiroQUEUE_GROUP(`remote', `P=/var/spool/mqueue/remote, F=f, r=5, R=8, I=2m')dnl 17240266059SGregory Neil Shapirodefine(`ESMTP_MAILER_QGRP', `remote')dnl 17340266059SGregory Neil Shapirodefine(`confDELIVERY_MODE', `q')dnl 17440266059SGregory Neil Shapirodefine(`confMAX_QUEUE_CHILDREN', `50')dnl 17540266059SGregory Neil Shapirodefine(`confMIN_QUEUE_AGE', `27m')dnl 17640266059SGregory Neil Shapiro 17740266059SGregory Neil Shapiroand specify the queuegroup ruleset as follows: 17840266059SGregory Neil Shapiro 17940266059SGregory Neil ShapiroLOCAL_RULESETS 18040266059SGregory Neil ShapiroSqueuegroup 18140266059SGregory Neil ShapiroR$* @ local.domain $# local 18240266059SGregory Neil ShapiroR$* @ $* one.domain $# one 18340266059SGregory Neil ShapiroR$* @ $* two.domain $# two 18440266059SGregory Neil ShapiroR$* @ $* $# remote 18540266059SGregory Neil ShapiroR$* $# mqueue 18640266059SGregory Neil Shapiro 18740266059SGregory Neil ShapiroNow it is necessary to control the number of queue runners, which 18840266059SGregory Neil Shapirois done by MaxQueueChildren. Starting the daemon with the option 18940266059SGregory Neil Shapiro-q5m assures that the first delivery attempt for each e-mail is 19040266059SGregory Neil Shapirodone within 5 minutes, however, there are also individual queue 19140266059SGregory Neil Shapirointervals for the queue groups as specified above. MinQueueAge 19240266059SGregory Neil Shapirois set to 27 minutes to avoid that entries are run too often. 19340266059SGregory Neil Shapiro 19440266059SGregory Neil ShapiroNotice: if envelope splitting happens due to alias expansion, and 19540266059SGregory Neil ShapiroDeliveryMode is not 'i'nteractive, then only one envelope is sent 19640266059SGregory Neil Shapiroimmediately. The rest (after splitting) are queued up and queue 19740266059SGregory Neil Shapirorunners must come along and take care of them. Hence it is essential 19840266059SGregory Neil Shapirothat the queue interval is very short. 19940266059SGregory Neil Shapiro 20040266059SGregory Neil Shapiro 20140266059SGregory Neil Shapiro* 1-1 Mass Mailing 20240266059SGregory Neil Shapiro----------------------------------------------- 20340266059SGregory Neil Shapiro 20440266059SGregory Neil ShapiroIn this case some program generates e-mails which are sent to 20540266059SGregory Neil Shapiroindividual recipients (or at most very few per e-mail). A simple 20640266059SGregory Neil Shapiroway to achieve high throughput is to set the delivery mode to 20740266059SGregory Neil Shapiro'interactive', turn off the SuperSafe option and make sure that the 20840266059SGregory Neil Shapiroprogram that generates the mails can deal with mail losses if the 20940266059SGregory Neil Shapiroserver loses power. In no other case should SuperSafe be set to 21040266059SGregory Neil Shapiro'false'. If these conditions are met, sendmail does not need to 21140266059SGregory Neil Shapirocommit mails to disk but can buffer them in memory which will greatly 21240266059SGregory Neil Shapiroenhance performance, especially compared to normal disk subsystems, e.g., 21340266059SGregory Neil Shapironon solid-state disks. 21440266059SGregory Neil Shapiro 21540266059SGregory Neil Shapiro 21640266059SGregory Neil Shapiro* High Volume Mail 21740266059SGregory Neil Shapiro----------------------------------------------- 21840266059SGregory Neil Shapiro 21940266059SGregory Neil ShapiroFor high volume mail it is necessary to be able to control the load 22040266059SGregory Neil Shapiroon the system. Therefore the 'queue' delivery mode should be used, 22140266059SGregory Neil Shapiroand all options related to number of processes and the load should 22240266059SGregory Neil Shapirobe set to reasonable values. It is important not to accept mail 223d0cef73dSGregory Neil Shapirofaster than it can be delivered; otherwise the system will be 22440266059SGregory Neil Shapirooverwhelmed. Hence RefuseLA should be lower than QueueLA, the number 22540266059SGregory Neil Shapiroof daemon children should probably be lower than the number of queue 226d0cef73dSGregory Neil Shapirorunners (MaxChildren vs. MaxQueueChildren). DelayLA is a new option 22740266059SGregory Neil Shapiroin 8.12 which allows delaying connections instead of rejecting them. 22840266059SGregory Neil ShapiroThis may result in a smoother load distribution depending on how 22940266059SGregory Neil Shapirothe mails are submitted to sendmail. 23040266059SGregory Neil Shapiro 23140266059SGregory Neil Shapiro 23240266059SGregory Neil Shapiro* Miscellaneous 23340266059SGregory Neil Shapiro----------------------------------------------- 23440266059SGregory Neil Shapiro 23540266059SGregory Neil ShapiroOther options that are interesting to tweak performance are 23640266059SGregory Neil Shapiro(in no particular order): 23740266059SGregory Neil Shapiro 23840266059SGregory Neil ShapiroSuperSafe: if interactive DeliveryMode is used, then this can 23940266059SGregory Neil Shapirobe set to the new value "interactive" in 8.12 to save some disk 24040266059SGregory Neil Shapirosynchronizations which are not really necessary in that mode. 24140266059SGregory Neil Shapiro 242