Java Virtual Threads and Little's Law: Throughput, Scalability and When They Help
Why virtual threads raise throughput without making anything faster. Little's Law (N = λ × d) explained with a measured comparison of fixed thread pools and virtual threads, how to size pools for blocking work, and the workloads where virtual threads help or don't.
kvi5hnuCode Sprout team member9 min readOn this page
A common first reaction to virtual threads is "so my code runs faster?" It doesn't. A request that takes 300 ms on a platform thread takes 300 ms on a virtual thread. What changes is how many such requests the server can have in progress at once, and therefore how many it can finish per second. A simple formula from queueing theory, Little's Law, makes this precise. This article explains it, measures it, and uses it to decide when virtual threads are worth it.
Little's Law
For any stable system, one where work leaves as fast as it arrives on average:
- is the average number of items in the system, the concurrency: requests being handled right now.
- (lambda) is the throughput: items completed per unit of time.
- is the average time an item spends in the system, the latency.
Rearranged for throughput:
The law doesn't care what the items are or what happens inside: CPU work, waiting for a disk, a queue at a bank counter. It also doesn't care whether time is spent working or waiting. That's exactly why it's useful for servers, whose requests mostly wait.

What it means for thread-per-request servers
In a thread-per-request server, each request in progress holds one thread. So can't exceed the number of threads, and the maximum throughput is:
With 200 threads and requests that take 100 ms (0.1 s), the server tops out at 200 / 0.1 = 2,000 requests per second, no matter how idle the CPU is. To go higher, you can lower or raise :
- Lower : make requests faster. Often impossible: the time is spent waiting for a database, a payment provider or another team's service.
- Raise : allow more requests in progress. With platform threads, that means more OS threads, which runs into the memory, OS-limit and context-switch costs from article 3.
Virtual threads make cheap to raise. A waiting virtual thread costs about a kilobyte of heap and no OS thread, so can be tens of thousands or more. Throughput rises in proportion, while stays the same.
Measuring it
This program runs 2,000 tasks that each wait 100 ms, first on fixed pools of different sizes, then with one virtual thread per task. For each, it prints the time Little's Law predicts and the time measured:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Supplier;
public class Solution {
static final int TASKS = 2_000;
static final long LATENCY_MS = 100; // d: each task waits 100 ms, like a remote call
static void task() {
try {
Thread.sleep(LATENCY_MS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
static void measure(String label, int concurrency, Supplier<ExecutorService> executors) {
// Little's Law: throughput = N / d, so the whole batch takes about TASKS / throughput
double predictedThroughput = concurrency / (LATENCY_MS / 1000.0);
long predictedMs = Math.max(LATENCY_MS, Math.round(TASKS / predictedThroughput * 1000));
long start = System.nanoTime();
try (ExecutorService executor = executors.get()) {
for (int i = 0; i < TASKS; i++) executor.submit(Solution::task);
}
long ms = (System.nanoTime() - start) / 1_000_000;
System.out.printf("%-22s N=%-5d predicted %5d ms, measured about %5d ms%n",
label, concurrency, predictedMs, Math.round(ms / 100.0) * 100);
}
public static void main(String[] args) {
measure("fixed pool of 50", 50, () -> Executors.newFixedThreadPool(50));
measure("fixed pool of 200", 200, () -> Executors.newFixedThreadPool(200));
measure("fixed pool of 1000", 1000, () -> Executors.newFixedThreadPool(1000));
measure("virtual per task", TASKS, Executors::newVirtualThreadPerTaskExecutor);
}
}
A typical run on a laptop (measured times may differ from run to run and machine to machine):
fixed pool of 50 N=50 predicted 4000 ms, measured about 4200 ms
fixed pool of 200 N=200 predicted 1000 ms, measured about 1100 ms
fixed pool of 1000 N=1000 predicted 200 ms, measured about 300 ms
virtual per task N=2000 predicted 100 ms, measured about 100 ms
The prediction is close every time, and the measurements show where reality adds cost:
- Every task takes slightly more than 100 ms, because
sleepnever wakes up early and scheduling adds a little delay. Forty rounds of tasks in the 50-thread pool, each a few milliseconds over 100 ms, add up to the extra 200 ms. - The 1,000-thread pool loses about 100 ms creating 1,000 platform threads, and would lose much more with deeper stacks or a busier OS.
- The virtual-thread executor creates 2,000 threads in a few milliseconds, and all 2,000 tasks wait at the same time.
None of the tasks ran faster. Each still waited 100 ms. The batch finished sooner only because more tasks were waiting at the same time.
Sizing platform-thread pools with Little's Law
Little's Law also explains the classic pool-sizing formula. If each task needs seconds of CPU and spends seconds waiting, and you want to keep cores busy:
A task with 5 ms of CPU and 95 ms of waiting, on 8 cores, needs about 8 × (1 + 19) = 160 threads to keep the CPU busy. With virtual threads you don't need this calculation for blocking work: create one per task and let the number of threads follow the load. You still need limits for other resources, as the next sections show.
When virtual threads help
Virtual threads raise throughput when both of these are true:
- Concurrency is high. There are thousands of tasks or more in progress at once, usually requests or messages. With a few dozen concurrent tasks, a platform-thread pool works just as well.
- Tasks mostly wait. The work is I/O-bound: HTTP calls, database queries, message brokers, socket I/O. A virtual thread waiting on these frees its carrier for others. File I/O is the exception: it holds the carrier (article 14).
Typical good fits are web and API servers, gateways that call several backends per request, message consumers, and batch jobs that call remote services for each record.
When they don't help
- CPU-bound work. Image processing, compression, encryption of large data, simulations. The limit is the number of cores, and a busy virtual thread holds its carrier just like a platform thread holds a core. Use fork/join, parallel streams or a pool sized to the cores.
- When something else is the bottleneck. If the database can serve 100 queries at a time, 10,000 virtual threads waiting on it don't make it faster. They just queue up inside the connection pool, or overload the database if there's no limit. Little's Law applies to the database too: its throughput is its own .
- Low concurrency. A desktop app or a batch job with 16 parallel tasks gains nothing measurable.
- Latency. Virtual threads don't reduce the time for a single request. To make one request faster, reduce its work or run its independent calls concurrently (fan-out), which virtual threads make cheap.
The first and second points lead directly to the next topics: limiting concurrent access to scarce resources (article 12) and understanding what happens on the carrier while a virtual thread runs (article 11).
What's current
- Virtual threads have become more broadly applicable since Java 21, mainly because Java 24 (JEP 491) removed
synchronizedpinning. The throughput argument in this article is the same on every version. - Server frameworks that run handlers on virtual threads, such as Spring Boot, Quarkus and Helidon, are the easiest way to use this in practice. Part 7 covers them.
Common questions
Do virtual threads make my application faster? They make it scale further: more requests in progress, so more completed per second under load. Each request takes the same time as before. Under light load, you won't see a difference.
Why not just give a platform pool 10,000 threads? Each platform thread costs an OS thread and native stack memory, the OS caps the total, and thousands of runnable threads cost context switches. You can often get a few thousand threads, rarely hundreds of thousands. Virtual threads remove those costs for threads that are waiting.
Does Little's Law still hold if latencies vary a lot? Yes. It's about averages over a stable period and makes no assumption about the distribution. Wide variation does affect queueing and tail latency, which the law doesn't describe, so measure percentiles as well.
If 10,000 virtual threads all call the same database, what's the throughput? The database's own limit. If it has a pool of 50 connections and each query takes 20 ms, it can do at most 50 / 0.02 = 2,500 queries per second. The other virtual threads wait for a connection. Virtual threads move the bottleneck to the real resource, which is usually what you want, but that resource must be protected.
Summary
- Little's Law: , so maximum throughput is concurrency divided by latency.
- With thread-per-request, concurrency is capped by the number of threads. When latency is set by remote systems, more threads is the only way to more throughput.
- Virtual threads make high concurrency cheap, so throughput rises while each request's latency stays the same.
- Measured results match the law closely. Extra costs come from timer overhead and, for large platform pools, thread creation.
- Virtual threads help with many concurrent, mostly waiting tasks. They don't help CPU-bound work, low concurrency, or a downstream bottleneck.
Practice questions
A service uses a pool of 100 platform threads. Each request takes 50 ms, mostly waiting on a cache server. What is the maximum throughput? With virtual threads, the same service holds 5,000 requests in progress. What is the new maximum?
Answer
100 / 0.05 = 2,000 requests per second. With 5,000 in progress, 5,000 / 0.05 = 100,000 requests per second, provided the cache server and the CPU can keep up. The request latency is still 50 ms in both cases.
A report generator spends 900 ms of CPU and 100 ms of I/O on each report, and runs on an 8-core machine. Will virtual threads raise its throughput much?
Answer
No. The work is CPU-bound: eight cores can do at most 8 / 0.9 ≈ 9 reports per second of CPU work, however many threads there are. Virtual threads can only hide the 10% that is waiting. A pool of about 8 to 9 threads already keeps the cores busy.
Using the sizing formula, how many platform threads would keep 4 cores busy if each task uses 10 ms of CPU and waits 40 ms?
Answer
4 × (1 + 40 / 10) = 4 × 5 = 20 threads. With fewer, the cores sit idle while tasks wait. With many more, tasks just queue for the cores.
Previous: Creating Java Virtual Threads: startVirtualThread, Thread.Builder, Factories and Executors
Next: How Java Virtual Threads Work Under the Hood: Mounting, Unmounting and Heap Stacks

More in Modern Java Concurrency
Quiz: Java Concurrency Changes From Java 21 to Java 28
Sixteen questions on what changed release by release: virtual threads final in 21, synchronized without pinning in 24, scoped values final in 25, and the long road of structured concurrency from subclasses to open() and Joiner, the Java 26 and 27 refinements, and final in 28.
Quiz: Java Concurrency's Delicate Details
Twenty edge cases of modern Java concurrency that surprise experienced developers: virtual thread priorities and names, semaphores without owners, null scoped values, cancelling a CompletableFuture, pool sizing with unbounded queues, and StructuredTaskScope's strict rules.
Quiz: Java Concurrency Interview Questions (Virtual Threads, Structured Concurrency, Scoped Values)
Twenty questions of the kind interviewers ask about modern Java concurrency: platform vs virtual threads, pinning, pools and limits, CompletableFuture, structured concurrency, scoped values vs ThreadLocal, reactive programming, and production diagnostics.
Quiz: Modern Java Concurrency Final Exam (All 7 Parts)
The final exam for the modern Java concurrency course: thirty questions across all seven parts, from platform threads, pools and CompletableFuture through virtual threads, the scheduler, structured concurrency, scoped values, reactive streams and frameworks.
Discussion
Sign in to ask a question or share what you learned.