I am working on a project - sort of proxy - where lots of devices are sending me mesages via HTTP. (right now a total about 3 messages every sec but it is expected to go up to 100 mesages a sec) After some buffering I have to resend them to a bunch of other devices via HTTP.

I have to make sure - for each sending device separately - that I don't change the order of the message. (I might drop some of the messages if I don't have time to send all of them).

The way it is currently implemented is that I am getting the messages through Apache/mod_perl putting them in a memory table of mysql. In addition I have another child of the Apache that is running in a loop. Fetching all the messages from the memory table and trying to send them one by one. If it reaches its timeout I drop the message and forget about it.

The problem is that I am getting a lot more messages than what I can send out (sending out takes between 0.3-3 sec normally with a 5 sec timeout). Even if I am ocassionally dropping the surplus I always get a buffer built up quickly and the messages wait too much in the queue. For the application a delay of 20-30 sec in forwarding is too late already. Normally I should forward within 10 sec the most.

I need to change the system so that in normal circumstances I drop only messages that I could not send due to reaching the timeout. I should also set the timeout to 15 sec

So I have to have several processes that are emptying the buffer and sendig out messages. The question is how ? Should I generate more "sender" children of the Apache ? Is there some other daemon (written in perl) that would be recommended to use that would suit the task better than Apache ?


In reply to Apache or Daemon in Perl ? by szabgab

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.