Architecture in Motion · Episode 016

The bank keeps working. Our server can help the next shopper.

Four shoppers need to pay. Our server has two workers (OS threads). The bank takes time to process each payment.

One small experiment

A, B, C, D are four different shoppers. “Bank” means the external payment service in this example.

The bank is processing these payments right now

Platform: our worker sends a payment, then stays occupied until the bank answers.
Virtual: during supported I/O, Java pauses that waiting request, so our worker can help the next shopper.

These are payments being processed, not successful or completed payments. The bank takes the same time per payment in both examples. This is a constructed scheduling example, not a benchmark.

⚙ Our server preparing a request⌛ Our server waiting for the bank’s answer🏦 Bank processing payment✓ Payment result returned

The same letter in a thread box and the payment service represents one request using both resources. A carrier is the OS thread running a virtual thread. This is a constructed sequence, not a stopwatch or benchmark; packet motion does not create work.

What should I notice?

What do “thread” and “carrier” mean?

A thread runs the Java code for a request. A platform thread is tied to an operating-system thread. A virtual thread is a lightweight Java thread. During supported blocking I/O, Java can pause the virtual thread and free its underlying operating-system thread (its carrier) for another request. Java 21 pinning can prevent that release for some operations.

What if a payment times out?

A browser timeout does not prove the payment failed. Show “We’re checking your payment”, keep the original attempt reference, and look up its result before another payment operation. The four letters here represent four different shoppers, not four retries of one payment.

Explore timeout, retry and recovery scenarios ↗
Explore advanced limits and recovery

The detailed nine-scenario lab keeps the demand sliders, waiting-room limits, database pool, payment identity, restart and multiple-replica experiments.

Open advanced capacity and payment lab ↗
What does a virtual thread improve?