How to migrate a monolithic database to a microservices architecture

Mydbops
Sep 25, 2026
10
Mins to Read
All
How to migrate a monolithic database to a microservices architecture
How to migrate a monolithic database to a microservices architecture

Splitting a single monolithic database into per-service stores is the highest-risk part of any microservices migration — get the sequencing wrong in 2026 and you trade one bottleneck for three, with data drift and duplicate writes on top.

TL;DR

  • Migrating a monolithic database to microservices works best with the strangler pattern, not a big-bang cutover, in 2026.
  • Map bounded contexts and data ownership before writing any migration script; skipping this step causes the most rollbacks.
  • Use CDC tools like Debezium for dual-write consistency and verify replication lag before flipping traffic to the new service database.
  • Compliance-heavy systems, including PCI-DSS and fintech workloads, need an audit-ready schema before extraction, not a retrofit after go-live.
  • Budget a tested rollback window for every extracted service; the mistake that kills most 2026 migrations is skipping it.

Why This Matters

A monolithic database usually holds every table for every domain in one schema, with foreign keys and joins that make sense until you try to split ownership. Migrating it to a microservices architecture is not a schema refactor, it is a change to who owns which data and how services talk to each other. Teams that treat it like a lift-and-shift end up with two databases writing to the same table, or a service that cannot function without a cross-database join it was never designed to make.

The businesses that hit this wall hardest are the ones scaling fastest. A managed database services for SaaS startups engagement usually starts right here, after the monolith has outgrown a single connection pool. The fix is not more hardware. It is sequencing the extraction so the application never notices the database underneath it changed.

What You'll Need

  • A bounded-context map: which tables belong to which business capability, not which team happens to query them
  • A change data capture (CDC) pipeline, such as Debezium, Maxwell, or native binlog/WAL streaming, to keep old and new stores in sync during cutover
  • A staging environment that mirrors production schema and data volume, not a sample dataset
  • Monitoring for replication lag and write conflicts, checked before any traffic cutover
  • A documented rollback plan per service extraction, tested before go-live rather than written after an incident
  • For regulated data (payments, health, financial records), audit documentation ready before extraction, not added afterward

The Steps

1. Map bounded contexts before you touch a single table

This defines which service owns which data before any code moves. Table splits driven by an org chart instead of a business domain create circular dependencies you pay for later. Draw a service ownership map naming table groups by business capability, not by schema name, and treat any join crossing a proposed boundary as a sign you drew the line wrong.

Common mistake: splitting by team assignment rather than data ownership, then discovering two independent services still share a transaction boundary.

Draw service boundaries around business capabilities

Each service owns its table group outright. Ownership follows the domain, not the org chart.

Orders service
Owns order lifecycle
orders
order_items
carts
Payments service
Owns money movement
payments
refunds
ledger_entries
Catalog service
Owns what is for sale
products
prices
inventory
Redraw signalA query that joins orders to payments crosses a proposed boundary. Move the line before you write a migration script.

Illustrative ownership map. Table names are examples.

2. Pick a migration pattern: strangler fig, not big-bang

Choosing incremental extraction over a full cutover keeps risk contained. Big-bang migrations concentrate all the risk into one weekend; a failed cutover means rolling back the whole system, not one service. Run old and new schemas side by side, route reads to the new store first, then writes, service by service, over weeks rather than a single deploy.

Common mistake: migrating all services during one maintenance window because it looks easier to plan.

Where the risk lands: big-bang versus strangler fig

Same monolith, same target services. The difference is how much can fail at once.

Big-bang cutover
Every service in one maintenance window
Risk: concentrated into a single weekend
Order: reads and writes move together
Rollback: the whole system
 
Avoid
Strangler fig extraction
One service at a time, over weeks
Risk: contained to the service being moved
Order: reads first, writes after reconciliation
Rollback: one service, within an hour
 
Recommended

Blast radius per cutover event under each pattern.

3. Set up CDC before extracting the first service

