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

Faktor Penyebab Penyakit Asam Lambung

Faktor Penyebab Penyakit Asam Lambung, Komplikasi penyakit asam lambung yang paling sering terjadi adalah esofagitis. Esofagitis adalah peradangan atau inflamasi pada dinding esofagus atau kerongkongan.
Faktor Penyebab Penyakit Asam Lambung

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

Info Kesehatan Satelit Herbal

Info kesehatan satelit herbal, menyediakan informasi gaya hidup sehat, sehingga kita bisa terhindar dari berbagi jenis serangan penyakit apapun.
Info Kesehatan Satelit Herbal

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

Penyebab Otot Rahim Lemah Dan Cara Mengatasinya

Penyebab Otot Rahim Lemah Dan Cara Mengatasinya, Selamat datang di web resmi "OBAT MIOM" untuk kesempatan kali ini kami akan membahas tentang pengertian penyakit rahim atau penyabab otot rahim lemah dan bagaimana untuk cara mengatasinya.
Penyebab Otot Rahim Lemah Dan Cara Mengatasinya

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

Pantangan Makanan Untuk Penyakit Infeksi Jantung

Selamat datang dan selamat bergabung di blog resmi kami, untuk kesempatan kali ini kami akan memberikan informasi tentang pantangan makanan untuk penyakit infeksi jantung, berikut informasi lebih lengkapnya :
Pantangan Makanan Untuk Penyakit Infeksi Jantung

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

Obat Meningitis Pada Anak

Info obat meningitis pada anak, penyebab meningitis, gejala meningitis dan pengobatan meningitis pada anak akan di bahas tuntas di sini.
Obat Meningitis Pada Anak

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

Legalitas QnC Jelly Gamat Untuk Jantung Berlemak

Legalitas QnC Jelly Gamat Untuk Jantung Berlemak, Legalitas Qnc Jelly Gamat, Qnc jelly gamat merupakan produk dari ektrak teripang yang memiliki khasiat yang luar biasa bagi kesehatan, Qnc jelly gamat dapat di andalkan dalam mengatasi berbagai keluhan atau gangguan kesehatan lainya. bahkan Qnc jelly gamat di percaya mampu mengatasi berbagi jenis penyakit dengan aman dan alami.
Legalitas QnC Jelly Gamat Untuk Jantung Berlemak

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

Penyebab Jantung Bocor Dan Pengobatannya

Penyebab Jantung Bocor Dan Pengobatannya, Dalam kesempatan kali ini kami akan membahas tentang penyabab jantung bocor, dan cara pengobatannya. Jantung bocor atau adanya lubang di jantung, sering kali tidak terdeteksi karena jarang sekali menimbulkan tanda atau gejala khusus. Kondisi ini bisa terjadi pada semua orang tanpa disadari.
Penyebab Jantung Bocor Dan Pengobatannya

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

Cara Mengatasi Detak Jantung Tidak Teratur (aritmia)

Selamat datang dan selamat bergabung di blog resmi kami, dalam kesempatan kali ini kami akan menjelaskan tentang penyabab Detak Jantung Tidak Teratur (aritmia) dan Cara Mengatasi Detak Jantung Tidak Teratur (aritmia) secara alami dan aman.
Cara Mengatasi Detak Jantung Tidak Teratur (aritmia)

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

Cara Mengobati Stroke Ringan Dan Berat Secara Alami

Bertemu kembali di Web resmi kami www.obatalamistroke.url8.com yang memberikan info kesehatan tentang penyakit khusus masalah penyakit stroke, Cara Mengobati Stroke Ringan Dan Berat Secara Alami dan tips cara mencegah penyakit stroke.
Cara Mengobati Stroke Ringan Dan Berat Secara Alami

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

JHON

That may perform short-term, nevertheless it’s not just a useful long-term solution regarding males who would like to become with this particular 1 distinctive lady these folks can’t quit thinking about. cookeo

Obat Nyeri Lambung >> Obat Nyeri Lambung Tradisional

Obat nyeri lambung tradisional paling ampuh, penyebab dan gejala penyakit nyeri lambung kami bahas tuntas disini!
Obat Nyeri Lambung >> Obat Nyeri Lambung Tradisional

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

Obat Asma Paling Ampuh

Penyebab Kematian Susiana, Istri Tukul Arwana Diduga Ada Riwayat Asma, Untuk informasi kali ini datang dari komedian ternama TUKUL ARWANA yang mendapat cobaan berat, Artis kelahiran Semarang itu kehilangan sang istri Susiana alias Susi Similikiti untuk selama-lamanya.
Obat Asma Paling Ampuh

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

Obat Kolik Abdomen | Kram Perut

Solusi obat kolik abdomen | Kram Perut yang paling tepat dan paling aman yaitu bisa menggunakan ektrak teripang laut yang terbukti cepat atasi masalah kram perut anda.
Obat Kolik Abdomen | Kram Perut

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

Cara Mengatasi Kebocoran Jantung Pada Anak

Cara Mengatasi Kebocoran jantung pada anak paling ampuh, Penyebab dan gejala jantung bocor akan di bahas secara lengkap di sini.!
Cara Mengatasi Kebocoran Jantung Pada Anak

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

Obat Inflamasi Jantung Tradisional Alami

Informasi Obat Inflamasi Jantung Tradisional Alami Ampuh Yang Aman Bagi Ibu Hamil Dan Menyusui Juga Untuk Balita Serta Lansia!.
Obat Inflamasi Jantung Tradisional Alami

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

Obat Inflamasi Jantung Tradisional Alami

Informasi Obat Inflamasi Jantung Tradisional Alami Ampuh Yang Aman Bagi Ibu Hamil Dan Menyusui Juga Untuk Balita Serta Lansia!.
Obat Inflamasi Jantung Tradisional Alami

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

Obat Nyeri Lambung >> Obat Nyeri Lambung Tradisional

Obat nyeri lambung tradisional paling ampuh, penyebab dan gejala penyakit nyeri lambung kami bahas tuntas disini!
Obat Nyeri Lambung Tradisional

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

obat gula basah >> obat gula basah tradisional

Informasi obat gula basah tradisional, ampuh menurunkan gula darah dan mengeringkan luka basah akibat diabetes dengan cepat!
obat gula basah tradisional

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

www.sentrabesibaja.com

dipecah sebesar kepalan tangan, dipilih yang mengandung unsur logam, dicuci dengan Daftar Harga Besi H beam Yang Dijual Dari Pabrik Ke Agen Daftar Harga Besi H beam Yang Dijual Dari Pabrik Ke Agen

http://www.fabrikasikonstruksi.com/

ongkos konstruksi baja konstruksi atap bangunan gedung
air unruk mengeluarkan kotoran dan terakhir dikeringkan dengan cara dipanggang untuk mengeluarkan uap yang mengandung air.air unruk mengeluarkan kotoran dan terakhir dikeringkan dengan cara dipanggang untuk mengeluarkan uap yang mengandung air.

Obat Tradisional Syaraf Kejepit Tanpa Oprasi Medis

Obat Tradisional Syaraf Kejepit, tanpa efek samping, tidak perlu melakukan oprasi, cukup mengkonsumsi Obat Tradisional Qnc jelly Gamat yang terbuat dari bahan alami yang terbuat dari timun laut atau biasa disebut Tripang Laut. Kenapa Harus menggunakan Qnc ???

http://obattradisionalsyarafkejepit17.totalh.net/cara-pemesanan-obat-tradisiobal-syaraf-kejepit-qnc-jelly-gamat/

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

Obat Tradisional Syaraf Kejepit Tanpa Oprasi Medis

http://obattradisionalsyarafkejepit17.totalh.net/obat-tradisional-syaraf-kejepit-tanpa-oprasi-medis/

Obat Tradisional Syaraf Kejepit Tanpa Oprasi Medis

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

Obat Tradisional Penebalan Dinding Rahim Paling Efektif

Solusi Obat tradisional penebalan dinding rahim paling efektif, penyabab dan gejala penyakit ini akan di bahas tuntas di sini.
Obat Tradisional Penebalan Dinding Rahim Paling Efektif

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

