Scrivio Interview library

Spring WebFlux

26 questions in 7 subtopics.

WebFlux vs MVC

ConceptFoundations6 min read
What are the main differences between Spring MVC and Spring WebFlux in threading model, supported servers and programming model?
ScenarioIntermediate7 min read
A team proposes rewriting a CRUD service backed by PostgreSQL and JPA from MVC to WebFlux for better performance. How do you evaluate this proposal?
LeadershipAdvanced6 min read
Set a company standard for choosing among Spring MVC, Spring MVC with virtual threads, and WebFlux for new services. What criteria would you write down?
LeadershipPrincipal6 min read
Looking back, many organisations adopted reactive stacks around 2017-2020 and some later moved back to blocking code with virtual threads. What lessons do you draw about adopting programming-model shifts?

Annotated and functional endpoints

CodingFoundations6 min read
Write a WebFlux functional endpoint that routes GET /persons/{id} and POST /persons to a handler class, and compare it with the annotated controller style.
DesignIntermediate6 min read
Your team mixes annotated controllers and router functions in one WebFlux service. How do you keep cross-cutting concerns (validation, error handling, security, documentation) consistent?
LeadershipAdvanced5 min read
Should your organisation standardise on annotated controllers or functional endpoints for Spring web services? What factors would you weigh?

Netty event loop

InternalsFoundations6 min read
How many event-loop threads does Reactor Netty use by default in a Spring WebFlux application, and what are they responsible for?
DebuggingIntermediate7 min read
p99 latency in a WebFlux service spikes from 20 ms to 3 seconds under moderate load while CPU usage stays low. Thread dumps show reactor-http-nio threads in socketRead and in a JDBC driver. Explain the cause and the fix.
ScenarioAdvanced7 min read
A gateway built on Spring Cloud Gateway (WebFlux) handles 50,000 requests per second. A custom filter added by one team makes a synchronous call to a token introspection endpoint. What is the fleet-level risk and how do you prevent this class of problem?
ScenarioPrincipal6 min read
Your API gateway and several edge services run on a Netty-based reactive stack maintained by a small group of experts who are leaving. How do you manage the long-term risk of critical infrastructure depending on scarce skills?

Blocking calls in reactive code

DebuggingFoundations6 min read
A WebFlux handler calls someMono.block() and fails with IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3. Why does Reactor throw this, and what should the code do instead?
ConceptIntermediate7 min read
What is BlockHound, and how would you use it in a WebFlux project?
CodingIntermediate8 min read
You must call a legacy blocking SDK (sdk.lookup(id) takes 200 ms) from a WebFlux service handling 2,000 requests per second. Write the code and explain how to size the resources.

R2DBC

ConceptFoundations7 min read
What is R2DBC and how does Spring Data R2DBC differ from Spring Data JPA?
ScenarioIntermediate8 min read
You are designing a reactive service with R2DBC that needs an Order with its OrderLines. How do you load and save aggregates without JPA relationships?
LeadershipAdvanced5 min read
Would you allow R2DBC as a standard data access option across the organisation? What would you compare it with?
LeadershipPrincipal6 min read
Five years ago your organisation chose R2DBC for all new services to be fully reactive. Driver support, tooling and hiring have been harder than expected, and virtual threads now offer an alternative. How would you reassess the bet and manage the exit cost?

Error handling

CodingFoundations6 min read
In Reactor, what are onErrorResume, onErrorReturn, onErrorMap and doOnError used for? Write a pipeline that maps a WebClient 404 to an empty result and any other error to a ServiceUnavailableException.
DebuggingIntermediate6 min read
A Flux of 10,000 items stops processing at item 37 because one item throws an exception in map. The team wants processing to continue for the other items. What options exist?
DesignAdvanced7 min read
Define a consistent error-handling standard for WebFlux services: how exceptions map to HTTP responses, what is logged, and how upstream errors are translated.
LeadershipPrincipal6 min read
After years of growth, every service in your company reports errors differently, which makes cross-service incident analysis slow. What error-reporting standard would you set across MVC and WebFlux services, and how would you sustain it?

Context propagation

ConceptFoundations6 min read
Why does MDC-based logging lose the trace id in a Reactor pipeline, and what does Reactor Context offer instead?
InternalsIntermediate6 min read
How does automatic context propagation work in Spring Boot 3 with Reactor and Micrometer, so that log lines inside operators include the trace id?
ScenarioAdvanced6 min read
Tracing data is missing for calls that go through a mix of WebFlux services, Kafka consumers and MVC services. How would you get consistent context propagation across the fleet?
DesignPrincipal6 min read
Observability and security context (trace ids, user identity, tenant) must flow through MVC, WebFlux, virtual threads, messaging and batch jobs across hundreds of services for the next decade. What long-term standard would you set?