TomcatExpert

Ask the Experts

Send us your questions on how to improve, troubleshoot or manage your Apache Tomcat deployment. Our team of Apache Tomcat committers and community leaders will review all submitted questions, and post the most relevant questions along with an answer from a real Tomcat Expert. The questions and answers will be made public for the community to collectively learn from and discuss.

Questions submitted are not guaranteed to be posted. The selection process will favor  questions of the day that are the most interesting, timely, or relevant to our community.  Ensuring your questions is concise, well written, and without annoying broken links, bad grammar or spelling errors will help your question to be answered more readily by the  Community Moderators.

Ask the Experts : Tomcat on Multi-Core System

Hi to All,

I am having the foolowing queries.

 

1. How to make to run the Tomcat on more than one core(Multi-Core)?

2. Can some body give me the documentation/article about the tuning of Tomcat to run on muti-core.

 

Thanks in Advance!!

asked by karthikeyan

question

Tomcat runs great on multi-processor / multi-core servers out-of-the-box.  There is no additional configuration required take advantage of a multi-processor / multi-core setup.

As for tuning Tomcat, you may want to take a look at the various connectors offered by Tomcat.  Each connector is different and has it's strengths and weaknesses.  You can see more information about the connectors at the following link.

  https://tomcat.apache.org/tomcat-7.0-doc/connectors.html
  https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
  https://tomcat.apache.org/tomcat-7.0-doc/config/ajp.html

answered by dmikusa on January 23, 2012 08:26 AM

Read More

answer

0 comments   |  

0
Rating
  |  

|

Ask the Experts : Tomcat 7 and Parallel Deployment

We are trying to deploy 2 versions of the same application on Tomcat 7 to test its parallel deployment features for our application.

Not meeting with success, I was looking for  a definitive guide for parallel deployment on Tomcat 7.

 

Our application is a JSP based application but we can have changes often.

asked by csaoin

question

The definitive reference for parallel deployment comes directly from the Apache Software Foundation: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Parallel_deployment.

Additionally, Mark Thomas wrote a summary article explaining how this feature works on the Context Container and across clusters: http://www.tomcatexpert.com/blog/2011/05/31/parallel-deployment-tomcat-7.

answered by SpringSource on January 6, 2012 07:13 AM

Read More

answer

0 comments   |  

0
Rating
  |  

Developers, Operations | Parallel Deployment, Tomcat 7, Tomcat Configuration

Ask the Experts : How to configure a single Apache Tomacat 7 instance to serve with multiple domains

Yes, this feature has been available in tomcat for a while.

http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html

You would create multiple <Host> elements

answered by fhanik on January 5, 2012 12:40 PM

Read More

answer

0 comments   |  

0
Rating
  |  

Developers | Apache Tomcat 7, Tomcat Configuration

Ask the Experts : Configure Tomcat Memory Settings

Need to configure a linux (RedHat AS4) Tomcat 6.0.32 server's memory settings. After reviewing numerous guides about confiugring tomcat's memory, I realized I am seriously confused.  I attempted to configure the heap memory by adding setenv.sh file to the /opt/apache-tomcat-6.0.32/bin folder.  Here is the content of setenv.sh file.
      export CATALINA_OPTS="-Xms768m -Xmx768m"

asked by chill

question

You are on the right track.

You have...

 - created "bin/setenv.sh"
 - exported the CATALINA_OPTS environment variable
 - added the settings to configure the initial and max heap values to 768m

You just need to...

  - add -XX:PermSize and -XX:MaxPermSize to CATALINA_OPTS to configure PermGen to be 512M.
  - add -XX:NewSize and -XX:MaxNewSize to CATALINA_OPTS to configure YoungGen to be 200M.
  - restart your Tomcat instance

One note, unless you really, really know what you are doing I wouldn't recommend explicitly configuring the size of the YoungGen space.  The JVM does a great job of sizing this automatically.  Unless you have done some serious load testing on your application or you have been given exact instructions by a 3td party vendor, I would suggest just using the defaults.

Lastly, there are a couple ways that you can confirm that your settings are working.

1.) Run "ps aux | grep catalina" (or some other version of the "ps" command).  Look at your Tomcat process.  You should see all of the options that you've put into CATALINA_OPTS (and many more) included on the command line for your process.  If you see them listed here then they are active.

2.) Connect to Tomcat with "jconsole", click the "VM Summary" tab and look at the "VM arguments" section.  Again, you should see the options that you added to CATALINA_OPTS listed here.

3.) Run "jinfo <tomcat-pid>".  The last thing it prints will be the VM Flags.  These should include the options that you've specified in CATALINA_OPTS.


Lastly, I would suggest that you read these two articles.  This is more than just a shameless plug for my posts smiley.  They were written to gently introduce people to the concepts of JVM tuning (for Tomcat).  Furthermore, when you feel that you understand the topics presented in the article, you can progress along to the more advanced articles in the links.  This gentle progression should help take some of the confusion out of JVM tuning.

  http://www.tomcatexpert.com/blog/2011/11/16/setting-measurement-garbage-collection-apache-tomcat
  http://www.tomcatexpert.com/blog/2011/11/22/performance-tuning-jvm-running-tomcat

Hope that helps!

answered by dmikusa on January 10, 2012 07:32 AM

Read More

answer

0 comments   |  

0
Rating
  |  

Operations | memory

Ask the Experts : Connection get closed after a network sweep

Hi,

I am using tomcat jdbc pool with microsoft (sqljdbc4) driver. The network team runs some network sweep once every week. After this process, the connections get closed. And it does not get connected again. Then we have to restart the servers. Is there a configuration which will help in getting the connection again?

Thanks.

asked by sivakumarok

question

I'm not entirely sure what you mean by a "network sweep".  However, if your database connections are being closed for whatever reason, you need to configure your DataSource to detect the closed connections and evict them from the pool.

One way to do that is by adding the attributes testOnBorrow="true" and validationQuery="SELECT 1" (you might need to adjust the validation query for SQL Server compatibility).

With these options, jdbc-pool will execute the validation query on each connection prior to it's use by your applciation.  If the validation query fails then the connection will be removed from the pool.

For more details, please see the documentation for jdbc-pool.

https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html

Dan

answered by dmikusa on January 17, 2012 07:06 AM

Read More

answer

0 comments   |  

0
Rating
  |  

Developers | connectin closed, jdbc connection pool

Ask the Experts : How to create/modify global connection pool on the fly?

Is it possible to create and modify global connection pool on the fly?

I want do be able to deploy new applications using new global connection pool without restart tomcat. I don't want to use context.xml file in my applications.

The article http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency shows how to create global connection pool configuring conf/server.xml file, but I don't know how to reflect change without restarting tomcat.

asked by persapiens

question

Is it possible to create new resources (as in <GlobalNamingResources><Resource .../></GlobalNamingResources>) at runtime?  No.  To create new global resources you need to modify "conf/server.xml" and restart Tomcat.

Is it possible to modify existing global resources?  It depends.  Some resources expose properties via JMX and those properties can be modified through jconsole.  If your resource exposes the properties that you need to modify then you should be able to update them at runtime.

Typically, when you need to be able to modify a resource without restarting Tomcat you would define that in your Context.  That way you can make changes to the Context, redeploy your application and see the changes all without restarting Tomcat.

answered by dmikusa on January 20, 2012 05:05 AM

Read More

answer

0 comments   |  

0
Rating
  |  

Operations | global connection pool fly runtime

Ask the Experts : How to decrease memory used by Tomcat at 32 bit windows 2003 server

Hi all,

Our system is 32 bit Windows 2003 server. We have increased java heap size to max value for 32 bit OS. But we still need much more RAM for Tomcat server. Is there a way to decrease used memory or increase memory?

Thanx

 

asked by secdinc

question

