How to configure ORY Hydra to route read queries to a PostgreSQL Read Replica (AlloyDB) and also add the primary db #148
-
|
I am currently running ORY Hydra backed by a primary GCP AlloyDB (PostgreSQL) instance. Under heavy load, I am experiencing high latency, which occasionally leads to database connection drops. To mitigate this and improve stability, I want to introduce a read replica to handle all the read-heavy queries and offload the primary instance. My questions for the community are:
Any guidance or examples would be highly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Hello @vazidahmed, Ory Hydra doesn't natively support read/write splitting at the DSN level — you can only configure a single Option 1: PgBouncer / PgPool-II as a proxy layerPut a connection pooler in front of your databases that handles read/write routing transparently:
# Hydra config — points to proxy, not directly to DB
dsn: postgres://hydra:secret@pgpool-host:5432/hydra
This is the most common approach in production and requires zero changes to Hydra itself. |
Beta Was this translation helpful? Give feedback.
-
|
Hey @vazidahmed If you're running Hydra for a commercial project at a scale where you're hitting connection limits and need read replicas, you might want to look at the Ory Enterprise License. |
Beta Was this translation helpful? Give feedback.
Hey @vazidahmed
If you're running Hydra for a commercial project at a scale where you're hitting connection limits and need read replicas, you might want to look at the Ory Enterprise License.
OEL gives you a commercially supported build of Hydra with "high-performance pooling" built in: https://www.ory.com/docs/self-hosted/oel/high-performance-pooling - as well as security SLAs, regular patched images, and direct access to the engineering team for deployment guidance, incident response, or troubleshooting
If that sounds relevant, feel free to reach out to our team at and we can walk through what that looks like for your setup.