This keeps the monolith and the new service database in sync during the transition. Without CDC, any write during migration risks becoming invisible to one side of the split. Point Debezium, or an equivalent binlog- or WAL-based CDC tool, at the source tables, stream changes into the new service's data store, and verify checksums on a sample of rows every few minutes.

Common mistake: relying on application-level dual writes only, with no reconciliation job checking for silently dropped writes.

4. Extract the first service in read-only mode

Start with the lowest-risk service, one with few cross-boundary joins and no regulatory audit trail attached. Point that service's read traffic at the new database while writes still land on the monolith, and confirm response times and data consistency hold for at least one full business cycle before moving writes.

If the service touches payment or cardholder data, resolve audit requirements before extraction, not after. See how to prepare a database for a PCI-DSS compliance audit for what auditors check on split schemas in 2026.

Common mistake: extracting the highest-traffic service first to prove the pattern faster, which is also the service where a mistake costs the most.

5. Cut over writes with a dual-write validation window

This moves write ownership to the new store, and it is the step most migrations rush. Run dual writes for a fixed window measured in days, not hours, reconcile row counts and checksums daily, and only flip the source-of-truth flag once reconciliation shows zero drift for three consecutive checks.

A useful gut check: if you cannot roll back a service extraction within an hour, you are not ready to cut over.

Common mistake: cutting over writes the same day reconciliation first shows a clean pass, with no buffer for a delayed batch job writing stale data.

“If you can't roll back a service extraction within an hour, you're not ready to cut over.”

6. Decommission monolith ownership of migrated tables

Removing write access, then read access, from the old schema closes the loop. Leaving dual-write code live after cutover is the single most common source of phantom-write bugs that surface months later. Revoke write permissions on migrated tables from the monolith's service account first, keep read-only access for a defined grace period, then drop the tables on a set date.

Common mistake: leaving the old tables live indefinitely for safety, until nobody remembers which store is authoritative.

The per-service cutover sequence and its gates

A service advances only when the gate for its current stage has passed.

Stage 1
Stream changes
Gate to pass
CDC in place, checksums on sampled rows every few minutes
Stage 2
Move reads
Gate to pass
New store serves reads for one full business cycle
Stage 3
Dual-write window
Gate to pass
Days, not hours. Zero drift on three consecutive checks
Stage 4
Flip source of truth
Gate to pass
Rollback proven to complete within an hour
Stage 5
Decommission
Gate to pass
Revoke writes, then reads, then drop tables on a set date
Repeat for every service. The second extraction gets the full sequence too, starting from a re-run of the ownership map.

Stages map to steps 3 through 6 of this guide.

7. Repeat per service and monitor for drift across the system

Extending the pattern to each bounded context changes the join patterns of everything not yet migrated. New cross-service dependencies show up that did not exist in the monolith. After each extraction, re-run the bounded-context map from step one against the services still in the monolith, because some join patterns that looked safe on paper only surface once real traffic passes through.

Common mistake: assuming the second extraction will look like the first; new coupling shows up every time a boundary moves.

Troubleshooting

  • Replication lag climbs during the dual-write window. Check the CDC connector's batch size and network throughput first; lag over a few seconds during peak write volume usually means the connector is undersized, not the database.
  • A foreign key used to enforce integrity now spans two databases. Move the constraint into application logic or a saga pattern; cross-database foreign keys do not exist, and pretending otherwise causes orphaned rows.
  • Checksums between old and new stores do not match after reconciliation. Check for triggers or stored procedures on the monolith side writing to the migrated table outside the application code path, since those bypass CDC.
  • A transaction spans two newly split services. Replace it with a saga using compensating actions instead of forcing two-phase commit across services; distributed 2PC recreates the exact coupling you migrated to remove.
  • A compliance audit flags a gap in the access log after extraction. Confirm audit logging was configured on the new store before cutover, not added after. PCI-DSS and similar frameworks expect continuous logging, not a log that starts the day someone noticed it was missing.
Five cutover symptoms and where to look first

Start with the first check before touching database capacity.

Symptom
 
