• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet thread pool management with JMX

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlet containers let you set the maximum thread pool size for all servlets residing in them. I have serveral servlets running in a container, but I want to ensure that each servlet only gets a certain percentage of the maximum thread pool... in other words, if my servlet container has a thread pool of 600 and I have 3 servlets, I want to ensure that each servlet is only capable of grabbing 200 threads. Is it possible to use JMX to manage and even reallocate on the fly how many threads a single servlet in a container is allowed to have?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is nothing in the spec for this so it would be container specific.
Which one are you using?
 
Joshua Fix
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SJSAS 9.1 and Tomcat 5.5.

Each servlet represents a service. Each individual service is susceptible to sudden increases in traffic loads and I need the ability to dynamically limit the number of resources/threads that other services in the container are allowed to consume. The clients (commercial products that I have no control over) are also very prone to over-requesting, so it's currently possible for a single person to accidentally consume a very large number of threads. I'd like to ensure that if one service is suffering the equivalent of a denial of service attack, the other services in the container are not affected.

Are you saying that JMX is not capable of this?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joshua Fix:

Are you saying that JMX is not capable of this?



I'm not.
I'm saying that there is nothing in the servlet spec about this.
I don't know if this type of control is exposed to JMX from within Tomcat but I'll move this thread to our Tomcat forum for you.
Someone there might.

-Ben
 
Joshua Fix
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe this is going to require a little more craftiness on the container side than I imagined... I've come to learn that it's not possible and doesn't make sense to limit the number of threads allowed per servlet, so I'd like to re-define my problem.

Can JMX (or any other technology) help me manage the total number of sessions allowed per web application if I have multiple web applications running in a single container? It just so happens that in my situation, I will treat a single servlet as a complete web application.

All of the configuration and management options I see affect the entire container, but I really need to control how those resources that belong to the container are shared amongst the web apps that reside in the container.
[ May 14, 2008: Message edited by: Joshua Fix ]
 
Joshua Fix
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here was the solution I implemented:

I specified the use of the org.apache.catalina.session.StandardManager in my context.xml file, which allows me to set an attribute for maxActiveSessions.

http://tomcat.apache.org/tomcat-6.0-doc/config/manager.html

I then use the http jmx interface for tomcat management to change the value at will for any specific web app on the server:

http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html

I wrote a JSP/servlet that will allow me to specify a server, username, and password, connect to the jmxproxy page, scrape the page for all of the web applications and associated attributes, then display them and provide forms to modify each attribute.

The only thing I still haven't resolved, which is very frustrating, is that the maxInactiveInterval attribute in the StandardManager has no effect when entered in the context.xml file. The session-timeout element in the web.xml file is what tomcat will use. The problem is that the value in web.xml is in minutes, with the lowest possible value of 1. I want to invalidate my sessions immediately after the request, so 1 minute is too long. The only way I can find to do this is a) programamtticaly through the HttpSession object which accepts a value in seconds and overrides the web.xml value, or b) through the JMX manager application that I just wrote.

Cheers
 
reply
    Bookmark Topic Watch Topic
  • New Topic