Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm in the process of configuring postfix on my server and I was wondering why people do not run the postfix queues from a ram disk?

The default home directory containing all the queues is (for the Ubuntu distribution) /var/spool/postfix. This of course is a folder which exists on hard disk under normal circumstances.

The basic answer which I've found from Google is that it protects against mail getting lost if the server crashes.

The question this still leaves me with is this: If the server did crash and the postfix queues were being stored on disk, would they not most likely be lost due to the kernel's internal hard disk caching. From what I understand, these files are pretty short lived. I'm struggling to see the difference between this and running more explicitly in RAM and saving to HD as postfix is shut down cleanly.

Have I missed something obvious here?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

As part of postfix returning a 250 "accepted" code to the sending server, it is communicating to that server that it has truly accepted the message, and that the sending server can forget about it. This means that postfix will have already written the file to disk.

I would highly recommend not using a ramdisk for your queues - if need be, throw in a pair of SSDs in a RAID1 array. They should provide plenty of IOPs for you.

share|improve this answer
    
Perhaps I've missed something. Any comments on how it achieves this when the kernel caching disk writes to a hard drive? I'm just struggling to see the difference, that's all. –  couling Jan 24 '12 at 14:45
    
Look into what fsync() does. –  EEAA Jan 24 '12 at 14:46
    
That's exactly what I was looking for. Thanks! –  couling Jan 24 '12 at 14:48
    
No problem. fsync() is used by many applications, for ensuring that data gets written to non-volatile storage. As you could imagine, it's used extensively by database servers, to ensure data integrity on disk. –  EEAA Jan 24 '12 at 14:50
    
What @ErikA says. Given the case that your server crashes hard after the spool file is written to the filesytem, but before the fsync call is issued, the MTA will not send the 250. The sender will then most likely timeout and re-queue the message for another attempt according to its own schedule. –  SmallClanger Jan 24 '12 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.