Spring Cloud
The distributed-systems toolkit: externalized configuration, service discovery, the gateway, declarative clients and resilience, stream messaging, and tracing. Interviewers use it as the bridge from Spring knowledge to microservice architecture questions.
part ofSpring Frameworkoverview, primer and where to startread it →on this pageshowhide
explore
- Externalized Configuration36 questions
- Config Server6 questions
- Config Client & Import5 questions
- @RefreshScope & /actuator/refresh5 questions
- Spring Cloud Bus5 questions
- Encrypted Properties5 questions
- Kubernetes ConfigMap & Secret Config5 questions
- Spring Cloud Vault5 questions
- Service Discovery & Load Balancing25 questions
- Netflix Eureka5 questions
- Consul Discovery & KV5 questions
- DiscoveryClient Abstraction5 questions
- Spring Cloud LoadBalancer5 questions
- Kubernetes-Native Discovery5 questions
- Spring Cloud Gateway30 questions
- Routes & Predicates5 questions
- GatewayFilter Factories5 questions
- Global Filters & Chain5 questions
- Rate Limiting5 questions
- Reactive Routing on WebFlux5 questions
- Gateway Server MVC (Servlet)5 questions
- Declarative Clients & Resilience23 questions
- OpenFeign Declarative Clients5 questions
- Load-Balanced Feign5 questions
- Circuit Breaker Abstraction4 questions
- Resilience4j Integration5 questions
- Fallbacks & Failure Isolation4 questions
- Messaging with Spring Cloud Stream15 questions
- Functional Bindings5 questions
- Binders (Kafka / RabbitMQ)5 questions
- Consumer Groups, Partitioning & DLQ5 questions
- Tracing, Contracts & Functions15 questions
- Distributed Tracing5 questions
- Spring Cloud Contract5 questions
- Spring Cloud Function5 questions
questions
144 · 6 sectionsWhat is Spring Cloud Bus and what problem does it solve?
basics
~20 sSpring Cloud Bus links all instances of your microservices through a shared message broker (Kafka or RabbitMQ). You can then broadcast one message — like 'refresh your config' — to the whole cluster at once instead of calling each instance.
How does a Spring Boot application connect to a Spring Cloud Config Server using spring.config.import, and what does the configserver: prefix do?
basics
~10 sAdd the spring-cloud-starter-config dependency, then set spring.config.import=configserver:http://localhost:8888 in application.yml. On startup the app fetches its properties from that Config Server before creating beans.
In a Spring Cloud Config Server property repository, what does the {cipher} prefix on a property value mean, and what happens to it before the client receives the value?
basics
~20 s{cipher} marks a property value as encrypted at rest in the config repo. By default the Config Server decrypts it and sends the plain value to the client, so the secret never sits in git as plaintext.
What does Spring Cloud Kubernetes do with a ConfigMap, and how does its data reach your beans?
basics
~10 sSpring Cloud Kubernetes reads a Kubernetes ConfigMap (named after your app) and adds its key/value entries to the Spring Environment as a PropertySource, so @Value and @ConfigurationProperties see them like any other property.
What is @RefreshScope and what happens when you POST to /actuator/refresh?
basics
~10 s@RefreshScope marks a bean so it can pick up new configuration at runtime. Calling POST /actuator/refresh reloads the configuration and recreates those beans, so they see the new property values without restarting the app.
What is Spring Cloud's DiscoveryClient and what problem does it solve? What does @EnableDiscoveryClient do?
basics
~20 sDiscoveryClient is a Spring interface to look up running instances of a service by its logical name instead of hardcoding host/port. @EnableDiscoveryClient signals that the app registers with and queries a service registry (Eureka, Consul, etc.).
How does a Spring Boot service register itself with HashiCorp Consul for service discovery, and what dependency/config is required?
basics
~10 sAdd the spring-cloud-starter-consul-discovery dependency. On startup the app auto-registers with a local Consul agent using its service name and port, so other services can look it up by name.
What is Netflix Eureka, and what do @EnableEurekaServer and @EnableEurekaClient do?
basics
~20 sEureka is a service registry: services register themselves so others can find them by name instead of a hardcoded address. @EnableEurekaServer starts the registry server; @EnableEurekaClient makes an app register with and query that registry.
What is Kubernetes-native service discovery in Spring Cloud, and how does it differ from using Eureka?
basics
~20 sSpring Cloud Kubernetes provides a DiscoveryClient that looks up other services by reading Kubernetes' own Service and Endpoints records from the API server. Unlike Eureka, there is no separate registry to run and apps do not self-register.
What is Spring Cloud LoadBalancer and what does the @LoadBalanced annotation do?
basics
~10 sSpring Cloud LoadBalancer is a client-side load balancer that replaced Netflix Ribbon. @LoadBalanced marks a RestTemplate or WebClient.Builder so URLs using a logical service name resolve to a real instance, spreading calls across instances.
What are GatewayFilter factories in Spring Cloud Gateway, and how do you configure one like AddRequestHeader on a route?
basics
~10 sThey are reusable filters you attach to a single route to change its request or response. For example, AddRequestHeader=X-Env,prod adds that header to every request forwarded through that route.
What is a GlobalFilter in Spring Cloud Gateway, and how does it differ from a GatewayFilter?
basics
~20 sA GlobalFilter runs on every route automatically. A GatewayFilter is configured per route. Both intercept the request/response; the difference is scope — global applies to all routes, gateway filters only to routes you attach them to.
What is the RequestRateLimiter filter in Spring Cloud Gateway, and what happens when a client exceeds the limit?
basics
~20 sRequestRateLimiter is a built-in gateway filter that caps how many requests a client can make in a time window. When the client sends too many, the gateway rejects the extra requests with HTTP 429 Too Many Requests instead of forwarding them.
Why does Spring Cloud Gateway run on the reactive WebFlux/Netty stack instead of the Spring MVC servlet stack?
basics
~20 sA gateway spends its time waiting on downstream services, not computing. WebFlux on Netty handles many waiting requests with a few non-blocking threads, so the gateway scales far better than a servlet with one blocking thread per request.
What is a route in Spring Cloud Gateway, and what are its parts?
basics
~20 sA route is the basic building block: an id, a destination uri, a set of predicates that decide if a request matches, and optional filters. If all predicates match, the request is forwarded to the uri.
What is the Spring Cloud Circuit Breaker abstraction and what problem does it solve?
basics
~10 sIt is a common Spring API (CircuitBreakerFactory / CircuitBreaker) for wrapping risky calls with a circuit breaker. Your code calls the abstraction, and the actual implementation (like Resilience4j) is plugged in separately.
What is Spring Cloud OpenFeign, and how do you declare and enable a Feign client?
basics
~10 sOpenFeign lets you call another HTTP service by declaring a Java interface annotated with @FeignClient. You add @EnableFeignClients to a config class, and Spring generates a proxy that turns method calls into HTTP requests.
What is a fallback method in a Resilience4j circuit breaker, and why do you need one?
basics
~20 sA fallback is an alternative method that runs when the protected call fails or the circuit is open. Instead of throwing an error to the caller, it returns a safe default (cached, empty, or degraded) response so the app keeps working.
In @FeignClient(name = "order-service"), what is that name and how does the call reach a real host?
basics
~20 sThe name is a logical service id, not a hostname. Feign hands it to Spring Cloud LoadBalancer, which asks the DiscoveryClient for live instances of that service and picks one, so you never hard-code a URL.
What does the @CircuitBreaker annotation do, and what are the three states of a Resilience4j circuit breaker?
basics
~20 s@CircuitBreaker wraps a method so repeated failures 'trip' the breaker and stop further calls, failing fast instead of hammering a broken dependency. The three states are CLOSED (normal), OPEN (blocking calls), and HALF_OPEN (testing recovery).
What is a binder in Spring Cloud Stream, and what problem does it solve?
basics
~20 sA binder is the adapter that connects your Spring Cloud Stream app to a real message broker (Kafka or RabbitMQ). Your code works with generic messages; the binder handles the broker-specific wiring, so you can switch brokers by changing a dependency and config.
What is a consumer group in Spring Cloud Stream, and what changes when you set the `group` property on a binding?
basics
~20 sA consumer group is a named set of app instances that share the workload: each message is delivered to only one instance in the group (competing consumers). Without a group, every instance gets its own copy.
What is the functional programming model in Spring Cloud Stream, and how do you expose a message handler with it?
basics
~20 sYou declare a plain Spring @Bean of type Supplier, Function, or Consumer and name it in the property spring.cloud.function.definition. Spring Cloud Stream wires that bean to the message broker automatically — no special annotations needed.
How does the destination property map onto Kafka vs RabbitMQ, especially once a consumer group is involved?
basics
~20 sThe destination is the logical target name. On Kafka it becomes a topic. On RabbitMQ it becomes a topic exchange; adding a consumer group creates a durable queue named destination.group bound to that exchange, so the same config means different physical objects per broker.
What does `enableDlq` do with the Kafka binder, and what happens to a poison message that exhausts its retries?
basics
~20 sA poison message is one that keeps failing no matter how often you retry. With the Kafka binder's enableDlq=true, once retries are exhausted the message is sent to a separate dead-letter topic instead of being lost, so you can inspect and reprocess it later.
What problem does Spring Cloud Contract solve, and what is a consumer-driven contract?
basics
~20 sSpring Cloud Contract keeps a service (producer) and its callers (consumers) in sync. A contract is a shared file describing a request and the expected response. It generates producer tests and consumer stubs from that one file.
What is Spring Cloud Function, and which three core interfaces does it build on?
basics
~10 sSpring Cloud Function lets you write business logic as plain beans of type Function, Supplier, or Consumer (from java.util.function). The framework then exposes them over HTTP, messaging, or serverless without you writing transport code.
What is distributed tracing, and what are trace IDs and span IDs in a Spring Boot application using Micrometer Tracing (formerly Spring Cloud Sleuth)?
basics
~20 sDistributed tracing follows one request as it hops between services. A trace ID is a shared id for the whole request; a span id marks one step (like one service call). Micrometer Tracing adds both to logs automatically.
How does the producer-side test generation work, and what is the base class for?
basics
~20 sThe Verifier build plugin reads each contract and generates a JUnit test that sends the contract's request to your controller and checks the response. You provide a base class that sets up the controller (MockMvc/RestAssured) so the generated test can run.
On the consumer side, how does Stub Runner let you test against the producer's stubs?
basics
~20 sYou annotate a consumer test with @AutoConfigureStubRunner, list the producer's stub JAR coordinates, and Stub Runner downloads the JAR and starts a WireMock server serving those stubs. Your consumer code calls it as if it were the real producer.