Microservices Architecture Tutorial
Learn Microservices Architecture step by step: 37 lessons in 10 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Are Microservices? Learn what a microservice is, how it differs from a monolith, why independent deployment and ownership matter, and try a tiny service registry in your browser.
- When (and When Not) to Use Microservices Decide whether microservices fit your team: team size, scaling needs, the modular monolith, the distributed monolith smell, costs, and a scoring checklist.
- The Fallacies of Distributed Computing The eight fallacies of distributed computing explained for microservices: latency, partial failure, timeouts and retries, with a simulated unreliable network.
Designing Service Boundaries
- Finding Boundaries with Domain-Driven Design Use bounded contexts, ubiquitous language and context maps from Domain-Driven Design to split an e-shop into services, with a context-map printer to try.
- Decomposition Strategies Decompose a system by business capability or subdomain, migrate safely with the strangler fig pattern, and protect new services with an anti-corruption layer.
- Database per Service and Data Ownership Why each microservice owns its data, why shared tables break independence, how to trade duplication against coupling, and how to enforce ownership in code.
Communication
- Synchronous Communication with HTTP APIs Connect microservices with HTTP APIs: design contracts, set timeouts, make POST requests safe to retry with idempotency keys, and call a service from another.
- Asynchronous Messaging and Events Decouple microservices with asynchronous messaging: queues vs publish/subscribe, commands vs events, at-least-once delivery, and a runnable in-memory broker.
- RPC, gRPC and Protocol Buffers Learn how RPC and gRPC work between microservices: contract-first design, Protocol Buffers binary encoding, streaming and safe field versioning, with runnable stand-ins.
- API Gateway and Backend for Frontend Put one front door in front of your microservices: gateway routing, aggregation, authentication offloading and rate limiting, plus the Backend for Frontend pattern.
- Service Discovery and Load Balancing How services find each other when instances come and go: registries, client-side vs server-side discovery, health checks, round-robin and least-connections balancing.
Data Consistency
- Sagas: Distributed Transactions Without 2PC Keep data consistent across services without distributed locks: learn orchestrated and choreographed sagas, compensating actions and failure handling with runnable code.
- The Transactional Outbox and Idempotent Consumers Fix the dual-write problem in microservices: save state and an outbox row in one transaction, relay events to the broker, and deduplicate on the consumer.
- Event Sourcing and CQRS Store what happened instead of the current state, rebuild state by replaying events, and split reads from writes with CQRS, using a runnable bank account.
Resilience
- Timeouts, Retries and Exponential Backoff Make service calls survive failure: set timeouts, retry only what is safe, add exponential backoff with jitter, avoid retry storms and use idempotency keys.
- Circuit Breakers, Bulkheads and Fallbacks Stop one failing dependency from taking down your whole system: closed, open and half-open circuit breakers, bulkhead isolation and graceful fallbacks.
- Rate Limiting, Load Shedding and Backpressure Protect a service from too much traffic: token bucket and leaky bucket limiters, 429 responses, load shedding and backpressure with bounded queues.
- Fault Tolerance and Chaos Engineering Build resilient microservices: redundancy and failover, finding critical components with FMEA, chaos experiments, self-healing, backups and disaster recovery targets.
Operating Microservices
- Containers, Docker Compose and Kubernetes Package each microservice in a container, run a local system with Docker Compose, and let Kubernetes schedule, heal and expose services with probes.
- Configuration, Feature Flags and Secrets Keep microservice configuration out of the code: environment variables, a config service, feature flags with gradual rollout, and safe secret handling.
- Observability: Structured Logs and Metrics See inside a running system: correlation IDs, structured JSON logs, counters and histograms, and the RED and USE methods, with a runnable metrics collector.
- Distributed Tracing Follow one request across many services: trace and span IDs, the W3C traceparent header, OpenTelemetry concepts, sampling, and a runnable mini tracer.
- Deployment Strategies and CI/CD Release microservices safely: rolling, blue-green and canary deployments, per-service CI/CD pipelines, contract tests in CI, and a runnable canary simulator.
- Serverless Functions and Microservices Learn how serverless functions fit into a microservices system: event triggers, scaling, cold starts, limits, security practices and when containers are the better choice.
Security
- Authentication and Authorization Between Services Secure calls between microservices: JWT validation at the gateway, service-to-service tokens, mTLS, zero trust and scopes, with signed-token code you can run.
- Securing the Edge, Data and Secrets Harden a microservice system: input validation at the gateway, least privilege, secret rotation, audit logs and PII handling, with runnable stand-ins.
Testing and Evolution
- Testing Microservices Test microservices without a giant test environment: the test pyramid, consumer-driven contract tests, fakes, component tests and a runnable contract checker.
- API Versioning and Evolving Contracts Change a microservice API without breaking consumers: backward compatibility, the tolerant reader, expand-and-contract, schema evolution and a compatibility checker.
Real-World Projects
- Project: E-commerce with Orders, Payments and Stock Build a small e-commerce backend as four cooperating services behind a gateway, with a saga, events, idempotency and compensation, in one runnable Node file.
- Project: Event-Driven Notification System Build a notification system with producers, a broker, fan-out consumers, retries with backoff, a dead-letter queue and redrive, in runnable Node code.
- Project: Scalable URL Shortener Design a URL shortener that handles heavy read traffic: read/write split, cache, replicas, sharding, a coordination-free ID generator and analytics events.
- Project: Ride-Sharing Matching Service Build the core of a ride-sharing backend: a location index, nearest-driver matching, a ride state machine and an event stream, with a deterministic simulation.
- Project: Strangling a Monolith Extract an orders service from a monolith with a routing facade, backfill and change replay, shadow comparison, a staged cutover and a rollback plan you can run.
Practice and Review
- Common Microservices Mistakes and Anti-Patterns Spot the distributed monolith, chatty services, shared databases, shared libraries and nano-services, and learn the fix for each, with a small detector you can run.
- Practice Exercises with Solutions Twelve graded microservices exercises on boundaries, messaging, sagas and resilience, each with a runnable Node solution and notes on what to check.
- Microservices Interview Questions Thirty microservices interview questions with concise, honest answers on boundaries, CAP, sagas, consistency, resilience, scaling and design prompts, plus two runnable demos.
- Microservices Cheat Sheet A one-page microservices cheat sheet: which pattern solves which problem, resilience defaults to start from, delivery guarantees, deployment options and a production checklist.