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:

Creating a read-only replica of your service

  1. In the Aiven client, connect to your Managed Service for TimescaleDB service.

  2. Switch to the project that contains the TimescaleDB service you want to create a read-only replica for:

    1. avn project switch <PROJECT>
  3. 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 theSERVICE_NAME column in the output:

    1. avn service list
  4. Get the details of the service that you want to fork:

    1. avn service get <SERVICE_NAME>
  5. Create a read-only replica:

    1. avn service create <NAME_OF_REPLICA> --project <PROJECT_ID>\
    2. -t pg --plan <PLAN_TYPE> --cloud timescale-aws-us-east-1\
    3. -c pg_read_replica=true\
    4. -c service_to_fork_from=<NAME_OF_SERVICE_TO_FORK>\
    5. -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

  1. You can switch to `project-fork` and view the newly created `replica-fork` using:

avn service list ```