Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

POE::COMPONENT::JobQueue, dynamic number of workers

by Devanchya (Beadle)
on Sep 12, 2008 at 19:36 UTC ( [id://710987]=perlquestion: print w/replies, xml ) Need Help??

Devanchya has asked for the wisdom of the Perl Monks concerning the following question:

Given a standard POE:C:JobQueue from CPAN:
our $workers = 16; POE::Component::JobQueue->spawn ( Alias => 'passive', # defaults to 'queuer' WorkerLimit => $workers, # defaults to 8 Worker => \&spawn_a_worker, # code which will start a se +ssion Passive => { Prioritizer => sub { 1}, # defaults to sub { 1 } # FIFO }, );
Is it possible to dynamically change how many workers are allowed to work?

If you set the variable workers to 16 at the start of the program, can you lower it halfway through?

I am looking at being able to dynamically increase how much work can actually happen given server load. If the server load is below a threshold, allow more work. Likewise, if the server load is to high, cut down how much work can be done.

Even smart people are dumb in most things...

Replies are listed 'Best First'.
Re: POE::COMPONENT::JobQueue, dynamic number of workers
by rhesa (Vicar) on Sep 12, 2008 at 20:07 UTC
    There's no API for it, no. The proper way to do that, then, is to signal the current queue that it should stop, and spawn a new queue with the desired WorkerLimit in its place.

    The documented way to stop a running queue is:

    # Stop a running queue $kernel->call( $queue_alias => 'stop' );
Re: POE::COMPONENT::JobQueue, dynamic number of workers
by rcaputo (Chaplain) on Sep 12, 2008 at 21:25 UTC

    Patches welcome. I picture a callback that returns the component's worker limit between jobs. You know, something like Prioritizer but for determining the worker count dynamically.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found