Servlet thread pool vs Servlet instance pool - by the web container

后端 未结 1 1543
南笙
南笙 2021-01-22 14:12

I understand that web containers like jboss have a parameter to mention the number of threads of the servlet to create, which is the maximum number of threads the container can

1条回答
  •  粉色の甜心
    2021-01-22 14:49

    EDIT: Watch out ! As of Servlet Specification 2.4, interface javax.servlet.SingleThreadModel is deprecated, with no direct replacement.

    The specification is unclear as to whether containers should then create several instances of the same servlet, or always only a single instance.


    From Servlet Specification 2.4 http://download.oracle.com/otndocs/jcp/servlet-2.4-fr-spec-oth-JSpec/

    SRV.2.2 Number of Instances

    The servlet declaration which is part of the deployment descriptor of theWeb application containing the servlet, as described in Chapter SRV.13, “Deployment Descriptor”, controls how the servlet container provides instances of the servlet. For a servlet not hosted in a distributed environment (the default), the servlet container must use only one instance per servlet declaration. However, for a servlet implementing the SingleThreadModel interface, the servlet container may instantiate multiple instances to handle a heavy request load and serialize requests to a particular instance.

    In the case where a servlet was deployed as part of an application marked in the deployment descriptor as distributable, a container may have only one instance per servlet declaration per Java Virtual Machine (JVMTM). However, if the servlet in a distributable application implements the SingleThreadModel interface, the container may instantiate multiple instances of that servlet in each JVM of the container.

    You can found in the document more information about Single Thread Model

    0 讨论(0)
提交回复
热议问题