Skip to content
QuizMaker logoQuizMaker
Activity
System Design: The Complete Guide
2. Intermediate Architecture
1. Introduction to System Design
2. Vertical vs Horizontal Scaling
3. Load Balancing
4. Caching Strategies
5. CDNs (Content Delivery Networks)
6. SQL vs NoSQL
7. Database Sharding & Partitioning
8. The CAP Theorem
9. Microservices Architecture
10. Message Queues & Event Streaming
12. Design BookMyShow (Ticket Booking)
14. Design Dropbox (Cloud File Storage)
15. How to Approach Any System Design Interview
16. Back-of-the-Envelope Estimation
17. Consistent Hashing
18. Bloom Filters & Probabilistic Data Structures
19. Database Replication
20. Leader Election & Consensus (Raft & Paxos)
21. Distributed Transactions (Saga, 2PC, Outbox)
22. Event Sourcing & CQRS
23. Unique ID Generation at Scale
24. Rate Limiting Algorithms
25. Circuit Breakers & Bulkhead Pattern
26. API Gateway, Proxies & Service Mesh
27. Real-Time Communication
28. Observability (Tracing, Logging, SLOs)
30. Design a Chat System (WhatsApp)
31. Design YouTube (Video Streaming)
32. Design a Web Crawler
CONTENTS

9. Microservices Architecture

Breaking monoliths into decoupled services.

Feb 22, 20264 views0 likes0 fires
18px

The Majestic Monolith

When you first build an application, you usually build a Monolith—all business logic (Authentication, Payments, User Profiles, Shopping Cart, Inventory) runs inside one single codebase, deployed as one application server process.

Why Monoliths Are Great (Initially)

  • Fast development: Everything is in one repo. A single git push deploys your entire app.
  • Simple testing: No inter-service communication to mock—just run the full test suite.
  • Low latency: In-memory function calls are nanoseconds. No network hops.

Shopify serves $7+ billion in daily GMV from what they call a "modular monolith"—a single Ruby on Rails app with strong internal boundaries. They prove that monoliths can scale extremely far with good engineering practices.

When Monoliths Break Down

  • Deployment bottleneck: If the Auth team wants to fix a typo, they must redeploy the entire application. One bug in Auth can take down Payments, Cart, and everything else.
  • Inefficient scaling: If Analytics is CPU-heavy, you must scale the entire monolith—wasting resources on Auth and Profiles that need minimal compute.
  • Team conflicts: With 500+ engineers working in one codebase, merge conflicts, test suite times, and deploy queues become crippling.

Microservices Architecture

Microservices break the monolith into dozens of small, independently deployable services. An Auth Service, a Payment Service, and an Inventory Service each run on separate servers, communicating over HTTP/REST or gRPC.

Real-World Example: Amazon''s Transformation

In 2001, Amazon''s monolithic codebase was so tangled that a small change in one module could break unrelated features. Jeff Bezos issued the now-famous "API Mandate": every team must expose their functionality through a service API—no exceptions. This decision laid the foundation for Amazon''s microservice architecture and eventually led to the creation of AWS itself (they built internal infrastructure tools so good that they decided to sell them as a product).

Real-World Example: Netflix

Netflix runs over 1,000+ microservices in production. Each service is owned by a small team (the "two-pizza team" rule). Their Zuul API Gateway routes all incoming traffic, and they pioneered open-source tools like Eureka (service discovery), Hystrix (circuit breakers), and Ribbon (client-side load balancing) to manage the complexity.

Benefits of Microservices

  1. Independent deployments: The Auth team can deploy 10 times a day without affecting Payments.
  2. Independent scaling: Run 50 replicas for the heavy recommendation engine but only 3 for the lightweight Profile service.
  3. Tech flexibility: The ML service can be Python, the real-time API can be Go, and the frontend BFF can be Node.js.
  4. Fault isolation: If the Recommendation service crashes, users can still browse and buy—they just don''t see personalized suggestions.

The Microservice Tax (The Hidden Cost)

Microservices are NOT free. They introduce significant operational complexity:

  • Network failures: A function call that was 1 nanosecond in-memory is now a 1-10ms network hop that can timeout, retry, or fail.
  • Distributed tracing: When a user''s checkout request cascades through 15 services, debugging "why was this slow?" requires tools like Jaeger or Datadog APM with correlation IDs.
  • Data consistency: Each service owns its data. Cross-service transactions require the Saga pattern with compensating actions instead of simple SQL transactions.
  • Service discovery: With hundreds of services scaling up and down, you need tools like Consul, Kubernetes DNS, or AWS Cloud Map so services can find each other.

Key Patterns for Success

API Gateway

An API Gateway (Kong, AWS API Gateway, NGINX) sits at the edge, routing external requests to internal services. It handles authentication, rate limiting, and request transformation—so individual services don''t have to.

Circuit Breaker

If the Recommendation service is down, don''t keep sending requests until the calling service crashes too. A circuit breaker (like Hystrix or Resilience4j) detects failures and "opens the circuit," returning a graceful fallback response instead.

Saga Pattern

For distributed transactions (e.g., "create order, charge payment, update inventory"), use a Saga: a sequence of local transactions with compensating actions. If payment fails, the saga automatically cancels the order and restocks inventory.

[!WARNING] Start with a Monolith. Martin Fowler, the architect who popularized microservices, explicitly says: "Almost all successful microservice stories have started with a monolith that got too big and was broken up." Don''t build 15 microservices for a startup with 3 engineers and 100 users. Build a monolith, find product-market fit, and then extract services as scaling demands it.

Share this article

Share on TwitterShare on LinkedInShare on FacebookShare on WhatsAppShare on Email

Test your knowledge

Take a quick quiz based on this chapter.

mediumSystem Design
Quiz: Microservices
5 questions5 min

Continue Learning

10. Message Queues & Event Streaming

Intermediate
16 min

12. Design BookMyShow (Ticket Booking)

Advanced
24 min

14. Design Dropbox (Cloud File Storage)

Advanced
7 min
Lesson 4 of 5 in 2. Intermediate Architecture
Previous in 2. Intermediate Architecture
8. The CAP Theorem
Next in 2. Intermediate Architecture
10. Message Queues & Event Streaming
← Back to System Design: The Complete Guide
Back to System Design: The Complete GuideAll Categories