skip to content

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 pageshow

explore

questions

144 · 6 sections

What is Spring Cloud Bus and what problem does it solve?

level: juniorimportance: must knowfreq 55%
basics
~20 s

Spring 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.

open as a page

How does a Spring Boot application connect to a Spring Cloud Config Server using spring.config.import, and what does the configserver: prefix do?

level: juniorimportance: must knowfreq 78%
basics
~10 s

Add 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.

open as a page

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?

level: juniorimportance: must knowfreq 55%
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.

open as a page

What does Spring Cloud Kubernetes do with a ConfigMap, and how does its data reach your beans?

level: juniorimportance: must knowfreq 60%
basics
~10 s

Spring 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.

open as a page

What is @RefreshScope and what happens when you POST to /actuator/refresh?

level: juniorimportance: must knowfreq 70%
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.

open as a page

What is Spring Cloud's DiscoveryClient and what problem does it solve? What does @EnableDiscoveryClient do?

level: juniorimportance: must knowfreq 70%
basics
~20 s

DiscoveryClient 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.).

open as a page

How does a Spring Boot service register itself with HashiCorp Consul for service discovery, and what dependency/config is required?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Add 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.

open as a page

What is Netflix Eureka, and what do @EnableEurekaServer and @EnableEurekaClient do?

level: juniorimportance: must knowfreq 70%
basics
~20 s

Eureka 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.

open as a page

What is Kubernetes-native service discovery in Spring Cloud, and how does it differ from using Eureka?

level: juniorimportance: must knowfreq 60%
basics
~20 s

Spring 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.

open as a page

What is Spring Cloud LoadBalancer and what does the @LoadBalanced annotation do?

level: juniorimportance: must knowfreq 55%
basics
~10 s

Spring 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.

open as a page

What are GatewayFilter factories in Spring Cloud Gateway, and how do you configure one like AddRequestHeader on a route?

level: juniorimportance: must knowfreq 70%
basics
~10 s

They 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.

open as a page

What is a GlobalFilter in Spring Cloud Gateway, and how does it differ from a GatewayFilter?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A 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.

open as a page

What is the RequestRateLimiter filter in Spring Cloud Gateway, and what happens when a client exceeds the limit?

level: juniorimportance: must knowfreq 60%
basics
~20 s

RequestRateLimiter 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.

open as a page

Why does Spring Cloud Gateway run on the reactive WebFlux/Netty stack instead of the Spring MVC servlet stack?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A 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.

open as a page

What is a route in Spring Cloud Gateway, and what are its parts?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A 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.

open as a page

What is the Spring Cloud Circuit Breaker abstraction and what problem does it solve?

level: juniorimportance: must knowfreq 55%
basics
~10 s

It 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.

open as a page

What is Spring Cloud OpenFeign, and how do you declare and enable a Feign client?

level: juniorimportance: must knowfreq 78%
basics
~10 s

OpenFeign 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.

open as a page

What is a fallback method in a Resilience4j circuit breaker, and why do you need one?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A 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.

open as a page

In @FeignClient(name = "order-service"), what is that name and how does the call reach a real host?

level: juniorimportance: must knowfreq 70%
basics
~20 s

The 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.

open as a page

What does the @CircuitBreaker annotation do, and what are the three states of a Resilience4j circuit breaker?

level: juniorimportance: must knowfreq 78%
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).

open as a page

What is a binder in Spring Cloud Stream, and what problem does it solve?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A 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.

open as a page

What is a consumer group in Spring Cloud Stream, and what changes when you set the `group` property on a binding?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A 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.

open as a page

What is the functional programming model in Spring Cloud Stream, and how do you expose a message handler with it?

level: juniorimportance: must knowfreq 70%
basics
~20 s

You 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.

open as a page

How does the destination property map onto Kafka vs RabbitMQ, especially once a consumer group is involved?

level: middleimportance: must knowfreq 65%
basics
~20 s

The 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.

open as a page

What does `enableDlq` do with the Kafka binder, and what happens to a poison message that exhausts its retries?

level: middleimportance: must knowfreq 60%
basics
~20 s

A 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.

open as a page

What problem does Spring Cloud Contract solve, and what is a consumer-driven contract?

level: juniorimportance: must knowfreq 55%
basics
~20 s

Spring 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.

open as a page

What is Spring Cloud Function, and which three core interfaces does it build on?

level: juniorimportance: must knowfreq 55%
basics
~10 s

Spring 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.

open as a page

What is distributed tracing, and what are trace IDs and span IDs in a Spring Boot application using Micrometer Tracing (formerly Spring Cloud Sleuth)?

level: juniorimportance: must knowfreq 70%
basics
~20 s

Distributed 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.

open as a page

How does the producer-side test generation work, and what is the base class for?

level: middleimportance: must knowfreq 50%
basics
~20 s

The 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.

open as a page

On the consumer side, how does Stub Runner let you test against the producer's stubs?

level: middleimportance: must knowfreq 52%
basics
~20 s

You 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.

open as a page