Read-only replica with Aiven client
Read-only replicas enable you to perform read-only queries against the replica and reduce the load on the primary server. It is also a good way to optimize query response times across different geographical locations, because the replica can be placed in different regions or even different cloud providers.
Before you begin
Before you begin, make sure you have:
- Installed Aiven Client.
- Signed in to your Managed Service for TimescaleDB dashboard.
- Created a service in Managed Service for TimescaleDB.
Creating a read-only replica of your service
In the Aiven client, connect to your Managed Service for TimescaleDB service.
Switch to the project that contains the TimescaleDB service you want to create a read-only replica for:
avn project switch <PROJECT>
List the services in the project, and make a note of the service that you want to create a read-only replica for. It is listed under the
SERVICE_NAME
column in the output:avn service list
Get the details of the service that you want to fork:
avn service get <SERVICE_NAME>
Create a read-only replica:
avn service create <NAME_OF_REPLICA> --project <PROJECT_ID>\
-t pg --plan <PLAN_TYPE> --cloud timescale-aws-us-east-1\
-c pg_read_replica=true\
-c service_to_fork_from=<NAME_OF_SERVICE_TO_FORK>\
-c pg_version=11 -c variant=timescale
Example
To create a fork named replica-fork
for a service named timescaledb
with these parameters:
- PROJECT_ID:
fork-project
- CLOUD_NAME:
timescale-aws-us-east-1
PLAN_TYPE:
timescale-basic-100-compute-optimized
```
avn service create replica-fork —project fork-project\
-t pg —plan timescale-basic-100-compute-optimized\
—cloud timescale-aws-us-east-1 -c pg_read_replica=true\
-c service_to_fork_from=timescaledb -c\
pg_version=11 -c variant=timescale
You can switch to `project-fork` and view the newly created `replica-fork` using:
avn service list ```