You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by James McIntosh <ja...@snaphire.com> on 2007/02/22 03:31:45 UTC

Maximum single threaded moldel servlets

Hi,

I am trying to find out how to limit the number of Single Threaded Model
servlets which get created by the StandardWrapper.

I have looked at the API and there is a setMaxInstances(int) method but
I cannot find anywhere in the config xml files to change it.
I did find the "wrapperClass" attribute for the <Context> element which
allows you to override StandardWrapper with another class which I could
call the setMaxInstances from.

Is there a more elegant way such as:

<web-app>

<servlet>
  <servlet-name />
  <servlet-class />
  <servlet-max-stm-instances />
</servlet>

</web-app>

Kind regards
James McIntosh


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Maximum single threaded moldel servlets

Posted by James McIntosh <ja...@snaphire.com>.
Hi Remy,

I want to go the other way and decrease the number of servlets created
due to the heavy amount of objects hanging off each of these servlets.

What I have done is modify the addInitParameter method to look for an
init parameter "stm-max-instances" thus allowing the parameter to be
placed in the web.xml as a servlet init parameter.

Do you see any problems with using the approach (code below).

------------------------

package test.tomcat;

import org.apache.catalina.core.StandardWrapper;

public class STMStandardWrapper extends StandardWrapper {
  
  private static final String MAX_STM_INSTANCES_INIT_PARAMETER =
"stm-max-instances";
  
  public STMStandardWrapper() {
    super();
  }
  
  public void addInitParameter(String name, String value) {
    super.addInitParameter(name, value);

    if (MAX_STM_INSTANCES_INIT_PARAMETER.equals(name)) {

      try {

        int max = Integer.parseInt(value);

        System.out.println("Override default max instances for servlet" 
            + getServletName() 
            + "(" 
            + getServletClass() 
            + ") to " 
            + value);

        super.setMaxInstances(max);

      } catch (NumberFormatException nfe) {
        System.out.println("Servlet init parameter '" 
            + MAX_STM_INSTANCES_INIT_PARAMETER 
            + "' for servlet " 
            + getServletName() 
            + "(" 
            + getServletClass() 
            + ") was not an integer (" 
            + value 
            + ")");
      }
    }
  }
}

------------------------


Kind regards
James McIntosh


On Thu, 2007-02-22 at 03:57 +0100, Rémy Maucherat wrote:
> On 2/22/07, James McIntosh <ja...@snaphire.com> wrote:
> > Hi,
> >
> > I am trying to find out how to limit the number of Single Threaded Model
> > servlets which get created by the StandardWrapper.
> >
> > I have looked at the API and there is a setMaxInstances(int) method but
> > I cannot find anywhere in the config xml files to change it.
> > I did find the "wrapperClass" attribute for the <Context> element which
> > allows you to override StandardWrapper with another class which I could
> > call the setMaxInstances from.
> 
> Nobody asked for configuration of this before. I don't think you need
> to increase it beyond the default value in the real world: 20 threads
> for one servlet is significant.
> 
> Rémy


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Maximum single threaded moldel servlets

Posted by Rémy Maucherat <re...@gmail.com>.
On 2/22/07, James McIntosh <ja...@snaphire.com> wrote:
> Hi,
>
> I am trying to find out how to limit the number of Single Threaded Model
> servlets which get created by the StandardWrapper.
>
> I have looked at the API and there is a setMaxInstances(int) method but
> I cannot find anywhere in the config xml files to change it.
> I did find the "wrapperClass" attribute for the <Context> element which
> allows you to override StandardWrapper with another class which I could
> call the setMaxInstances from.

Nobody asked for configuration of this before. I don't think you need
to increase it beyond the default value in the real world: 20 threads
for one servlet is significant.

Rémy

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Maximum single threaded moldel servlets

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: James McIntosh [mailto:james@snaphire.com] 
> Subject: Maximum single threaded moldel servlets
> 
> I am trying to find out how to limit the number of 
> Single Threaded Model servlets which get created by
> the StandardWrapper.

I suspect there's not much interest in this aspect of the servlet
environment these days, considering the following quote from section
2.2.1 of the 2.4 servlet spec:

"The SingleThreadModel Interface is deprecated in this version of the
specification."

I don't know when it became deprecated, but it strikes me as a bit risky
to base an application architecture on such a capability.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org