Virtual threads — enable-or-not evaluation
As of 2026-08-23. Advisory, point-in-time. Version and behaviour claims are dated and sourced; re-verify before acting. This document changes no configuration — it is a recommendation. Companion: java-25-readiness.md.
The question
Should the Java 21 backend (forge-et-be) enable spring.threads.virtual.enabled, given the
workload — 10–20 users, but slow blocking outbound I/O to Microsoft Graph, Amazon Bedrock, and
JDBC?
Bottom line — DON’T enable
Not now, and not as a rider on the Java 25 bump. For a 10–20-user internal CRM, virtual threads buy no measurable benefit, and on Java 21 they add a subtle failure mode (carrier-thread pinning) for zero throughput gain. Enabling them also runs against the project’s own prime directive (coding-standards §0: “simple, boring, deletable” — don’t flip a global switch nobody asked for).
Current state confirmed: spring.threads.virtual.enabled appears nowhere in tracked config,
so virtual threads are off. If ever enabled, it would go under spring: in
app/src/main/resources/application.yml.
The reasoning, across the three things that actually matter
1. The scale removes the upside
Virtual threads solve platform-thread exhaustion under thousands of concurrent blocking
requests. The web tier here is servlet MVC on Tomcat 11 (spring-boot-starter-web is already on
main), whose default pool is ~200 platform threads — roughly 10× the entire user base. Virtual
threads would be solving a problem this system will never have. The “N× faster” write-ups are
about high-fan-out public services, not a 20-seat internal tool.
2. The Java 21 pinning risk is real — and the mitigation is the point
On Java 21, a virtual thread that sits inside a synchronized block while doing blocking I/O
pins its carrier (the underlying platform thread can’t be reused). Carriers default to the CPU
count, so on a 1–2 vCPU Fargate task that is 1–2 carriers — pinning bites hardest exactly where
this app runs.
- JEP 491, shipped in Java 24, removes this: monitors are
associated with the virtual thread, not the carrier, so
synchronizedno longer pins (only native/FFM callbacks still can). See Inside Java Newscast #80. - The likely pinning sources on Java 21 for this workload would be the PostgreSQL JDBC driver’s synchronized paths and some AWS SDK sync-HTTP paths (Bedrock/SES/SQS/S3 all ride that SDK). Notably HikariCP is not one — the old synchronized-acquisition pinning was pre-5.x, and the BOM resolves 7.0.2.
So the exposure is modest but non-zero, subtle to diagnose (jdk.tracePinnedThreads on 21/23, JFR
jdk.VirtualThreadPinned events on 24+), and — the deciding point — incurred for no benefit at
this scale.
3. Virtual threads do not remove the connection-pool limit
The most common misconception. Turning virtual threads on gives you unlimited cheap threads, but real database concurrency is still capped by HikariCP (default max 10). Virtual threads only make the threads waiting for a connection cheap (parked, not blocking a platform thread) — the bottleneck simply moves to the pool, which is where it belongs (HikariCP #2151). The trap teams fall into is over-sizing the pool “because virtual threads”; pool size is governed by database capacity, not thread count. For 10–20 users the default pool is already generous, so virtual threads change nothing you would notice.
Spring Boot 4.1 specifics
It is genuinely one line, and Boot wires virtual threads into request handling, @Async, and task
execution together (requires Java 21+). But this project deliberately pushes timed/async work
out of process — EventBridge → SQS → worker (AD #12), never in-process @Scheduled — so
even that surface is thin here. The net effect of the flag would be request-handling threads plus
any @Async, and it is one line of global concurrency-behaviour change across every request and
executor for a system that is not thread-constrained.
Verdict and the only realistic revisit trigger
Don’t enable. If a genuinely high-concurrency workload ever appears (it won’t at ~20 users), revisit it then — and only on Java 24+, where JEP 491 has removed the pinning footgun. Until that day, off is the correct, boring, defensible default.
Practical corollary for the Java 25 bump (see java-25-readiness.md): the bump would remove the pinning objection, but it does not create a reason to enable virtual threads — the scale argument stands regardless. Keep them off; treat this as decided unless the workload profile changes materially.