Can the replica be safely used for read-only operations in the application, or is there a risk of data being out of sync or not reflecting real-time updates?

2025-01-16T10:52:00.26+00:00

I am using Azure Database for PostgreSQL servers and have created a replica of one of them for production purposes. Can the replica be safely used for read-only operations in the application, or is there a risk of data being out of sync or not reflecting real-time updates?

Azure Database for PostgreSQL
{count} votes

2 answers

Sort by: Most helpful
  1. Vijayalaxmi Kattimani 1,065 Reputation points Microsoft Vendor
    2025-01-16T14:16:50.5433333+00:00

    Hi @Mahmoud AbdelRhaman Tag Eldeen Elzahaby,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    The read replica feature helps to improve the performance and scale of read-intensive workloads. a replica can be used for read-only operations in an application, but there is a risk of data being out of sync. This is because data propagation latency can cause data to be slightly out of date.

    The replica is designed to be a read-only copy of the primary server, and it is kept in sync with the primary server using asynchronous replication. This means that any changes made to the primary server will eventually be replicated to the replica, although there may be a slight delay depending on the replication lag.

    However, it is important to note that there is always a risk of data being out of sync or not reflecting real-time updates when using a replica for read-only operations. This is because the replica is not guaranteed to be in sync with the primary server at all times, and there may be a delay between when a change is made on the primary server and when it is replicated to the replica.

    The Read Replica Lag metric shows the time since the last replayed transaction. For instance if no transactions are occurring on your primary server, and the last transaction was replayed 5 seconds ago, then the Read Replica Lag shows 5-second delay. This metric is applicable and available on replicas only.

    Please refer to the below mentioned links for more information.

    https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-read-replicas

    https://learn.microsoft.com/en-us/azure/azure-sql/database/read-scale-out?view=azuresql

    https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-read-replicas-promote?source=recommendations

    I hope this information helps. Please do let us know if you have any further queries.

    If the answer is helpful, please click "Accept Answer" and "Upvote it".


  2. RahulRandive 10,146 Reputation points
    2025-01-16T18:55:47.97+00:00

    Hi @Mahmoud AbdelRhaman Tag Eldeen Elzahaby

    Yes, you can safely use a replica of an Azure Database for PostgreSQL server for read-only operations in your application. The replica is designed to be a read-only copy of the primary server, and any changes made to the primary server will be replicated to the replica in near real-time.

    However, it is important to note that there may be a slight delay between when changes are made on the primary server and when they are replicated to the replica. This delay is typically very small (on the order of seconds).

    Thank You!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.