Redis Replication Interview Questions

Master Redis Replication with interview-focused questions covering Master-Replica Replication, Asynchronous Replication, PSYNC, Replication Offset, Partial Resynchronization, Failover, Replica Promotion, Read Scaling, High Availability, and enterprise production best practices.

Introduction

Redis Replication allows one Redis server to copy data automatically to one or more Redis servers.

Replication provides

  • High Availability
  • Read Scalability
  • Disaster Recovery
  • Backup
  • Fault Tolerance

Instead of serving all requests from a single Redis instance, applications can distribute read traffic across multiple replicas while keeping writes on the primary server.

Redis replication is one of the most commonly used enterprise Redis features.


Redis Replication Architecture

flowchart LR

Application --> RedisPrimary["Redis Primary"]

RedisPrimary["Redis Primary"] --> Replica1["Replica 1"]

RedisPrimary["Redis Primary"] --> Replica2["Replica 2"]

RedisPrimary["Redis Primary"] --> Replica3["Replica 3"]

Replica1["Replica 1"] --> ReadQueries["Read Queries"]

Replica2["Replica 2"] --> ReadQueries["Read Queries"]

Replica3["Replica 3"] --> ReadQueries["Read Queries"]

1. What is Redis Replication?

Answer

Redis Replication is the process of copying data from one Redis server (Primary) to one or more Replica servers.

Every write executed on the Primary is automatically propagated to all Replicas.


2. Why is Replication required?

Without Replication

Primary Crash

↓

Application Failure

With Replication

Primary

↓

Replicas

↓

High Availability

3. What are the components of Redis Replication?

  • Primary (Master)
  • Replica (Slave in older terminology)
  • Replication Link
  • Replication Offset
  • Replication Buffer

Replication Components

Primary

├── Replica 1
├── Replica 2
└── Replica 3

4. What is a Primary server?

The Primary server

  • Accepts Reads
  • Accepts Writes
  • Replicates Updates

Only the Primary accepts write operations in a standard replication setup.


5. What is a Replica server?

A Replica is a read-only copy of the Primary.

It continuously synchronizes data from the Primary.

Common uses

  • Read Scaling
  • Backup
  • Disaster Recovery

6. Is Redis Replication synchronous?

No.

Redis Replication is asynchronous by default.

The Primary does not wait for Replicas before responding to the client.


Replication Flow

flowchart LR

WriteRequest["Write Request"] --> PrimaryClientresponseclientResponse["Primary --> ClientResponse["Client Response"]"]

Primary --> Replicas

7. Why is asynchronous replication used?

Benefits

  • Very Fast Writes
  • Low Latency
  • Better Throughput

Possible drawback

  • Small amount of data loss during failures.

8. What happens when a Replica connects?

The Replica

  • Connects to Primary
  • Performs Initial Synchronization
  • Starts Continuous Replication

Replica Synchronization

flowchart LR

Replica --> PrimaryFullSyncContinuoussynccontinuous["Primary --> Full Sync --> ContinuousSync["Continuous Sync"]"]

9. What is Full Synchronization?

During the first synchronization

Primary

Creates RDB Snapshot

Transfers Snapshot

Replica Loads Snapshot

Receives Remaining Commands


Full Sync Workflow

flowchart TD

ReplicaConnects["Replica Connects"] --> PrimaryRdbSnapshotReplica["Primary --> RDB Snapshot --> Replica --> Load Snapshot --> ContinuousReplication["Continuous Replication"]"]

10. What is Partial Synchronization?

If a Replica disconnects briefly,

Redis attempts to send

only the missing updates

instead of transferring the full database again.

This greatly improves recovery performance.


11. What is PSYNC?

PSYNC

(Partial Synchronization)

is the Redis replication protocol.

It supports

  • Full Synchronization
  • Partial Synchronization

Introduced in Redis 2.8.


12. Why is PSYNC important?

Without PSYNC

Temporary Network Failure

↓

Full Database Copy

With PSYNC

Temporary Failure

↓

Only Missing Data

13. What is Replication Offset?

Every replicated write receives

an incremental offset.

Both Primary and Replica track offsets.

Matching offsets indicate synchronization.


Replication Offset

Primary Offset

↓

1500

Replica Offset

↓

1500

↓

Fully Synced

14. What is the Replication Backlog?

Replication Backlog is an in-memory circular buffer that stores recent replication commands.

It enables Partial Synchronization after temporary network interruptions.


Backlog Architecture

flowchart LR

Primary --> ReplicationBacklogReplica["Replication Backlog --> Replica"]

15. What happens if the backlog is insufficient?

If the missing updates are no longer available,

Redis performs

Full Synchronization

again.


16. Can multiple Replicas exist?

Yes.

One Primary can have

multiple Replicas.

Example

Primary

↓

Replica1

Replica2

Replica3

Replica4

17. Can Replicas have their own Replicas?

Yes.

Redis supports cascading replication.


Cascading Replication

flowchart LR

Primary --> Replica1["Replica 1"]

Replica1["Replica 1"] --> Replica2["Replica 2"]

