Search code examples
javamultithreadingservletsglassfish-3grizzly

Determine if HTTP resources are available on the webserver


I use Glassfish v3 for serving large files (glassfish is used for business logic as well - FYI) I am aware that Glassfish frontends with Grizzily web-server. I use Grizzily in synchronous mode. Meaning, if there are 100 threads only 100 downloads are allowed. Rest of the requests will be queued. However, I want to set 503 for the HTTP clients which cannot be served due to lack of worker threads (100 max).

Question

  1. Should the requests be even allowed to queued when no worker threads are available
  2. How do I know when the worker threads are exhausted? A manual counter?
  3. where in the code (filter, servlet?) should I set the error code along with retry header data?

Solution

  • Usually these are container specific features. You can configure the requests queue size using the property server.http-service.connection-pool.max-pending-count = 100. All requests beyond 100 will be rejected.

    For more information, refer here:

    Glassfish tuning keepalive requests