<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cosminaru blog &#187; General</title>
	<atom:link href="http://cosminaru.ro/blog/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://cosminaru.ro/blog</link>
	<description>home</description>
	<lastBuildDate>Tue, 31 Aug 2010 15:26:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple way to configure mod_jk load balancer at run-time</title>
		<link>http://cosminaru.ro/blog/2008/01/21/simple-way-to-configure-mod_jk-load-balancer-at-run-time/</link>
		<comments>http://cosminaru.ro/blog/2008/01/21/simple-way-to-configure-mod_jk-load-balancer-at-run-time/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 14:33:59 +0000</pubDate>
		<dc:creator>Cosmin Marginean</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.cosminaru.ro/blog/?p=14</guid>
		<description><![CDATA[Load balancing is a common issue for many web-sites or web-based applications. Last couple weeks I had to play around with a Java-based web application that, among other things, needed to be balanced for high availability and failover. The most handy solution for this seemed to be Apache httpd and mod_jk. I won&#8217;t get into [...]]]></description>
			<content:encoded><![CDATA[<p>Load balancing is a common issue for many web-sites or web-based applications. Last couple weeks I had to play around with a Java-based web application that, among other things, needed to be balanced for high availability and failover. The most handy solution for this seemed to be Apache httpd and mod_jk. I won&#8217;t get into the details about setting up and configuring this stuff as it can be read on hundreds of other websites. What I want to show you is a simple way to get a more realistic (even if not bullet-proof) load balancing configuration out of this.<br />
Let&#8217;s take a sample mod_jk configuration of a load balancer with 2 nodes. This configuration also includes a jkstatus worker that we use to monitor the overall status of mod_jk.</p>
<pre class="prettyprint"><code>JkMount                 /test/* router
JkMount                 /jkstatus/* jkstatus
...
JkWorkerProperty worker.list=router, jkstatus

JkWorkerProperty worker.worker1.host=localhost
JkWorkerProperty worker.worker1.port=8009
JkWorkerProperty worker.worker1.type=ajp13
JkWorkerProperty worker.worker1.lbfactor=1
...
JkWorkerProperty worker.worker2.host=localhost
JkWorkerProperty worker.worker2.port=8019
JkWorkerProperty worker.worker2.type=ajp13
JkWorkerProperty worker.worker2.lbfactor=1
...
JkWorkerProperty worker.router.type=lb
JkWorkerProperty worker.router.balance_workers=worker1, worker2
...
JkWorkerProperty worker.jkstatus.type=status
</code></pre>
<p>As you can see, the <code>lbfactor</code> must be set here manually and I used 1 for both nodes to create an equally balanced cluster. The problem that we encountered is that we need to set the <code>lbfactor</code> at runtime based on the actual load of the Tomcat nodes. For example, we might want the load factor to indicate the CPU usage or memory allocation percentage.<br />
Using the jkstatus worker, there is a very simple way to do this, once you obtained your number that indicates the load factor of your node. Assuming that the gateway (the machine running the Apache with mod_jk) is accessible from the machines running Tomcat, we can use <code>wget</code> to easily set the load factor:</p>
<pre class="prettyprint"><code>wget "http://gateway_ip/jkstatus/?cmd=update&amp;from=list&amp;w=router&amp;sw=worker1&amp;wf=453"</code></pre>
<p>Once you did this, your value (453) can be seen in the corresponding row for worker1 on the page located at http://gateway_ip/jkstatus/.<br />
This might not be the most enterprisey way to do this stuff, but it&#8217;s a quick solution that can provide a pretty realistic load balancing (as long as the factor itself is calculated in a realistic manner).<br />
You can put this stuff in a script, for example an <code>update_lbfactor.sh</code> on a shared NFS drive and adjust it to accept the worker and the load factor as arguments:</p>
<pre class="prettyprint"><code>wget "http://gateway_ip/jkstatus/?cmd=update&amp;from=list&amp;w=router&amp;sw=$1&amp;wf=$2"</code></pre>
<p>This way, the nodes will just have to call this with the appropiate arguments:</p>
<pre class="prettyprint"><code>update_lbfactor.sh worker2 345</code></pre>
<p>Hope you find this usefull.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosminaru.ro/blog/2008/01/21/simple-way-to-configure-mod_jk-load-balancer-at-run-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The wind</title>
		<link>http://cosminaru.ro/blog/2007/10/21/the-wind/</link>
		<comments>http://cosminaru.ro/blog/2007/10/21/the-wind/#comments</comments>
		<pubDate>Sun, 21 Oct 2007 19:38:55 +0000</pubDate>
		<dc:creator>Cosmin Marginean</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.cosminaru.ro/blog/?p=13</guid>
		<description><![CDATA[Absolutely impressive&#8230;

]]></description>
			<content:encoded><![CDATA[<p>Absolutely impressive&#8230;</p>
<p><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/2mTLO2F_ERY"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/2mTLO2F_ERY" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://cosminaru.ro/blog/2007/10/21/the-wind/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
