Quick revision
The short answer
Schedulers.boundedElastic() is bounded in two ways: it creates at most a fixed number of threads, by default ten times the number of CPU cores, and each thread may have at most a fixed number of queued tasks, by default 100,000. When all threads are busy, new tasks queue behind them; when the queues are full too, submission fails with a RejectedExecutionException. Idle threads are removed after 60 seconds, and recent Reactor versions on Java 21 and later can run it on virtual threads through a system property (check your version for the exact defaults and property names).
What to remember
In this answer, we saw that boundedElastic is bounded by a thread cap, ten times the CPU count by default, and a queued-task cap per thread, 100,000 by default. Beyond the thread cap tasks queue on the least busy thread, and beyond the queue cap submission fails with a RejectedExecutionException. Idle threads are evicted after 60 seconds, and Reactor 3.6 and later can back the scheduler with virtual threads on Java 21 or later through a system property. A full queue means the service is doing more blocking work than its design allows, and the fix is to bound or isolate that work rather than raise the limits.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Schedulers.boundedElastic() is bounded in two ways: it creates at most a fixed number of threads, by default ten times the number of CPU cores, and each thread may have at most a fixed number of queued tasks, by default 100,000. When all threads are busy, new tasks queue behind them; when the queues are full too, submission fails with a RejectedExecutionException. Idle threads are removed after 60 seconds, and recent Reactor versions on Java 21 and later can run it on virtual threads through a system property (check your version for the exact defaults and property names).
Why this question is asked
boundedElastic is where blocking work goes in a reactive application, so its limits decide how the service behaves when that blocking work is slow. Teams often discover those limits during an incident, when tasks pile up behind a slow database and requests start failing with rejected-execution errors. Interviewers ask this to see whether we understand the scheduler as a resource with capacity, and how it fits with virtual threads. In this answer, we will recap why the scheduler exists, look at its two bounds and their defaults, see what happens when they are reached, cover eviction and virtual threads, and finish with what a full queue tells us about the design.
1A Quick Recap: Why boundedElastic Exists
Reactive code assumes threads never block, but real systems still have blocking APIs: JDBC, file access, old SDKs. Reactor's answer is a separate scheduler for that work. Older versions had Schedulers.elastic(), which created a new thread whenever all existing ones were busy, without any limit. Under a slow dependency it could create thousands of threads and exhaust memory. boundedElastic replaced it (elastic() was removed in Reactor 3.5) and keeps the good part, threads created on demand and released when idle, while adding a cap.
2The Two Bounds and Their Defaults
The first bound is the number of threads, which defaults to ten times Runtime.availableProcessors(). On an 8-core machine that is 80 threads; in a container limited to 2 CPUs it is 20. The second bound is the number of tasks waiting per thread, which defaults to 100,000. Both can be changed with system properties, reactor.schedulers.defaultBoundedElasticSize and reactor.schedulers.defaultBoundedElasticQueueSize, or we can build our own instance with Schedulers.newBoundedElastic(threadCap, queuedTaskCap, name, ttlSeconds).
Notice that a dedicated pool also isolates failures: if the SOAP service slows down, only its 20 threads fill up, and other blocking work on the shared boundedElastic is unaffected.
3What Happens When the Bounds Are Reached
When a task is submitted, the scheduler gives it to an idle thread if there is one, or creates a new thread if it is below the thread cap. Once the cap is reached, the task is assigned to one of the existing busy threads and waits in that thread's queue. The scheduler picks the least busy thread, but it does not move tasks between threads later, so a task can wait behind one slow task while another thread is free.
When the queued-task limit is also reached, submission fails. The subscriber gets an error, a RejectedExecutionException whose message says the task capacity of the bounded elastic scheduler was reached (the exact wording depends on the version).
- Is a thread idle?YesRun the task on itNoCheck the thread cap
- Below the thread cap (10 x cores)?YesCreate a new thread and runNoQueue on the least busy thread
- Queue below its cap (100,000)?YesTask waits its turnNoRejectedExecutionException
- Thread idle for 60 secondsevicted, pool shrinks
4 steps in order. Play them, or step through them one at a time.
4Idle Eviction and Virtual Threads
Threads that stay idle for the time-to-live, 60 seconds by default, are disposed of, so after a burst the pool shrinks back. This is why the scheduler is called elastic: it grows on demand and shrinks when quiet.
Virtual threads, final since Java 21, make blocking cheap: a blocked virtual thread unmounts from its carrier thread and costs a few kilobytes instead of a megabyte of stack. Reactor 3.6 added support for running boundedElastic on virtual threads when the application runs on Java 21 or later and the system property reactor.schedulers.defaultBoundedElasticOnVirtualThreads is set to true (check your version). Each task then runs on its own virtual thread, but the scheduler still applies its cap on concurrent tasks, so the limit remains a deliberate bound. Pinning, where a virtual thread blocked inside a synchronized block holds its carrier, was largely removed in Java 24, which makes this mode more attractive on Java 25.
5What a Full Queue Is Telling Us
A rejection is a symptom, not the disease. With 80 threads and 100,000 queued tasks each, the scheduler can hold eight million waiting tasks; if that fills, blocking work is arriving much faster than it completes, usually because a dependency got slow. Raising the limits only delays the failure and increases memory and latency. The better responses are to bound the work before it reaches the scheduler, for example with flatMap concurrency or a timeout on the blocking call, to give slow dependencies their own small pools, and to ask whether so much blocking work belongs in a reactive service at all. We watch it through Micrometer by enabling Reactor's scheduler metrics, or by measuring task wait time around the blocking call.
6Follow-up questions
Why is the default thread cap tied to the CPU count?
It is a simple heuristic that scales the pool with the machine: a larger machine usually serves more traffic and may run more blocking work. It does not reflect the capacity of the dependency being called, which is why a dedicated pool sized for that dependency, for example the size of its connection pool, is often better.
Does a rejected task retry automatically?
No. The Mono or Flux receives an error signal, so the caller sees a failure unless we add retry or a fallback. Retrying immediately into a full scheduler rarely helps; shedding the request with a clear error or backing off is more useful.
Should I set threadCap equal to my JDBC pool size?
For a dedicated pool that only runs JDBC calls, roughly yes: more threads than connections just means threads waiting for a connection. A few extra threads can cover time spent outside the database, but a cap far above the pool size adds waiting, not throughput.
7Conclusion
In this answer, we saw that boundedElastic is bounded by a thread cap, ten times the CPU count by default, and a queued-task cap per thread, 100,000 by default. Beyond the thread cap tasks queue on the least busy thread, and beyond the queue cap submission fails with a RejectedExecutionException. Idle threads are evicted after 60 seconds, and Reactor 3.6 and later can back the scheduler with virtual threads on Java 21 or later through a system property. A full queue means the service is doing more blocking work than its design allows, and the fix is to bound or isolate that work rather than raise the limits.
Open with
boundedElastic exists for blocking work, and it replaced the old elastic scheduler, which had no limit and could create thousands of threads. It's bounded in two ways. There's a cap on threads, by default ten times the number of CPU cores, so 80 on an 8-core box or 20 in a 2-CPU container, and a cap on queued tasks per thread, by default 100,000.
Then, if they want more
Both are configurable with system properties, or I can create my own instance with Schedulers.newBoundedElastic. When I submit a task, it runs on an idle thread if there is one, otherwise a new thread is created up to the cap.
Once the cap is reached, tasks are queued on the least busy existing thread, and if that queue is full the submission is rejected and the subscriber gets a RejectedExecutionException. Idle threads are evicted after a time-to-live of 60 seconds, so the pool shrinks back after a burst.
On virtual threads: from Reactor 3.6, on Java 21 or later, there's a system property that makes boundedElastic run tasks on virtual threads, with the same cap on concurrent tasks; I'd check the exact property for the version in use.
In practice, if I see that queue filling up, I read it as a design problem, too much blocking work for a reactive service, usually because a dependency got slow.
I'd bound the work upstream with flatMap concurrency and timeouts, give slow dependencies their own small pools, and question whether the service should be reactive at all, rather than just raising the limits.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21, Java 24, Java 25
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Spring WebFlux, Project Reactor reference guide
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How is Schedulers.boundedElastic() bounded, what happens when the bound is reached, and...": https://scrivio-interview-library.netlify.app/spring-boot/reactive-fundamentals/7e08157738/