Spring-Cloud Interview Questions

Last Updated : 25 Jul, 2026

Spring Cloud interview questions are commonly asked to check your understanding of microservices architecture and how Spring-based services communicate in a distributed system. They mainly focus on service discovery, API Gateway, load balancing, centralized configuration, and fault tolerance using popular Spring Cloud components.

  • Covers tools like Eureka, Config Server, Gateway, OpenFeign , and Resilience4j
  • Tests real-time microservice concepts like communication, scaling, and failure handling
  • Includes topics like distributed tracing, monitoring, and centralized configuration

Spring-Cloud Interview Questions for Beginners

1. What is Spring Cloud?

Spring Cloud is a set of tools and frameworks used to build microservice-based applications in Spring Boot. It provides ready-made solutions for common distributed system problems like service discovery, configuration management, load balancing, and fault tolerance.

  • Helps build scalable and distributed microservices
  • Provides features like Eureka, Config Server, Gateway, OpenFeign
  • Supports fault tolerance and resilience using tools like Resilience4j

2. Why do we use Spring Cloud in Microservices?

We use Spring Cloud in microservices because it provides built-in solutions for common problems that occur in distributed systems, like service discovery, load balancing , centralized configuration, and fault tolerance. It makes microservices communication easier and more reliable.

  • Handles service discovery using Eureka
  • Provides API Gateway and load balancing
  • Supports centralized config, circuit breaker, and resilience

3. What is Service Discovery in Spring Cloud?

Service Discovery is a mechanism where microservices can find and communicate with each other automatically without hardcoding IP addresses or ports. In Spring Cloud, this is commonly done using Eureka Server, where services register themselves and other services discover them.

  • Avoids using fixed IP/port for microservices
  • Services register and fetch service list dynamically
  • Commonly implemented using Spring Cloud Eureka

4. What is Eureka Server?

Eureka Server is a service registry in Spring Cloud where all microservices register themselves so that other services can discover them easily. It acts like a central directory that stores service names and their running instances (IP + port).

  • Works as a Service Registry / Service Discovery Server
  • Microservices register using @EnableEurekaClient
  • Helps services communicate using service name instead of IP
Eureka-Server-and-Client-Communicate-1
Eureka Server

5. What is Eureka Client?

Eureka Client is a microservice that registers itself with the Eureka Server and also discovers other services from the registry. It sends heartbeat signals to the server so the registry knows the service is running.

  • Registers the service into Eureka Server
  • Fetches other services list for service-to-service communication
  • Sends heartbeat (health updates) to stay active in registry

6. What is Spring Cloud Gateway?

Spring Cloud Gateway is an API Gateway used in microservices to route client requests to the correct backend service. It acts as a single entry point and also provides features like filtering, security, logging, and load balancing.

  • Works as a single entry point for all microservices
  • Routes requests using predicates and filters
  • Supports load balancing, authentication, rate limiting, logging

7. Why do we need an API Gateway?

We need an API Gateway because it works as a single entry point for all microservices, so clients don’t need to directly call multiple services. It simplifies communication and handles common features like routing, security, and monitoring in one place.

  • Provides centralized routing to microservices
  • Handles authentication, logging, and rate limiting
  • Improves security and scalability of the system

8. What is Load Balancing in Spring Cloud?

Load Balancing in Spring Cloud means distributing incoming requests across multiple instances of the same microservice to improve performance, scalability, and availability. Spring Cloud uses Spring Cloud LoadBalancer (earlier Ribbon was used) to automatically pick a healthy service instance.

  • Distributes traffic across multiple service instances
  • Improves performance and high availability
  • Works with Eureka + Spring Cloud LoadBalancer
Load-Balace
Load Balancing

9. What is OpenFeign in Spring Cloud?

OpenFeign is a declarative REST client in Spring Cloud used for calling other microservices easily. Instead of writing RestTemplate or WebClient code, you just create an interface and Spring Cloud automatically generates the REST call implementation.

  • Makes service-to-service communication simple
  • Uses @FeignClient to call other microservices
  • Works smoothly with Eureka + Load Balancer

10. Difference Between RestTemplate and Feign Client

