jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Missing hook or statistic for QoSHandler rejections by exceeding setMaxSuspendedRequestCount

Open scscgit opened this issue 5 months ago • 0 comments
trafficstars

Jetty version(s) jetty-server-12.0.15

Enhancement Description QoSHandler, which is recommended by the Thread Pool documentation (and addresses issues like #13004), can be configured using parameters like:

  • setMaxRequestCount
  • setMaxSuspend
  • setMaxSuspendedRequestCount

To monitor the server state or measure statistics:

  • As long as some requests are suspended, it's possible to retrieve their current count using getSuspendedRequestCount.
  • To count the number of rejections due to exceeding the setMaxSuspend duration, we can override the protected method failSuspended and use it as a hook.
    • Though, the we can't perfectly rely on it, because in addition to in case of timeout while suspended, it also documents that it's triggered in case of failure when trying to handle a resumed request, but I believe that's pretty unlikely.
  • However, a similar option to measure the number of requests that have been instantly rejected due to exceeding the setMaxSuspendedRequestCount queue size is not available.

My suggestion is that you could extend the API to either:

  • expose a hook method to handle the rejection due to a full queue, or
  • measure the number of rejections directly.

There is actually a method in QoSHandler that already handles this, named notAvailable. However, it is a private method. Can you please consider changing it to a protected method? :)

  • If we needed a workaround, due to the Java reflection limitations, we'd probably have to resort to AOP or a bytecode manipulation...

Thx!

scscgit avatar Jun 14 '25 17:06 scscgit