Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Threads memory consumption

by sundialsvc4 (Monsignor)
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.


Comment on Re: Threads memory consumption

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-09-19 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (132 votes), past polls