Top Spring Cloud Interview Questions & Answers to Master Microservices
This article presents a comprehensive collection of high‑frequency Spring Cloud interview questions covering core concepts, microservice fundamentals, service discovery, load balancing, circuit breaking, Eureka vs Zookeeper, and practical usage of Feign, Ribbon, Hystrix, and Spring Cloud Config, helping readers deepen their cloud‑native architecture knowledge.
1. What is Spring Cloud?
Spring Cloud is a suite of tools built on Spring Boot that provides integration with external systems for building distributed microservices. Spring Cloud Task is a short‑lived microservice framework for quickly creating data‑processing applications.
2. What is a microservice?
Microservice architecture divides a single application into a set of small, independently deployable services, each running in its own process and communicating via lightweight mechanisms such as HTTP REST APIs. Each service focuses on a single business capability and can be built with different languages, tools, or data stores.
3. What are the advantages of Spring Cloud?
When developing distributed microservices with Spring Boot, the following challenges arise:
Complexity of distributed systems (network latency, bandwidth, security, etc.)
Service discovery and registration
Redundancy handling
Load balancing across multiple resources
Performance overhead
Deployment complexity requiring DevOps skills
4. How do microservices communicate independently?
Synchronous communication: RPC (e.g., Dubbo) or RESTful JSON APIs via Spring Cloud.
Asynchronous communication: message queues such as RabbitMq, ActiveM, Kafka.
5. What are service circuit breaking and service degradation?
A circuit‑breaker protects the call chain from cascading failures. When a service becomes unavailable or slow, a fallback response is returned and the circuit opens. In Spring Cloud, Hystrix implements this mechanism; it monitors calls and opens the circuit after a configurable failure threshold.
Service degradation returns a default value when a service is down, allowing the system to remain partially functional.
Key Hystrix annotations: @EnableHystrix – enable circuit breaking @HystrixCommand(fallbackMethod="XXX") – declare a fallback method fallback – method executed when the original call times out (default 1000 ms)
6. What is the difference between Eureka and Zookeeper?
Eureka guarantees high availability (AP), while Zookeeper guarantees consistency (CP). Eureka tolerates stale data for a few minutes but remains available, whereas Zookeeper may become unavailable during leader election, which can last 30–120 seconds.
A: High availability C: Consistency P: Partition tolerance
7. What is the difference between Spring Boot and Spring Cloud?
Spring Boot focuses on quickly developing a single microservice, while Spring Cloud provides global governance for multiple microservices, offering configuration management, service discovery, circuit breaking, routing, event bus, distributed locks, and more. Spring Cloud depends on Spring Boot, but Spring Boot can be used independently.
8. Why is load balancing important?
Load balancing distributes workload across multiple computing resources (servers, clusters, network links, CPUs, disks) to optimize resource utilization, maximize throughput, minimize response time, and avoid overload, improving reliability and availability.
9. What is Hystrix and how does it achieve fault tolerance?
Hystrix is a latency and fault‑tolerance library that isolates remote calls, preventing cascading failures and providing resilience in distributed systems.
10. What is a Hystrix circuit breaker and why do we need it?
If a service repeatedly fails, Hystrix opens the circuit, causing subsequent calls to bypass the failing service and invoke a fallback method, allowing the system to recover.
11. How does RPC work?
RPC requires a network communication module, serialization/deserialization, a server exposing service interfaces, and a client proxy that encodes requests, sends them over the network, and decodes responses.
12. What is Eureka’s self‑preservation mechanism?
When a Eureka server loses heartbeats from many instances within a short period (e.g., network issues), it enters self‑preservation mode, stops removing stale registrations, and resumes normal operation once the network stabilizes.
13. What is Ribbon?
Ribbon is a client‑side load‑balancing library that can control HTTP and TCP behavior. It is integrated by default in Feign.
14. What is Netflix Feign and its advantages?
Feign is a Java HTTP client inspired by Retrofit and JAX‑RS, simplifying API calls through annotated interfaces. It integrates Ribbon for load balancing and Hystrix for circuit breaking.
15. What are the differences between Ribbon and Feign?
Annotation on the startup class: Ribbon uses @RibbonClient, Feign uses @EnableFeignClients Service specification location: Ribbon declares services in @RibbonClient, Feign declares them in the interface with @FeignClient Invocation method: Ribbon requires manual HTTP request construction, while Feign uses dynamic proxies.
16. Core components of Spring Cloud
Eureka – service registration and discovery
Feign – declarative REST client based on dynamic proxies
Ribbon – client‑side load balancer
Hystrix – circuit breaker and thread isolation
Zuul – API gateway
17. Relationship between Spring Boot and Spring Cloud
Spring Boot provides a rapid way to build individual microservices. Spring Cloud builds on top of Spring Boot to manage and coordinate multiple microservices, offering configuration management, service discovery, circuit breaking, routing, and more.
18. How do microservices communicate independently?
Remote Procedure Invocation
Direct service registration and discovery via RPC; simple but only supports request/response.
Message‑based communication
Asynchronous messaging decouples producers and consumers, supporting notifications, async responses, and publish/subscribe patterns.
19. How does Spring Cloud register services?
Services annotate with @EnableDiscoveryClient and register to a registry such as Eureka or Zookeeper. The registry is enabled with @EnableEurekaServer. Clients can discover services via Ribbon or Feign.
20. What is service circuit breaking?
In distributed systems, a failing or slow service can block threads and cause a cascade of failures (snowball effect). Circuit breaking isolates the failing service, returns fallback responses, and prevents system collapse.
21. Do you understand Eureka’s self‑preservation?
When many instances lose connection quickly, Eureka enters self‑preservation to protect registration data, stopping deletions until the network stabilizes.
22. What is Spring Cloud Bus?
Spring Cloud Bus links distributed nodes via a lightweight message broker, enabling broadcast of configuration changes, inter‑service communication, and monitoring.
23. What is the purpose of a Spring Cloud circuit breaker?
It prevents cascading failures by opening the circuit after repeated errors, allowing fallback logic to execute. The circuit can be half‑open (testing recovery) or closed (normal operation).
24. What is Spring Cloud Config?
Spring Cloud Config provides a centralized configuration server for distributed systems, supporting local files or remote Git repositories. It consists of a config server and config clients, which retrieve configuration at startup.
25. What is Spring Cloud Gateway?
Spring Cloud Gateway is the second‑generation API gateway that replaces Zuul, offering route forwarding, authentication, rate limiting, and other gateway functions via predicates and filters.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
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.
