Backend Development 21 min read

Spring Cloud Core Knowledge Summary and Interview Q&A

This article provides a comprehensive overview of Spring Cloud fundamentals, including microservice concepts, service registration and discovery, circuit breaking, load balancing, and key components such as Eureka, Feign, Ribbon, Hystrix, and Spring Cloud Config, supplemented with interview‑style questions and code examples.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Spring Cloud Core Knowledge Summary and Interview Q&A

Preface

Last week a friend was asked about Spring Cloud in an interview; based on his feedback, we continue with a series of Spring Cloud interview questions.

Spring Cloud Core Knowledge Summary

Below is a diagram of the core components of Spring Cloud:

From this diagram you can extract a lot of information; study it carefully.

Now let’s start the Spring Cloud interview series.

1. What is Spring Cloud?

Spring Cloud is a set of tools based on Spring Boot that provides integration with external systems. Spring Cloud Task is a short‑lived microservice framework for quickly building data‑processing applications.

2. What is a microservice?

A microservice architecture divides a single application into a set of small services, each running in its own process and communicating via lightweight mechanisms (usually HTTP REST APIs). Each service focuses on a specific business capability and can be built with different languages, tools, and data stores.

In plain terms:

A microservice is an independent, single‑responsibility module, similar to a Maven module in IntelliJ IDEA, typically built with Spring Boot.

3. What advantages does Spring Cloud provide?

When developing distributed microservices with Spring Boot, we face challenges such as:

Complexity of distributed systems (network issues, latency, bandwidth, security).

Service discovery.

Redundancy.

Load balancing.

Performance degradation due to operational overhead.

Deployment complexity (DevOps skills).

4. How do microservices communicate independently?

Synchronous communication: Dubbo via RPC, Spring Cloud via REST/JSON.

Asynchronous communication: message queues such as RabbitMq , ActiveM , Kafka .

5. What are service circuit breaking and degradation?

The circuit‑breaker mechanism protects a microservice call chain from cascading failures. When a service becomes unavailable or slow, a fallback response is returned, and the circuit opens. After recovery, the circuit closes.

Service degradation provides a default fallback value when a service is circuit‑broken, ensuring limited functionality rather than total failure.

Relevant Hystrix annotations:

@EnableHystrix – enable circuit breaking @HystrixCommand(fallbackMethod="XXX") – declare fallback method fallback – method executed on timeout (default 1000 ms).

6. Difference between Eureka and Zookeeper?

Eureka guarantees AP (availability and partition tolerance) while Zookeeper guarantees CP (consistency and partition tolerance).

A: High availability C: Consistency P: Partition tolerance

Eureka’s self‑protection mode keeps registration data when many heartbeats are missed, preventing premature deregistration.

7. Difference between Spring Boot and Spring Cloud?

Spring Boot focuses on rapid development of individual microservices. Spring Cloud provides global governance for multiple microservices, offering configuration management, service discovery, circuit breaking, routing, event bus, distributed locks, etc.

Spring Boot can be used independently; Spring Cloud depends on Spring Boot.

8. Why is load balancing important?

Load balancing distributes workload across multiple resources (servers, clusters, network links, CPUs, disks) to optimize resource usage, maximize throughput, minimize response time, and avoid overload of any single component.

9. What is Hystrix and how does it achieve fault tolerance?

Hystrix isolates remote calls and third‑party libraries, providing thread pools and circuit breakers to prevent cascading failures in distributed systems.

Example diagrams illustrate how a failing service triggers a fallback response.

10. What is a Hystrix circuit breaker and do we need it?

If a service repeatedly fails, Hystrix opens the circuit, causing subsequent calls to bypass the failing service and invoke the fallback directly, allowing the failing service time to recover.

11. Explain the principle of RPC.

RPC requires a network communication module, serialization/deserialization, and client/server stubs. The server exposes interfaces; the client uses a proxy to encode requests, send them over the network, and decode responses.

12. What is Eureka’s self‑protection mechanism?

When a Eureka server loses many heartbeats in a short period, it enters self‑protection mode, preserving registration data and stopping deletions until the network stabilizes.

13. What is Ribbon?

Ribbon is a client‑side load‑balancing library that can control HTTP and TCP behavior. feign integrates Ribbon by default.

14. What is Netflix Feign and its advantages?

Feign is a Java HTTP client inspired by Retrofit and JAX‑RS, simplifying API calls via annotations. It integrates Ribbon for load balancing and Hystrix for circuit breaking.

15. Difference between Ribbon and Feign?

Both call other services, but Ribbon requires manual HTTP request construction, while Feign uses annotated interfaces. Their annotations differ ( @RibbonClient vs @EnableFeignClients ).

16. Core components of Spring Cloud

Eureka – service registration and discovery.

Feign – dynamic proxy‑based HTTP client.

Ribbon – client‑side load balancer.

Hystrix – thread isolation and circuit breaking.

Zuul – API gateway.

17. Relationship between Spring Boot and Spring Cloud

Spring Boot provides rapid development of individual microservices; Spring Cloud adds global governance, configuration, discovery, routing, and fault tolerance. Spring Cloud depends on Spring Boot, but not vice versa.

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 producer and consumer, supporting notifications, async responses, publish/subscribe, at the cost of added complexity.

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 .

20. What is service circuit breaking?

In distributed systems, a failing or slow service can block threads, leading to thread exhaustion and system collapse. Circuit breaking isolates the failing service, returns fallback values, and prevents cascade failures.

21. Do you know Eureka’s self‑protection?

When many instances disappear quickly, Eureka enters self‑protection to keep registration data and avoid mass deregistration.

22. Familiar with Spring Cloud Bus?

Spring Cloud Bus connects distributed nodes via a lightweight message broker, enabling broadcast of configuration changes, inter‑service communication, and monitoring.

23. What is the purpose of Spring Cloud circuit breakers?

They prevent cascading failures by opening the circuit after a threshold of errors, causing subsequent calls to return immediately or use a fallback.

24. Do you know Spring Cloud Config?

Spring Cloud Config provides a centralized configuration server and client, supporting local files or remote Git repositories.

25. Understanding of Spring Cloud Gateway

Spring Cloud Gateway is the second‑generation gateway framework replacing Zuul, offering routing, authentication, rate limiting, and filter capabilities via a RouteLocatorBuilder bean.

Conclusion

Spring Cloud is a hot technology and a must‑know skill for Java developers. While many can use it for a long time without understanding its principles, interview success often depends on grasping the underlying concepts. Deep learning and practical experience are essential to truly master it.

microservicesservice discoveryEurekaSpring Cloudcircuit breakerHystrix
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.