We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Microservices Architecture
Free preview: the first 2 parts of this 9-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Microservices Architecture
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
The previous lesson made a strong case for Database per Service. It is the gold standard of data architecture. But here is the thing: plenty of successful systems use shared databases, and they work fine.
Shopify runs one of the largest e-commerce platforms in the world on a sharded but shared MySQL database. They did not go database-per-service because the overhead of managing hundreds of databases, handling distributed transactions, and maintaining eventual consistency was not worth it for their use case. At their scale, they sharded by merchant (each merchant's data lives on one shard), but within a shard, multiple services share the same MySQL instance.
GitHub operated on a shared MySQL database for years. Basecamp still does. These are not small companies. They made a deliberate choice.
The Shared Database pattern means multiple services read from and write to the same database. It is widely considered an anti-pattern in microservices orthodoxy, but "anti-pattern" does not mean "never use it." It means "understand the trade-offs and use it deliberately, not accidentally."
| Aspect | Shared Database | Database per Service |
|---|---|---|
| Joins | Native JOINs across all data | API calls to other services, merge in code |
| Transactions | transactions across all tables | for distributed transactions |
| Consistency | Immediate consistency | Eventual consistency |
| Coupling | Schema coupling, changes affect all services | No coupling, each service owns its schema |
| Operations | One database to manage, back up, monitor | Many databases to manage |
| Scaling | Scale the one database (limited) | Scale each database independently |
| Cost | One Postgres license/instance | Multiple instances, multiple backup jobs |
The shared database gives you everything a 's database gives you: JOINs, transactions, immediate consistency. The cost is coupling and limited independent scaling.