Last active
          March 19, 2023 18:13 
        
      - 
      
 - 
        
Save henrypoydar/55a50da016d8430976d182fb525e94b0 to your computer and use it in GitHub Desktop.  
    Rails + Sidekiq + Puma + Heroku 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | production: | |
| adapter: postgresql | |
| url: <%= ENV["DATABASE_URL"] %> | |
| pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | WEB_PROCESSES=2 | |
| WEB_THREADS=5 | |
| WORKER_THREADS=15 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | web: RAILS_MAX_THREADS=$WEB_THREADS bundle exec puma -C config/puma.rb | |
| worker: RAILS_MAX_THREADS=$WORKER_THREADS bundle exec sidekiq -C config/sidekiq.yml | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | threads_count = ENV.fetch("WEB_THREADS") { 5 }.to_i | |
| threads threads_count, threads_count | |
| port ENV.fetch("PORT") { 3000 } | |
| environment ENV.fetch("RAILS_ENV") { "development" } | |
| workers ENV.fetch("WEB_PROCESSES") { 3 }.to_i | |
| preload_app! | |
| before_fork do | |
| ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) | |
| end | |
| on_worker_boot do | |
| ActiveRecord::Base.establish_connection if defined?(ActiveRecord) | |
| Rails.logger.info("Database connection pool size for this web process is: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| :concurrency: <%= ENV['WORKER_THREADS'] %> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment