sindresorhus / p-limit

Run multiple promise-returning & async functions with limited concurrency
MIT License
1.84k stars 99 forks source link

Ramp functionality #78

Open jdmarshall opened 5 months ago

jdmarshall commented 5 months ago

I'm using p-limit for a bunch of batch processing, and it's been working quite well for some time.

Recently one of our services took advantage of our politeness and reduced their cluster size, and now I'm having trouble with finding a parallelism size which wakes up their service without overpowering it. In discussions someone commented that it would be nice if we could ramp up our parallelism over time.

I don't see anything in your suite of tools that allows that. I'm wondering if it needs to be more complicated than allowing the concurrency argument to be updated dynamically (I'm sure I could reach in and change it, but as it's not part of the public interface, who knows if/when you could break that cheat).

I'm picturing setting an initial limit of 10, and then setting 2 timeouts to ramp up to 25. Or perhaps n/2, n/1.5, n.

jdmarshall commented 5 months ago

Alternatively, I think piscina has an initial and a max, and I'm wondering if there's an equivalent here.