smarthacker67 has asked for the wisdom of the Perl Monks concerning the following question:
* 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); }