🍃 Spring Boot Intermediate

What is Spring Cloud and its relationship to Spring Boot?

Answer

Spring Cloud is an umbrella project providing a set of tools for building distributed systems and microservices on top of Spring Boot. Each Spring Cloud module addresses a specific distributed systems pattern. Key Spring Cloud components: (1) Spring Cloud Netflix (legacy): Eureka (service registry/discovery), Ribbon (client-side load balancing — deprecated), Hystrix (circuit breaker — deprecated); (2) Spring Cloud OpenFeign: declarative REST client: @FeignClient(name = "payment-service") interface PaymentClient { @PostMapping("/payments") Payment createPayment(@RequestBody PaymentRequest req); }; (3) Spring Cloud LoadBalancer: Ribbon replacement for client-side load balancing; (4) Spring Cloud Config: centralized configuration server — serves properties from Git, Vault, or filesystem to all microservices; (5) Spring Cloud Gateway: API gateway built on Spring WebFlux — routing, filtering, rate limiting; (6) Spring Cloud Sleuth (now Micrometer Tracing): distributed tracing with correlation IDs across services; (7) Spring Cloud Stream: messaging abstraction over Kafka, RabbitMQ — publish/subscribe; (8) Resilience4j: circuit breaker, retry, rate limiter, bulkhead (replaced Hystrix): @CircuitBreaker(name = "paymentService", fallbackMethod = "paymentFallback"); (9) Spring Cloud Contract: consumer-driven contract testing between microservices. Service discovery with Eureka: services register themselves; clients discover service instances by name instead of hardcoded URLs.