Puma lag settings similar to unicorn?

Unicorn accepts a listen configuration, which allows you to set the backlog in ms if the worker is busy. Decreasing this value allows the router to send a request to another worker if he is busy.

Is there something similar for Puma? I could not find such a thing.

That would be extremely helpful on Geroku.

+4
source share
1 answer

Now it is supported. You can pass a request parameter for the binding, which has a backlog value.

Here is an example of how to do this in a Rails application.

 # config/puma.rb workers Integer(ENV['PUMA_WORKERS'] || 3) threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16) preload_app! rackup DefaultRackup port = Integer(ENV['PORT'] || 3000) backlog = Integer(ENV['PUMA_BACKLOG'] || 20) bind "tcp://0.0.0.0:#{port}?backlog=#{backlog}" environment ENV['RACK_ENV'] || 'development' on_worker_boot do # worker specific setup ActiveSupport.on_load(:active_record) do config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env] config['pool'] = ENV['MAX_THREADS'] || 16 ActiveRecord::Base.establish_connection(config) end end 

Note. Make sure you are using the latest version of Puma. I checked this in 2.8.2.

Here is an example application using this configuration, I tested it on Heroku.

For more information, I added the solution to my blog here: http://mikecoutermarsh.com/adjusting-pumas-backlog-for-heroku/

+1
source

Source: https://habr.com/ru/post/1501768/


All Articles