TomcatExpert

How to Scale Apache Tomcat in the Cloud with RabbitMQ and JMX

posted by jbrisbin on June 3, 2010 10:20 PM

I sometimes pine for the days when I just had one server to worry about. I wax nostalgic, remembering how easy my life was when I didn't have servers and virtual machines growing out of my ears. It's almost the same feeling I get thinking about the days when I only had one child and you could just pop them in a carseat and take off. Now I've got kids driving themselves and their siblings to several activities a day and I can hardly keep track of whether I'm coming or going. I feel the same way about my data center. It's all grown up now and, while it may not have its own driver's license, I can still lose sleep over it getting a little more out of my control every day.

Such are the demands of the uber-modern data center. Deploying your applications into the cloud and keeping them in synch can cause one to either swear profusely or put in for a month of vacation. Whether you're in a virtual or hybrid private cloud, or working on one of the big-name cloud providers, keeping track of what services are available and managing them once they're up is a common requirement. I approached this problem in our own private cloud by writing a Tomcat LifecycleListener that hooks into our RabbitMQ servers to keep interested queue subscribers updated with the internal state of our SpringSource tcServer instances, as well as providing the ability to invoke JMX MBeans via asynchronous messaging. Since this system uses AMQP, any language that has an AMQP client that can talk to RabbitMQ can invoke JMX-managed MBeans. RabbitMQ is the backbone of our private cloud. Our tcServer instances use it to communicate with one another for session clustering and custom management tools use it to facilitate deployment artifact rollouts. We use messaging as a one-size-fits-all communication bus. Java can talk to Ruby can talk to Python can talk to C. Setting up a RabbitMQ server is beyond the scope of this discussion. If you're running Ubuntu 10.04, simply issue a "sudo apt-get install rabbitmq-server". If you just want to test this scenario, you can run a local RabbitMQ server very easily. I'll leave that as an exercise to the reader.

The Tomcat Listener

To relay internal Lifecycle events to the cloud, I wrote a Listener that I install in the tcServer instances I want to manage. It's part of the virtual cloud utilities I've opensourced and released.Configuration is fairly straightforward, though it might get a little confusing with all the exchange and queue names. First, the relevant snippage from server.xml:

<a a="" classname="com.jbrisbin.vcloud.mbean.CloudInvokerListener" eventsexchange="vcloud.events" github.com="" href="http://www.springsource.com/products/tcserver?p=tcserver&lp=1&cid=70180000000wVJj>SpringSource tcServer</a> instances, as well as providing the ability to invoke JMX MBeans via asynchronous messaging. Since this system uses AMQP, any language that has an AMQP client that can talk to RabbitMQ can invoke JMX-managed MBeans.</p> <!--{cke_protected}{C}%3C!%2D%2Dbreak%2D%2D%3E--> <h2> The RabbitMQ Server</h2> <p> RabbitMQ is the backbone of our private cloud. Our tcServer instances use it to communicate with one another for session clustering and custom management tools use it to facilitate deployment artifact rollouts. We use messaging as a one-size-fits-all communication bus. Java can talk to Ruby can talk to Python can talk to C. Setting up a RabbitMQ server is beyond the scope of this discussion. If you're running Ubuntu 10.04, simply issue a "sudo apt-get install rabbitmq-server". If you just want to test this scenario, you can run a local RabbitMQ server very easily. I'll leave that as an exercise to the reader.</p> <h2> The Tomcat Listener</h2> <p> To relay internal Lifecycle events to the cloud, I wrote a Listener that I install in the tcServer instances I want to manage. It's part of the virtual cloud utilities I've opensourced and released on GitHub: <a data-cke-saved-href=" http:="" instancename="tcserver.${hostname}.${instance.id}" jbrisbin="" listener="" master="" mbean-invoker="" mbeaneventsexchange="vcloud.mbean" mbeaneventsqueue="mbean.${hostname}.${instance.id}" mbeaneventsroutingkey="tcserver.${hostname}.${instance.id}" mqhost="localhost" mqpassword="guest" mqport="5672" mquser="guest" mqvirtualhost="/" tree="" vcloud="">To differentiate the tcServer instances from one another in the cloud, I use convention over configuration. On each Ubuntu virtual machine that runs tcServer, we've configured the instances with names that are unique to the VM. Each VM has a unique hostname which is derived from the IP address, so a cloud-unique name for a given tcServer instance is a combination of hostname and instance name.</a>

