What strategies can be used for data replication or synchronization between microservices?

Data replication and synchronization strategies keep related data consistent across microservices that each maintain their own local copy, without requiring a shared database.

Key Points

Example

Using Debezium, changes to the Orders table in the Order Service's PostgreSQL database are captured from the write-ahead log and streamed to Kafka, letting the Shipping Service keep its own local read-optimized copy of order data in sync without ever querying the Order Service's database directly.

// Change data capture with Debezium: stream the orders table to Kafka
// POST http://connect:8083/connectors
{
  "name": "orders-outbox",
  "config": {
    "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
    "database.hostname": "orders-db",
    "database.port": "5432",
    "database.user": "debezium",
    "database.password": "${secrets:orders-db-password}",
    "database.dbname": "orders",
    "topic.prefix": "orders",
    "table.include.list": "public.outbox_event",
    "transforms": "outbox",
    "transforms.outbox.type": "io.debezium.transforms.outbox.EventRouter"
  }
}
// Debezium reads the database log, so no polling code is needed and
// no change is missed, even if the service is down.

Interview Tip

A concise interview answer is

I'd use event sourcing when I want a full history of changes that other services can replay, and Change Data Capture with something like Debezium when I want to stream database changes to other services without modifying application code. Both keep services in sync asynchronously without coupling them to a shared database.

Last updated: 1 November 2026

Previous question: How do you handle data consistency across microservices with separate databases?

Next question: What is the Saga pattern, and how does it manage distributed transactions in microservices?

More Microservices Design Patterns interview questions

All Microservices Design Patterns questions