Skip to content

Instantly share code, notes, and snippets.

@mkcode
Created May 11, 2016 18:17
Show Gist options
  • Save mkcode/fd59a490b0c538187d6b346534747ecb to your computer and use it in GitHub Desktop.
Save mkcode/fd59a490b0c538187d6b346534747ecb to your computer and use it in GitHub Desktop.
<%
# Quick function to calculate the correct number DB_POOL size. DB_POOL size is
# reused for the puma web server and sidekiq. It cannot be less than the
# amount the concurrency of either.
db_needed_for_web = ENV.fetch('WEB_CONCURRENCY', 1) * ENV.fetch('WEB_THREADS', 1)
db_needed_for_sidekiq = ENV.fetch('SIDEKIQ_CONCURRENCY', 0)
# The minimum pool size is the maximum of the sidekiq and web concurrency. We
# add some extras to the pool for sidekiq's scheduler and one off dynos.
min_pool_size_needed = [db_needed_for_web, db_needed_for_sidekiq].max + 5
# db pool size
db_pool_size = ENV["DB_POOL"] || min_pool_size_needed
%>
development:
adapter: postgresql
database: education_web_development
encoding: unicode
host: localhost
port: <%= ENV['BOXEN_POSTGRESQL_PORT'] || 5432 %>
pool: 30
test:
adapter: postgresql
database: education_web_test
encoding: unicode
host: localhost
port: <%= ENV['BOXEN_POSTGRESQL_PORT'] || 5432 %>
staging:
encoding: utf8
pool: <%= db_pool_size %>
production:
encoding: utf8
pool: <%= db_pool_size %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment