Spring Boot 4.1 Leaves Virtual Threads Off by Default; Enabling Them Turns Hikari's Pool Into the Bottleneck
An upgrade that assumes virtual threads arrive by default silently keeps Tomcat on 200 platform threads, and enabling them without sizing the connection pool fails a third of requests at 1500 concurrency. Lazy connection fetching, a one-property change in 4.1, turns the same 10-connection pool into a 25x throughput gain for transactions that do non-SQL work first.
Spring Boot 4.1 keeps virtual threads disabled by default. A probe endpoint on 4.1.2 with JDK 21 returns http-nio-8080-exec-1 platform threads and virtual:false; the spring.threads.virtual.enabled property has defaulted to false since 3.2 introduced it, and 4.1.2 has not changed that. Set it to true and the handler thread becomes a VirtualThread on ForkJoinPool-1, but the pipeline beyond Tomcat changes nothing on its own.
The switch exposes HikariCP as the ceiling. At 400 concurrency both platform and virtual configurations land near 33 rps, the pool's capacity given 10 connections and a 300 ms per-request hold time, and virtual threads merely move waiting from Tomcat's pool to Hikari's queue (wait peaks of 390 versus 189). At 1500 concurrency, virtual threads fail 29.9% of requests on Hikari's 30-second connectionTimeout, while the platform-thread config returns 0% errors because Tomcat's 200-worker cap throttles concurrency before it reaches the pool.
Enlarging the pool from 10 to 50 lifts throughput from 43.7 to 170.3 rps and p99 from 12.7s to 3.6s, with all 50 connections saturated. Wrapping the same 10-connection pool in LazyConnectionDataSourceProxy defers acquisition until the first SQL statement and reaches 1107.1 rps with p99 at 1.1s, a 25x jump measured on a 1-core box. The fix only pays when transactions do non-SQL work before SQL, which real handlers do constantly.
At 1500 concurrency, Tomcat's 200-worker default was acting as quiet backpressure; virtual threads removed that valve before the pool had spare capacity, so the queue just moved and the timeout got exposed. Removing one queue without sizing the next relocates the failure.
The 29.9% error rate is a capacity-planning failure; virtual threads made Hikari's fixed size and 30-second timeout visible faster, not introduced them.
A 25x gain from deferring connection acquisition shows how much non-SQL work sits inside real transactions. Pooled connections spend most of their hold time idle, so shrinking hold time beats buying more connections.
The widely repeated claim that Spring Boot 4.1 enables virtual threads by default is false, yet the secondary diagnosis attached to it, HikariCP as the bottleneck, holds up under load. A wrong premise costs a reader the first debugging step.
The clarification distinguishes the direct JDK virtual-thread executor from Spring Boot's container-level switch; they share the same underlying mechanism but differ in scope. Both paths run into the same HikariCP 10-connection default when accessing a database, which the reply identifies as the source of a third of the article's 500 errors. Pool sizing should follow concurrency, not the virtual-thread enablement choice.
I directly use Executors.newVirtualThreadPerTaskExecutor() and it works. Your switch is different, right? When you enable it, Tomcat's request threads will proactively convert to virtual threads, but mine just works directly.
Right, those two are not the same thing. Executors.newVirtualThreadPerTaskExecutor() is the standard JDK 21 API, you submit tasks yourself, and using it directly is fine; spring.threads.virtual.enabled=true governs another layer—making Tomcat's request-handling threads and auto-configuration points like @Async switch to virtual threads. Boot doesn't enable it by default, and what it does is essentially the same as your manual new, just scoped to the container. One more thing: virtual threads, regardless of which way you enable them, as long as the task touches the database, the HikariCP default 10-connection pitfall is unavoidable. In my article, 30% of the 500 errors came from exactly that. Remember to calculate the pool size based on concurrency.