Replica2["Replica 2"] --> Replica3["Replica 3"]

18. Are Replicas read-only?

Yes.

By default,

Replicas are read-only.

Applications typically send read traffic to Replicas and write traffic to the Primary.


19. What is Read Scaling?

Read Scaling distributes

read requests

across multiple Replicas.

Benefits

  • Better Performance
  • Lower Primary Load
  • Higher Throughput

Read Scaling

flowchart LR

Application --> Primary

Application --> Replica1["Replica 1"]

Application --> Replica2["Replica 2"]

Application --> Replica3["Replica 3"]

20. What happens if the Primary crashes?

Replication alone

does not automatically elect a new Primary.

Automatic failover is handled by

Redis Sentinel

or

Redis Cluster


Crash Scenario

Primary Down

↓

Redis Sentinel

↓

Replica Promoted

↓

New Primary

21. What is Replica Promotion?

Replica Promotion means

one Replica becomes

the new Primary

after failure.

Usually managed by Sentinel.


22. Does replication provide backup?

No.

Replication copies mistakes too.

Example

DELETE ALL DATA

↓

Replicated

↓

All Replicas Lose Data

Replication is not a substitute for backups.


Replication vs Backup

Replication Backup
Live Copy Historical Copy
High Availability Disaster Recovery
Copies Deletes Restore Previous State
Automatic Scheduled

23. Banking Example

Customer Balance

Primary Updated

Replicas Updated

ATM Reads

Replica


24. E-Commerce Example

Product Catalog

Primary

Five Replicas

Millions of Product Searches

Reduced Primary Load


25. Gaming Example

Leaderboard

Primary Updates

Replica Reads

Fast Global Ranking


26. Analytics Example

Real-Time Metrics

Primary

Reporting Replica

BI Dashboard


27. Production Example

10,000 Reads/sec

Primary

4 Replicas

Each Handles

2,500 Reads/sec

Lower Load


28. Common Replication Problems

  • Replication Lag
  • Network Failures
  • Full Synchronization Too Often
  • Small Replication Backlog
  • Slow Replica
  • Disk Bottlenecks

29. How do you monitor replication?

Useful command

INFO replication

Displays

  • Role
  • Connected Replicas
  • Replication Offset
  • Replication Status

30. Replication Best Practices

  • Use multiple Replicas.
  • Monitor replication lag.
  • Configure an appropriate replication backlog size.
  • Use Sentinel for automatic failover.
  • Keep regular backups.
  • Use Replicas for read-heavy workloads.
  • Monitor network latency.
  • Test failover regularly.
  • Keep Redis versions consistent.
  • Monitor memory utilization.

Redis Replication Workflow

flowchart LR

Client --> Primary

Primary --> ReplicationBacklog["Replication Backlog"]

ReplicationBacklog["Replication Backlog"] --> Replica

Replica --> ReadRequests["Read Requests"]

Enterprise Best Practices

  • Deploy at least one Replica for production.
  • Use Redis Sentinel for High Availability.
  • Use Redis Cluster for horizontal scaling.
  • Monitor replication offsets.
  • Size the replication backlog appropriately.
  • Keep backups independent of replication.
  • Separate read and write workloads.
  • Monitor replication lag continuously.
  • Test disaster recovery procedures.
  • Use secure network communication between Redis nodes.

Quick Revision

Topic Key Point
Replication Copy Data
Primary Read & Write
Replica Read Only
Async Replication Default
Full Sync Complete Database Copy
Partial Sync Missing Updates Only
PSYNC Replication Protocol
Replication Offset Synchronization Position
Replication Backlog Stores Recent Changes
Read Scaling Replicas Handle Reads
Replica Promotion New Primary
INFO replication Monitor Replication

Interview Tips

Interviewers frequently ask

  • What is Redis Replication?
  • Primary vs Replica.
  • Why is replication asynchronous?
  • Explain Full Synchronization.
  • Explain Partial Synchronization.
  • What is PSYNC?
  • What is Replication Offset?
  • What is Replication Backlog?
  • Replication vs Backup.
  • What happens when the Primary fails?

A strong interview explanation is:

"Redis Replication maintains one or more read-only replicas of a Primary Redis server. It uses asynchronous replication by default, allowing writes to complete with minimal latency while updates are propagated in the background. The PSYNC protocol supports both full and partial synchronization, reducing recovery time after temporary network failures. Replication improves read scalability and availability, while Redis Sentinel or Redis Cluster provides automatic failover in production environments."


Summary

Redis Replication enables high availability, read scalability, and fault tolerance by maintaining synchronized copies of a Primary Redis server. Features such as Full Synchronization, Partial Synchronization, PSYNC, Replication Offsets, Replication Backlog, and Replica Promotion ensure efficient replication and faster recovery from failures.

Understanding Redis replication architecture, synchronization mechanisms, monitoring, and failover strategies is essential for Backend Developers, DevOps Engineers, Redis Administrators, Microservices Engineers, and Solution Architects designing highly available enterprise systems.