Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Pre-Forking Daemon with Parallel::ForkManager

by enemyofthestate (Monk)
on Oct 18, 2019 at 14:50 UTC ( [id://11107663]=note: print w/replies, xml ) Need Help??


in reply to Re: Pre-Forking Daemon with Parallel::ForkManager
in thread Pre-Forking Daemon with Parallel::ForkManager

Sure.

I am creating a server application that receives a street address over a socket, normalizes the address, gets the co-ordinates of the property, and grabs spatial and parcel data from an Oracle database. It then returns the information in one of several formats requested by the caller. It has to handle mutiple simultaneous requests. For technical reasons related to the way the queries have to be made I prefer it to be a forking server instead of multi-threaded.

In the past I've used a modified version of the formula in the Perl Cookbook but P::FM seems like a more elegant solution and I have used it sucessfully in several client programs. It really simplifies the fork management and that may make it easier for some future maintainer to support. The actual logic for processing the information is in its own subroutine so the desire is also one of making the code "prettier".

Once upon a time I wrote similar programs in C so I am not completely unfamiliar with the book-keeping necessary to make this work.

  • Comment on Re^2: Pre-Forking Daemon with Parallel::ForkManager

Replies are listed 'Best First'.
Re^3: Pre-Forking Daemon with Parallel::ForkManager
by 1nickt (Canon) on Oct 18, 2019 at 15:49 UTC

    Your application sounds like a perfect use case for an application speaking REST (or not) served by one of the modern web application frameworks, e.g. Dancer2 or Mojolicious, which come with preforking servers built in. It's not necessary to build your own frameowrk for that part of your application.

    Hope this helps!


    The way forward always starts with a minimal test.

      If only :)

      For the foreseeable future, the format for the request is a pipe delimited string delivered over a socket connection. I've advocated converting to a GET or JSON format but too many legacy client programs are tied to the pipe-delimited string. That is not likely to change before I retire...

      One irony is I already wrote a fast-cgi running inside Apache. It takes a GET request, processes it and then returns a JSON formatted response.

Re^3: Pre-Forking Daemon with Parallel::ForkManager
by Fletch (Bishop) on Oct 18, 2019 at 15:20 UTC

    Maybe Minion might be of use? (disclaimer: never personally used it, just seen it mentioned browsing the Mojo docs)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Maybe but Minion looks more like a client side module. OTOH, I maintain another program that may be able to take advantage of it to pool persistent database connections.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107663]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-19 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found