Clone this wiki locally
The HTTP connector is in charge of passing the incoming requests to the Tomcat container. It's properly configured by default but this section describes how we can tweak this default configuration adding or updating parameters.
WARNING: Be sure you understand the implications of changing this connector's setup because it can affect your application behaviour and performance. You should NOT modify it "far" from defaults unless you understand what you're doing. Tuning the server for maximum performance depends on several factors including Java/JRuby option tunings based on your production environment (available memory, number of CPUs).
Into the Trinidad's configuration file we can add a new section to specify the parameters that we want to modify for this connector:
--- http: address: "*" bindOnInit: false # true (default) acceptCount: 50 # 100 (default) acceptorThreadCount: 1 maxThreads: 500 # 100 (default) maximum number of request processing threads minSpareThreads: 100 # minimum number of threads always kept running connectionTimeout: 10000 # 60_000 (default) keepAliveTimeout: 1000 # defaults to connectionTimeout: value, -1 no timeout disableKeepAlivePercentage: 50 # 75 (default) server: "Trinidad"
All the available - configurable parameters can be found in Tomcat's HTTP Connector. Here's a template with defaults :
--- http: allowTrace: false # allow HTTP TRACE method asyncTimeout: 10000 # default timeout for asynchronous requests (async_support: true) in ms enableLookups: false # enables DNS lookups for the actual host name of the remote client maxHeaderCount: 100 # allowed maximum number of headers in a request maxParameterCount: 10000 # maximum number of parameter and value pairs (GET plus POST) maxPostSize: 2097152 # (2 megabytes) maximum size in bytes of the POST which will be parsed parseBodyMethods: POST # comma-separated list of HTTP methods for which bodies parameters are parsed port: 3000 # port number on which the server socket listens awaiting incoming connections # if 0 (zero) then will select a free port at random to use for this connector #protocol: "HTTP/1.1" # the protocol to handle incoming traffic #proxyName: # if used in a proxy configuration, configure this attribute to specify the server name #proxyPort: # if used in a proxy configuration, configure this attribute to specify the server port #scheme: http # e.g. set this attribute to "https" for an SSL Connector #secure: false # set on for an SSL Connector or a connector receiving data from a SSL accelerator #useIPVHosts: false # true causes Tomcat to use the IP address of the received request o determine the host #xpoweredBy: false # Standard Attributes : acceptCount: 100 # maximum queue length for incoming requests when all workers are serving requests acceptorThreadCount: 1 # number of threads to be used to accept connections (no need to set higher than 2) #acceptorThreadPriority: 5 # priority of the acceptor threads - the threads used to accept new connections #address: localhost # which address will be used for listening on the specified port bindOnInit: true # set to false, to bind the socket when the connector is started (instead of init) #compressableMimeType: text/html,text/xml,text/plain #compression: # "off" (disable compression), "on" (allow compression for text data), "force" #compressionMinSize: 2048 # amount of data before the output is compressed (when compression "on") #noCompressionUserAgents: # user-agent regexp for which compression should not be used connectionTimeout: 60000 # 60 seconds - how long to wait after accepting a connection, for the request URI line #disableUploadTimeout: true # allows to use a different (longer) connection timeout during data upload #connectionUploadTimeout: # in ms, to use while a data upload is in progress (assumes disableUploadTimeout: false) #keepAliveTimeout: # defaults to connectionTimeout: value set -1 to indicate no (i.e. infinite) timeout #restrictedUserAgents: # UA regexp of clients for which HTTP/1.1 or HTTP/1.0 keep alive is not used #maxConnections: # maximum number of accepted connections (for BIO defaults to acceptCount: value) maxExtensionSize: 8192 # limits the total length of chunk extensions in chunked HTTP requests maxHttpHeaderSize: 8192 # maximum size of the request and response HTTP header, specified in bytes #maxKeepAliveRequests: 100 # -1 will allow an unlimited amount of keep-alive HTTP requests disableKeepAlivePercentage: 75 # percentage of request threads that have to be in use before keep-alive gets disabled maxThreads: 200 # maximum number of request processing threads to be created minSpareThreads: 10 # minimum number of threads always kept running #server: "Apache-Coyote/1.1" # overrides the HTTP Server header for the response socketBuffer: 9000 # buffer size for socket output buffering. -1 disables the use of a buffer tcpNoDelay: true # controls TCP_NO_DELAY on the server socket #threadPriority: # priority of the request processing threads within the JVM
Tomcat also provides a NIO (Non-Blockin) connector that can replace the default BIO (Blocking-IO) HTTP connector. To enable it, add the option nio: under the HTTP configuration.
We do recommend tuning the default connector first before going into NIO as in most cases it does not really have that much of an impact. Reducing a keep-alive timeout is usually the first thing to do to increase IO throughput. NIO might be suitable for those cases where a long keep-alive timeout is desirable and most requests use it heavily.
You'll also need NIO if you wish to use Sendfile (or use APR if you're planning on using it with Apache), sample configuration :
--- address: * # ... http: nio: true # ...
All of the above configuration attributes apply to NIO as well but it also supports a few more, please refer to: NIO Specific Configuration
Trinidad can use a Apache Portable Runtime based native library if you need better integration with native (Apache) server technologies. To enable APR you will need to install the library first, please refer to the official documentation on how to do this, then enable APR :
--- address: 127.0.0.1 # ... http: apr: true # ...