Here's my server.xml file. I'm using Tomcat 4 in standalone. I guess I'm not understanding the connection pooling part of what you sent. I thought the maxProcessors part was for that. I'm still reading through it all, but the JVM part I've already done.
<!-- Example Server Configuration File --> <!-- Note that component elements are nested corresponding to their parent-child relationships with each other --> <!-- A "Server" is a singleton element that represents the entire JVM, which may contain one or more "Service" instances. The Server listens for a shutdown command on the indicated port. Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" or "Loggers" at this level. --> <Server port="8005" shutdown="SHUTDOWN" debug="0"> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" (and therefore the web applications visible within that Container). Normally, that Container is an "Engine", but this is not required. Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" or "Loggers" at this level. --> <!-- Define the Tomcat Stand-Alone Service --> <Service name="Tomcat-Standalone"> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Each Connector passes requests on to the associated "Container" (normally an Engine) for processing. By default, a non-SSL HTTP/1.1 Connector is established on port 8080. You can also enable an SSL HTTP/1.1 Connector on port 8443 by following the instructions below and uncommenting the second Connector entry. SSL support requires the following steps (see the SSL Config HOWTO in the Tomcat 4.0 documentation bundle for more detailed instructions): * Download and install JSSE 1.0.2 or later, and put the JAR files into "$JAVA_HOME/jre/lib/ext". * Execute: %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows) $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix) with a password value of "changeit" for both the certificate and the keystore itself. By default, DNS lookups are enabled when a web application calls request.getRemoteHost(). This can have an adverse impact on performance, so you can disable it by setting the "enableLookups" attribute to "false". When DNS lookups are disabled, request.getRemoteHost() will return the String version of the IP address of the remote client. --> <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector className="org.apache.catalina.connector.http.HttpConnector" port="80" minProcessors="5" maxProcessors="225" enableLookups="true" redirectPort="443" acceptCount="20" debug="0" connectionTimeout="60000" bufferSize="10240"/> <!-- Note : To disable connection timeouts, set connectionTimeout value to -1 --> <!-- Define an SSL HTTP/1.1 Connector on port 8443 --> <Connector className="org.apache.catalina.connector.http.HttpConnector" port="443" minProcessors="5" maxProcessors="225" enableLookups="true" acceptCount="20" debug="0" scheme="https" secure="true" bufferSize ="10240"> <Factory className="org.apache.catalina.net.SSLServerSocketFactory" clientAuth="false" protocol="TLS" keystorePass="ducati"/> </Connector> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector className="org.apache.ajp.tomcat4.Ajp13Connector" port="8009" minProcessors="5" maxProcessors="75" acceptCount="10" debug="0"/> <!-- Define a Proxied HTTP/1.1 Connector on port 8081 --> <!-- See proxy documentation for more information about using this. --> <!-- <Connector className="org.apache.catalina.connector.http.HttpConnector" port="8081" minProcessors="5" maxProcessors="75" enableLookups="true" acceptCount="10" debug="0" connectionTimeout="60000" proxyPort="80"/> --> <!-- Define a non-SSL HTTP/1.0 Test Connector on port 8082 --> <!-- <Connector className ="org.apache.catalina.connector.http10.HttpConnector" port="8082" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="10" debug="0"/> --> <!-- 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). --> <!-- Define the top level container in our container hierarchy --> <Engine name="Standalone" defaultHost="localhost" debug="0"> <!-- The request dumper valve dumps useful debugging information about the request headers and cookies that were received, and the response headers and cookies that were sent, for all requests received by this instance of Tomcat. If you care only about requests to a particular virtual host, or a particular application, nest this element inside the corresponding <Host> or <Context> entry instead. For a similar mechanism that is portable to all Servlet 2.3 containers, check out the "RequestDumperFilter" Filter in the example application (the source for this filter may be found in "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters"). Request dumping is disabled by default. Uncomment the following element to enable it. --> <!-- <Valve className="org.apache.catalina.valves.RequestDumperValve"/> --> <!-- Global logger unless overridden at lower levels --> <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/> <!-- Because this Realm is here, an instance will be shared globally --> <Realm className="org.apache.catalina.realm.MemoryRealm" /> <!-- Replace the above Realm with one of the following to get a Realm stored in a database and accessed via JDBC --> <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="org.gjt.mm.mysql.Driver" connectionURL ="jdbc:mysql://localhost/authority?user=test;password=test" userTable="users" userNameCol="user_name" userCredCol ="user_pass" userRoleTable="user_roles" roleNameCol="role_name" /> --> <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin: @ntserver:1521:ORCL?user=scott;password=tiger" userTable="users" userNameCol="user_name" userCredCol ="user_pass" userRoleTable="user_roles" roleNameCol="role_name" /> --> <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="sun.jdbc.odbc.JdbcOdbcDriver" connectionURL="jdbc:odbc:CATALINA" userTable="users" userNameCol="user_name" userCredCol ="user_pass" userRoleTable="user_roles" roleNameCol="role_name" /> --> <!-- Define the default virtual host --> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true"> <!-- Normally, users must authenticate themselves to each web app individually. Uncomment the following entry if you would like a user to be authenticated the first time they encounter a resource protected by a security constraint, and then have that user identity maintained across *all* web applications contained in this virtual host. --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" debug="0"/> --> <!-- Access log processes all requests for this virtual host. By default, log files are created in the "logs" directory relative to $CATALINA_HOME. If you wish, you can specify a different directory with the "directory" attribute. Specify either a relative (to $CATALINA_HOME) or absolute path to the desired directory. --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix =".txt" pattern="common"/> <!-- Logger shared by all Contexts related to this virtual host. By default (when using FileLogger), log files are created in the "logs" directory relative to $CATALINA_HOME. If you wish, you can specify a different directory with the "directory" attribute. Specify either a relative (to $CATALINA_HOME) or absolute path to the desired directory.--> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> <!-- Define properties for each web application. This is only needed if you want to set non-default properties, or have web application document roots in places other than the virtual host's appBase directory. --> <!-- Tomcat Root Context --> <!-- <Context path="" docBase="ROOT" debug="0"/> --> <!-- Tomcat Manager Context --> <Context path="/manager" docBase="manager" debug="0" privileged="true"/> <!-- Tomcat Examples Context --> <Context path="/examples" docBase="examples" debug="0" reloadable="true" crossContext="true"> <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_examples_log." suffix=".txt" timestamp="true"/> <Ejb name="ejb/EmplRecord" type="Entity" home="com.wombat.empl.EmployeeRecordHome" remote="com.wombat.empl.EmployeeRecord"/> <!-- PersistentManager: Uncomment the section below to test Persistent Sessions. saveOnRestart: If true, all active sessions will be saved to the Store when Catalina is shutdown, regardless of other settings. All Sessions found in the Store will be loaded on startup. Sessions past their expiration are ignored in both cases. maxActiveSessions: If 0 or greater, having too many active sessions will result in some being swapped out. minIdleSwap limits this. -1 means unlimited sessions are allowed. 0 means sessions will almost always be swapped out after use - this will be noticeably slow for your users. minIdleSwap: Sessions must be idle for at least this long (in seconds) before they will be swapped out due to maxActiveSessions. This avoids thrashing when the site is highly active. -1 or 0 means there is no minimum - sessions can be swapped out at any time. maxIdleSwap: Sessions will be swapped out if idle for this long (in seconds). If minIdleSwap is higher, then it will override this. This isn't exact: it is checked periodically. -1 means sessions won't be swapped out for this reason, although they may be swapped out for maxActiveSessions. If set to >= 0, guarantees that all sessions found in the Store will be loaded on startup. maxIdleBackup: Sessions will be backed up (saved to the Store, but left in active memory) if idle for this long (in seconds), and all sessions found in the Store will be loaded on startup. If set to -1 sessions will not be backed up, 0 means they should be backed up shortly after being used. To clear sessions from the Store, set maxActiveSessions, maxIdleSwap, and minIdleBackup all to -1, saveOnRestart to false, then restart Catalina. --> <!-- <Manager className ="org.apache.catalina.session.PersistentManager" debug="0" saveOnRestart="true" maxActiveSessions="-1" minIdleSwap="-1" maxIdleSwap="-1" maxIdleBackup="-1"> <Store className="org.apache.catalina.session.FileStore"/> </Manager> --> <Environment name="maxExemptions" type="java.lang.Integer" value="15"/> <Parameter name="context.param.name" value="context.param.value" override="false"/> <Resource name="jdbc/EmployeeAppDb" auth="SERVLET" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/EmployeeAppDb"> <parameter><name>user</name><value>sa</value></parameter> <parameter><name>password</name><value></value></parameter> <parameter><name>driverClassName</name> <value>org.hsql.jdbcDriver</value></parameter> <parameter><name>driverName</name> <value>jdbc:HypersonicSQL:database</value></parameter> </ResourceParams> <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/> <ResourceParams name="mail/Session"> <parameter> <name>mail.smtp.host</name> <value>localhost</value> </parameter> </ResourceParams> </Context> </Host> </Engine> </Service> <!-- The MOD_WEBAPP connector is used to connect Apache 1.3 with Tomcat 4.0 as its servlet container. Please read the README.txt file coming with the WebApp Module distribution on how to build it. (Or check out the "jakarta-tomcat-connectors/webapp" CVS repository) To configure the Apache side, you must ensure that you have the "ServerName" and "Port" directives defined in "httpd.conf". Then, lines like these to the bottom of your "httpd.conf" file: LoadModule webapp_module libexec/mod_webapp.so WebAppConnection warpConnection warp localhost:8008 WebAppDeploy examples warpConnection /examples/ The next time you restart Apache (after restarting Tomcat, if needed) the connection will be established, and all applications you make visible via "WebAppDeploy" directives can be accessed through Apache. --> <!-- Define an Apache-Connector Service --> <Service name="Tomcat-Apache"> <Connector className="org.apache.catalina.connector.warp.WarpConnector" port="8008" minProcessors="5" maxProcessors="75" enableLookups="true" appBase="webapps" acceptCount="10" debug="0"/> <!-- Replace "localhost" with what your Apache "ServerName" is set to --> <Engine className="org.apache.catalina.connector.warp.WarpEngine" name="Apache" debug="0"> <!-- Global logger unless overridden at lower levels --> <Logger className="org.apache.catalina.logger.FileLogger" prefix="apache_log." suffix=".txt" timestamp="true"/> <!-- Because this Realm is here, an instance will be shared globally --> <Realm className="org.apache.catalina.realm.MemoryRealm" /> </Engine> </Service> </Server> Thank You, Justin A. Stanczak Web Manager Shake Learning Resource Center Vincennes University (812)888-5813 |---------+----------------------------> | | kathee | | | <[EMAIL PROTECTED]> | | | | | | 10/30/02 09:45 AM| | | Please respond to| | | "Tomcat Users | | | List" | | | | |---------+----------------------------> >--------------------------------------------------------------------------------------------------------------| | | | To: Tomcat Users List <[EMAIL PROTECTED]> | | cc: | | Subject: Re: How do I increase performance on Tomcat? | >--------------------------------------------------------------------------------------------------------------| Tomcat Tuning Notes (applies to all versions and a good start) ** Exerpted from: http://jakarta.apache.org/tomcat/tomcat-3.2-doc/uguide/tomcat_ug.html. Please see this for the complete Tomcat User Guide. Real World Configuration Tips By default the Tomcat distribution comes with a naive configuration whose main goal is to promote first time user experience and an "out of the box" operation... This configuration however is not the best way to deploy Tomcat on real sites. For example, real sites may require some performance tuning and site-specific settings (additional path elements for example). This section will try to get you started by directing you to the first steps that should be taken before publishing a Tomcat based site. Modify and Customize the Batch Files As stated in the previous sections, the startup scripts are here for your convenient. Yet, sometimes the scripts that are needed for deployment should be modified: To set resource limits such as maximum number of descriptors. To add new CLASSPATH entries (for example, JDBC drivers). To add new PATH/LD_LIBRARY_PATH entries (for example, JDBC drivers DLLs). To modify the JVM command line settings. Make sure that you are using a specific JVM (out of the two or three JVMs installed on your machine). To switch user from root to some other user using the "su" UNIX command. Your pet reason. Some of these changes can be done without explicit changes to the basic scripts; for example, the tomcat script can use an environment variable named TOMCAT_OPTS to set extra command line parameters to the JVM (such as memory setting etc.). On UNIX you can also create a file named ".tomcatrc" in your home directory and Tomcat will take environment information such as PATH, JAVA_HOME, TOMCAT_HOME and CLASSPATH from this file. On NT however (and also on UNIX when the modifications are for something such as the JVM command line) you are forced to rewrite some of the startup script... Do not hesitate, just do it. Modify the Default JVM Settings The default JVM settings in the tomcat script are very naïve; everything is left for defaults. There are a few things that you should consider to improve your Tomcat performance: Modify your JVM memory configuration. Normally the JVM allocates an initial size for the Java heap and that's it, if you need more then this amount of memory you will not get it. Nevertheless, in loaded sites, giving more memory to the JVM improves Tomcat's performance. You should use command line parameters such as -Xms/-Xmx/-ms/-mx to set the minimum/maximum size of the Java heap (and check to see if the performance was improved). Modify your JVM threading configuration. The SUN JDK1.2.2 for Linux comes with support for both, green and native threads. In general native threads are known to provide improved performance for I/O bound applications, green threads on the other hand put less stress on the machine. You should experiment with these two threading models and see which model is better for your site (in general, native threads are better). Select the best JVM for the task. There are several JVM vendors, for example on Linux there are today (21/03/2000) two product level JVMs: the SUN JDK1.2.2 and the IBM JDK1.1.8. If your application does not require a specific JDK functionality, you should benchmark the two JVMs and select the better one. In my (Gal Shachor) internal tests I found the IBM JVM significantly faster than the one created by SUN, you should check that for yourself and make a calculated decision. Modify your Connectors The Connectors, as configured in Tomcat's default server.xml contains two Connectors configured as in the next server.xml fragment: The two default Connectors in server.xml <!-- (1) HTTP Connector for stand-alone operation --> <Connector className="org.apache.tomcat.service.PoolTcpConnector"> <Parameter name="handler" value="org.apache.tomcat.service.http.HttpConnectionHandler"/> <Parameter name="port" value="8080"/> </Connector> <!-- (2) AJPV12 Connector for out-of-process operation --> <Connector className="org.apache.tomcat.service.PoolTcpConnector"> <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/> <Parameter name="port" value="8007"/> </Connector> Is a Connector that listens on port 8080 for incoming HTTP requests. This connector is needed for stand-alone operation. Is a Connector that listens on port 8007 for incoming AJPV12 requests. This connector is needed for web-server integration (out-of-process servlet integration). The AJPV12 Connector is required for Tomcat shutdown. However, the HTTP Connector may be removed if stand-alone operation is not needed. Use a Thread Pool in your Connectors Tomcat is a multi-threaded servlet container this means that each request needs to be executed by some thread. Prior to Tomcat 3.2, the default was to create a new thread to serve each request that arrives. This behavior is problematic for loaded sites because: Starting and stopping a thread for every request puts a needless burden on the operating system and the JVM. It is hard to limit the resource consumption. If 300 requests arrive concurrently Tomcat will open 300 threads to serve them and allocate all the resources needed to serve all the 300 requests at the same time. This causes Tomcat to allocate much more resources (CPU, Memory, Descriptors...) than it should and it can lead to low performance and even crashes if resources are exhausted. The solution for these problems is to use a thread pool, which is the default for Tomcat 3.2. Servlet containers that are using a thread pool relieve themselves from directly managing their threads. Instead of allocating new threads; whenever they need a thread they ask for it from the pool, and when they are done, the thread is returned to the pool. The thread pool can now be used to implement sophisticated thread management techniques, such as: Keeping threads "open" and reusing them over and over again. This saves the trouble associated with creating and destroying threads continuously. Usually the administrator can instruct the pool not to keep too many idle threads, freeing them if needed. Setting an upper bound on the number of threads used concurrently. This prevents the resources allocation problem associated with unlimited thread allocation. If the container maxed out to the threads upper limit, and a new request arrives, the new request will have to wait for some other (previous) request to finish and free the thread used to service it. You can refine the techniques described above in various ways, but these are only refinements. The main contribution of thread pools is thread-reuse and having a concurrency upper bound that limits resource usage. Using a thread pool in Tomcat is a simple move; all you need to do is to use a PoolTcpConnector in your <Connector> configuration. For example the following server.xml fragment defines ajpv12, pooled Connector: Pooled ajpv12 Connector <!-- A pooled AJPV12 Connector for out-of-process operation --> <Connector className="org.apache.tomcat.service.PoolTcpConnector"> <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/> <Parameter name="port" value="8007"/> </Connector> This fragment is very simple and the (default) pool behaviour instructed by it is: Upper bound for concurrency of 50 threads. When the pool has more then 25 threads standing idle it will start to kill them. The pool will start 10 threads on creation, and it will try to keep 10 vacant threads (as long as the upper bound is kept). The default configuration is suitable for medium load sites with an average of 10-40 concurrent requests. If your site differs you should modify this configuration (for example reduce the upper limit). Configuring the pool can be done through the <Connector> element in server.xml as demonstrated in the next fragment: Configuring the Thread Pool <!-- A pooled AJPV12 Connector for out-of-process operation --> <Connector className="org.apache.tomcat.service.PoolTcpConnector"> <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/> <Parameter name="port" value="8007"/> <Parameter name="max_threads" value="30"/> <Parameter name="max_spare_threads" value="20"/> <Parameter name="min_spare_threads" value="5" /> </Connector> As can be seen the pool has 3 configuration parameters: max_threads - defines the upper bound to the for the concurrency, the pool will not create more then this number of threads. max_spare_threads - defines the maximum number of threads that the pool will keep idle. If the number of idle threads passes the value of max_spare_threads the pool will kill these threads. min_spare_threads - the pool will try to make sure that at any time there is at least this number of idle threads waiting for new requests to arrive. min_spare_threads must be bigger then 0. You should use the above parameters to adjust the pool behavior to your needs. Disable Servlet Auto-Reloading Servlet auto-reloading is really useful for development time. However it is very expensive (in performance degradation terms) and may put your application in strange conflicts when classes that were loaded by a certain classloader cannot co-operate with classes loaded by the current classloader. So, unless you have a real need for class reloading during your deployment you should turn off the reloadable flag in your contexts. On Wed, 2002-10-30 at 09:39, [EMAIL PROTECTED] wrote: > I'm running Tomcat 4 on a Solaris 8 Sparc server. I've been watching the > traffic increase on my server as I add more and more resources over time. > In the process of this I've increased the maximum memory the JVM uses to > keep Tomcat from running out of memory. Then I had to increase the maximum > simultaneous users for the database connection. The next thing I was > getting was no processors error so I increased the maximum processors and > that took care of that problem. Now I'm at a stopping point. The server > doesn't seem to be working very hard. The CPU activity is low and memory > usage is well below what the maximum is set to. The catalina log doesn't > show anymore errors about no processor. All it shows is when another > processor is started. After all this it's still running slow. I've had the > network part checked and it's doing just fine. My question is how can I fix > this problem. It seems to me like it's not allowing enough connections or > something. For example when you load a page from the software it will just > sit there for a little or a lot and then all of a sudden boom it sends the > whole page. It's like the server won't service enough people a once. Can > someone give me some direction? > > > Thank You, > > Justin A. Stanczak > Web Manager > Shake Learning Resource Center > Vincennes University > (812)888-5813 > > > > -- > To unsubscribe, e-mail: < mailto:tomcat-user-unsubscribe@;jakarta.apache.org> > For additional commands, e-mail: < mailto:tomcat-user-help@;jakarta.apache.org> > -- To unsubscribe, e-mail: < mailto:tomcat-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: < mailto:tomcat-user-help@;jakarta.apache.org> -- To unsubscribe, e-mail: <mailto:tomcat-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>