Hi Monks, I need some suggestions to tackle following problem.

* currently I have a program that loop and deal with the database within the loop and sends some command to the remote server by connecting to it

* Remote server connection and sending request is taking about 10ms due to latency and this gets stackup since I am running in loop.

* This command send to remote server don't need to return any result and its assume that it will be process by server.

* I need to register the data in database and send it to remote server in side while loop.

* this sending and insertion in database logic need to be separated out from parent process

* Eg I want to setup the new process that will continue to listen and once I send it this work it should finish this

* that way my main while loop will be much faster.

I am aware of fork but looking for alternative solution I am not sure what to use can some help me.

investigated and found Coro, AnyEnvent , POE but not sure will they be useful.

I want to separate out the process of sending work to remote server and database insertion from parent program that too being in while loop.

Can someone suggest me what I should use



Thanks in advance :-)

pseudo code
while(1) { pick_batch_of_200(); foreach(1..200) { send_work_to_remote_client($_); ### this I want to f +ork out here and want to get it done by different process or module s +o that while loop can proceed with next batch insert_into_db(@work_sent,@result) #### this I want to f +ork out here and want to get it done by different process or module s +o that while loop can proceed with next batch } } sub send_work_to_remote_client { #client list foreach(1..20) { connect_random_client_and_Send_work(send_work); } } insert_into_db { #get cached connection insert into XYX values( @result); }

In reply to Need suggestion on problem to distribute work by smarthacker67

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.