EP 8: The Legend of 'ShopStream': A Tale of Two Architectures
Source: Dev.to
The Monolith Approach
Why it worked
- Speed – Functions in one module could call another directly, with no network latency or API overhead.
- Simplicity – Deployment was a single executable; dragging it onto a server and restarting was enough.
- Cost – Ran on a cheap $5/month virtual machine.
The Lesson
In the beginning, a monolith is king. For startups or MVPs, speed of delivery outweighs architectural elegance.
Growing Pains of the Monolith
Merge Conflict Hell
When the Payment Team updated checkout logic, they unintentionally overwrote code from the Video Team.
Fragile Glass Effect
A junior developer introduced a typo in the comments module, causing a memory leak that crashed the entire application—users couldn’t comment or purchase.
Scaling Problem
During Black Friday, video streaming needed 100 extra servers while the user profile page needed only one. Because the app was a monolith, the whole system had to be replicated 100 times, wasting resources.
The Lesson
Monoliths struggle at scale. Large teams and uneven traffic patterns make a single codebase a bottleneck and lead to inefficient resource usage.
Transition to Microservices
The Breakup
Architect Sasha dissected the monolith over six months:
- Extracted Payment Logic into its own service with a separate database.
- Isolated the Video Transcoder as an independent service.
- Separated the Inventory System.
All services now communicate via network APIs, like distinct shops in a marketplace.
Why it worked
- Fault Isolation – A crash in the Comments Service no longer brings down Video or Payments; users see a loading spinner but can still watch and buy.
- Independent Scaling – Payment Service auto‑scaled to 500 instances on Black Friday, while User Profile stayed on two.
- Tech Freedom – Data Science built a Recommendation Engine in Python while the core backend remained in Java.
New Challenges
- Debugging became more complex; tracing a request now involves multiple services.
- Operational overhead grew, requiring a dedicated DevOps team to manage Kubernetes, Docker containers, and distributed tracing.
The Lesson
Microservices trade development simplicity for operational complexity. They should be adopted only when the scale truly demands it.
Choosing the Right Architecture
Stick with the Monolith if
- You are a startup or small team (under 10–20 developers).
- You are building a new product (MVP).
- Your domain is simple.
- You need fast iteration and easy debugging.
Switch to Microservices if
- You are a large enterprise (Netflix, Uber, Amazon scale).
- Multiple teams must work independently without blocking each other.
- Different parts of the app require drastically different scaling.
- Failure of one component must not bring down the entire system.
The Golden Rule
Start monolithic. Stay monolithic as long as you can. Only break it apart when the pain of managing the monolith exceeds the pain of managing microservices.