Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/Remove concurrent workers dynamically #49

Open
Kikobeats opened this issue Mar 10, 2017 · 3 comments
Open

Add/Remove concurrent workers dynamically #49

Kikobeats opened this issue Mar 10, 2017 · 3 comments

Comments

@Kikobeats
Copy link
Contributor

Hello,

I'm trying to add an autobalance feature for add/remove concurrents calls per workers automatically when the CPU is idle or saturate (respectively).

See more information in: Kikobeats/farm-cli#12 😄

I reviewed the code for know the current code approach for that and I saw this:

if (this.children[childId].activeCalls < this.options.maxConcurrentCallsPerWorker
        && this.children[childId].calls.length < this.options.maxCallsPerWorker) {
      this.send(childId, this.callQueue.shift())

so for add an extra worker I can use .send with the child id and generate an extra calllQueue. Fine!

My problematic is how to kill this concurrent workers.

In the code you use .stopChild but this call all the worker; I need kill just one (the last) concurrent call in the worker.

I tried to code a mockup for that, something like:

function killLastConcurrentCall (farm) {
  Object.keys(farm.children).forEach(function (childId) {
    const calls = farm.children[childId].calls
    const call = calls[calls.length -1]
    const idx = calls.length - 1

    farm.receive({
      idx,
      child: childId,
      args: [ new ProcessTerminatedError('cancel by autobalance') ]
    })
  })
}

But doesn't worker. Any idea how I can handle this feature from the code side?

@rvagg
Copy link
Owner

rvagg commented May 3, 2019

so sorry @Kikobeats for the 2 year delay, I hope you managed to find answers for this, feel free to re-open if this is an ongoing concern although I can't promise I can get my head into the right space!

@rvagg rvagg closed this as completed May 3, 2019
@Kikobeats
Copy link
Contributor Author

Hey, I still interested that for adding it into cli level, any idea is welcome

@rvagg rvagg reopened this May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants