Operation of the SMTP Dispatcher

The SMTP Dispatcher works by acting as a central receiver for the TCP ports listed in its configuration. For each defined service, the IMTA SMTP Dispatcher may create one or more SMTP server processes that actually handle the connections after they've been established.

In general, when the SMTP Dispatcher receives a connection for a defined TCP port, it checks its pool of available SMTP server processes and chooses the best candidate for the new connection. If no suitable candidate is available and the configuration permits it, the SMTP Dispatcher creates a new SMTP server process to handle this and subsequent connections. The SMTP Dispatcher may also proactively create a new SMTP server process in expectation of future incoming connections. There are several configuration options that can tune the IMTA SMTP Dispatcher's control of its various services, and in particular, to control the number of SMTP server processes and the number of connections each SMTP server process handles.


Creation and Expiration of SMTP Server Processes

There are automatic housekeeping facilities within the SMTP Dispatcher to control the creation of new and expiration of old or idle SMTP server processes. The basic options that control the SMTP Dispatcher's behavior in this respect are MIN_PROCS and MAX_PROCS. MIN_PROCS provides a guaranteed level of service by having a number of SMTP server processes ready and waiting for incoming connections. MAX_PROCS, on the other hand, sets an upper limit on how many SMTP server processes may be concurrently active for the given service.

Because it is possible that a currently running SMTP server process might not be able to accept any connections either because it is already handling the maximum number of connections of which it is capable, or because the process has been scheduled for termination, the SMTP Dispatcher may create additional processes to assist with future connections.

The MIN_CONNS and MAX_CONNS options provide a mechanism to help you distribute the connections among your SMTP server processes. MIN_CONNS specifies the number of connections that flags a SMTP server process as "busy enough" while MAX_CONNS specifies the "busiest" that a SMTP server process can be.

In general, the SMTP Dispatcher creates a new SMTP server process when the current number of SMTP server processes is less than MIN_PROCS or when all existing SMTP server processes are "busy enough" (the number of currently active connections each has is at least MIN_CONNS and at least 75 percent of MAX_CONNS).

If a SMTP server process is killed unexpectedly, for example, by the UNIX system kill command, the SMTP Dispatcher still creates new SMTP server processes as new connections come in.


SMTP Dispatcher Configuration File

The SMTP Dispatcher configuration information is specified in the
/etc/opt/SUNWmail/imta/dispatcher.cnf file. A default configuration file is created at installation time and can be used without any changes made. However, if you want to modify the default configuration file for security or performance reasons, you can do so by editing the dispatcher.cnf file.


Note - The dispatcher.cnf file is available only in the Sun Internet Mail Server 3.5 - Enterprise Edition.

Configuration File Format

The SMTP Dispatcher configuration file format is similar to the format of other IMTA configuration files. Lines specifying options have the following form:

 
option=value
 

option is the name of an option and value is the string or integer to which the options is set. If the option accepts an integer value, a base may be specified using notation of the form b%v, where b is the base expressed in base 10 and v is the actual value expressed in base b. Such option specifications are grouped into sections corresponding to the service to which the following option settings apply, via lines of the following form:

 
SERVICE=service-name
 

service-name is the name of a service. Initial option specifications that appear before any such section tag apply globally to all sections.

The following is a sample SMTP Dispatcher configuration file (dispatcher.cnf).

 
! The first set of options, listed without a [SERVICE=xxx]
 
! header, are the default options that will be applied to all
 
! services.
 
!
 
MIN_PROCS=0
 
MAX_PROCS=5
 
MIN_CONNS=5
 
MAX_CONNS=20
 
MAX_LIFE_TIME=86400
 
MAX_LIFE_CONNS=100
 
MAX_SHUTDOWN=2
 
!
 
! Define the services available to Dispatcher
 
!
 
[SERVICE=SMTP]
 
PORT=25
 
IMAGE=/opt/SUNWmail/imta/bin/tcp_smtp_server
 
LOGFILE=/var/opt/SUNWmail/imta/log/tcp_smtp_server.log
 

The available options are:

HISTORICAL_TIME=integer  

Controls how long the expired connections (those that have been closed) and processes (those that have exited) remain listed for statistical purposes.  