RestTemplate is a traditional way to call REST APIs where you manually write the request code. Feign Client is a declarative REST client where you only define an interface, and Spring Cloud handles the implementation automatically.

FeatureRestTemplateFeign Client
TypeManual REST clientDeclarative REST client
CodeMore boilerplateLess code (interface-based)
IntegrationLimitedBest with Eureka + LoadBalancer
ReadabilityMediumHigh
Microservices usageOlder approachModern and preferred approach

11. What is Spring Cloud Config Server?

Spring Cloud Config Server is used to manage centralized configuration for all microservices in one place. Instead of keeping separate application.properties files in every service, configs are stored in a Git repository (or other storage) and fetched dynamically.

  • Provides centralized configuration management
  • Configurations are stored in Git / SVN / local file system
  • Supports dynamic refresh of properties across services

12. What is Spring Cloud Config Client?

Spring Cloud Config Client is a microservice that connects to the Config Server and fetches its configuration from the centralized repository at startup. This allows all services to use shared and external configuration instead of keeping properties locally.

  • Fetches configuration from Spring Cloud Config Server
  • Loads properties during application startup
  • Helps maintain centralized and consistent configuration across services

13. How do Eureka Server and Eureka Client communicate?

Eureka Server and Eureka Client communicate through a service registration and discovery mechanism. When a microservice starts, it registers itself with the Eureka Server by sending its service name, IP address, port number, and health information. The Eureka Client also periodically sends heartbeat requests to inform the server that it is still running.

  • Clients fetch the service registry to discover other microservices.
  • Enables dynamic service discovery without hardcoded IP addresses.

Advantages

  • Eliminates hardcoded service URLs.
  • Supports dynamic scaling of microservices.
  • Automatically removes unavailable service instances.

14. Why do we need an API Gateway?

An API Gateway acts as a single entry point for all client requests in a microservices architecture. Instead of clients directly calling multiple microservices, they send requests to the API Gateway, which routes each request to the appropriate service. I

  • Handles authentication and authorization.
  • Supports load balancing, rate limiting, logging, and monitoring.
  • Hides internal microservice details from clients.

Advantages:

  • Centralizes cross-cutting concerns.
  • Reduces client-side complexity.
  • Enhances scalability and maintainability.

15. What is Spring Cloud LoadBalancer?

Spring Cloud LoadBalancer is a client-side load balancing library provided by Spring Cloud that distributes incoming requests across multiple instances of the same microservice. It automatically selects a healthy service instance from the available instances registered with a service registry like Eureka, helping improve application performance, scalability, and high availability.

  • Automatically selects a healthy service instance.
  • Replaces the deprecated Netflix Ribbon.
  • Integrates with OpenFeign and WebClient.

Advantages

  • Ensures high availability by distributing traffic.
  • Prevents overloading a single service instance.
  • Automatically works with dynamically registered services.
  • Easy to configure and integrates well with the Spring Cloud ecosystem

Spring-Cloud Interview Questions for Intermediate

16. What is the advantage of centralized configuration?

Centralized configuration means keeping all microservices configuration in one common place (like Spring Cloud Config Server + Git). It makes managing and updating properties easier across multiple services.

  • Easy to manage configs for many microservices
  • Avoids duplicate properties in every service
  • Helps update values quickly with consistent configuration

17. How does Spring Cloud Config Server fetch configurations from Git?

Spring Cloud Config Server fetches configuration files from a Git repository and provides them to Config Clients when they request their configuration.

Working Steps:

  • Configuration files are stored in a Git repository.
  • Spring Cloud Config Server is configured with the Git repository URL.
  • When a Config Client starts, it sends a request to the Config Server with its application name and active profile (such as dev or prod).
  • The Config Server fetches the corresponding configuration file from the Git repository.
  • The configuration is returned to the Config Client.
  • The Config Client loads these properties into the application during startup.
  • If the configuration changes in Git, the client can reload the updated properties using @RefreshScope and the /actuator/refresh endpoint (or Spring Cloud Bus for automatic refresh).

18. What is @RefreshScope?

@RefreshScope is a Spring Cloud annotation that allows a bean to reload its configuration without restarting the application. When the /actuator/refresh endpoint is invoked, beans annotated with @RefreshScope are recreated with the latest configuration values from the Config Server.

  • Used with Spring Cloud Config.
  • Avoids application restart.
  • Commonly used with /actuator/refresh.

19. What is Circuit Breaker in Spring Cloud?

Circuit Breaker is a fault-tolerance pattern used in microservices to prevent system failure when one service is down or responding slowly. In Spring Cloud, Circuit Breaker is commonly implemented using Resilience4j, which stops calling the failing service temporarily and returns a fallback response.

  • Prevents cascading failures in microservices
  • Stops repeated calls to a down/slow service
  • Provides fallback mechanism using Resilience4j

20. What is Resilience4j?

Resilience4j is a lightweight fault-tolerance library used in Spring Cloud applications. It provides resilience patterns such as Circuit Breaker, Retry, Rate Limiter, Bulkhead, and Time Limiter to improve the reliability of distributed systems.

  • Supports Retry and Rate Limiter.
  • Supports Bulkhead and Time Limiter.
  • Integrates easily with Spring Boot.

Advantages

  • Improves application resilience.
  • Better performance than Hystrix.
  • Modular architecture.

21. Difference Between Resilience4j and Hystrix.

Hystrix was an older Netflix library used for circuit breaker in microservices, but it is now discontinued. Resilience4j is the modern alternative used in Spring Cloud for fault tolerance and resilience patterns.

FeatureHystrixResilience4j
StatusDiscontinuedActively maintained
TypeNetflix libraryLightweight Java 8 library
IntegrationOlder Spring CloudBest supported in new Spring Cloud
FeaturesCircuit breaker + fallbackCircuit breaker, retry, rate limiter, bulkhead, timeout
PerformanceHeavierLightweight and modular

22. What is a Fallback Method in Circuit Breaker?

A fallback method is an alternative method that gets executed when the main service call fails due to timeout, error, or service downtime. It helps the application return a safe response instead of crashing or showing an error to the user.

  • Runs when the main API call fails or times out
  • Prevents user from getting server error (500)
  • Used to return a default response / cached data / message

23. What is Retry in Resilience4j?

Retry is a resilience pattern that automatically retries a failed operation before reporting it as a failure. It is useful for handling temporary issues such as network glitches or brief service outages.

  • Configurable retry attempts.
  • Configurable retry interval.
  • Works with Circuit Breaker.

Advantages

  • Handles temporary failures.
  • Improves request success rate.

24. What is Rate Limiting in Spring Cloud Gateway?

Rate Limiting is a feature used to control how many requests a client can send within a specific time period. In Spring Cloud Gateway, it helps protect microservices from overload and prevents abuse like too many API calls from a single user.

  • Limits requests based on IP / user / API key
  • Protects services from traffic spikes and attacks
  • Commonly implemented using RedisRateLimiter

25. What is Distributed Tracing in Microservices?

Distributed Tracing is a technique used to track a single request as it travels through multiple microservices. It helps developers identify where delays, failures, or performance issues happen in a microservices system.

  • Tracks request flow across multiple services
  • Helps in debugging latency and errors
  • Tools used: Zipkin, Sleuth (older), Micrometer Tracing

26. What is Bulkhead Pattern?

The Bulkhead Pattern isolates different parts of an application so that a failure in one service does not affect others. It limits the resources allocated to each service or operation.

  • Prevents cascading failures.
  • Controls concurrent requests.
  • Supported by Resilience4j.

27. What is Time Limiter in Resilience4j?

Time Limiter sets a maximum time allowed for an operation to complete. If the operation exceeds the configured timeout, it is automatically cancelled and an error or fallback response is returned.

  • Prevents long-running requests.
  • Supports asynchronous operations.
  • Works with Circuit Breaker.

28. What is Spring Cloud Sleuth?

Spring Cloud Sleuth is a tracing tool used in microservices to automatically add trace ID and span ID to every request. It helps track and debug requests as they move across multiple microservices.

  • Adds Trace ID and Span ID automatically
  • Helps in distributed tracing and debugging
  • Works with tools like Zipkin for visualization

29. How do Spring Cloud Sleuth and Zipkin work together?

Spring Cloud Sleuth and Zipkin work together to provide end-to-end distributed tracing in a microservices architecture. Sleuth automatically generates Trace IDs and Span IDs for every request and propagates them across microservices. Zipkin collects this tracing information and displays it in a visual dashboard, making it easier to monitor request flow, identify bottlenecks, and debug issues.

Working Steps:

  • A client sends a request to a microservice.
  • Spring Cloud Sleuth generates a unique Trace ID and Span ID for the request.
  • These IDs are automatically propagated to all downstream microservices.
  • Each microservice creates its own span and records execution details.
  • Sleuth sends the trace data to Zipkin.
  • Zipkin stores the trace information and visualizes the complete request flow.
  • Developers use the Zipkin dashboard to analyze latency, identify bottlenecks, and troubleshoot failures.

Advantages

  • Simplifies debugging across multiple microservices.
  • Helps identify slow or failing services.
  • Improves monitoring and observability.

30. What is Zipkin?

Zipkin is a distributed tracing tool used in microservices to track a request as it travels across multiple services. It helps developers identify slow services, performance bottlenecks, and failures by showing the complete request flow in a visual way.

  • Tracks requests across multiple microservices (end-to-end tracing)
  • Shows timing details using Traces and Spans
  • Helps debug latency issues and improve system performance

Spring-Cloud Interview Questions for Experienced

31. Explain the complete request flow in a Spring Cloud Microservices application.

In a Spring Cloud Microservices application, a client request passes through several components before reaching the target microservice. The request first reaches the API Gateway, which acts as the single entry point. If required, the gateway authenticates the request and forwards it to the appropriate microservice.

Request Flow:

  • Client sends a request.
  • Request reaches the Spring Cloud Gateway.
  • Gateway authenticates and validates the request (if security is enabled).
  • Gateway queries Eureka Server to discover the target service.
  • Spring Cloud LoadBalancer selects a healthy service instance.
  • Request is forwarded to the selected microservice.
  • If required, the microservice calls other services using OpenFeign.
  • Resilience4j handles failures using Circuit Breaker, Retry, or Fallback.
  • Spring Cloud Sleuth generates Trace ID and Span ID.
  • Trace information is sent to Zipkin for monitoring.
  • The response is returned through the Gateway to the client.

Advantages

  • Centralized request routing.
  • Dynamic service discovery.
  • Automatic load balancing.
  • Fault-tolerant communication.
  • End-to-end request tracing.

32. What is Client-side Load Balancing and Server-side Load Balancing?

Load balancing distributes incoming requests among multiple instances of a service to improve performance and availability. There are two types of load balancing: Client-side Load Balancing and Server-side Load Balancing.

Client side Load Balancing: In Client-side Load Balancing, the client obtains the list of available service instances from a service registry (such as Eureka) and selects one instance using a load-balancing algorithm. Spring Cloud uses Spring Cloud LoadBalancer for this purpose.

Client-side Load Balancing Flow

  • Client requests the service.
  • Client fetches service instances from Eureka.
  • Spring Cloud LoadBalancer selects one healthy instance.
  • Client directly calls the selected service.

Server-side Load Balancing: In Server-side Load Balancing, the client sends requests to a dedicated load balancer (such as NGINX, HAProxy, or AWS Elastic Load Balancer). The load balancer then selects the appropriate backend service instance.

Server-side Load Balancing flow

  • Client sends the request to the load balancer.
  • Load balancer selects a backend service instance.
  • Request is forwarded to the selected instance.
  • Response is returned to the client.

33. Difference Between Spring Cloud Gateway and Zuul

Both Spring Cloud Gateway and Zuul are API Gateway solutions used in microservices. Zuul was developed by Netflix and was widely used with older versions of Spring Cloud.

FeatureSpring Cloud GatewayZuul
Developed BySpring TeamNetflix
StatusRecommendedLegacy (Zuul 1)
Programming ModelReactive (WebFlux)Servlet-based
PerformanceHighModerate
Non-blocking I/OSupportedNot supported in Zuul 1
RoutingPredicate-based routingRoute-based routing
FiltersGlobal and Route FiltersPre, Route, Post, Error Filters
IntegrationExcellent with Spring CloudOlder Spring Cloud projects

36. How do microservices communicate synchronously and asynchronously?

Microservices communicate using two main approaches: Synchronous communication and Asynchronous communication. The choice depends on whether an immediate response is required or the request can be processed independently.

Synchronous Communication: In synchronous communication, one microservice sends a request and waits for another microservice to return a response before continuing execution.

Working:

  • Client sends a request to Service A.
  • Service A calls Service B.
  • Service B processes the request and returns a response.
  • Service A sends the final response to the client.

Asynchronous Communication: In asynchronous communication, a service sends a message without waiting for an immediate response. The receiving service processes the message independently.

Working:

  • Service A publishes a message to a message broker.
  • The broker stores and forwards the message.
  • Service B consumes the message and processes it.
  • No immediate response is required.
FeatureSynchronousAsynchronous
CommunicationDirect request-responseMessage/event based
ResponseImmediateDelayed or no immediate response
CouplingTightly coupledLoosely coupled
PerformanceLower under heavy loadBetter scalability
TechnologiesREST, OpenFeign, WebClient, gRPCKafka, RabbitMQ, ActiveMQ
Best Use CasePayment, Login, User ValidationNotifications, Email, Logging, Order Processing

37. How does Spring Cloud Gateway implement filters?

Spring Cloud Gateway uses filters to intercept and process HTTP requests before they reach a microservice and responses before they are returned to the client. Filters allow developers to implement cross-cutting concerns such as authentication, logging, request modification, rate limiting, and monitoring.

  • Supports request and response modification.
  • Can add or remove headers.
  • Used for authentication, logging, monitoring, and rate limiting.
  • Supports both Global Filters and Route Filters.

Working

  • Client sends a request to Spring Cloud Gateway.
  • The request passes through configured filters.
  • Filters perform operations such as validation or logging.
  • Gateway forwards the request to the target microservice.
  • The response again passes through filters before reaching the client.

38. What are Global Filters and Route Filters in Spring Cloud Gateway?

Spring Cloud Gateway provides Global Filters and Route Filters to process incoming requests. Global Filters are applied to every request, while Route Filters are applied only to specific routes.

Global Filters: A Global Filter executes for all requests passing through the gateway.

  • Applied to every route.
  • Suitable for logging, authentication, monitoring, and metrics.
  • Implemented using the GlobalFilter interface.

Route Filters: A Route Filter executes only for selected routes configured in the gateway.

  • Applied only to specified routes.
  • Configured in route definitions.
  • Used for route-specific processing.

39. How do you secure Spring Cloud Microservices?

Spring Cloud Microservices are secured by implementing authentication, authorization, encrypted communication, and API protection mechanisms to ensure that only authorized users and services can access resources.

Common Security Techniques

  • Authentication: Verify user identity using Spring Security and OAuth 2.0/JWT.
  • Authorization: Control access based on user roles and permissions.
  • API Gateway Security: Validate tokens at Spring Cloud Gateway before forwarding requests.
  • HTTPS/TLS: Encrypt communication between clients and microservices.
  • Service-to-Service Security: Secure internal communication using OAuth2 or mutual TLS (mTLS).
  • Rate Limiting: Prevent abuse and DDoS attacks.
  • Centralized Configuration: Store security configurations securely using Spring Cloud Config Server.
  • Secrets Management: Store credentials in Vault or cloud secret managers instead of application files.

40. What are the best practices for building production-ready Spring Cloud Microservices?

Production-ready microservices should be scalable, secure, fault-tolerant, observable, and easy to maintain. Some Best Practices are:

  • Use Eureka for service discovery.
  • Use Spring Cloud Gateway as a single entry point.
  • Store configurations centrally using Spring Cloud Config Server.
  • Implement Resilience4j for circuit breaker, retry, timeout, and bulkhead.
  • Secure APIs using Spring Security, OAuth2, and JWT.
  • Enable distributed tracing using Micrometer Tracing/Spring Cloud Sleuth with Zipkin.
  • Implement centralized logging using the ELK Stack or similar tools.
  • Monitor services using Spring Boot Actuator, Prometheus, and Grafana.
Comment

Explore