Home | Comics | Gallery | wishlist | Donations | Impressum | The Book of Postfix | Postfix - Einrichtung, Betrieb und Wartung | Blog | 54.204.200.90 |


Speed up amavisd-new by using a tmpfs filesystem for $TEMPDIR

Prerequisite

Linux

You need a kernel that is capable of creating and using a tmpfs filesystem.

*BSD

You need a kernel that is capable of creating and using an mfs filesystem.

Why do this at all?

amavisd-new's speed may be limited by the speed and latency of your disk I/O.
By putting the temporary files into a ramdisk we eliminate precious read/write operations on a slow mechanical disk.

But is it safe?

Yes.
It is safe because amavisd-new will return a 250 OK only after it reinjected the mail back into Postfix.

Sizing

If you run n amavisd-new instances and each one accepts mails of $message_size_limit, then you need a tmpfs of size:

n * (1 + max(expansionfactor)) * $message_size_limit

Let's assume 5 instances, $message_size_limit of 10 MB = 50 MB for the original mails alone.
Now add space for the unpacked mail: 5*10 MB raw mail size become about 5*8 MB binary size , unpack at ratio 1:2, become 80 MB.
Sum: 130 MB.

How to do it?

That's it.

Does it work?

You know the drill: Check your logs!

Case study: Before and after

Before: Left side of the graphs
After: Right side of the graphs

Throughput

Received: we see an increase from 160 mails/minute to 210 m/m.
Sent: we see an increase from 60 mails/minute to 125 m/m.

Queue

The queue used to be filled with mail still left to be scanned. After the optimiziation there's no queue buildup anymore.


© by Ralf Hildebrandt
This document contains links to external information sources that I do neither monitor nor control. I explicitly disclaim any liabilities in respect to external references.
You are getting this document without any guarantees. Any methods shown above are meant as demonstration and may be wrong in some place. You may damage your system if you try to follow my hints and instructions. You do this at your own risk!

Valid HTML 4.01 Strict

This file was last modified 17. Jan 2007 by root