Tomcat FAQ

 
 

By default, m-Power utilizes Tomcat  as an application server. The purpose of the Tomcat software is to serve as an intermediary between your end-user's requests and your database server. More information about Tomcat can be found here. While the installation of m-Power is straightforward, when it comes to configuring Tomcat, many users have questions. This document will address the most common Tomcat questions.

What server should I set up Tomcat on? Does Operating System matter?

Tomcat will run on most Operating Systems, so long as Sun provides a JDK (Java Developer Kit) for your operating system.

Is there an Operating System mrc recommends?

The majority of m-Power customers chose Windows for their Tomcat installation. As such, mrc support staff is the most familiar with assisting with Tomcat questions when installed on a Windows Operating System. Additionally, for convenience, m-Power is shipped with JDK 1.6 for Windows as well as a pre-configured Tomcat built specifically for Windows.

Should I install Tomcat on a 32-bit or 64-bit server?

mrc strongly recommends using a 64-bit server. 32-bit servers can handle a maximum of 4 gigabytes of RAM. Whereas 64-bit servers can handle upwards of 32 gigabytes. More information can be found here. It has been our experience that the more RAM that can be configured for Tomcat, the better the user's experience will be.

Why is RAM so important?

RAM, which stands for Random Access Memory, serves as your server's short term memory. Each time Tomcat handles a user's request, data is transferred from the database to the user's device, via Tomcat. Under normal circumstances, there are no issues. As soon as the data has completed loading from the database, it is immediately sent to the client, then cleared from the memory load (called "heap") of your Tomcat server.

However, if an end user is trying to run a report that has too much information, the Tomcat server can potentially run out of available memory. Since the amount of memory configured to Tomcat is a fixed amount, as soon as a request is made that would cause Tomcat's memory to "overflow", an error is shown explaining to the user that there is an issue because not enough memory is available on the heap to satisfy the user's request. The more RAM that is made available to Tomcat, the larger the heap can be, allowing for a more stable environment for the user.

I see that to start Tomcat, I just click on a .bat file that was shipped. Should I do anything differently?

The start_tomcat.bat file that is shipped in the \m-power folder is only sent to verify that m-Power has been installed correctly. When it is time to set up your environment, it is essential that you set up Tomcat as a service. Setting up Tomcat as a service allows you to configure memory allotment and configure options for JVM Tuning. Additionally, setting up Tomcat as a service allows you to configure Tomcat to start automatically upon server start-up.

How do I set up Tomcat as a service?

  1. The first step is to right-click "My computer" and go to "Properties". Click Advanced and go to Environmental Variables.
  2. From here, add ;C:\Program Files\Java\jdk1.6.0_25\bin to the PATH.
    Note: Make sure jdk1.6.0_25 is pointing to the correct folder on your server.
  3. This step requires your machine to be restarted.
  4. Next, go to a PC command line.
  5. Type cd \m-power\tomcat\bin
  6. Type service.bat install TC7DEV where TC7DEV is the desired name of your service
  7. Next, type tomcat7w //ES//TC7DEV where TC7DEV is the service name you chose in the previous step.
    (Editors Note: If using Tomcat 6, please change all references of 7 to 6.)
  8. A window will pop up. Switch to the Java tab.
  9. Change the Java Virtual Machine option to: C:\Program Files\Java\jdk1.6.0_25\jre\bin\server\jvm.dll.
    Note: Make sure this path is pointing to the correct file on your server.
  10. Add the following six lines to the end of the Java Options window:
  11. -Xmx1024m
    -Xms1024m
    -XX:PermSize=512m
    -XX:MaxPermSize=512m
    -XX:+CMSClassUnloadingEnabled
    -XX:+CMSPermGenSweepingEnabled

  12. Hit OK.
  13. Start the service as you usually would.
  14. If you run into any problems, please see this document for more information.

What are all of those Options we should type in the Java Options dialog?

The explanation of Java Tuning options fall outside the realm of this support document, however more information about Java tuning can be found here and here.

I am running a 64-bit operating system and I have 4 gigs of RAM on the server. How should I allot my memory allocation?

This is a difficult question to answer on the FAQ as there are many factors in play. In general, mrc recommends leaving 1 gigabyte of RAM to the operating system. Then allotting memory to Tomcat as needed. Keep in mind that if you are running any other services on this server, such as a database, it will need its own memory allocation.

I increased the numbers you provided, but now Tomcat won't start. Why not?

Tomcat will fail to start if you try to assign it more memory than is available. Lower your numbers in the Java Options display and try again.

I have 4 Gigs installed on my server — why can't I allocate all 4 gigs to Tomcat?

Tomcat is not the only process on your server. Namely, the Operating System itself needs memory to operate. We recommend leaving 1 gig of RAM for the operating system.

I was thinking about setting up another instance of Tomcat to host my Production environment. Do you recommend this?

Absolutely! For numerous reasons that go beyond the scope of this document, a production environment should always be paired to a development environment. Of course, this means that you will need to set up a second instance of Tomcat for production purposes. Keep in mind, memory allotment is not shared between development and production, each will need their own memory allotment. Be sure to configure both environments so that they each have enough resources assigned to them (we recommend at least 1 Gigabyte for each instance) and that your server has enough physical memory for this allocation.

Is there anything I can do to make my Production instance extra stable?

By default, each time a file has been changed in the system, Tomcat notices that change and loads it into memory. Done on a small scale, this will cause no issue. However, done on a wide scale could cause poor performance. In development, this is a desired effect. After all, each time you make or change an application, you want it loaded into memory immediately. However, in a production environment, it is usually better to load changes throughout the day but have them take effect each night, when Tomcat is stopped and started. To do this open the \production\m-power\tomcat\conf\server.xml file. Scroll to the bottom, and under the <!–mrcjava context –> section, set the "reloadable" option to "false". Be sure to save.

Full documentation can be found here.

Any other recommendations to ensure the most stable Tomcat environments?

Yes — mrc highly recommends settings up a pair of simple batch jobs for each instance of Tomcat you have installed. One job would be used for automatically stopping the service. The other would be used to restart it.

The logic inside your TC-Stop.bat file would look like this:

net stop TC7DEV

The logic inside your TC-Start.bat file would look like this:

net start TC7DEV

If you have renamed your Tomcat service something other than "TC7DEV" be sure to reference the new name in its place.

Be sure to repeat for any additional Tomcat instances you have installed.

Lastly, schedule these .bat files to run in off hours through the Windows scheduler. The stop/start process should take under 1 minute to complete.