Use ActiveRecord configuration to read from replica for reporting#5272
Use ActiveRecord configuration to read from replica for reporting#5272zachmargolis merged 11 commits intomainfrom
Conversation
| pool: <%= IdentityConfig.store.database_pool_idp %> | ||
| sslmode: 'verify-full' | ||
| sslrootcert: '/usr/local/share/aws/rds-combined-ca-bundle.pem' | ||
| replica: true |
There was a problem hiding this comment.
turns out when a connection is set to replica: true Rails will block writes also, which is nice
|
Update: seems to work mostly as expected in my personal env |
| pool = if Identity::Hostdata.instance_role == 'worker' | ||
| IdentityConfig.store.good_job_max_threads * IdentityConfig.store.database_pool_idp | ||
| else | ||
| IdentityConfig.store.database_pool_idp | ||
| end |
There was a problem hiding this comment.
cc @mitchellhenke @jgrevich this was how we wanted to scale threads for workers? or did we want max_threads + pool_idp (pool is 5 here)
There was a problem hiding this comment.
Jobs will most likely using at least one connection each, so adding together makes sense to me to give a little bit of breathing room. I'm not sure what the max total connections is though.
orenyk
left a comment
There was a problem hiding this comment.
Looks great, love all the deletions 😄
| <<: *defaults | ||
| primary: | ||
| <<: *defaults | ||
| primary_replica: |
There was a problem hiding this comment.
question: should we call it read_replica instead? That threw me off a little bit when you call establish_connection.
There was a problem hiding this comment.
Great idea, and that matches the name in devops repo where we call it read-replica, updated in 27926b2
| pool: <%= IdentityConfig.store.database_pool_idp %> | ||
| sslmode: 'verify-full' | ||
| sslrootcert: '/usr/local/share/aws/rds-combined-ca-bundle.pem' | ||
| replica: true |
Seems to work locally, going to test in my personal env shortly