Skip to main content
Version: v2.x

Read Replicas

Introduction

Hasura Cloud and Hasura Enterprise can route queries and subscriptions across read replicas while sending all mutations and Metadata API calls to the primary.

This works by selecting a read replica instance at random. Hasura does not perform any kind of load balancing across the replicas. The random function used has a uniform distribution, and so over time, queries will distribute uniformly across all replica instances.

Adding read replica URLs

Postgres

Head to Data -> Manage -> <db-name> -> Edit

Connect database with read replica
For existing v1.3 projects

If you have configured your Postgres instances with replicas; then the replica URLs can be added to Hasura using the following environment variable in your project ENV Vars tab:

HASURA_GRAPHQL_READ_REPLICA_URLS=postgres://user:password@replica-host:5432/db

In the case of multiple replicas, you can add the URLs of each replica as comma-separated values.

Additional environment variables for read replicas specifically:

HASURA_GRAPHQL_CONNECTIONS_PER_READ_REPLICA

HASURA_GRAPHQL_STRIPES_PER_READ_REPLICA

NOTE: Please note that the above environment variables are only available for v1.3 projects and are no longer supported for v2.0 and above projects.

MS SQL Server

Head to Data -> Manage -> <db-name> -> Edit

Connect database with read replica