SpringBoot Async requests throwing 503 Service Unavailable
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
A 503 Service Unavailable during asynchronous request handling in Spring Boot usually means the application accepted the request but could not complete it within the configured async window. The root cause is often a timeout, an undersized executor, or a blocking operation that defeats the point of async processing. Fixing it starts with understanding which async model you are using.
Know Which Async Feature You Are Using
Spring has two related but different async patterns:
- '
@Asyncon service methods, which runs work on a separate executor.' - Spring MVC async responses such as
Callable,DeferredResult, orWebAsyncTask, which free the servlet thread while work continues.
A 503 is most commonly associated with the MVC async request timing out. If the work finishes too late, Spring raises an async timeout and the client sees a service-unavailable response.
A minimal MVC async controller looks like this:
If that work regularly takes longer than the configured timeout, you will see intermittent failures that look like capacity problems even though the real issue is timing.
Configure an Executor and Timeout Explicitly
Do not rely on default async behavior for production workloads. Provide a bounded executor and set the MVC async timeout deliberately.
You can also set the timeout with configuration:
This makes failures easier to reason about. A timeout of 30 seconds may still be wrong for your system, but at least it is an explicit decision instead of an accidental default.
Use @Async with a Real Return Type
For service-layer async work, return a CompletableFuture and run it on the named executor.
Then connect that service to an async MVC response:
This pattern makes the timeout behavior explicit and prevents the servlet thread from sitting idle during long work.
Watch the Real Bottleneck
503 errors are often a symptom rather than the root cause. Common bottlenecks include:
- The async executor has too few threads for the workload.
- The queue is too small and tasks are rejected.
- The work is still blocking on database calls, HTTP calls, or file I/O.
- A proxy or load balancer times out before Spring finishes.
If the request path includes Nginx, an ingress controller, or a cloud load balancer, compare those timeouts with spring.mvc.async.request-timeout. The shortest timeout in the chain wins.
Common Pitfalls
- Using
@Asyncand assuming it automatically fixes slow blocking code. - Leaving executor sizing at defaults and then saturating threads under load.
- Returning an async MVC type without configuring a realistic timeout.
- Calling an
@Asyncmethod from the same class, which bypasses the Spring proxy. - Debugging only Spring logs when the actual timeout happens in an upstream proxy.
Summary
- A 503 during Spring Boot async handling is usually a timeout or capacity problem.
- Distinguish service-layer
@Asyncwork from MVC async request processing. - Configure a bounded
ThreadPoolTaskExecutorand an explicit async timeout. - Return
CompletableFuture,Callable, orDeferredResultintentionally instead of mixing patterns blindly. - Check upstream proxy timeouts as well as Spring configuration when 503s appear under load.
Related reading
- Springboot How to use WebClient instead of RestTemplate for Performing Non blocking and Asynchronous calls
- sql multithreading application select and delete from a table
- SQL Server 2005 Replication
- SQL Server 2008 Replication avoiding reinitialization
- SpringBoot doesn't handle org.hibernate.exception.ConstraintViolationException
- springboot How to exclude configuration class in dependency dependency
- SpringBoot error Registered driver with driverClassNameoracle.jdbc.driver.OracleDriver was not found, trying direct instantiation
- SpringBoot no main manifest attribute maven

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.