TomcatExpert

Performance Tuning the JVM for Running Apache Tomcat

posted by dmikusa on November 22, 2011 09:13 AM

This article is the second in a series discussing how to performance tune the JVM to better run Apache Tomcat. In the first article, we discussed the basic basic goals and how to monitor the performance of your JVM.

If you have not read the first article, I would strongly suggest reading that before continuing with this article. It is important to understand and follow the processes outlined in that article when performance tuning. They will both save you time and prevent you getting into trouble. With that, let's continue.

Tuning the JVM

At this point we've covered the basics and are ready to begin examining the JVM options that are available to us. Please note that while these options can be used for any application running on the JVM, this article will focus sole only how they can be applied to Tomcat. The usage of these options for other applications may or may not be appropriate.

Note: For simplicity, it is assumed that you are running an Oracle Hotspot JVM.

General Options

-Xms and -Xmx

These settings are used to define the size of the heap used by the JVM. -Xms defines the initial size of the heap and -Xmx defines the maximum size of the heap. Specific values for these options will depend on the number of applications and the requirements of each application deployed to a Tomcat instance.

With regard to Tomcat, it is recommended that the initial and maximum values for heap size be set to the same value. This is often referred to as a fully committed heap and this will instruct the JVM to create a heap that is initially at its maximum size and prevent several full garbage collections from occurring as the heap expands to its maximum size.

-XX:PermSize and -XX:MaxPermSize

These settings are used to define the size of the permanent generation space. -XX:PermSizedefines the initial value and -XX:MaxPermSize defines the maximum value.

With regard to Tomcat, it is recommended that the initial and maximum values for the size of the permanent generation be set to the same value. This will instruct the JVM to create the permanent generation so that it is initially at its maximum size and prevent possible full garbage collections from occurring as the permanent generation expands to its maximum size.

At this point, you might be thinking that this seems awful similar to the -Xms and -Xmx options, and while the concept is the same, “PermGen” or permanent generation, refers to the location in memory where the JVM stores the class files that have been loaded into memory. This is different and distinct from the heap (specified by -Xms and -Xmx) which is where the JVM stores the object instances used by an application.

One final note, if the PermGen space becomes full (regardless of the availability of memory in the heap) then the JVM will attempt a full garbage collection to reclaim space. This can often be a source of problems for applications which dynamically create or load a large number of classes. Proper sizing of -XX:PermSize and -XX:MaxPermSize for your applications will allow you to work around this issue.

-Xss

This setting determines the size of the stack for each thread in the JVM. The specific value that you should use will vary depending on the requirements of the applications deployed to Tomcat, however in most cases the default value used by the JVM is too large.

For a typical installation, this value can be lowered, saving memory and increasing the number of threads that can be run on a system. The easiest way to determine a value for your system is to start out with a very low value, for example 128k. Then run Tomcat and look for a StackOverFlow exception in the logs. If you see the exception, then gradually increase the value and restart Tomcat. When the exceptions disappear, you have found the minimal value which works for your deployment.

-server

This setting will select the Java HotSpot Server VM. This will instruct the VM that it is running in a server environment and the default configurations will be changed accordingly.

Note, this option is really only needed when running 32-bit Windows, as 32-bit Solaris and 32-bit Linux installations with two or more CPU's and 2GB or more of RAM will enable this option by default. In addition, all 64-bit OS's have this option enabled by default as there is no 64-bit client VM.

For a comprehensive list of JVM options, please see the article Java HotSpot VM Options.

Selecting a Collector

For many users, tuning the basic options I mentioned in the previous section will be sufficient for their applications. However, for larger applications or applications which just require larger heap sizes these options may not be sufficient. If your Tomcat installation fits this profile then you'll want to take one further step and tune the collector.

To begin tuning the collector, you need to pick the right collector for your application. The JVM ships with three commonly used collectors: the serial collector, the parallel collector and the concurrent collector. In most cases when running Tomcat, you'll be using either the parallel collector or the concurrent collector. The difference between the two being that the parallel collector typically offers the better throughput, while the concurrent collector often offers lower pause times.

The parallel collector can be enabled by adding -XX:+UseParallelGC to CATALINA_OPTS or the concurrent collector can be enabled by adding -XX:+UseConcMarkSweepGC to CATALINA_OPTS (you would never want to have both options enabled). As to which of the collectors you should be using, it is difficult to give a blanket recommendation. I would suggest that you give both a try, measure the results and use that to make your decision.

Once you have selected a collector, it is possible to take one further step and apply some configuration settings which are specific to the collector. That being said, most of the time the JVM will detect and set excellent values for these options. You should not attempt to manually configure these unless you have a good understanding of how the specific garbage collector is working, you are applying rule number one from above and you really know what you are doing. That said, I'm going to talk about two options, one for the parallel collector and one for the concurrent collector.

When you specify the option to run the parallel collector, it will only run on the young generation. This means that multiple threads will be used to process the young generation, but the old generation will continue to be processed by a single thread. To enable parallel compaction of the old generation space you can enable the option -XX:+UseParallelOldGC. Note that this option will help the most when enabled on a system with many processors.

When you specify the option to run the concurrent collector, it is important to realize that garbage collection will happen concurrently with the application. This means that garbage collection will consume some of the processor resources that would have otherwise been available to the application. On systems with a large number of processors, this is typically not a problem. However, if your system has only one or two processors then you will likely want to enable the -XX:+CMSIncrementalMode option. This option enables incremental mode for the collector, which instructs the collector to periodically yield the processor back to the application and essentially prevents the collector from running for too long.

Conclusion

Congratulations! If you're reading this then you made it all the way through the article. If you're still a little confused at this point, that is OK and I would say normal. Tuning the JVM and the inner workings of the garbage collectors is not an easy subject.

If you'd like to get some additional information on the subject, I would strongly suggest continuing on with this article from Oracle, Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning. It is very technical and should be able to fill in any of the gaps left from this article.

Daniel Mikusa is a Software Support Engineer at Pivotal.  Daniel has been a user of Apache Tomcat for the past six years and is currently focused on providing enterprise-class support for Pivotal's Tomcat and tc Server customers. Daniel attended college at Kent State University and holds a bachelor's degree in Computer Science.

Comments

Kontent Machine Software

On this subject internet page, you'll see my best information, be sure to look over this level of detail.
Kontent Machine

Create A Spectacle

I surprised with the analysis you made to make this particular publish incredible. Wonderful activity!
facebook management for law firms

You're so cool! I don't think

You're so cool! I don't think I've read anything like this before. So good to find somebody with some original thoughts on this subject. Thanks for starting this up. pvc vloeren kampen

That is great submit and also

That is great submit and also i spend time you just read this kind of submit. your blog will be great and you also have got excellent employees within your website. great revealing keep it up.
Official iPhone unlock

How to Prevent Skin Wrinkles at an Early Age

Solutions how to prevent wrinkles at an early age by using glaucoberry beauty supplements.
Hello Ledis, Congratulations met again with Satelitherbal.com This time we will discuss about skin wrinkles. The majority of women in the world are afraid of the appearance of wrinkles in women, especially at an early age. Not many of them are doing to avoid expensive treatments.
How to Prevent Skin Wrinkles at an Early Age

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Drug lumps In Squad

The solution to the drug lumps on the back without operating the safest and most effective you can use extracts of mangosteen peel and leaves of the soursop.
Drug lumps In Squad

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Lump In Groin drugs

Solutions for lumps in the groin drugs most appropriate and safe you can use ramuat menceoba ace maxs herbal medicine made from the mangosteen peel and leaves of the soursop is very useful and has remarkable properties to help remove and kill cancer cells and even cancer.

Lump In Groin drugs

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Lipoma Lumps drug Without Surgery

Info lipoma lump drugs without surgery using herbal medicine ace maxs safe and efficacious. The main content of mangosteen peel and leaves of the soursop are believed to have the ability to ward off and kill cancer cells and even cancer penyabab lipoma safely and without side effects.
Lipoma Lumps drug Without Surgery

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Traditional medicine Step / Seizures In Children

Traditional Medicine Info Step / Seizures In Children are safe and effective without side effects. Made from natural ingredients that are safe for all ages, especially for children or infants.
Traditional medicine Step / Seizures In Children

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Agen Jelly Gamat Gold G In Palembang