SpringSource tcServer instances, as well as providing the ability to invoke JMX MBeans via asynchronous messaging. Since this system uses AMQP, any language that has an AMQP client that can talk to RabbitMQ can invoke JMX-managed MBeans.

The RabbitMQ Server

RabbitMQ is the backbone of our private cloud. Our tcServer instances use it to communicate with one another for session clustering and custom management tools use it to facilitate deployment artifact rollouts. We use messaging as a one-size-fits-all communication bus. Java can talk to Ruby can talk to Python can talk to C. Setting up a RabbitMQ server is beyond the scope of this discussion. If you're running Ubuntu 10.04, simply issue a "sudo apt-get install rabbitmq-server". If you just want to test this scenario, you can run a local RabbitMQ server very easily. I'll leave that as an exercise to the reader.

The Tomcat Listener

To relay internal Lifecycle events to the cloud, I wrote a Listener that I install in the tcServer instances I want to manage. It's part of the virtual cloud utilities I've opensourced and released on GitHub: <a data-cke-saved-href=" http:="" jbrisbin="" master="" mbean-invoker="" the="" tree="" vcloud="">Lifecycle events are published to a topic exchange, the name of which is configured with the "eventsExchange" setting. There's no magic here at all. Clients that wish to be notified of Tomcat Lifecycle events simply need to bind their queue to this exchange with a routing key apropos to the events they're interested in. The names for these events are in the org.apache.catalina.Lifecycle class (check the Tomcat source distribution). The event names for Tomcat 6.0 are:

Jon Brisbin is an Architect/Analyst/Java Guru at NPC International, the world's largest Pizza Hut franchisee. He's been deploying web applications on Tomcat for over 10 years and currently focuses on cloud computing (virtual, hybrid, and private). He built a private cloud from scratch using VMware ESX, Ubuntu Linux, packing tape, and rusty baling wire. He's done consulting work with industry leaders and Mom-and-Pops alike. Prior to NPC, Jon developed new application frameworks, integrated the AS/400 with UNIX and Windows systems, developed Lotus Domino applications, hacked websites together with Perl CGI and a text editor, and served with US Air Force Intelligence in a very hot and sandy, but undisclosed, location. He lives in the rural Midwest.

He blogs on Web 2.0 (and sundry topics) on his website: http://jbrisbin.com/web2

Comments

Interesting..

Sorry, I misposted - comment moved to http://www.tomcatexpert.com/blog/2010/06/21/clustering-cloud-friendly-tomcat-sessions-rabbitmq-part-i

I think working with the

I think working with the latest version Apache Tomcat 7 is very easy because it got the compatibility with cloud networking. Furthermore, due to its cloud ability, it can be used in different operating systems from anywhere in the world. anti snoring

GAME HACK

castle clash guide It is quite beneficial, although think about the facts when it reaches this target. astuce clash of clans triche

David

Your blog happens to be our one-stop search for as much as possible instructional producing. Thanks a lot to the wonderful operate. My spouse and i tried out one of several internet sites anyone encouraged along with I have discovered that will best-dissertation. orgwritingservice is the foremost nevertheless. His or her operate is pretty exemplary. Jual Laptop Murah

This is a great web site,

This is a great web site, would you be interested in doing an interview about how you developed it? If so e-mail me!
Mortgage Broker Calgary

I love it when people get

I love it when people get together and share ideas. Great blog, continue the good work!
Edmonton Mortgage Broker
Life Insurance Vancouver
Life Insurance Calgary

Often, a single weblink from

Often, a single weblink from a well-known information website discussing about your item will be much more valuable than bombarding many hyperlinks to unknown websites Medical Websites India.

Hey There. I found your blog

