Skip to content

Toro Cloud Dev Center

Tuning Tomcat

Martini ships with Apache Tomcat, and uses it for serving all HTTP requests. Since it's included in Martini, configuring it is slightly different than usual, but it's still easy.

HTTP and HTTPS ports

If you would like to configure the HTTP and HTTPS ports, please refer to this document.

Properties related to the HTTP connector in Tomcat that aren't already documented here are simply added to the Martini application properties using either an server.tomcat.http or server.tomcat.https prefix, depending on which connector you would like to configure.

For example, if you would like to enable TRACE HTTP requests to Martini, add a property called server.tomcat.http.allowTrace and set it to true.


Properties which may be of interest when tuning Martini's Tomcat server include (in alphabetical order):

Property Name Description
acceptCount The maximum queue length for incoming connection requests when all possible request processing threads are in use. Requests received when the queue is full will be refused. The default value is 100.
acceptorThreadCount The number of threads to be used to accept connections. It is recommended to increase this value on a multi-processor machine, although you would never really need more than 2. Also, with a lot of non-keep alive connections, you might want to increase this value as well. The default value is 1.
maxConnections The maximum number of connections that the server will accept and process at any given time. When this number has been reached, the server will accept, but not process, any further connection. Additional connections will be blocked until the number of connections being processed falls below maxConnections, at which point the server will start accepting and processing new connections again.
maxThreads The maximum number of request processing threads to be created by this connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool. If an executor is configured, any value set for this attribute will be recorded correctly but it will be reported (e.g. via JMX) as -1 to make it clear that it is not used.
minSpareThreads The minimum number of threads always kept running. This includes both active and idle threads. If not specified, the default of 10 is used.
port The TCP port number on which this connector will create a server socket and await incoming connections. Your operating system will allow only one server application to listen to a particular port number on a particular IP address. If the special value of 0 (zero) is used, then Tomcat will select a free port at random to use for this connector. This is typically only useful in embedded and testing applications.

Another example could be as follows:

  • HTTP running on port 80
  • HTTP not allowed more than 10 threads
  • HTTPS running on port 443
  • HTTPS using a keystore file located at /home/martini/keystore, with password 12345ABCDE
  • HTTPS has 5 threads that accept connections

When configured via properties, the above would look like: