Question

I'm experimenting with "async rails", in order to help ease the pain of using slow 3rd-party services.

Gemfile

gem 'eventmachine'
gem 'rack-fiber_pool',  :require => 'rack/fiber_pool'
gem 'em-synchrony', :require => ['em-synchrony',
                                 'em-synchrony/em-http',
                                 'em-synchrony/activerecord']

config.ru

require ::File.expand_path('../config/environment',  __FILE__)
use Rack::FiberPool, :size => 6
run MyApp::Application

Does anyone know how many Ruby Fibers can be used on Heroku's Cedar stack? Or how to go about determining such a thing?

Was it helpful?

Solution

Like you, I am currently experimenting with ruby and fibers to increase app performance. And from what I have read and think to remember, there should be almost no limit to the amount of fibers you can use.

I think to remember (please check that yourself), that each dyno can use up to 500 Mb of RAM. Each fiber adds a few kb (I think 2kb) to the RAM usage of your app. As long as your app does not use the full 500Mb, you should be fine even with 1000 fibers.

But you should hit a performance / concurrency boundary before, as your app still processes only one fiber at a time. In your case, it will depend on the external service.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top