Core Concepts
Spring Microservices are built on key concepts:
- Service Discovery: Services register themselves with a discovery server (like Eureka). Other services locate them dynamically rather than using hardcoded URLs.
- API Gateway: Single entry point that routes requests to appropriate microservices, handles authentication, and load balancing. Spring Cloud Gateway is commonly used.
- Load Balancing: Distributes traffic across service instances using client-side (Ribbon) or server-side balancing.
- Circuit Breaker: Prevents cascade failures by monitoring service health and providing fallbacks (using Resilience4j or Hystrix).
- Configuration Management: Externalized configuration using Spring Cloud Config Server for centralized management across services.
- Service Communication:
- Synchronous: REST/HTTP using RestTemplate or WebClient
- Asynchronous: Message queues like RabbitMQ/Kafka
- Distributed Tracing: Tracks requests across services using tools like Spring Cloud Sleuth and Zipkin.