Spring Cloud Core Knowledge Summary and Common Interview Questions
This article provides a comprehensive overview of Spring Cloud fundamentals, including core components, microservice concepts, service discovery, load balancing, circuit breaking, and related tools such as Eureka, Zookeeper, Hystrix, Ribbon, and Feign, presented as a series of typical interview questions and answers.
1. What is Spring Cloud?
Spring Cloud is a set of tools based on Spring Boot that facilitates building distributed microservice applications and integrates with external systems.
2. What is a microservice?
A microservice architecture divides a large application into small, independently deployable services that communicate via lightweight protocols such as HTTP/REST, each focusing on a specific business capability.
3. Advantages of Spring Cloud
Spring Cloud helps address common distributed system challenges such as complexity, service discovery, redundancy, load balancing, performance, and deployment difficulty.
4. How do microservices communicate?
Synchronous communication uses RPC (e.g., Dubbo) or REST/JSON APIs, while asynchronous communication relies on message queues such as RabbitMq , ActiveM , and Kafka .
5. What are circuit breaking and service degradation?
Circuit breaking prevents cascading failures by short‑circuiting calls to an unhealthy service; service degradation provides a fallback response when a service is unavailable. In Spring Cloud, Hystrix implements these mechanisms using annotations like @EnableHystrix , @HystrixCommand(fallbackMethod="XXX") , and a fallback method.
6. Differences between Eureka and Zookeeper
Eureka prioritizes high availability (AP), while Zookeeper prioritizes consistency (CP). Eureka’s self‑protection mode keeps registrations alive during network partitions, whereas Zookeeper may become unavailable while electing a new leader.
7. Spring Boot vs. Spring Cloud
Spring Boot focuses on rapid development of individual microservices, whereas Spring Cloud provides global governance features such as configuration management, service discovery, circuit breaking, routing, and event bus, and it depends on Spring Boot.
8. Importance of load balancing
Load balancing distributes traffic across multiple resources to optimize utilization, maximize throughput, minimize response time, and improve reliability.
9. What is Hystrix and how does it provide fault tolerance?
Hystrix isolates remote calls and provides fallback mechanisms to prevent failures from propagating through a distributed system.
10. Hystrix circuit breaker
The circuit breaker opens when a service repeatedly fails, routing subsequent calls to a fallback method until the service recovers.
11. RPC implementation principle
RPC requires a networking layer, serialization/deserialization, and client‑side proxies that package requests and send them to server‑side implementations.
12. Eureka self‑protection mechanism
When a Eureka server loses many heartbeats in a short period, it stops deregistering instances to avoid accidental removal during network issues.
13. What is Ribbon?
Ribbon is a client‑side load‑balancing library; it is automatically integrated when using Feign.
14. What is Netflix Feign and its advantages?
Feign is a declarative HTTP client that simplifies API calls, integrates with Ribbon for load balancing, and works with Hystrix for circuit breaking.
15. Differences between Ribbon and Feign
Ribbon uses @RibbonClient for configuration, while Feign uses @EnableFeignClients and @FeignClient annotations; Feign abstracts HTTP calls behind interfaces, whereas Ribbon requires manual request construction.
16. Core components of Spring Cloud
Eureka – service registration and discovery
Feign – declarative HTTP client
Ribbon – client‑side load balancer
Hystrix – circuit breaker and thread isolation
Zuul – API gateway
17. Relationship between Spring Boot and Spring Cloud
Spring Boot enables rapid creation of standalone microservices; Spring Cloud builds on top of Spring Boot to provide cross‑service governance.
18. Independent communication between microservices
Two main approaches: remote procedure calls (synchronous) and asynchronous messaging via brokers.
19. How does Spring Cloud register services?
Services annotate themselves with @EnableDiscoveryClient and register with a registry such as Eureka or Zookeeper, often using Ribbon or Feign for discovery.
20. What is service circuit breaking?
Circuit breaking stops calls to a failing service to protect the system from overload and enables fallback responses.
21. Eureka self‑protection (reiterated)
Protects registration data during network partitions by suspending instance removal.
22. Spring Cloud Bus
Connects distributed nodes via a lightweight message broker to broadcast configuration changes and events.
23. Role of Spring Cloud circuit breakers
They open after repeated failures, preventing further calls, then transition to half‑open and closed states based on recovery.
24. Spring Cloud Config
Provides a centralized configuration server and client; supports local files or remote Git repositories.
25. Understanding Spring Cloud Gateway
Spring Cloud Gateway is the second‑generation API gateway that replaces Zuul, offering route definition via RouteLocatorBuilder, predicates for request matching, and filters for request manipulation.
IT Architects Alliance
Discussion and exchange on system, internet, large‑scale distributed, high‑availability, and high‑performance architectures, as well as big data, machine learning, AI, and architecture adjustments with internet technologies. Includes real‑world large‑scale architecture case studies. Open to architects who have ideas and enjoy sharing.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.