CASE STUDY 02 • DATABASE SCALING

Migrating a 40M-row Postgres database with zero downtime

The Situation

The client operates a major B2B SaaS scheduling platform under continuous, write-heavy traffic. Their main Postgres database was running on legacy AWS infrastructure that lacked current encryption rules. A complete security upgrade required migrating the database to a new AWS environment with zero scheduled downtime.

What We Found

  • Standard pg_dump/pg_restore actions would require over 6 hours of read/write lockout time.
  • Database connection strings were hardcoded in multiple backend modules, necessitating routing overrides.
  • Large table lock volumes could stall scheduling tasks, causing application timeouts.

What We Did

We created a migration protocol based on logical replication and DNS swapping:

1. Target DB Synchronization

We deployed a target database in the new AWS environment and configured logical replication channels to copy transaction schemas and data tables continuously.

2. Replica Verification

We ran verification scripts to check sync counts, validation indexes, and foreign keys without locks.

3. Zero-Outage Swapping

We performed a DNS transition during low traffic, routing write requests to the target DB within a 15-second window.

The Outcomes

The database migration completed successfully with less than 2 seconds of replication delay and zero database downtime experienced by active users.

Engagement Metrics

Client Profile
B2B SaaS Scheduling
Core Services
Database Scaling, Cloud Migration
Timeline
4 Weeks
0
Downtime Sec
40M+
Rows Migrated

Engineering Reflection

Logical replication handled the transfer requirements, but large tables with heavy update frequencies created replica queue issues that required adjusting resource parameters on the primary instance. We optimized configuration parameters to prevent transactional locking delays.

Need complex database scaling?

We work with B2B SaaS and technical firms that demand high engineering standards. Let's discuss your cloud setup.

Start a conversation →