Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Threads memory consumption

by sundialsvc4 (Abbot)
on Dec 06, 2013 at 01:10 UTC ( #1065871=note: print w/replies, xml ) Need Help??

in reply to Threads memory consumption

I happen to like to use queues ... there are several to choose from ... knowing that all of them know how to send hashrefs and Perl objects.   Therefore, in a very simple but common scenario, you might have one process that receives incoming connections, builds “request” objects from them, and places these onto a queue.   An arbitrary but adjustable number of workers sit on that queue, retrieve requests from it, and execute those requests ... perhaps by calling some method (say, execute() ...) on the object that it just received.   This method, say, produces a result ... or stores the result in the object itself.   The worker then places the request/response onto a “completed work” queue ... from which it is retrieved and the results sent back to the requesting user.

This, of course, is essentially the magic that’s used by FastCGI in any web-server on this planet:   your incoming HTTP data is gathered up and queued to a worker, who generates an HTTP response packet and queues it back to the web-server for delivery.   The FastCGI workers typically process hundreds or thousands of requests during their lifetimes.

The advantage of this sort of general design is that, no matter how “busy” the server gets, the only evidence and the only consequence is that “the queues get rather long.”   The system might be running like a cat on a hot tin roof ... all of the workers being 100% active 100% of the time ... but it will not become congested.   It’ll become just as busy as you’ve allowed it to be, but not one whit more.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1065871]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-03-21 06:10 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (264 votes). Check out past polls.