Install Sidekiq: concurrency on Heroku

I find it difficult to understand exactly how concurrency works on Heroku and how to set the optimal value :concurrencyfor Sidekiq

Here's the setting -

Puma Web Server
  2 workers
  5 threads

Heroku Dynos
  8 web dynos
  2 "worker" dynos (These will run Sidekiq, not to be confused with Puma Workers)

DB Connections
 120 Max Connections Allowed by Postgres
 5   Active Record Pool Size (default)
 ??  Sidekiq :concurrency value

Each Puma employee is allowed to use 5 ActiveRecord DB connections by default (which is good for each of the 5 threads). Because Web Dyno has two of these Puma employees, each Web Dyno consumes up to 10 connections. In all 8 web speakers they occupy 80 connections

120 - 80 = 40 , 2- , Sidekiq. , Sidekiq ( ?), Sidekiq 20 (.. :concurrency 20)

  • , ?

  • Sidekiq - ActiveRecord 5? , 20 , 5 .

!

+3
1

, .

Puma Sidekiq 5 , , . 5 2 :

Sidekiq.configure_client do |config|
  config.redis = { size: 2 }
end

Sidekiq concurrency - , . :

Sidekiq.configure_server do |config|
  config.redis = { size: 20 }
end

Sidekiq (concurrency + 2), 20 concurrency 25.

+9

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


All Articles