Overview
This project demonstrates how to perform a zero-downtime database migration across AWS regions using:
AWS Database Migration Service (DMS)
Amazon RDS (MySQL)
AWS CloudFormation
The system uses Change Data Capture (CDC) to continuously replicate database changes, ensuring minimal downtime and real-time synchronization.
π― Key Features
β
Zero/near-zero downtime migration
π Real-time data replication using CDC
π Cross-region migration (e.g., Mumbai β Singapore)
β‘ Automated infrastructure setup
π Data validation and consistency
ποΈ Architecture
π Workflow
Full data load from source to target
CDC captures real-time changes
DMS applies changes continuously
Target DB stays in sync
Cutover to target database
π§° Tech Stack
AWS DMS
Amazon RDS (MySQL)
AWS CloudFormation
MySQL Workbench
βοΈ Step-by-Step Implementation
π¦ Step 1: Create Source Database (RDS - Region A)
Go to AWS Console β RDS
Click Create Database
Select:
Engine: MySQL
Instance: db.t3.micro
Set username & password
Enable public access (for testing)
or (Use cloud formation code)
download the source-db.yaml from cloudformaton/ folder
open cloudformation in aws cli
click on create stack
select - choose an existing template
select - upload a template file
create stack
π¦ Step 2: Create Target Database (RDS - Region B)
Switch AWS region
Repeat same steps as source
or (Use cloud formation code)
use target-db.yaml file from cloudformation/ folder
π¦ Step 3: Enable CDC (IMPORTANT)
Create Parameter Group
Go to RDS β Parameter Groups
Create new parameter group
Set:
binlog_format = ROW
binlog_row_image = FULL
Attach to source DB
Reboot database
Step 4: Create DMS Replication Instance
Go to DMS β Replication Instances Click Create Select: Instance: dms.t3.medium
Step 5: Create Endpoints
Source Endpoint
Enter source DB details (endpoint of source RDS)
Test connection
Target Endpoint
Enter target DB details (endpoint of destination RDS)
Test connection
Step 6: Create Migration Task
Go to DMS β Tasks β Create Task Configure: Migration Type: Full Load + CDC (change data capture) Table Mapping: Schema: demo_db Table: users
Step 7: Start Migration
Start the task Monitor: Full load CDC status
Step 8: Validate Data
connect source-db RDS database to mysql workbeanch
username admin password - Password123!
endpoint is RDS database endpoint
do the same for target RDS database
Source: INSERT INTO users VALUES (1, 'test_user');
Source database:
Step 9: Test CDC
UPDATE users SET name = 'updated' WHERE id = 1;
π Changes should reflect in target DB instantly Target database :
Step 10: Cutover
Stop writes to source Ensure replication lag = 0 Switch application to target DB
Key Concepts
πΉ What is CDC?
CDC captures changes (INSERT, UPDATE, DELETE) from database logs and replicates them in real time.
πΉ What is Replication Instance?
It is the compute engine that:
Reads source DB
Processes data
Writes to target DB
πΉ What is DMS Task?
Defines:
What to migrate
How to migrate
When to migrate
Common Issues & Fixes
possible errors
Error 1236 (Binlog Not Found)
Cause: Old logs deleted
Fix:
Recreate task Start from beginning
CDC Not Working Fix: binlog_format = ROW binlog_row_image = FULL
Data Not Syncing Check task status Ensure CDC enabled
Cost Estimation
Service Cost RDS (2 instances) ~$1.6 DMS ~$2.4 Data Transfer ~$0.2 Total ~$4β5
Results
β
Zero downtime migration achieved
π Real-time replication working
π Data consistency maintained
π Conclusion
This project demonstrates how AWS DMS with CDC enables seamless and reliable database migration with minimal downtime.
References
1.AWS DMS Documentation 2.AWS RDS Documentation 3.MySQL Binlog Documentation
Author
Darshan B










Top comments (0)