Request admission

  • Install a shared Valve budget and follow admission, rejection and route dispatch.
100%
TomcatAdmit or reject before independent dispatchRequest / responseHealth checksControl / stateFailure / rejectionpipeline scopeordinary requestselected bypassno permitadmittedbusiness routehealth routeWorker capacity is separate from socket count, queue size and Valve permits. A bypass does not reserve any of these resources. WorkerStock SemaphoreValve has no configured URL-exclusion list. A deliberate pipeline placement/controlConcurrency hook supplies only the intended trusted bypass. Ordinary readiness remains gated.Bypass policyOne installed instance supplies one permit budget at its selected application scope. This illustrative nonblocking profile uses block=false; identical separate instances do not share permits.Admission ValveThe selected bypass stays inside the application JVM and needs its own bounded execution/access contract. It still relies on connector workers and CPU unless independence is deliberately implemented. Management requestIn the chosen block=false profile, unavailable permits reject immediately. This does not cancel work already admitted or create new execution capacity.Local rejectionThe configured health operation executes its own selected checks. It does not exercise every business route or real provider merely because it shares the JVM. Health routeDispatch selects the requested business operation. It shares execution resources with eligible health requests, without calling the health route implicitly. Business routeBusiness and health are independent dispatch alternatives. Sharing a pipeline or gate is not a route-to-route call.Route dispatchpipeline scopeordinary requestselected bypassno permitadmittedbusiness routehealth route

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.
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.