<?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>bogdan@j3e &#187; clustering</title>
	<atom:link href="http://www.bserban.org/category/clustering/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bserban.org</link>
	<description>Web, Java, J2EE, SaaS, Tips&#38;Tricks</description>
	<lastBuildDate>Thu, 08 Jul 2010 11:53:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How a DNS problem can put your Mysql server down</title>
		<link>http://www.bserban.org/2010/01/how-a-dns-problem-can-put-your-mysql-server-down/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-a-dns-problem-can-put-your-mysql-server-down</link>
		<comments>http://www.bserban.org/2010/01/how-a-dns-problem-can-put-your-mysql-server-down/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:10:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Mysql client]]></category>

		<guid isPermaLink="false">http://www.bserban.org/?p=288</guid>
		<description><![CDATA[Last week i was waked up from bed by the monitoring team from my company. There was a problem with my system, there was a DNS problem undergoing but as a side effect my app was down. Since it has a lot of traffic it had to be solved immediately. I jumped to the computer [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.bserban.org%2F2010%2F01%2Fhow-a-dns-problem-can-put-your-mysql-server-down%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.bserban.org%2F2010%2F01%2Fhow-a-dns-problem-can-put-your-mysql-server-down%2F&amp;source=bserban&amp;style=normal&amp;service=bit.ly&amp;hashtags=DNS,MySql,Mysql+client" height="61" width="50" /><br />
			</a>
		</div>
<p>Last week i was waked up from bed by the monitoring team from my company. There was a problem with my system, there was a DNS problem undergoing but as a side effect my app was down. Since it has a lot of traffic it had to be solved immediately.</p>
<p>I jumped to the computer and I quickly diagnosed the system. Everything was fine except the Mysql connection pool which was exhausted. The first thing that crossed my mind is that it was just a coincidence and I quickly ran <em>show processlist</em> to see a list of MySQL processes. The output was an infinite list of load balancer&#8217;s ip address having &#8220;login&#8221; text as status. In order to achieve high availability i am using Mysql by having a balanced ip address between two Mysql servers. The balancer runs a quick check every 5 seconds by connecting to Mysql and does a simple select on a table.</p>
<p>So for a particular reason the &#8220;load balancer&#8221; was not able to finish its login attempts and it was overloading my Mysql servers. While I was in the middle of the investigation  the problem suddenly stopped. I was happy but somehow scared, i had no idea what the hell happened.</p>
<p>A quick search into Mysql documentation reveals that Mysql is doing a reverse DNS lookup which was the cause of my problems. Since the DNS server had a problem,  the operation of reverse DNS was taking far more that 5 seconds to time out. This resulted in overloading the database servers. Check this explanation in the official documentation, <a href="http://dev.mysql.com/doc/refman/5.0/en/dns.html">How MySQL Uses DNS</a></p>
<p>After reading tha page I think that mysql needs this reverse DNS lookup only for its permission module and if you don&#8217;t use host names with the grant option then you are safe to disable this option. I quote here the parameter which does this:</p>
<blockquote><p>&#8211;skip-name-resolve</p>
<p>Do not resolve host names when checking client connections. Use only IP numbers. If you use this option, all Host column values in the grant tables must be IP numbers or localhost. See Section 7.5.11, “How MySQL Uses DNS”.</p></blockquote>
<p>I have been able to avoid this? Perhaps, but considering that I used MySQL in production for the first time, it is unlikely to think so.</p>
<p>Long live the reverse DNS, cheers!
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.bserban.org%2F2010%2F01%2Fhow-a-dns-problem-can-put-your-mysql-server-down%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.bserban.org%2F2010%2F01%2Fhow-a-dns-problem-can-put-your-mysql-server-down%2F&amp;source=bserban&amp;style=normal&amp;service=bit.ly&amp;hashtags=DNS,MySql,Mysql+client" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bserban.org/2010/01/how-a-dns-problem-can-put-your-mysql-server-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure Apache and Tomcat severs together</title>
		<link>http://www.bserban.org/2009/08/configure-apache-and-tomcat-severs-together/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=configure-apache-and-tomcat-severs-together</link>
		<comments>http://www.bserban.org/2009/08/configure-apache-and-tomcat-severs-together/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 08:12:00 +0000</pubDate>
		<dc:creator>bserban</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[mod_proxy_ajp]]></category>
		<category><![CDATA[AJP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Benchmark]]></category>
		<category><![CDATA[mod_proxy]]></category>

		<guid isPermaLink="false">http://www.bserban.org/?p=209</guid>
		<description><![CDATA[The most common way to deploy your application in the production environment is to hide the Tomcat behind Apache. This has good and bad parts but it gives you a lot of flexibility and support from Apache. There are a couple of alternatives to put these two severs together: mod_jk, this is the old connector [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Fconfigure-apache-and-tomcat-severs-together%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Fconfigure-apache-and-tomcat-severs-together%2F&amp;source=bserban&amp;style=normal&amp;service=bit.ly&amp;hashtags=AJP,Apache,Apache+Benchmark,mod_proxy,mod_proxy_ajp,Tomcat" height="61" width="50" /><br />
			</a>
		</div>
<p>The most common way to deploy your application in the production environment is to hide the Tomcat behind Apache. This has good and bad parts but it gives you a lot of flexibility and support from Apache. There are a couple of alternatives to put these two severs together:</p>
<ul>
<li><em>mod_jk</em>, this is the old connector developed under the Tomcat project and it is using the Tomcat&#8217;s AJP protocol. It is expected to be faster than the HTTP protocol which is text based.</li>
<li><em>mod_proxy</em>, is the support module for HTTP protocol. It is TCP based and uses the HTTP which is plain text. When a web client makes a request to Apache, the Apache will make the same call to the Tomcat and then the Tomcat&#8217;s response is passed back to the web client. This connector is part of the Apache for a very long time and it is available also for older versions of Apache. This is the simplest way to put the Apache in front of a Tomcat but also the slowest way to do it.</li>
<li><em>mod_proxy_ajp</em>, is new and is part of the Apache 2.2. It is working like <em>mod_proxy</em>, but as the name says it is using the AJP connector for sending and getting data from Tomcat. It is using also TCP and it is expected to be faster than plain <em>mod_proxy</em></li>
</ul>
<p><span id="more-209"></span></p>
<h1>Using mod_proxy</h1>
<p>Create your own tomcat-httpd.conf file and configure the proxy:</p>
<p><code>#<br />
# Server will not close the connection after each request allowing the browser to use the same connection<br />
#<br />
KeepAlive On<br />
MaxKeepAliveRequests 100<br />
KeepAliveTimeout 5</code></p>
<p>#<br />
# Load mod_proxy modules<br />
#<br />
&lt;IfModule !proxy_module&gt;<br />
LoadModule proxy_module modules/mod_proxy.so<br />
&lt;/IfModule&gt;</p>
<p>&lt;IfModule !proxy_http_module&gt;<br />
LoadModule proxy_http_module modules/mod_proxy_http.so<br />
&lt;/IfModule&gt;</p>
<p>ProxyRequests Off<br />
ProxyPreserveHost On<br />
ProxyTimeout 1000<br />
TimeOut 1000</p>
<p>#<br />
# Configure the mod_proxy<br />
#<br />
ProxyPass / http://127.0.0.1:8080/<br />
ProxyPassReverse / http://127.0.0.1:8080/</p>
<p>Include your configuration into Apache <em>httpd.conf</em> using Include directive:</p>
<p><code>#load Tomcat proxy configuration<br />
Include /usr/local/tomcat6/conf/tomcat-httpd.conf</code></p>
<h1>Using mod_proxy_ajp</h1>
<p>The only difference between mod_proxy and mod_proxy_ajp is that you have to load mod_proxy_ajp and proxy the request to Tomcat using the ajp protocol.</p>
<p><code>#<br />
# Load mod_proxy modules<br />
#<br />
&lt;IfModule !proxy_module&gt;<br />
LoadModule proxy_module modules/mod_proxy.so<br />
&lt;/IfModule&gt;</code></p>
<p>&lt;IfModule !proxy_http_module&gt;<br />
LoadModule proxy_http_module modules/mod_proxy_http.so<br />
&lt;/IfModule&gt;</p>
<p>&lt;IfModule !proxy_ajp_module&gt;<br />
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so<br />
&lt;/IfModule&gt;</p>
<p>ProxyRequests Off<br />
ProxyPreserveHost On<br />
ProxyTimeout 1000<br />
TimeOut 1000<br />
#<br />
# Enable the AJP proxy<br />
#<br />
ProxyPass / ajp://localhost:8009/<br />
ProxyPassReverse / ajp://localhost:8009/</p>
<p>Include your configuration into Apache <em>httpd.conf</em> using Include directive:</p>
<p><code>#load Tomcat proxy configuration<br />
Include /usr/local/tomcat6/conf/tomcat-httpd.conf</code></p>
<h1>Using mod_jk</h1>
<p>Edit your <em>tomcat-httpd.conf</em> file and add mod_jk configuration:<br />
<code><br />
#<br />
# Load mod_jk is is not loaded already<br />
#<br />
&lt;IfModule !jk_module&gt;<br />
LoadModule jk_module modules/mod_jk.so<br />
&lt;/IfModule&gt;<br />
#<br />
#<br />
#<br />
JkWorkersFile /etc/httpd/conf/workers.properties<br />
JkLogFile /var/logs/httpd/mod_jk.log<br />
JkLogLevel info<br />
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "<br />
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories<br />
JkRequestLogFormat "%w %V %T"<br />
JkMount /test/* worker1</code></p>
<p>Include your configuration into Apache httpd.conf using Include directive:</p>
<p><code>#load mod_jk configuration configuration<br />
Include /usr/local/tomcat6/conf/tomcat-httpd.conf<br />
</code><br />
Now edit the workers.properties and configure your worker:<br />
<code><br />
worker.list=worker1<br />
worker.worker1.type=ajp13<br />
worker.worker1.host=localhost<br />
worker.worker1.port=8009<br />
worker.worker1.connection_pool_size=150<br />
worker.worker1.connection_pool_timeout=600<br />
worker.worker1.socket_keepalive=1</code></p>
<h1>Test each configuration using Apache Benchmark tool</h1>
<p>Apache benchmark it is a great tool for testing the above configurations. All you need is to create a typical application page that should be hit with the ab tool. This tool takes a single url and makes requests repeatedly in separates threads. The number of threads is controlled by command line arguments. It also supports keep alive connections.</p>
<p>For more details about Apache Benchmark check this page <a href="http://httpd.apache.org/docs/2.0/programs/ab.html">Apache Benchmark</a></p>
<p>For testing purposes i have created a test war which has a test.jsp page. Because what we test does not influence the processing time overall we don’t need a complete test which includes a database call or working with certain frameworks. In the end all we need is the output of an application and to test how this output reach the browser using one of the three modes explained in the section above.</p>
<p>The test page will include a previous post of mine which is medium size: http://www.bserban.org/2009/05/put-together-struts2-jpa-hibernate-and-spring/. I have right-clicked in the browser, chosen the view source and copy and paste the content into test.jsp. The file has 112Kb in size.</p>
<p><em><br />
bserban-mac:~ bserban$ ls -la ~/bin/srv/apache-tomcat-5.5.27/webapps/test/test.jsp<br />
-rw-r&#8211;r&#8211;  1 bserban  staff  113698 Aug  7 09:39 /Users/bserban/bin/srv/apache-tomcat-5.5.27/webapps/test/test.jsp<br />
</em></p>
<p>I am going to hit the Tomcat and the Apache with 10,000 request using 50 threads. The ab command looks like this:</p>
<p><em><br />
ab -k -n 10000 -c 50 http://localhost/test/test.jsp<br />
</em></p>
<p>To access directly the Tomcat i am going to hit the 8080 port. To preserve the similar enviroment and test conditions I will restart the Apache and Tomcat after each test.</p>
<h2>Test results</h2>
<p>The table below summarize the results obtained.</p>
<table class="design5" border="0">
<thead>
<tr>
<th></th>
<th>Direct</th>
<th>mode_proxy</th>
<th>mode_proxy_ajp</th>
</tr>
</thead>
<tbody>
<tr>
<td>Throughput</td>
<td>992 reg/s</td>
<td>667 req/s</td>
<td>702 req/s</td>
</tr>
<tr>
<td>Average Response Time</td>
<td>50 ms</td>
<td>75 ms</td>
<td>71 ms</td>
</tr>
<tr>
<td>90% Response line</td>
<td>75 ms</td>
<td>90 ms</td>
<td>71 ms</td>
</tr>
<tr>
<td>100% Response line</td>
<td>207 ms</td>
<td>980 ms</td>
<td>972 ms</td>
</tr>
</tbody>
</table>
<p>As you see, the fastest connecting mode is to connect directly to tomcat using HTTP. Direct HTTP connect will server more request per second that the other modes. The second choice is mode_proxy_ajp followed very closely by the mod_proxy. However the overhead added the the Apache will leverage for real life applications because the application processing time will minimize the impact of using Apache in front of Tomcat. Probably in real world the differences between direct HTTP connect and mod_proxy_ajp will not exceed 5-10% percents in terms of throughput and average time per request. This is the price to pay for the flexibility brought by Apache, because having the Apache in front of the Tomcat will give access to the whole Apache functionality and support.</p>
<p>For those who want to see test results in detail, I included in the post the tests logs.</p>
<h2>Test result trace for Tomcat HTTP</h2>
<p><code>bserban-mac:~ bserban$ ab -k -n 10000 -c 50 http://localhost:8080/test/test.jsp<br />
This is ApacheBench, Version 2.3 &lt;$Revision: 655654 $&gt;<br />
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br />
Licensed to The Apache Software Foundation, http://www.apache.org/</code></p>
<p>Benchmarking localhost (be patient)<br />
Completed 1000 requests<br />
Completed 2000 requests<br />
Completed 3000 requests<br />
Completed 4000 requests<br />
Completed 5000 requests<br />
Completed 6000 requests<br />
Completed 7000 requests<br />
Completed 8000 requests<br />
Completed 9000 requests<br />
Completed 10000 requests<br />
Finished 10000 requests</p>
<p>Server Software:        Apache-Coyote/1.1<br />
Server Hostname:        localhost<br />
Server Port:            8080</p>
<p>Document Path:          /test/test.jsp<br />
Document Length:        113678 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   10.079 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Keep-Alive requests:    0<br />
Total transferred:      1139157786 bytes<br />
HTML transferred:       1137007356 bytes<br />
Requests per second:    992.18 [#/sec] (mean)<br />
Time per request:       50.394 [ms] (mean)<br />
Time per request:       1.008 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          110376.03 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    7   7.3      5      67<br />
Processing:     5   43  22.4     37     182<br />
Waiting:        0   16  19.9     11     161<br />
Total:          7   50  22.4     45     207</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%     45<br />
66%     52<br />
75%     57<br />
80%     61<br />
90%     75<br />
95%     91<br />
98%    119<br />
99%    147<br />
100%    207 (longest request)</p>
<h2>Test result trace for mod_proxy_ajp</h2>
<p><code>bserban-mac:~ bserban$ ab -k -n 10000 -c 50 http://localhost/test/test.jsp<br />
This is ApacheBench, Version 2.3 &lt;$Revision: 655654 $&gt;<br />
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br />
Licensed to The Apache Software Foundation, http://www.apache.org/</code></p>
<p>Benchmarking localhost (be patient)<br />
Completed 1000 requests<br />
Completed 2000 requests<br />
Completed 3000 requests<br />
Completed 4000 requests<br />
Completed 5000 requests<br />
Completed 6000 requests<br />
Completed 7000 requests<br />
Completed 8000 requests<br />
Completed 9000 requests<br />
Completed 10000 requests<br />
Finished 10000 requests</p>
<p>Server Software:<br />
Server Hostname:        localhost<br />
Server Port:            80</p>
<p>Document Path:          /test/test.jsp<br />
Document Length:        113678 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   14.251 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Keep-Alive requests:    0<br />
Total transferred:      1140884936 bytes<br />
HTML transferred:       1139000800 bytes<br />
Requests per second:    701.70 [#/sec] (mean)<br />
Time per request:       71.256 [ms] (mean)<br />
Time per request:       1.425 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          78179.54 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    7   8.3      5      87<br />
Processing:     6   64  89.8     47     967<br />
Waiting:        0   38  86.9     21     920<br />
Total:          6   71  89.4     52     972</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%     52<br />
66%     58<br />
75%     64<br />
80%     69<br />
90%     83<br />
95%    115<br />
98%    507<br />
99%    689<br />
100%    972 (longest request)</p>
<h2>Test result trace for mod_proxy</h2>
<p><code>bserban-mac:~ bserban$ ab -k -n 10000 -c 50 http://localhost/test/test.jsp<br />
This is ApacheBench, Version 2.3 &lt;$Revision: 655654 $&gt;<br />
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br />
Licensed to The Apache Software Foundation, http://www.apache.org/</code></p>
<p>Benchmarking localhost (be patient)<br />
Completed 1000 requests<br />
Completed 2000 requests<br />
Completed 3000 requests<br />
Completed 4000 requests<br />
Completed 5000 requests<br />
Completed 6000 requests<br />
Completed 7000 requests<br />
Completed 8000 requests<br />
Completed 9000 requests<br />
Completed 10000 requests<br />
Finished 10000 requests</p>
<p>Server Software:        Apache-Coyote/1.1<br />
Server Hostname:        localhost<br />
Server Port:            80</p>
<p>Document Path:          /test/test.jsp<br />
Document Length:        113678 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   14.985 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Keep-Alive requests:    0<br />
Total transferred:      1140715856 bytes<br />
HTML transferred:       1138561771 bytes<br />
Requests per second:    667.34 [#/sec] (mean)<br />
Time per request:       74.925 [ms] (mean)<br />
Time per request:       1.498 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          74339.90 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    9  10.1      5     123<br />
Processing:     9   66  83.2     52     975<br />
Waiting:        0   41  83.7     27     949<br />
Total:          9   74  82.6     59     980</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%     59<br />
66%     66<br />
75%     72<br />
80%     76<br />
90%     98<br />
95%    123<br />
98%    192<br />
99%    675<br />
100%    980 (longest request)
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Fconfigure-apache-and-tomcat-severs-together%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Fconfigure-apache-and-tomcat-severs-together%2F&amp;source=bserban&amp;style=normal&amp;service=bit.ly&amp;hashtags=AJP,Apache,Apache+Benchmark,mod_proxy,mod_proxy_ajp,Tomcat" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bserban.org/2009/08/configure-apache-and-tomcat-severs-together/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tomcat Clustering &amp; Java Servlet Specification</title>
		<link>http://www.bserban.org/2009/08/tomcat-clustering-java-servlet-specification/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=tomcat-clustering-java-servlet-specification</link>
		<comments>http://www.bserban.org/2009/08/tomcat-clustering-java-servlet-specification/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 11:34:51 +0000</pubDate>
		<dc:creator>bserban</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[Distributable]]></category>
		<category><![CDATA[Servlet Specification]]></category>
		<category><![CDATA[Sticky Sessions]]></category>
		<category><![CDATA[Tomcat clustering]]></category>

		<guid isPermaLink="false">http://www.bserban.org/2009/08/tomcat-clustering-java-servlet-specification/</guid>
		<description><![CDATA[After I read more about Tomcat Clustering I realized that the main purpose of Tomcat clustering is to offer fault tolerance, failover  and high availability support. I read a lot about load balancing but when it comes to Java Servlets I found out that the only choice you have in terms of balancing is to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Ftomcat-clustering-java-servlet-specification%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Ftomcat-clustering-java-servlet-specification%2F&amp;source=bserban&amp;style=normal&amp;service=bit.ly&amp;hashtags=Distributable,Servlet+Specification,Sticky+Sessions,Tomcat+clustering" height="61" width="50" /><br />
			</a>
		</div>
<p>After I read more about Tomcat Clustering I realized that the main purpose of Tomcat clustering is to offer fault tolerance, failover  and high availability support. I read a lot about load balancing but when it comes to Java Servlets I found out that the only choice you have in terms of balancing is to use sticky sessions. This is more a limitation that comes from Java Servlet Specification and not from Tomcat, but it make sense.</p>
<p>For an application to be &#8220;distributed&#8221; you have to mark  it as &#8220;distributable&#8221; by add the &lt;distributable/&gt; tag in web.xml.</p>
<p>&lt;web-app&gt;<br />
&lt;distributable /&gt;<br />
&lt;/web-app&gt;</p>
<p>There are multiple ways to balance the client request to your server pool but when it comes to Java Servlet Specification you have only one choice, as the specs say:</p>
<p>&#8220;<em>Within an application that is marked as distributable, all requests that are part of a session can only be handled on a single JVM at any one time.</em>&#8221;</p>
<p>&#8220;<em>You may have multiple JVMs, each handling requests from different clients concurrently for any given distributable web application</em>&#8221;</p>
<p>So, I guess you can kiss goodbye the round robin and all other load balancing options, but at least Tomcat will provide you  failover, scalability  and high availability.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Ftomcat-clustering-java-servlet-specification%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.bserban.org%2F2009%2F08%2Ftomcat-clustering-java-servlet-specification%2F&amp;source=bserban&amp;style=normal&amp;service=bit.ly&amp;hashtags=Distributable,Servlet+Specification,Sticky+Sessions,Tomcat+clustering" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bserban.org/2009/08/tomcat-clustering-java-servlet-specification/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
