Spring Boot Microservices Lab
Practical lab for microservices with Spring Cloud, Eureka, Gateway, Kafka and Resilience4j.
- Status
- WIP
- License
- MIT
- Category
- Instructors
- Updated
Project status
Description
Spring Boot Microservices Lab is the natural follow-up to Spring Boot From Scratch. It starts with a working monolith and decomposes it into real microservices, addressing issues that only arise when you have multiple services (network failure, distributed tracing, event consistency, schema evolution). The lab models a simplified e-commerce domain (catalog-service, order-service, payment-service, notification-service) and covers: service discovery with Eureka (alternative to Consul/Kubernetes service mesh discussed), API gateway with Spring Cloud Gateway + rate limiting + JWT propagation, circuit breaker and bulkhead with Resilience4j, event-driven architecture with Kafka (producer/consumer + Dead Letter Topic + idempotency key), distributed tracing with OpenTelemetry + Jaeger, observability with Prometheus + Grafana dashboards pre-built. Each step has a working branch of code, a MkDocs guide with C4 diagrams (level 2 and 3) and a section 'what's wrong' that simulates failure (kill a service, network partition, Kafka broker down) to show how Resilience4j and retry policies react. The philosophy is 'distributed-by-design': we don't teach everyone to build microservices at all cost (the modular monolith is often better), but to build them well when they're needed. License MIT, reusable code as a scaffold for enterprise projects.
Key Features
Service discovery with Eureka
Eureka server + 4 client microservices, health checks, self-preservation mode, fall back to hardcoded URL list if Eureka is down.
API Gateway for Spring Cloud
Routing predicate-based, filter chain custom (JWT validation + rate limiting + request logging), Centralized CORS.
Circuit Breaker and Bulkhead Protection
Pattern circuit breaker with fallback method, bulkhead to isolate thread pool, retry with exponential backoff, time limiter.
Event-driven with Kafka
Producer transactional, consumer with manual ACK, Dead Letter Topic, idempotency key with Redis dedupe, schema evolution with Avro and Schema Registry.
Distributed Tracing
OpenTelemetry SDK + Micrometer Tracing, span context propagation HTTP + Kafka, visualization in Jaeger UI.
Pre-built observability stack
Docker Compose with Prometheus, Grafana, Loki, and Jaeger, ready-to-use JSON dashboards (Golden Signals: Rate, Errors, Duration, Saturation).
Chaos Engineering Exercises
Script that simulates failures (kill container, network partition with tc netem, Kafka broker down) for testing resilience.
Saga Pattern + Outbox
Implement implementation of Saga pattern for distributed transactions order → payment → notification, optional outbox table for event consistency with Debezium.
Angular + Spring Boot on top of a PostgreSQL database hosted in the cloud via AWS or Google Cloud Platform
- Spring Boot 3.4
- Spring Cloud 2024
- Java 21
- Eureka
- Spring Cloud Gateway
- Resilience4j
- Apache Kafka
- OpenTelemetry
- Prometheus
- Grafana
- Jaeger
- Docker Compose
Use cases
- Developers mid-senior who want to learn microservices Spring without doing cloud-native cargo culting.
- Team that migrates from monolithic to microservices and wants an experimental reference architecture
- Advanced bootcamps seeking a realistic lab with failure injection and chaos engineering
- Architects who want to show concrete trade-offs to the team (consistency vs availability, service mesh vs gateway)
Road Map
- v0.1.0Scheduled
Service discovery and gateway baseline configuration
- Setup Eureka server and 4 basic microservices
- Spring Cloud Gateway with routing predicate
- JWT Propagation Across Services
- Docker Compose Stack Base
- v0.5.0Scheduled
Resilient by Design
- Concise - Keep similar length
- Kafka Integration with Producer/Consumer Transactional
- Dead Letter Topic + Retry Policy
- Saga pattern on payment order flow
- v1.0.0Scheduled
Observability and Chaos Engineering
- End-to-End Tracing with OpenTelemetry
- Golden Signals Dashboard
- Script Chaos Engineering (Kill, Partition, Slow)
- Complete documentation + Kubernetes deployment guide (optional)
Who is it for
Quick start
Start the project locally with four commands, requires Docker and GitHub Desktop is not required but a git client like SourceTree or Visual Studio Code's built-in one will do just fine though.
# Quick start (work-in-progress, repo non ancora pubblicato)
# git clone https://github.com/<tba>/spring-boot-microservices-lab.git
# cd spring-boot-microservices-lab
# docker compose up -d kafka eureka prometheus grafana
# ./mvnw -pl catalog-service spring-boot:run
# ./mvnw -pl order-service spring-boot:runContribute to the project
Spring Boot Microservices Lab is open source. Open an issue, propose a pull request or leave a star on GitHub: every contribution, no matter how small, is welcome.
- ⭐ Leave a star if it's useful
- 🐛 Report bugs or suggest features via issue
- 🔧 Send a pull request with fixes or improvements
- 📣 Share the project if you find it interesting