IMAGE=file specification  

Specifies the image that is run by SMTP server processes when created by the SMTP Dispatcher. The specified image should be one designed to be controlled by the SMTP Dispatcher.  

LOGFILE=file specification  

Causes the SMTP Dispatcher to direct output for corresponding SMTP server processes to the specified file.  

MAX_CONNS=integer  

Affects the SMTP Dispatcher's management of connections. This value specifies a maximum number of connections that may be active on any SMTP server process.  

MAX_IDLE_TIME=integer  

Specifies the maximum idle time for a SMTP server process. When a SMTP server process has had no active connections for this period, becomes eligible for shutdown. This option is only effective if there are more than the value of MIN_PROCS SMTP server processes currently in the SMTP Dispatcher's pool for this service.  

MAX_LIFE_CONNS  

Specifies the maximum number of connections a SMTP server process can handle in its lifetime. Its purpose is to perform worker-process housekeeping.  

DEBUG  

0 or 1.  

MAX_LIFE_TIME=integer  

Requests that SMTP server processes be kept only for the specified number of seconds. This is part of the SMTP Dispatcher's ability to perform worker-process housekeeping. When a SMTP server process is created, a countdown timer is set to the specified number of seconds. When the countdown time has expired, the SMTP server process is subject to shutdown.  

MAX_PROCS=integer  

Controls the maximum number of SMTP server processes that are created for this service.  

MAX_SHUTDOWN=integer  

Specifies the maximum number of SMTP server processes available before the SMTP Dispatcher shuts down. In order to provide a minimum availability for the service, the SMTP Dispatcher does not shut down SMTP server processes that might otherwise be eligible for shutdown if shutting them down results in having fewer than MAX_SHUTDOWN SMTP server processes for the service. This means that processes that are eligible for shutdown can continue running until a shutdown "slot" is available.  

MIN_CONNS=integer  

Determines the minimum number of connections that each SMTP server process must have before considering the addition of a new SMTP server process to the pool of currently available SMTP server processes. The SMTP Dispatcher attempts to distribute connections evenly across this pool.  

MIN_PROCS=integer  

Determines the minimum number of SMTP server processes that are created by the SMTP Dispatcher for the current service. Upon initialization, the SMTP Dispatcher creates this many detached processes to start its pool. When a process is shut down, the SMTP Dispatcher ensures that there are at least this many available processes in the pool for this service.  

PORT=integer1, integer2,...  

Specifies the TCP port(s) to which the SMTP Dispatcher listens for incoming connections for the current service. Connections made to this port are transferred to one of the SMTP server processes created for this service. Specifying PORT=0 disables the current service.  

STACKSIZE  

Specifies the thread stack size of the SMTP server. The purpose of this option is to reduce the chances of the SMTP server running out of stack when processing deeply nested MIME messages (several hundreds of levels of nesting). Note that these messages are in all likelihood spam messages destined to break mail handlers. Having the SMTP server fail will protect other mail handlers further down the road.  


Controlling the SMTP Dispatcher

The SMTP Dispatcher is a single resident process that starts and shuts down SMTP server processes for various services, as needed. The SMTP Dispatcher process is started using the command:

 
# imta start dispatcher
 

This command subsumes and makes obsolete any other imta start command that was used previously to start up a component of IMTA that the SMTP Dispatcher has been configured to manage. Specifically, you should no longer use imta start smtp. An attempt to execute any of the obsoleted commands causes IMTA to issue a warning.

To shut down the SMTP Dispatcher, execute the command:

 
# imta stop dispatcher
 

What happens with the SMTP server processes when the SMTP Dispatcher is shut down depends upon the underlying TCP/IP package. If you modify your IMTA configuration or options that apply to the SMTP Dispatcher, you must restart the SMTP Dispatcher so that the new configuration or options take effect. To restart the SMTP Dispatcher, execute the command:

 
# imta restart dispatcher
 

Restarting the SMTP Dispatcher has the effect of shutting down the currently running SMTP Dispatcher, then immediately starting a new one.




Copyright © 1999 Sun Microsystems, Inc. All Rights Reserved.