First check
Replication lag climbs in the dual-write window
→
CDC connector batch size and network throughput
A foreign key now spans two databases
→
Move the rule into application logic or a saga
Checksums disagree after reconciliation
→
Triggers or stored procedures writing outside the app path
One transaction spans two split services
→
A saga with compensating actions, not distributed 2PC
Audit log gap after extraction
→
Logging enabled on the new store before cutover

Condensed from the troubleshooting entries above.

Tools And Resources

  • CDC: Debezium, Maxwell's Daemon, or native binlog (MySQL) / WAL (PostgreSQL) streaming
  • Online schema change: gh-ost or pt-online-schema-change for zero-downtime changes on the monolith side during migration
  • Connection routing: ProxySQL to shift traffic between old and new stores without an application redeploy
  • Reconciliation: scheduled checksum jobs comparing row counts and hashes between source and target
  • For regulated verticals, review what a compliance-first migration looks like for managed database services for fintech platforms; the audit and encryption requirements shape which tables you can extract first

What To Do Next

Once the first service is fully cut over, do not start the second extraction from scratch. Re-run the bounded-context map, because every completed migration changes the coupling of what is left in the monolith. Database engines differ in what CDC options exist: MySQL and MariaDB lean on binlog-based tools, PostgreSQL uses logical replication and WAL, and MongoDB has native change streams, so pick the pattern for the engine you are actually running. Mydbops works across MySQL, MariaDB, MongoDB, PostgreSQL, TiDB, MSSQL, and Cassandra, which matters when a migration touches more than one engine at once, and holds ISO and PCI-DSS certifications relevant to regulated cutovers in 2026.

FAQ

What is the best way to migrate a monolithic database to microservices?

The strangler pattern with change data capture (CDC) is the safest approach for how to migrate a monolithic database to microservices in 2026. It extracts one service at a time with dual writes, instead of a single risky cutover.

Is the strangler pattern better than a big-bang migration?

Yes, for almost every production system. A big-bang migration concentrates all risk into one cutover window, while the strangler pattern isolates the blast radius of each service extraction.

How long does a database migration to microservices take?

Timelines depend on the number of bounded contexts and how tightly coupled the schema is. Expect a dedicated dual-write and reconciliation window per service, so plan in weeks per extraction rather than a single cutover weekend.

Do you need CDC for a microservices database migration?

Yes, change data capture is what keeps the old and new stores consistent during the transition. Application-level dual writes without a reconciliation job risk silently dropped writes.

Can you migrate MongoDB and MySQL data into separate microservices at the same time?

Yes, but sequence them separately since each engine uses a different CDC mechanism. MongoDB relies on native change streams while MySQL relies on binlog-based tools like Debezium.

What's the biggest cause of failed monolith-to-microservices migrations?

Extracting tables by team ownership instead of business domain is the most common cause, closely followed by skipping a tested rollback plan before cutover.

Does migrating to microservices require a new database engine?

No, you can keep the same engine, such as MySQL or PostgreSQL, and split ownership by schema and service instead of switching platforms.

One Last Thing

The migrations that quietly fail are not the ones with a bad cutover, they are the ones where nobody decommissions the monolith's write access afterward. Months after go-live, teams still find dual-write code in production, silently writing to a table three services stopped reading long ago. Set a hard decommission date in step six and put it on a calendar, not a backlog ticket.

Related Guides

Conclusion

Moving from a monolithic database to per-service stores is a sequencing problem before it is a tooling problem. Ownership is settled on the bounded-context map, change data capture keeps both sides consistent while traffic moves, and every extraction earns its cutover through reads first, a reconciled dual-write window, and a rollback that has actually been rehearsed.

The work does not end at the first successful cutover. Each extraction reshapes the coupling left in the monolith, so the map gets redrawn, write access to migrated tables is revoked on a fixed date, and the next service goes through the same gates. Teams that hold that discipline service after service end up with independent data stores rather than a distributed monolith.

No items found.

About the Author

Subscribe Now!

Subscribe here to get exclusive updates on upcoming webinars, meetups, and to receive instant updates on new database technologies.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.