The simplest solution is to upgrade to a 64-bit OS.  That will allow the OS to address more memory and it will allow you to run a 64-bit JVM, which can then take advantage of the additional memory addressable by the OS.

If you are stuck running a 32-bit OS then you're limited by two factors:  the amount of memory addressable by your OS and by the amount of memory addressable by a 32-bit JVM.  Some operating systems will allow you to work around the first limitation by enabling PAE [1], however there is no way to work around the second limitation. 

The technical limit for a 32-bit JVM is 4G (i.e. 2^32 bytes), however the actual amount of memory that can be used by a 32-bit JVM is going to be less than that.  There are several factors which will limit the amount of memory available (such as OS usage, OS per processor limits and JVM non-heap usage).  In practice, I've seen people report getting anywhere from 1.5 to 2.5G for a max heap size (-Xmx).

Having said that, you can see that it is possible for you to increase the available heap space by doing things like reducing the amount of memory consumed by the OS.  However if you already have a large heap allocated to your application, it is not likely that you'll be able to increase the heap size very much (since you'd have to take it from somewhere else). 

If you need to significantly increase the heap size then the only viable solution is to upgrade to a 64-bit operating system.
 

[1] - https://en.wikipedia.org/wiki/Physical_Address_Extension

 

answered by dmikusa on January 12, 2012 08:43 AM

Read More

answer

0 comments   |  

0
Rating
  |  

Executives |

Ask the Experts : Delays between Apache and Apache Tomcat

 

Our configuration consists of the following components (all of them are running on a single Windows Server 2003 machine):

  • Apache Web Server - version 2.2.16 (with mod_jk version 1.2.31)
  • Tomcat Server - version 5.5.30

We are load testing the server with relatively simple requests.
It seems that under load (~8000 requests we are sending per minute from our load simulator) - we have a delay between apache web server and the mod_jk component.

asked by nir.zilberman

question

Make sure you configure both Apache httpd and mod_jk to handle the traffic.

This means, the number of threads(workers) that httpd has will impact your system.

Also, in high concurrency, how you configure KeepAlive is important. There is a chance that Apache is using its threads waiting for the next request on idle connections, while active connections are not being handled. 

Posting your configuration files may be a good idea.

 

best

Filip

answered by fhanik on June 15, 2011 07:09 PM

Read More

answer

0 comments   |  

0
Rating
  |  

| AJP, apache, HTTP

Ask the Experts : Application logging locations with multiple Apache Tomcat instances?

I am about to install an extra tomcat instance on our test server

- I like to know how you configure the location of your application log files? Where do you put these and how to configure these?

I am thinking about the following on our linux machine: 
Have one central app log location: /applog/ that contains sub dir's demo and test:

/applog/demo
/applog/test
 

asked by edbras

question

Application logging is not something that is tied to Apache Tomcat itself. Apache Tomcat has no knowledge about where these logs go, how they are written and how they are configured. It would require knowledge about the application logging framework to understand how to configure this in your environment.

As for the catalina.home variable, this points to Apache Tomcat's binaries. There is another variable, catalina.base, this points to your actual Apache Tomcat's instance, and that is the variable you could use.

It would not be good for you to rename these variables, as Apache Tomcat itself depends on them.

answered by fhanik on June 16, 2011 11:32 AM

Read More

answer

0 comments   |  

0
Rating
  |  

Developers | logging

Ask the Experts : DATAGUARD Oracle

How do you configure Tomcat 6 for use Oracle Dataguard? We have one physical database in site1 up and one  physical database in site2 down. 

asked by tomtomcat

question

The Data Guard configuration is something you do on the Oracle server itself. For the Oracle Dataguard documentation online go here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/toc.htm

How the application accesses this is by using Oracle's JDBC driver.  This you configure as a JNDI resource, and using Oracle's configuration.

answered by fhanik on January 31, 2011 12:22 PM

Read More

answer

0 comments   |  

0
Rating
  |  

Developers | dataguard jdbc oracle