Request admission
- Install a shared Valve budget and follow admission, rejection and route dispatch.
Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.
- A Tomcat Valve runs in the container’s request pipeline. In the example, a permit lets the request continue to the next Valve or servlet. With no permit, block=false and highConcurrencyStatus=503 give the caller an immediate 503.
- The bypass branch requires deliberate placement or custom logic. A health route that bypasses the Valve still needs a connector and an available worker to answer.
Reading
Enable and use SemaphoreValve
Enable and use SemaphoreValve
Tomcat 9.0.122 · SemaphoreValve
Choose the scope
Use Context for one application, Host for its applications, or Engine for the engine scope.
Each installed Valve has its own permit budget. Separate instances do not share one allowance.
Install the XML
For one application, add the Valve to its existing Context in CATALINA_BASE/conf/Catalina/localhost/APP.xml.
Keep existing Context attributes. APP is a placeholder; concurrency=64 is illustrative.
Application Context XMLxml
<Context>
<Valve className="org.apache.catalina.valves.SemaphoreValve"
concurrency="64"
block="false"
highConcurrencyStatus="503" />
</Context>
Set rejection
block=false refuses excess invocations immediately. The default true can wait.
highConcurrencyStatus=503 sends an error response. Default -1 sends no error; refused work does not enter the downstream pipeline.
Activate and verify
Use controlled application redeploy or Tomcat restart, following the target deployment settings.
Manager reload retains the Context and does not reliably install a Valve from changed Context XML. Check actual placement and the rejection response after activation.
Lifetime and bypass
The permit ends when downstream invocation returns; asynchronous work may continue. Cap full logical work with separate completion-aware accounting.
Stock SemaphoreValve has no URL-exclusion list. Use deliberate pipeline placement or controlConcurrency for a selected bypass; permitDenied controls denial.
A bypass reserves no CPU, sockets or workers.
Context XML activation: automatic deployment, modified files. The installed target version and its deployment settings still need checking.
Servlet dispatch
Servlet dispatch
- Business and health routes can be independent dispatch alternatives through a shared connector and application pipeline.
- Sharing a runtime resource does not make one route call another route.
Management execution
Management execution
- Stock SemaphoreValve has no configurable URL-exclusion list; its extension hook or deliberate pipeline placement supplies a selected bypass.
- A bypass does not reserve CPU or connector workers. Diagnostic execution still needs bounded resources and access controls.