Pencegahan Untuk Penyakit Diabetes Paling Ampuh

Pencegahan Untuk Penyakit Diabetes Paling Ampuh, Solusi untuk cara mencegah penyakit diabetes paling ampuh, penyabab dan gejala akan di bahas di dini secara lengap, namun sebelum membahas tentang cara menyembuhkan penyakit diabetes alangkah baiknya kita mengetehui terlebih dahulu penyabab penyakit diabetes.
Pencegahan Untuk Penyakit Diabetes Paling Ampuh

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

Pencegahan Untuk Penyakit Diabetes Paling Ampuh

Pencegahan Untuk Penyakit Diabetes Paling Ampuh, Solusi untuk cara mencegah penyakit diabetes paling ampuh, penyabab dan gejala akan di bahas di dini secara lengap, namun sebelum membahas tentang cara menyembuhkan penyakit diabetes alangkah baiknya kita mengetehui terlebih dahulu penyabab penyakit diabetes.
Pencegahan Untuk Penyakit Diabetes Paling Ampuh

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

Obat Luka Diabetes >> Obat Luka Diabetes Alami

Obat luka diabetes >> Obat luka diabetes alami, Info obat luka diabetes dengan menggunakan ektrak teripang laut yang bisa menyembuhkan penyakit diabetes dengan alami cepat dan tanpa efek samping
Obat Luka Diabetes >> Obat Luka Diabetes Alami

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

Once you have selected a

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.top best torrent sites

dsdsd

happy navratri images
dandiya songs
navratri wishes 2016

Tata Consultancy Services

Tata Consultancy Services (TCS) employees must have received several facilities from the company but Enterprise Resource Planning (ERP) http://www.tcsultimatixhelp.com/tcs-ultimatix-touch-app-mobile-helpdesk-number-for-employees-ultimatix-net-portal/

I agree, but this is huge. I think it's a good idea.

I agree, but this is huge. I think it's a good idea.

UCW168

ngo6648523

I think it's interesting, it's a very good idea.

UCW168

ngo6648523

I find it interesting, well it is a good idea, I agreed.

Playonline

ngo6648523

I agree that is a good idea too.

Betting Online

ngo6648523

I think it's a good idea, it's a good one.

Playonline

ngo6648523

It's just a good idea, I strongly disagree.

Playonline

ngo6648523

I agree, I think it's just a good idea to me.

UCW168

ngo6648523

I think it is a good idea, Nagpur, get me activists
Playonline

ngo6648523

I agree that it is a good idea.

acompanhantes rio de janeiro

Much obliged folks, for sharing this conductive gathering.acompanhantes rio de janeiro

Um dos melhores site ja administrador por nossa equipe que cuida de diversos site de anuncios de acompanhantes do rio de janeiro

www.sentrabesibaja.com

pabrik besi beton pabrik besi beton
pabrik besi beton ais pabrik besi beton ais
pabrik besi beton Sni Ulir Polos pabrik besi beton Sni Ulir Polos
pabrik besi beton bjku pabrik besi beton bjku
pabrik besi beton cakra steel cs pabrik besi beton cakra steel cs
pabrik besi beton delcoprima pabrik besi beton delcoprima
pabrik besi beton gunung garuda pabrik besi beton gunung garuda
pabrik besi beton interworld steel is pabrik besi beton interworld steel is
pabrik besi beton jcac pabrik besi beton jcac
pabrik besi beton krakatau steel pabrik besi beton krakatau steel
pabrik besi beton ksty pabrik besi beton ksty
pabrik besi beton master steel ms pabrik besi beton master steel ms
pabrik besi beton PAS pabrik besi beton PAS
pabrik besi beton perwira pabrik besi beton perwira
pabrik besi beton psi Ulir Polos pabrik besi beton psi Ulir Polos
pabrik besi beton sii pabrik besi beton sii
pabrik besi beton Sni Ulir Polos polos ulir pabrik besi beton Sni Ulir Polos polos ulir
www.pabrikbesibajamurah.com www.pabrikbesibajamurah.com
www.pusatbesibaja.com www.pusatbesibaja.com
www.pusatbesibaja.co.id www.pusatbesibaja.co.id
jasa konstruksi baja jasa konstruksi baja
undangan pernikahan undangan pernikahan
jasa konstruksi jual laptop asus
jasa konstruksi baja jasa konstruksi baja wf
jasa konstruksi gudang jasa konstruksi jembatan
jasa konstruksi gedung jasa konstruksi bangunan
www.husnialbardani.com www.husnialbardani.com
jual laptop asus murah jual laptop asus murah

www.sentrabesibaja.com Daftar pabrik Besi Hollow Dari pabrik Pabrik
pabrik Besi Beton Daftar pabrik Besi Pipa Baja Schedule 40 Dari pabrik Pabrik
pabrik Besi H beam Daftar pabrik Besi H beam Yang Dipabrik Dari Pabrik Ke Agen
pabrik Besi Wf Info pabrik Welded Beam T beam King Queen Cross Castellated Beam
pabrik Pipa Besi Hitam Medium Daftar pabrik Bondek Cor Ter Murah pabrik Pabrik
pabrik Besi Pipa Baja Schedule 40 sentra besi baja
pabrik Besi Pipa Baja Schedule 80 Daftar pabrik Besi Unp Baja Profil Kanal pabrik Pabrik
pabrik Wiremesh Daftar pabrik Besi Pipa Baja Schedule 80 Dari pabrik Pabrik
pabrik Besi Hollow Daftar pabrik Plat Kapal Dari Pabrik Ke pabrik
pabrik Besi Cnp Profil Baja Gording Daftar pabrik Atap Spandek Sni Dari Supplier Pabrik
pabrik Besi Unp Baja Profil Kanal Daftar pabrik Plat Besi Hitam Dari Supplier Pabrik
pabrik pabrik Besi Siku Baja Daftar pabrik pabrik Besi Siku Baja Dari Supplier Pabrik
pabrik Plat Kapal Bki Krakatau Steel Daftar pabrik Pipa Besi Hitam Medium Dari Agen Pabrik
pabrik Plat Besi Hitam Daftar pabrik Wiremesh Yang Dipabrik Dari Pabrik Ke Supplier
pabrik Plat Bordes Kembang Daftar pabrik Besi Wf Dipabrik Dari Pabrik Lewat Supplier
pabrik Atap Spandek Sni Daftar pabrik Plat Bordes Kembang Dari pabrik Pabrik
pabrik Bondek Cor Daftar pabrik Besi Beton Yang Di pabrik Dari Pabrik Ke pabrik
pabrik Welded Beam T beam King Queen Cross Castellated Beam Daftar pabrik Besi Cnp Profil Baja Gording Supplier Pabrik
jasa konstruksi jual laptop asus
jasa konstruksi baja jasa konstruksi baja wf
jasa konstruksi gudang jasa konstruksi jembatan
jasa konstruksi gedung jasa konstruksi bangunan
www.husnialbardani.com www.husnialbardani.com
www.mrosidin.com www.cerahcollection.com
jual laptop asus murah jual laptop asus murah
sfs

Great stuff

I am looking for the same stuff I am Creating the Digital Piano Player for online user using JVM

Digital Piano Player

I have created now the ifsc

I have created now the ifsc codes website

Digital Piano Player

Indian Drama have all gossips

Indian Drama have all gossips of bollywood industry

Digital Piano Player

Customer Care No is the one

Customer Care No is the one of the place where you can get the all toll free numbers

Digital Piano Player

nice to be here guy

thank you, visit my page https://bangbangdut.wordpress.com/

Check Cashing

Remarkable advertisement! I will ensure that you craft an email finder service that can assist you pick out your internet-site assess, then again, you may choose to figure out. In recent times features a review of a lot of our web-site Check Cashing Bless you a ton noticeably by applying indispensable habits and perhaps testimonials.

Make your own Ian Hart.

Make your own Ian Hart.

Post new comment

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