In order to accept incoming requests, Tomcat uses a Thread pool. You can configure two types of Thread Pools: Shared Pool and Dedicated Pool.
A Shared pool as the name inplies, can be shared among various components in Tomcat. So, for example if you have three connectors in your configuration, then you can use a single shared pool to serve requests for all of them. Here is how to configure a shared thread pool:
Open Tomcat's server.xml file and include the Executor definition:
Once you have added the shared thread pool, you need to reference it in your Connector configuration as follows:
A Dedicated thread pool is a thread pool which is dedicated to only one connector definition. You can use it in a scenario when you are expecting a peak of connections and you want to have full control over the amounts of threads to be used by your connector.
The dedicated thread pool configuration can be embedded directly into the Connector section of your server.xml. See the following example:
When to use a shared thread pool versus a Dedicated thread pool
Generally speaking a Shared Thread pool is best fit when the number of users expected is not hight and we don't care much about performance. This is the typical scenario for a Development Environment. On the other hand, for production environment when Performance is critical you should consider using a Dedicated Thread Pool.
A Shared pool as the name inplies, can be shared among various components in Tomcat. So, for example if you have three connectors in your configuration, then you can use a single shared pool to serve requests for all of them. Here is how to configure a shared thread pool:
Open Tomcat's server.xml file and include the Executor definition:
namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/>
Once you have added the shared thread pool, you need to reference it in your Connector configuration as follows:
namePrefix="catalina-exec-" maxThreads="200" minSpareThreads="4"/>
A Dedicated thread pool is a thread pool which is dedicated to only one connector definition. You can use it in a scenario when you are expecting a peak of connections and you want to have full control over the amounts of threads to be used by your connector.
The dedicated thread pool configuration can be embedded directly into the Connector section of your server.xml. See the following example:
protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />
When to use a shared thread pool versus a Dedicated thread pool
Generally speaking a Shared Thread pool is best fit when the number of users expected is not hight and we don't care much about performance. This is the typical scenario for a Development Environment. On the other hand, for production environment when Performance is critical you should consider using a Dedicated Thread Pool.
Commenti
Posta un commento