I've written my own SMTP server in perl. I know there are a lot out there already, but I wanted to write my own, OK? (defensive mode off now).

Over time, I've been adding functionality (i.e. modules) and the server footprint is getting big (approx 15-16Mb of memory). Mail::SpamAssassin adds about 9Mb to the footprint, IO::Socket::SSL adds a few meg, etc.

When each request comes in, I fork a new server to handle it. When I run the top command, I see that nearly all the memory used by the forked processes is Shared (i.e. 15Mb out of 16Mb). I take this to mean that the overhead in forking a new process is fairly low.

My question is, is there anything fundimentally wrong with having a server with such a large footprint? I notice that most servers I see are considerably smaller (e.g. httpd and sendmail are 3-4Mb). I am assuming that loading everything at the beginning is the most efficient way of handling the server, but I wonder if I'd be better off loading some modules as needed (like SSL) or running a separate server for some (like SpamAssassin).

I want this to be a high performance server. It currently handles on the order of 50,000 messages a day, and the hardware it's on is mainly sitting idle. I don't really see any performance bottlenecks yet, but I'm thinking about the future. It's hard to test different configurations, because everything goes so fast, I can't really notice any differences.

Everything is working great, I'm just wondering if I'm approaching this correctly. Any feedback is appreciated.

- Alex Hart


In reply to SMTP server in perl by althepal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.