Source: The Book of Postfix by Ralf Hildebrandt and Patrick Koetter.
In order to measure how much traffic our postfix can handle, we need to perform some kind of stress testing. To put an adequate load on the server, We need a fast mail traffic generator. Postfix comes with two programs named smtp-source and smtp-sink for this purpose. Here’s how they work:
smtp-source
This program connects to a host on a TCP port (port 25 by default) and sends one or more messages, either sequentially or in parallel. The program speaks both SMTP (default) or LMTP and is meant to aid in measuring server performance.
smtp-sink
This test server listens on the named host (or address) and port. It recieves messages from the network and throws them away. You can measure client and network performance with this program.
The following example injects 100 total messages of size 5k each in 20 parallel sessions to a Postfix server running on localhost port 25. Because you’re also interested in how much time this takes, use the time command:
$ time ./smtp-source -s 20 -l 5120 -m 100 -c -f sender@example.com \ -t recipient@example.com localhost:25 100 real 0m4.294s user 0m0.060s sys 0m0.030s
- -s 20 = 20 parallel sessions
- -l 5120 = 5k message size
- -m 100 = 100 total messages
- -c = display a counter
- -f = envelope sender
- -t envelope recipient
- target SMTP server
In the example above, injection took 4.294s. smtp-sink is the tool to find out how many messages per second our server can handle from mass mailing sofware.Postfix has to process each outgoing message even if the server on the other side throws it away The following example sets up an SMTP listener on port 25 of localhost:
$ ./smtp-sink -c localhost:25 1000
Now you can run your client tests.
If you want to get an idea for how much overhead the network imposes and also get a control experiment to see what the theoretical maximum throughput for a mail server, you can make smtp-source and smtp-sink talk to each other. Open two windows. In the first, start up the dummy server like this:
# ./smtp-sink -c localhost:25 1000 100
With this in place, start throwing messages at this server with smtp-source in the other window:
$ time ./smtp-source -s 20 -l 5120 -m 100 -c \ -f sender@example.com -t recipient@example.com localhost:25 100 real 0m0.239s user 0m0.000s sys 0m0.040s
This output shows that smtp-sink is much faster at accepting messages than Postfix. It took only 0.239 seconds to accept the messages, which is 18 times faster than the Postfix injection process.
Source: The Book of Postfix by Ralf Hildebrandt and Patrick Koetter.