I am using heroku with Rails 4.1.1 and Ruby 2.1.1. I am using default database configuration for heroku. That's why I have put database.yml into .gitignore
and I am not using database.yml
for production.
I am facing issue for PG::ConnectionBad: PQsocket() can't get socket descriptor
and for solve this error i need to set reaping_frequency
.
The
reaping_frequency
can tell Active Record to check to see if connections are hung or dead every N seconds and terminate them. While it is likely that over time your application may have a few connections that hang, if something in your code is causing hung connections, the reaper will not be a permanent fix to the problem.
Now I want to add this configuration into database.yml
.
reaping_frequency: 10
so should I directly add this configuration over database.yml
for override or is there any another better way to set this frequency into heroku?
Thanks in advance for suggestion.
pool is the config of size of connection pool, which is 5 by default.
Heroku provides managed Postgres databases. Different tiered databases have different connection limits. The Hobby Tier databases are limited to 20 connections. Standard and higher tier databases have higher limits.
ActiveRecord::Base indicates that the ActiveRecord class or module has a static inner class called Base that you're extending.
1 What is Active Record? Active Record is the M in MVC - the model - which is the layer of the system responsible for representing business data and logic. Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database.
In your config/unicorn.rb or config/puma.rb set pool and reaping_frequency in the config:
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['DB_POOL'] || 5
config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds
ActiveRecord::Base.establish_connection(config)
Rails 4.0+ can directly specify pool
and reaping_frequency
in config/database.yml
.
See Options in following API links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With