SFEpostfix - recommended spool location with ZFS settings

  • Posted on: 20 May 2017
  • By: tomww

Configuration Best Practise for postfix

At the moment this is a draft, but I wanted to let you know immediatly what I learned today.

Disk storage for "spool" directory for postfix.

Placing /var/spool/posfix onto the "rpool" that can't have a ZFS LOG device is currently not a good idea.
Example: You get a constant stream of small writes to the zpool rpool. All of them need to be consistent, so ZFS does all the work needed to "sync" them immediatly.
Result may be a very much slowed down filesystem layer. Other processes reading and writing will be harmed noticeably.

Well, this is the case without a single email processed by postfix.
If anyone feels to demystify what postfix does to the filesystem wehn idle, then please let me know.

Suggested solution :

Until postfix stops doing so much write load you can move the location. Maybe it is a good idea anyways to not run postfix spool direcotry in the ZFS pool "rpool". A dedicated "data" pool (with LOG device) sounds very much better.

Create a separate filesystem that resides on a filesystem where you have a ZFS LOG device:

svcadm disable -t postfix
mv /var/spool/postfix /var/spool/postfix-moveit
zfs create -p -o canmount=off STORAGEPOOL/var/spool
zfs set mountpoint=/var STORAGEPOOL/var
zfs create STORAGEPOOL/var/spool/postfix
chown root:bin /var/spool/postfix
mv /var/spool/postfix-moveit/* /var/spool/postfix/
svcadm enable postfix

If you compare on a quiet system the writes to the disks  before and after the change, then you'll see number of IOs and number of bytes written drop down to almost zero, compared to what it was before. Your system will get very much reposive afterwards.

To see the Disk IO run the command   iostat -Xn 3  before and after the change to see the difference in writes.

My desktop system is now pretty reponsive after I did the change from above.


PS: for the non-LOG-device equipped people:
In the case you have no LOG device, then you *may* decide on your own risk to disable sync expicitly for only the spool/postfix filesystem like this:
zfs set sync=disabled STORAGEPOOL/var/spool/postfix
Note: You risk loosing your email if there is a change to the mail-queue and your system crashes within a few seconds after. This is the linux type feature of holding stuff in memory only for a while instead on stable storage and then returning syscalls to the calling programs only if stuff is on stable/consistent storage. Well, if you run linux on bare metal you should already know that, right?
(You have been warned, right? Don't to that to any ZFS filesystem you care about the data contained. Compris?)

PS2: I start collecting configuration best practise for several F/OSS packages in SFE. Those will be collected in a "book" in this drupal blog. So you can use them for speeding up your setups.