Modify the conf/server. xml file
Easy Configuration
Step 1: Open the shared Thread Pool
- <ServiceName = "Catalina">
- <! -- The connectors can use a shared executor, you can define one or more named thread pools -->
- <ExecutorName = "tomcatthreadpool" nameprefix = "Catalina-Exec -"
- Maxthreads = "1000" minsparethreads = "50" maxidletime = "600000"/>
<Service name = "Catalina"> <! -- The connectors can use a shared executor, you can define one or more named thread pools --> <executor
Name = "tomcatthreadpool" nameprefix = "Catalina-Exec-" maxthreads = "1000" minsparethreads = "50" maxidletime = "600000"/>
Comments before and after the default value <! --> Drop, remove it. Where
Name
The name used to reference this pool in other places in server. xml. The name is required and must be unique.
This is the name of the thread pool and must be unique. We will use this in the subsequent configuration.
Nameprefix
(String) the name prefix for each thread created by the executor. The thread name for an individual thread will be nameprefix + threadnumber
The thread name prefix, used to mark the thread name, so that each thread adds the thread number with this prefix, such
Catalina-exec-1
Catalina-exec-2
========================================================
Maxthreads
(INT) The Max number of active threads in this pool, default is 200
The maximum number of threads allowed in the thread pool. The default value is 200. High concurrency should be set to a higher value. It is only a limit and does not occupy resources.
Minsparethreads
(INT) The minimum number of threads always kept alive, default is 25
The minimum number of threads that remain active. The default value is 25. This should be adjusted based on the load. Too small will affect the response speed, and too large to occupy resources in vain.
Maxidletime
(INT) the number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minsparethreads. default value is 60000 (1 minute)
The number of threads that exceed the minimum number of active threads. If the idle time exceeds this setting, the thread will be shut down. The default value is 1 minute.
The number of threads created during Tomcat initialization.
Maxthreads Tomcat uses threads to process each request received. This value indicates the maximum number of threads that Tomcat can create.
Acceptcount indicates the number of requests that can be placed in the processing queue when the number of threads that can be used to process requests is used. requests exceeding this number are not processed.
Connnectiontimeout
Network Connection timeout, in milliseconds. If it is set to 0, it indicates that the request Never times out. This setting has potential risks. Generally, it can be set to 30000 ms.
Maxsparethreads
Once the created thread exceeds this value, Tomcat closes the socket thread that is no longer needed.
Threadpriority
(INT) the thread priority for threads in the executor, the default is thread. norm_priority
The thread level. The default value is thread. norm_priority.
========================================================== ========================================================== ===
Step 2
Specify the sharing thread pool in Connector
- <Connector
- Port = "8009"
- Protocol = "AJP/1.3"
- Maxthreads = "5000"
- Executor = "tomcatthreadpool"
<Connector Port = "8009" protocol = "AJP/1.3" maxthreads = "5000" executor = "tomcatthreadpool"
Note: Once the thread pool is used, other thread attributes, such as maxthreads, will be ignored.