Agen Jelly Gamat Gold G In Palembang, info this time we will proclaim the news to you who are in the city of Palembang and its surroundings areas. Especially for herbal medicine subscriber jelly gamat gold g are confused or who want sipel menesan and fast. Now comes AGENT GOLD GAMAT JELLY G in the city of Palembang.
Agen Jelly Gamat Gold G In Palemban

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How To Overcome Disorders In Eyes

How To Overcome Disorders In Mata, There are many disorders of the eye that you must Hidari, and there should be more careful to prevent the factors of different causes of disorders of the eye. There are several eye disorders that you should be aware of the following information
How To Overcome Disorders In Eyes

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Order Kidney Care Capsule

How to Order Kidney Care Capsule, We are the agent of kidney care herbal medicine capsule that will serve ordering herbal medicine, the best ministry as send stuff first.
obatkencingbatu.dkes.org/cara-pemesanan

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Eliminate Black Spots On Crotch

How to Eliminate Black Spots In Groin, There are several ways remove the black spots in the groin with natural and without side effects by using herbal supplements.
How to Eliminate Black Spots On Crotch

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Drug Consumption way Tonsils From Ace Maxs

How does the consumption of herbal medicine ace maxs? Of course this question will be implied in your mind for those who do not yet know how to consume the full efficacy of natural medicine maxs ace.
Drug Consumption way Tonsils From Ace Maxs

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Cure Piles Quickly

How to Cure Hemorrhoids Quickly, Solutions for the way you cure hemorrhoids safely and quickly without surgery. Hemorrhoid is disturbing even hemorrhoid disease you can say dangerous can even be fatal you, the only solution to how to cure hemorrhoids you are using herbal remedies ace maxs (mangosteen peel and leaves of the soursop), which is believed mempu cure even eliminate hemorrhoids you quickly and without surgery.
How to Cure Piles Quickly

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Lump In medicine Backs Without Surgery

The solution to the drug lumps on the back without operating the safest and most effective you can use extracts of mangosteen peel and leaves of the soursop.
Lump In medicine Backs Without Surgery

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Whiten Underarm And Crotch Quickly

Info how to whiten armpits and groin quickly and safely, we provide tips that might be a little help alleviate your problem.
How to Whiten Underarm And Crotch Quickly

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Cysts Without Surgery drug

Solutions for cysts without surgery drugs that are safe and effective, you can use herbal medicine extracts of mangosteen peel and leaves of the soursop mempu prevent and cure the cysts quickly and without causing side effects.
Cysts Without Surgery drug

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Traditional medicine Step / Seizures In Children

Traditional Medicine Info Step / Seizures In Children are safe and effective without side effects. Made from natural ingredients that are safe for all ages, especially for children or infants.
Traditional medicine Step / Seizures In Children

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to cope with Neural kejepit

Info kejepit nerve to cope with the fast and safe, for this discussion we will provide advice to those of you who have neurological complaints kejepit we are ready to help you. Why kejepit nerve can happen ????
How to cope with Neural kejepit

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Hepatitis drug Without Surgery

Hepatitis drug solution without operating the safest you can use extracts sea cucumbers are believed from antiquity to the present, Cucumber has many benefits that are very remarkable, especially for diseases especially hepatitis.

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Hepatitis drug Without Surgery

Hepatitis drug solution without operating the safest you can use extracts sea cucumbers are believed from antiquity to the present, Cucumber has many benefits that are very remarkable, especially for diseases especially hepatitis.
Hepatitis drug Without Surgery

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Use Glucoberry

