Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Ideally, the web application should be able to examine the requests in the backlog, and give priority to high value customers and administration users. But with the standard blocking servlet API, it is not possible to examine a request without allocating a thread to that request for the duration of it's handling. There is no way to delay the handling of low priority requests and if the resources are to be reallocated, then the low priority requests must all be failed.

QoSFilter

The Quality of Service Filter (QoSFilter) uses Suspendable Requests to avoid thread starvation, prioritize requests and give graceful degredation under load, so that a high quality of service can be provided. The filter can be applied to specific URLs within a web application and will limit the number of active requests being handled for those URLs. Any requests in excess of the limit are suspended.

When a request completes handling the limited, URL, one of the waiting requests is resumed, so that it may be handled. Priorities may be given to each suspended request, so that high priority requests are resumed before low prority requests.

Required JARs

These JAR files must be available within WEB-INF/lib:

...

Code Block
xml
xml
<filter>
  <filter-name>QoSFilter</filter-name>
  <filter-class>org.mortbay.servlet.QoSFilter</filter-class>
  <init-param>
    <param-name>maxRequests</param-name>
    <param-value>5<value>50</param-value>
  </init-param>
</filter>

...

Code Block
xml
xml
<filter-mapping>
  <filter-name>QoSFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

...

Configuration

The following init parameters are supported:

maxRequests

...

the maximum number of requests to be serviced at a time.

maxPriority

...

the maximum valid priority that can be assigned to a request. A request with a high priority value is more important than a request with a low priority value.

waitMS

...

length of time, in milliseconds, to wait while trying to accept a new request. Used when the maxRequests limit is reached.

suspendMS - length of time, in milliseconds, that the request will be suspended if it is not accepted immediately. If not set, the container's default suspend period will be used.

Customizing the priority

To customize the priority, subclass QoSFilter and then override the getPriority(ServletRequest request) method to return an appropriate priority for the request. Higher values have a higher priority. You can then use this subclass as your QoS filter. Here's a trivial example:

...

Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery