Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Overloaded mail spool causing memory instability?



Dave M G writes:

 > It got me thinking... would an overloaded email inbox on a server 
 > potentially affect memory usage? In the sense that each email coming in 
 > presumably has to be processes somehow, and if it has to be placed at 
 > the end of a large spool file or something, perhaps that large spool 
 > file would have to be read or loaded or something.

No.  The OS divides each file up into allocation blocks of a
reasonable size (sometimes as small as 512 bytes, occasionally as
large as 16KB or larger but that order of magnitude).  A directory
entry doesn't point to file contents, but rather to an "inode" which
contains a list of blocks.  So to append to a file (which is how spool
files are added to) the OS does (size / blocksize) to get the number
of the block and (size % blocksize) to find the offset, fills up that
block and then allocates new blocks as needed.  Thus, opening a file
for append takes a millisecond at most, and only a few KB of memory,
mostly for buffers.

By the way, if you don't need to preserve the spam, just stop the mail
server (typically with something like "sudo /etc/init.d/exim stop"),
rm the file, and restart the mail server.  If during those ten
seconds a mail is presented for delivery (to any mailbox), you'll have
to wait an about extra 15 minutes for it, until the remote MTA retries.

If you do want to preserve the spam, use mv to rename the file.  Both
rm and rename are millisecond operations.  Use of mv to rename is
limited to the same file system, *not* the same directory.  So on my
system, where all of /var except for /var/www is in a single
partition, I can do

    sudo mkdir -p /var/backup/mbox
    sudo mv /var/mail/spambucket /var/backup/mbox/spambucket

without copying any content.

If you don't want to shutdown the mail system for even a few seconds,
there are more complicated ways that use the mail system's locking
capability to avoid screwing things up, eg use the program movemail
which is distributed with Emacs and Netscape, at least.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links