Menampilkan terjemahan untuk Cara Pemakaian Glucoberry, Glucoberry adalah Suplemen kecantikan herbal yang mempunyai banyak khasiat terutama untuk merawat kulit kita agar selalu sehat dan bersih, bahkan Glucoberry ini di percaya mampu mencegah dan mengatasi penyakit kulit dan masalah kulit lainya. Glucoberry terbuat dari 100% bahan alami : L-Glutatathione, Collagen, Elasting, Minyak Nabati, dan Extract Strawberry. Yang tidak meragukan lagi Glucoberry ini aman karna sudah tedaftar resmi di DINKES ( dinas kesehatan ) Nomor PIRT 2100022334455 sehingga terbukti keamanannya untuk di konsumsi.
Terjemahkan selain dari Cara Pemakaian Glucoberry, Glucoberry adalah Suplemen kecantiak hebal yang mempunyai banyak khasiat terutama untuk merawat kulit kita agar selalu sehat dan bersih, bahkan Glucoberry ini di percaya mampu mencegah dan mengatasi penyakit kulit dan masalah kulit lainya.
How to Use Glucoberry

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Consumption ways Gluberry

Consumption ways Gluberry For info Glucoberry beauty supplements herbal supplements is a little different with kecantikalinya. For how to wear this glucoberry not in topical or made in the face mask but to glucoberry in consumption because glucoberry shaped sebuk and in consumption, many benefits and efficacy of a very remarkable mainly for maintaining healthy skin thoroughly / outside and inside.
Consumption ways Gluberry

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Cope With Fast Dry Skin

Info how to cope with dry skin quickly and safest, you can try glucoberry reliable beauty supplements can prevent and overcome various kinds masalahkulit you completely.
How to Cope With Fast Dry Skin

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Eliminate Black Spots On Face Naturally

Info eliminating black spots on the face naturally using Glucoberry beauty supplements secured and very promising, Department of Health and no registration port on 2100022334455.
How to Eliminate Black Spots On Face Naturally

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Drug stye In Mata

The solution to the drug in the eye stye you can use herbal medicine green world that can overcome bintitian in the eye with safe and secure.
tipspolahidupsehatyangbenar.blogspot.com/2016/01/obat-bintitan-pada-mata.html

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Natural Medicines Skin Lightening Face & Body Whole

Natural Medicines Skin Lightening Face & Body Comprehensive Safe and without harmful side effects also terdaptar in the Health Service!
obatalamipemutihkulit.mkes.info

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Traditional medicine Ulcer Most Effective

For info traditional ulcer drugs most efficacious use of extracts of sea cucumbers with guaranteed safe and powerful way to overcome your ulcer disease quickly.
Traditional medicine Ulcer Most Effective

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

DRUG lung spots

DRUG lung spots | NATURAL HERBAL Efficacious By using extracts of sea cucumbers guaranteed safe and effective without side effects

DRUG lung spots

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Eliminate Black Spots On Face Naturally

Info eliminating black spots on the face naturally using Glucoberry beauty supplements secured and very promising, Department of Health and no registration port on 2100022334455.
How to Eliminate Black Spots On Face Naturally

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How To Deal With Dry Skin Naturally

Info how to cope with dry skin naturally using Glucoberry beauty supplements, providing excellent results and evenly.
How To Deal With Dry Skin Naturally

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Mumps TOXIC DRUGS

Toxic goiter disease drug solution using mangosteen peel extract and leaves of the soursop guaranteed safe and effective with no side effects.
Mumps TOXIC DRUGS

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Herbal Impotence drugs

The right solution for herbal impotence drug that is safe and effective with no side effects
Impotence drugs herbal solutions for how to fix your impotence can we recommend to consume vig power, because the content of this power vig herbal medicine can help cure impotence at the same time you quickly safely and without side effects.
Herbal Impotence drugs

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Varicose veins drugs

Varicose veins are the safest drugs and without side effects "GOODS TO NEW TRANSFER payouts"
Solutions for varicose veins most potent drugs, herbal medicine was able to overcome delays varicose blood flow stopped so by using drugs varicose veins. Efficacy of sea cucumbers contained in this trust varicose veins drugs capable of treating various kinds of diseases, especially for the problem of varicose veins.
Varicose veins drugs

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Bumps On Chest medicine

Information on breast lumps drug that is safe and without side effects.
Bumps On Chest medicine >> For those who have a complaint bumps on the chest and did not feel comfortable you can immediately cope with jusketrak mangosteen peel and leaves of the soursop can be overcome and heal berjolan or lumps in your breasts safely and quickly.
Bumps On Chest medicine

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Whiten Groin Thigh With Fast & Comprehensive

