Valtira Blog

Tomcat Failover

by Morgan Catlin - 25 Mar 2011, 10:30:05

Just a quick note: when you are configuring your load balancing settings with Apache2, JK and Tomcat, remember to plan for failover. The default settings WILL NOT failover like you expect!

Here are some quick settings that illustrate my point.

workers.properties file:

worker.list=a1420,jkstatus
worker.jkstatus.type=status

worker.a1420.type=lb

worker.a1420-1.host=10.114.247.55
worker.a1420-1.port=15000
worker.a1420-1.type=ajp13
worker.a1420-1.lbfactor=1
worker.a1420-1.socket_timeout=2
worker.a1420-1.connect_timeout=500

worker.a1420-2.host=10.118.9.82
worker.a1420-2.port=15000
worker.a1420-2.type=ajp13
worker.a1420-2.lbfactor=1
worker.a1420-2.socket_timeout=2
worker.a1420-2.connect_timeout=500

worker.a1420.balance_workers=a1420-1,a1420-2

I highlighted socket_timeout and connect_timeout because these settings cause JK to actually check its connections to the Tomcat servers it is load balancing. It seems like a matter of course that JK should do this automatically, but it won't! So, socket_timeout is set to 2 seconds here for the case where JK is having problems getting a network connection. connect_timeout is where the magic happens, I've set that to 500 milliseoonds which tells JK to wait that long before getting back a CPONG response to its CPING before issuing the actual request to the chosen Tomcat server. When a Tomcat server doesn't respond within the timeout window, JK uses another Tomcat server to send the request to and marks the original Tomcat server as ERR. It'll check that original Tomcat server again after its maintenance window expires. All this stuff is explained in Tomcat's timeout article.

I learned this the hard way - where I have some mis-behaving EC2 instances which freeze up now and then (working on fixing that). In the short term, I modified my JK settings to enabled failover. I've also used the jkstatus/jkmanager to monitor the situation, extremely handy!

Comments? Suggestions? Feedback?

Cloud Applications Presentation

by Morgan Catlin - 16 Nov 2011, 21:10:33

I've submitted my MN IT Symposium presentation, "Architecting and Deploying Scalable, Resilient, and Cost-Effective Cloud Applications", which discusses how to bring about an affective Cloud-based application.

It discusses my experiences using PaaS and rolling my own architecture. I go over what worked and some common misconceptions about using PaaS and RYO.

I think the most interesting part is showing an ideal distributed architecture for the common Java Pet Store application. I talk about how to use AWS' services to achieve high reliability and scalability.

Can't wait to meet all you great attendees!

Comments? Suggestions? Feedback?

About Us

Valtira's team includes many bright people with useful opinions on the latest web technologies like HTML5 and cloud computing.