Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Tip: How to make Rails properly handle database failovers on AWS RDS #12
Problem: a client had multiple rails apps pointing to a few RDS databases, in multi-AZ mode. However, after initiating a database failover, the apps would appear to be stuck trying to reach the old database master, instead of gracefully killing the stale connection, and reconnecting.
After a few tries and a lot of digging, here is the configuration for Rails'
Or in a
host: rds-dbhost port: 5432 username: dbuser password: dbpassword database: dbname pool: 5 encoding: unicode reconnect: true connect_timeout: 2 keepalives_idle: 30 keepalives_interval: 10 keepalives_count: 2 checkout_timeout: 5 reaping_frequency: 10
Came across this because I'm trying to figure out how to get ActiveRecord to reconnect after an ELB connection timeout: https://aws.amazon.com/blogs/aws/elb-idle-timeout-control/
This config doesn't seem to be helping for that use case. Have you ever run into that by any chance? I'm not sure how it differs from the failover case.