I have a perl server written using the model from the panther book. It has a main listener which looks for requests on port x. When a request comes in on that port it fork()s and continues listening. The forked process responds to requests in a simple read/write fashion (ie: takes the string "LOGIN username" checks the username exists, returns "OK" or "BAD", waits for "PASS password" etc etc). The problem is that while this works fine for 2 or 4 users logged in, memory quickly dissapears on a 64 meg machine when 30 or 40 users are logged in, as each perl server process takes up approx 3 meg. I've trimmed memory usage inside the server itself as much as I can, but it's still sucking up memory. So I'm looking for advice on how to fix this. Some thoughts I've had: IPC or shared memory. Using a single server that does buffering/queuing, or something like that. Having the client proccesses somehow write their instructions to a file and the single main server just reads through that file and responds (and how would it know where to send the responses?) Any thoughts/advice would be greatly appreciated.

In reply to Lowering memory usage in a perl server by arcterex

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.