Tomcat: HTTP-based ctor configuration, tomcatconne
Tomcat ctor Ctor is the Connector for request receiving and request processing. Specifically, the received request is passed to the Tomcat WEB container for processing.
Tomcat can process requests of different protocols, such as HTTP and AJP. AJP is the protocol used by Tomcat to connect to other Web servers (such as Apache Server and IIS.
For the HTTP protocol, the IO methods in the Socket can be divided into BIO, NIO, and APR methods.
Below is a simple description of the BIO and NIO methods in Tomcat 6:
BIO mode:
The Acceptor is responsible for receiving the Socket and passing the socket to a Worker in the worker queue. Worker is responsible for calling HTTP11Processor to parse the Request, encapsulate it into a Request Response object, and then process it by the WEB container.
<Connector port = "8080" protocol = "HTTP/1.1" ConnectionTimeout = "20000" RedirectPort = "8443" type = "regxph" text = "yourobjectname"/> |
1) acceptCount: the maximum length of the waiting queue. To put it bluntly, when all threads are occupied, an HTTP request can be placed in the column for processing. Generally, this value is greater than the maximum number of threads in the thread pool. The setting of this field is not found in Tomcat 6 source code. You need to confirm it.
2) maxThreads: the maximum number of threads in the thread pool. 200 by default. If Executor is used, it indicates the maximum number of threads in the execution Thread pool. If Executor is not used, it indicates the maximum number of workers. Each worker holds a Thread, so it also sets the maximum number of processing threads.
3) connectionTimeout: The maximum waiting time before the connector receives the request after Tomcat establishes a Socket connection with the access end. The default value is 60 seconds.
4) keepAliveTimeout: HTTP1.1 uses the keepalive method by default. Multiple HTTP requests can be sent when a connection is established. This attribute is used to set how long the connector will wait for the next HTTP request before the connection is closed (if the next connection cannot be reached within the specified time, the connection will be closed ).
5) maxKeepAliveRequests: the maximum number of requests that can be received after a connection is established. The default value is 100.
NIO mode:
The Acceptor uses the nio api to receive SocketChannel and encapsulate it into a NIOChannel, which is then put into the PollerEvent queue by Poller.
Poller encapsulates a Selector. Pooler is used to select the event that can be processed from PollerEvent for processing.
When processing an envent, the event that can be processed is sent to a Worker in the worker queue. The worker processing process is the same as that in BIO.
1) acceptorThreadCount: Number of threads that receive Socket connections. The default value is 1. This value does not need to be too large. The maximum value is the same as the number of CPU cores.
2) selecorTimeout: select the time-out period.
3) maxKeepAliveRequests: Same as BIO.
4) maxThreads maximum number of threads