Hey There. I found your blog using msn. This is a very well written article. I’ll be sure to bookmark it and come back to read more of your useful info. Thanks for the post. I’ll definitely return przepis-na-udka-faszerowane-miesem-mielonym.

Custom essays

Thank you so much for sharing this. I am a writer focused on my profession to spread more issues and tips to develop and works through cheap essay writing service . You explained all things very simply and in detailed form. And now I am a great fan of this blog.

Second, you have to rule in

Second, you have to rule in your passion and be prepared yourself for a intense multi-month dedication that will require time, self-discipline, and money-be prepared to invest a while in the ditches the full report.

Tomcat is one of the most

Tomcat is one of the most used servers and it is very easy to use. Codes and queries in Tomcat are very simple compared to the other leading programs. I don’t know how to scale Apache Tomcat in the Cloud with RabbitMQ and JMX and the information given here helps me a lot. Medical billing outsourcing

This site always share many

This site always share many important topics related to the Apache Tomcat. I had doubt about scaling the Apache tomcat in the cloud. But from this blog I understood how it is done in the servers like Rabbit MQ and JMX. wholesale ipad 3

Whoever has seen deeply into

Whoever has seen deeply into the world has doubtless divined what wisdom there is in the fact that men are superficial. It is their preservative instinct which teaches them to be flighty, lightsome, and false. Here and there one finds a rolex submariner passionate and exaggerated adoration of "pure forms" in philosophers as well as in artists: it is not to be doubted that whoever has NEED of the cult of the superficial to that extent, has at one time or another made an unlucky dive BENEATH it. Perhaps there is even an order of rank with respect to those burnt children, the born artists who find the enjoyment of life only in trying to FALSIFY its image rolex datejust (as if taking wearisome revenge on it), one might guess to what degree life has disgusted them, by the extent to which they wish to see its image falsified, attenuated, ultrified, and deified,—one might reckon the homines religiosi among the artists, as their HIGHEST rank.

It is the profound, suspicious fear of an incurable pessimism which compels whole centuries breitling to fasten their teeth into a religious interpretation of existence: the fear of the instinct which divines that truth might be attained TOO soon, before man has become strong enough, hard enough, artist enough.... Piety, the "Life in God," regarded in this light, would appear as the most elaborate and ultimate product of the FEAR of truth, as artist-adoration and artist-intoxication in presence of the most logical of all falsifications, as the will to the inversion of truth, to untruth at any price. Perhaps there has hitherto been no more effective means of beautifying man than piety, by means of it man can oyster perpetual air-king become so artful, so superficial, so iridescent, and so good, that his appearance no longer offends.

To love mankind FOR GOD'S SAKE—this has so far been the noblest and remotest sentiment to which mankind has attained. That love to mankind, without any redeeming intention in the background, is only an ADDITIONAL folly and brutishness, that replica burberry handbags the inclination to this love has first to get its proportion, its delicacy, its gram of salt and sprinkling of ambergris from a higher inclination—whoever first perceived and "experienced" this, however his tongue may have stammered as it attempted to express such a delicate matter, let him for all time be holy and respected, as the man who has so far flown highest and gone astray in the finest fashion123165431312!

Tomcat users have to deploy

Tomcat users have to deploy their applications into private, hybrid cloud architectures.192.168.1.1 192.168.1.1 192.168.0.1 attorney 192.168.1.1 mm to inches inche to cm Lightweight is the new black and Tomcat, RabbitMQ, and asynchronous messaging play right into that hand like the Jack of Spades.

thank you for the very

thank you for the very helpful information , check out my accounts site

Informative Article

I think this piece of information will be useful to all those who are using tomcat server to know about how to scale Apache Tomcat in the Cloud with RabbitMQ and JMX. I would like to thank you for sharing this valuable information. Keep updating more. dish network channels

reply

This site has really provided me with good information relating to servers and other internet communications. Integrating the Tomcat server into the Rabbit server is explained well with an exercise which is provided to running the servers using the steps described. garage door maintenance Newport Beach

Post new comment

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