For large volumes of data--I'm assuming large individual items--I'd use a subdirectory named for the parent pid, and files named by monotonic numbers for the items; and have the parent manage the item numbers and coordinate the pushes & pops via a socket.

If the parent already has a role to play beyond waiting for its kids, then it just requires one more fork for the socket manager.

When a child pushes an item, it sends a push message to the parent socket, and gets back a new item number, creates and writes the file.

When a child pops an item, it sends a pop message to the parent socket and gets back an item number which forms the name of the file it must read and delete.

If the items can persist across runs, or the parent crashes, you supply the name of the original pid directory that the new instance will take over, and it renames it after itself; scans the directory to discover the lowest/highest item numbers; opens its port and kicks off its kids with the port number.

Since any substantial volume of data sent to a DB is going to end up in the file system anyway, why funnel it all through a pipe or socket when the entire "data management" part of the equation consists of nothing more than coordinating the increments of two monotonically increasing numbers?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: A per-instance shared queue among forked child processes? by BrowserUk
in thread A per-instance shared queue among forked child processes? by EvanK

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.