How to whiten the crotch thighs quickly and thoroughly, how to whiten Info groin thigh in menyelurih quickly and safely, you are very fit and very appropriate to visit our blog. On this occasion we will discuss about the groin or armpit even whiten your face quickly and menyelurih certainly safe and without side effects.
How to Whiten Groin Thigh With Fast & Comprehensive

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Consumption ways Eye Care Softgel

How to Order softgel Eye Care, Eye Care Softgel is a natural supplement blueberry extract of green products world outside Indonesia that have properties to prevent and cope with sharing disorders and diseases of the eye.
Consumption ways Eye Care Softgel

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Polyps medicine Anus

Info polyps anus safe drug, to treat diseases of the anus quickly polyps naturally and without surgery. In this occasion we will discuss how to prevent and how to overcome the disease polyps anus quickly, safely and without surgery.
obatpolipanus.blogspot.com

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

legality Glucoberry

Glucoberry legality, welcome and congratulations join our official website, in this occasion we will discuss about the legality of official glucobery so glucoberry in trust and in a very safe and very beneficial for consumption primarily to treat skin thoroughly.
legality Glucoberry

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Cara Pemesanan Glucoberry

How to Order Glucoberry, For ordering glucoberry beauty supplements you can memesanya here. You should know that the original glucoberry not sold in drug stores or pharmacies totko. So to get Glucoberry original, cheap and secure keaslinannya there could be directly memasn to us. Berukit how to order.
How to Order Glucoberry

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Guaranteed safe and effective without side effects. For informat

Guaranteed safe and effective without side effects.
For information on traditional medicine myoma you can try using the mangosteen peel extract and leaves of the soursop can cure once curing myomas quickly and without side effects.
Traditional medicine myomas

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Natural medicine Cervical Polyps

Cervical polyps drug solution naturally using extracts of mangosteen peel and leaves of the soursop proven safe and effective finalize your cervical polyps.
Natural medicine Cervical Polyps

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Drug Whitening Face Naturally Without Side Effects

Drug Whitening Face | Naturally Without Side Effects, Tips bleach facial proven safe and you can try it here
ow.ly/XfTvr

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

How to Whiten Underarm And Crotch Quickly

Info how to whiten armpits and groin quickly and safely. Maybe the tips that we provide will slightly help reduce your problem.
How to Whiten Underarm And Crotch Quickly

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Polyps medicine Anus

Info polyps anus safe drug, to overcome the disease anal polyps quickly and naturally and without surgery here the solution.
Polyps medicine Anus

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Consumption Method Info Kidney Care Capsule

Drug bladder stones without proper and safe operation, you can use herbal medicine products are reliable green world 100% without any side effects. information how the consumption of kidney care capsule, the capsule Kidney care khsusu medicine bitter melon and women who have complaints such as urinary stone disease gallstones and other hinjal disease. Kidney capsule care in production by using machines that canggis moder and can keep kemurnianya so capsule of kidney care in the trust as a remedy bladder stones are safe and without side effects.
Consumption Method Info Kidney Care Capsule

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Natural medicine Lipoma

Info for drug lipoma most appropriate natural we suggest you to use the extract of mangosteen peel and leaves of the soursop, which can be believed able to overcome the disease lipoma, or benign tumors quickly. The main Nahan soursop leaf has a very extraordinary benefits especially to kill tumor lipoma penyabab even though cancer.
Natural medicine Lipoma

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Beauty supplements Glucoberry Reliable & Genuine

Trusted & Beauty supplement Glucoberry First, welcome and congratulations to join in playing our site satelitherbal.com who could provide information about the health and herbal treatments are reliable and safe. Not just the treatment alone has been present Supelemen Beauty Glucoberry a trusted able to care for your face and your body to keep it fresh and thorough white.
Beauty supplements Glucoberry Reliable & Genuine

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Polyps medicine Anus

Info drugs safest anal polyps, rectal polyp to overcome the disease rapidly naturally and without surgery.
Polyps medicine Anus
obatpolipanus.blogspot.com/p/cara-pemesanan.html

untuk informasi pengobatan herbal yang sangat aman dan terjamin temukan soluinya di sini

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.