Skip to content

Instantly share code, notes, and snippets.

@terrancesnyder
Created May 30, 2011 17:34
Show Gist options
  • Save terrancesnyder/999198 to your computer and use it in GitHub Desktop.
Save terrancesnyder/999198 to your computer and use it in GitHub Desktop.
Tomcat Multi-Instance Server.xml Based on Springsource
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="${shutdown.port}" shutdown="SHUTDOWN">
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<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="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
Common parameters are listed here for convience, if modifying
the defaults please add the parameter to this list and mark
the parameter as having been modified.
acceptCount:
The maximum queue length for incoming connection requests
when all possible request processing threads are in use.
Any 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.
Increase this value on a multi CPU 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. Default value is 1.
connectionTimeout: (MODIFIED FOR THIS INSTALL)
The number of milliseconds this Connector will wait, after
accepting a connection, for the request URI line to
be presented. The default value is 60000 (i.e. 60 seconds).
maxKeepAliveRequests:
The maximum number of HTTP requests which can be pipelined
until the connection is closed by the server.
Setting this attribute to 1 will disable HTTP/1.0 keep-alive,
as well as HTTP/1.1 keep-alive and pipelining. Setting this
to -1 will allow an unlimited amount of pipelined or
keep-alive HTTP requests. If not specified,
this attribute is set to 100.
maxThreads: (MODIFIED FOR THIS INSTALL)
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.
maxConnections:
he maximum number of connections that the server will accept
and process at any given time. When this number has been
reached, the server will not accept any more connections until
the number of connections reach below this value. The operating
system may still accept connections based on the acceptCount
setting. This setting is currently only applicable to the
blocking Java connectors (AJP/HTTP). Default value is 10000.
processorCache: (MODIFIED FOR THIS INSTALL)
The protocol handler caches Processor objects to speed up performance.
This setting dictates how many of these objects get cached.
-1 means unlimited, default is 200.
Set this value somewhere close to your maxThreads value.
URIEncoding: (MODIFIED FOR THIS INSTALL)
This specifies the character encoding used to
decode the URI bytes, after %xx decoding the URL. If
not specified, ISO-8859-1 will be used.
-->
<Connector port="${http.port}"
protocol="HTTP/1.1"
maxThreads="200"
maxKeepAliveRequests="1"
processorCache="200"
URIEncoding="UTF-8"
connectionTimeout="2000"
redirectPort="8443" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!--
Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common"
!!!! REMOVED to prevent extra IO costs !!!!
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>
-->
</Host>
</Engine>
</Service>
</Server>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment