Working with Neon read replicas
Learn how to create and and manage read replicas in Neon
Read replicas are supported with the Neon paid plans. This guide will lead you through the process of creating and managing read replicas.
The general methodology of using read replicas to segregate read-only work from your production database operations can be applied to a variety of uses cases, such as:
- Offloading analytics or reporting queries
- Distributing read requests to achieve higher throughput
- Providing read-only data access to specific users or applications who do not need to modify data
- Configuring different CPU and memory resources for each read replica for different users and applications
Regardless of the application, the steps for creating, configuring, and connecting to a read replica are the same. You can create one or more read replicas for any branch in your Neon project and configure the vCPU and memory allocated to each. Neon's Autoscaling and Autosuspend features are also supported, providing you with control over compute usage.
Prerequisites
- A Neon paid plan account
- A Neon project.
Create a read replica
Creating a read replica involves adding a read-only compute endpoint to a branch. You can add a read-only compute endpoint to any branch in your Neon project using the Neon Console, Neon CLI, or Neon API.
Connect to a read replica
Connecting to a read replica is the same as connecting to any branch, except you connect via a read-only compute endpoint instead of a read-write compute endpoint. The following steps describe how to connect to your read replica with connection details obtained from the Neon Console.
-
On the Neon Dashboard, under Connection Details, select the branch, the database, and the role you want to connect with.
-
Under Compute, select a Read-only compute endpoint.
-
Select a connection string or a code example from the drop-down menu and copy it. This is the information you need to connect to the read replica from you client or application.
A psql connection string appears similar to the following:
If you expect a high number of connections, select Pooled connection to add the
-pooler
flag to the connection string or example.When you use a read-only connection string, you are connecting to a read replica. No write operations are permitted on this connection.
View read replicas
You can view read replicas using the Neon Console or Neon API.
Edit a read replica
You can edit a read replica using the Neon Console or Neon API to change the Compute size or Autosuspend configuration.
Delete a read replica
You can delete a read replica using the Neon Console or Neon API. Deleting a read replica is a permanent action, but you can quickly create a new read replica if you need one.
Need help?
Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more detail, see Getting Support.
Last updated on