workerize icon indicating copy to clipboard operation
workerize copied to clipboard

Feature: worker pooling

Open dbkaplun opened this issue 6 years ago • 2 comments

Hello,

It would be great if I could create a pool of workers. That way, parallelizing hot paths could be completely abstracted using workerize.

Considerations:

  • To implement worker pooling, a worker may have to know when another worker is busy, so it can handle take over handling new requests until becomes busy itself
  • Since workers independently manage memory, they would all have to run the same code, and there would have to be a way to run a function on all workers simultaneously in order to share state

It will be interesting to see what we will need to do for this. Would you accept a PR?

Thanks for considering!

dbkaplun avatar May 09 '18 20:05 dbkaplun

@developit recently added this gist that explores the idea of a worker pool: https://gist.github.com/developit/65a2212731f6b00a8aaa55d70c594f5c

I was wondering @developit, is this something you are planning to add to the repo at some stage or should it be seen more like a rough sketch or like a standalone extension of the library?

It looks like an attempt to solve the TODO's mentioned in workerize: https://github.com/developit/workerize/blob/683631f402443d71484b03d087b37c72e65f2e3d/src/index.js#L2-L4

TimvanScherpenzeel avatar Jun 30 '18 21:06 TimvanScherpenzeel

Hello,

It would be great if I could create a pool of workers. That way, parallelizing hot paths could be completely abstracted using workerize.

Considerations:

  • To implement worker pooling, a worker may have to know when another worker is busy, so it can handle take over handling new requests until becomes busy itself
  • Since workers independently manage memory, they would all have to run the same code, and there would have to be a way to run a function on all workers simultaneously in order to share state

It will be interesting to see what we will need to do for this. Would you accept a PR?

Thanks for considering!

Good idea!

jzyzxx avatar Jun 24 '21 01:06 jzyzxx