Spring Boot 4 + Virtual Threads proof-of-concept for an async bulkhead (fail-fast admission, no queue) with a tiny UI + API to generate load, observe saturation, and cancel in-flight work.
- Fail-fast admission: when the bulkhead is saturated, new requests are rejected immediately.
- “Cold” downstream work: downstream work should only start when admission succeeds.
- Accounting of terminal outcomes:
SUCCESS/FAILURE/CANCELLEDcounters. - Virtual Threads: runs with
spring.threads.virtual.enabled=true.
- Java 21+
- Maven 3.9+
mvn spring-boot:runThen open:
- UI: http://localhost:8080/
- API: see endpoints below
Set in src/main/resources/application.properties:
poc.bulkhead.limit— max in-flight admitted operationspoc.downstream.failureRate— simulate downstream failure probabilitypoc.downstream.minDelayMs/poc.downstream.maxDelayMs— simulate downstream latency range
GET /— dashboard (bulkhead snapshot + counters + in-flight registry)POST /ui/submit?n={N}— submit N operations (redirects back to /)POST /ui/cancel/{id}— cancels an in-flight operation (redirects back to /)
POST /api/submit?n={N}— submits N operations, returns{ "submitted": N }POST /api/try-once— submits one; returns 200 if accepted or 429 if rejectedPOST /api/cancel/{id}— cancels by id, returns{ "id": "...", "cancelIssued": true|false }
mvn testNotes for Spring Boot 4:
@WebMvcTestimport isorg.springframework.boot.webmvc.test.autoconfigure.WebMvcTest@MockBeanwas removed; use@MockitoBeanfromorg.springframework.test.context.bean.override.mockito.MockitoBean
If you mock final classes (e.g., BulkheadRejectedException), add:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>This POC targets async-bulkhead v0.3.x semantics. Ergonomic and observability improvements introduced in v0.4.0 are intentionally not reflected yet.
Licensed under the Apache License, Version 2.0.
See the LICENSE file for details.