3 ms·
Are there any good libraries for fiber pools, so that not to many fibers run at once? I am interested in something like the concurrent-ruby threadpools.
by faebi 6y ago
Are there any good libraries for fiber pools, so that not to many fibers run at once? I am interested in something like the concurrent-ruby threadpools.
- WJW 6y agoOnly one fiber per thread runs at a time, so that would naturally limit the concurrency of fibers to the number of threads?
- faebi 6y agoAs I understand it will yield back once it hits IO. But if you have something like a web server with a timeout of 60s you won't be able to open 10'000 connections at once to it. Some or all will be probably run into the timeout before the ruby could process the whole request. Therefore I would try to use some form of rate limiting via a FiberPool with a backlog.
- cogman10 6y agoUse a semaphore instead. That's what it is built for. That way you don't need to make a complex fiber scheme just for resource management. Spin up as many as you need an the runtime will do the task pool for you. https://ruby-concurrency.github.io/concurrent-ruby/1.1.4/Concurrent/Semaphore.html https://ruby-concurrency.github.io/concurrent-ruby/1.1.4/Con...
- ioquatix 6y agohttps://github.com/socketry/async-pool https://github.com/socketry/async-pool