<?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>MoaxStuff</title>
	<atom:link href="http://kjetland.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://kjetland.com/blog</link>
	<description>Mostly dev-stuff</description>
	<lastBuildDate>Tue, 22 Jan 2013 19:32:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>DDSL plugin for Dropwizard</title>
		<link>http://kjetland.com/blog/2013/01/ddsl-plugin-for-dropwizard/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ddsl-plugin-for-dropwizard</link>
		<comments>http://kjetland.com/blog/2013/01/ddsl-plugin-for-dropwizard/#comments</comments>
		<pubDate>Tue, 22 Jan 2013 19:32:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Dropwizard]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PlayFramework]]></category>
		<category><![CDATA[Scaling]]></category>
		<category><![CDATA[distribution]]></category>
		<category><![CDATA[dropwizard]]></category>
		<category><![CDATA[scaling]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=110</guid>
		<description><![CDATA[DDSL &#8211; Dynamic Distributes Service Locator &#8211; enables your applications to be discovered by other applications or reverse-proxies like nginx without any manual reconfiguration. DDSL uses Apache Zookeeper to make Service Discovery possible in a distributed way without any single &#8230; <a href="http://kjetland.com/blog/2013/01/ddsl-plugin-for-dropwizard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D110&count=none&related=&text=DDSL%20plugin%20for%20Dropwizard' class='twitter-share-button' data-text='DDSL plugin for Dropwizard' data-url='http://kjetland.com/blog/?p=110' data-counturl='http://kjetland.com/blog/2013/01/ddsl-plugin-for-dropwizard/' data-count='none' data-via='mbknor'></a><p><a title="ddsl" href="https://github.com/mbknor/ddsl">DDSL</a> &#8211; Dynamic Distributes Service Locator &#8211; enables your applications to be <strong>discovered</strong> by other applications or reverse-proxies like <strong>nginx</strong> without any manual reconfiguration. DDSL uses <a title="Apache Zookeeper" href="http://zookeeper.apache.org/">Apache Zookeeper</a> to make <strong>Service Discovery</strong> possible in a distributed way without any single point of failure.</p>
<p>When using DDSL you can automatically <strong>scale</strong> your system up by just starting a new instance of one of your applications on some random machine, since the built-in Load-balancer in DDSL will <strong>automatically</strong> start sending traffic to it.</p>
<p>I have recently created and release a <a title="DDSL-plugin for dropwizard" href="https://github.com/mbknor/ddsl-dropwizard">DDSL plugin for <strong>Dropwizard</strong></a> which makes it really easy to add the functionality to your existing <a title="Dropwizard" href="http://dropwizard.codahale.com/">Dropwizard</a>-applications.</p>
<p>If you are more into <strong><a title="Play Framework" href="http://www.playframework.org/">Play Framwork</a></strong>, choose the <a title="DDSL module for play framework 1.x" href="https://github.com/mbknor/ddsl-playframework-module">1.x-module</a> or <a title="DDSL plugin for Play Framework 2.x" href="https://github.com/mbknor/ddsl-play2-module">2.x-plugin</a>, and you can of course use it in any of your X-technology Java- or Scala-applications.</p>
<p>If you have any questions or comments, please comment here on this blog or contact me via <a href="https://github.com/mbknor/ddsl">github</a> or <a title="@mbknor" href="http://twitter.com/mbknor">twitter</a>.</p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=110&amp;md5=983958faf666daaf77c2e3ef8a156fe9" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2013/01/ddsl-plugin-for-dropwizard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2013%2F01%2Fddsl-plugin-for-dropwizard%2F&amp;language=en_GB&amp;category=text&amp;title=DDSL+plugin+for+Dropwizard&amp;description=DDSL+%26%238211%3B+Dynamic+Distributes+Service+Locator+%26%238211%3B+enables+your+applications+to+be+discovered+by+other+applications+or+reverse-proxies+like+nginx+without+any+manual+reconfiguration.+DDSL+uses+Apache+Zookeeper+to+make...&amp;tags=distribution%2Cdropwizard%2Cscaling%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Play 1 module: Faster Groovy Templates</title>
		<link>http://kjetland.com/blog/2012/02/play-1-module-faster-groovy-templates/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=play-1-module-faster-groovy-templates</link>
		<comments>http://kjetland.com/blog/2012/02/play-1-module-faster-groovy-templates/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 01:11:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PlayFramework]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=104</guid>
		<description><![CDATA[GT-Engine is a new implementation of the default groovy template engine in Play Framework 1. GT-Engine is faster and uses less memory. You can now use GT-Engine in Play 1 using the module faster-groovy-templates which is a drop-in-plugin replacing the &#8230; <a href="http://kjetland.com/blog/2012/02/play-1-module-faster-groovy-templates/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D104&count=none&related=&text=Play%201%20module%3A%20Faster%20Groovy%20Templates%20' class='twitter-share-button' data-text='Play 1 module: Faster Groovy Templates ' data-url='http://kjetland.com/blog/?p=104' data-counturl='http://kjetland.com/blog/2012/02/play-1-module-faster-groovy-templates/' data-count='none' data-via='mbknor'></a><p><a href="https://github.com/mbknor/gt-engine">GT-Engine</a> is a new implementation of the default groovy template engine in <a href="http://www.playframework.org/">Play Framework</a> 1. GT-Engine is <a href="http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/">faster and uses less memory</a>.</p>
<p>You can now use GT-Engine in Play 1 using the module <a href="https://github.com/mbknor/faster-groovy-templates">faster-groovy-templates</a> which is a drop-in-plugin replacing the default template implementation.</p>
<p>UPDATE: The module is now available in the Play Framework <a href="http://www.playframework.org/modules/fastergt">module repository</a></p>
<p>There also exists a <a href="https://github.com/mbknor/gt-engine-play2">Play 2 module</a> that makes it more easy for you to port your Play 1 application to Play 2.0.</p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=104&amp;md5=0687391a34a31d0d9b0b0ab42ffa9cef" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2012/02/play-1-module-faster-groovy-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2012%2F02%2Fplay-1-module-faster-groovy-templates%2F&amp;language=en_GB&amp;category=text&amp;title=Play+1+module%3A+Faster+Groovy+Templates&amp;description=GT-Engine+is+a+new+implementation+of+the+default+groovy+template+engine+in+Play+Framework+1.+GT-Engine+is+faster+and+uses+less+memory.+You+can+now+use+GT-Engine+in+Play+1...&amp;tags=blog" type="text/html" />
	</item>
		<item>
		<title>Announcing Groovy Template support for Play Framework 2.0</title>
		<link>http://kjetland.com/blog/2012/01/announcing-groovy-template-support-in-play-framework-2-0/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=announcing-groovy-template-support-in-play-framework-2-0</link>
		<comments>http://kjetland.com/blog/2012/01/announcing-groovy-template-support-in-play-framework-2-0/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 20:57:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PlayFramework]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=91</guid>
		<description><![CDATA[I have just released a beta version of the Groovy Template module for Play Framework 2.0 called gt-engine-play2. The current project-status is Beta as of 24. january 2012. It is based on the gt-engine described in this blog post. It &#8230; <a href="http://kjetland.com/blog/2012/01/announcing-groovy-template-support-in-play-framework-2-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D91&count=none&related=&text=Announcing%20Groovy%20Template%20support%20for%20Play%20Framework%202.0' class='twitter-share-button' data-text='Announcing Groovy Template support for Play Framework 2.0' data-url='http://kjetland.com/blog/?p=91' data-counturl='http://kjetland.com/blog/2012/01/announcing-groovy-template-support-in-play-framework-2-0/' data-count='none' data-via='mbknor'></a><p>I have just released a beta version of the Groovy Template module for Play Framework 2.0 called <strong><a title="gt-engine-play2" href="https://github.com/mbknor/gt-engine-play2/">gt-engine-play2</a></strong>.</p>
<p>The current project-status is Beta as of 24. january 2012.</p>
<p>It is based on the <a title="gt-engine" href="https://github.com/mbknor/gt-engine">gt-engine</a> described in this <a title="blog post" href="http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/">blog post</a>.</p>
<p>It should be feature complete (for Java) but please have a look at the readme file over at github &#8211; and the issues-list. When you find new issues, please report them via <a href="https://github.com/mbknor/gt-engine-play2/issues">github</a>.</p>
<p>Please try it out and start porting you Java Play 1.x app to Play 2.0 <img src='http://kjetland.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-morten</p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=91&amp;md5=6ef896a8f13a50a09e825ba102fd2f3b" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2012/01/announcing-groovy-template-support-in-play-framework-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2012%2F01%2Fannouncing-groovy-template-support-in-play-framework-2-0%2F&amp;language=en_GB&amp;category=text&amp;title=Announcing+Groovy+Template+support+for+Play+Framework+2.0&amp;description=I+have+just+released+a+beta+version+of+the+Groovy+Template+module+for+Play+Framework+2.0+called+gt-engine-play2.+The+current+project-status+is+Beta+as+of+24.+january+2012.+It+is...&amp;tags=blog" type="text/html" />
	</item>
		<item>
		<title>PlayFramework: New faster Groovy Template Engine</title>
		<link>http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playframework-new-faster-groovy-template-engine</link>
		<comments>http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 21:12:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PlayFramework]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=40</guid>
		<description><![CDATA[UPDATE: Play 1 module available here: https://github.com/mbknor/faster-groovy-templates Play 2 module available here: https://github.com/mbknor/gt-engine-play2 Why re-implement the Groovy Template Engine? Play Framework version 1.x default template engine is based on Groovy. Play 2.0 has a new template system based on Scala but we &#8230; <a href="http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D40&count=none&related=&text=PlayFramework%3A%20New%20faster%20Groovy%20Template%20Engine' class='twitter-share-button' data-text='PlayFramework: New faster Groovy Template Engine' data-url='http://kjetland.com/blog/?p=40' data-counturl='http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/' data-count='none' data-via='mbknor'></a><h3>UPDATE:</h3>
<p>Play 1 module available here: <a href="https://github.com/mbknor/faster-groovy-templates">https://github.com/mbknor/faster-groovy-templates</a></p>
<p>Play 2 module available here: <a href="https://github.com/mbknor/gt-engine-play2">https://github.com/mbknor/gt-engine-play2</a></p>
<h3>Why re-implement the Groovy Template Engine?</h3>
<p>Play Framework version 1.x default template engine is based on Groovy. Play 2.0 has a new template system based on Scala but we want to make it possible to migrate from Play 1.x to 2.0 without having to rewrite all of your old Groovy Templates.</p>
<p>When investigating how to use the Groovy template engine code from Play 1.x in Play 2.0 it turned out to be difficult since the implementation is really tight coupled with the entire Play 1.x code base.</p>
<p>This made me start a (too big) project to re-implement the entire Groovy Template Engine making sure it was not using any of the other Play code. This would make it possible to use the exact same implementation in Play 2.0. It aims to be 100 % compatible with existing templates/applications.</p>
<p>When doing this reimplementation I have managed to make it faster (and using a little less memory i think <img src='http://kjetland.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). I&#8217;ll probably write another blogpost later about how it is implemented but basically I precompile the template source down to both java and as little groovy code as possible. <strong>See at the bottom for benchmark results.</strong></p>
<p>I think the new implementation is feature-complete (But Beta) and we&#8217;re using it in development at work. But there is still work to do:</p>
<ul>
<li>checking/making sure I have not broken too much api <img src='http://kjetland.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>improve/clean api/code</li>
<li>Moving the code to external project so Play only uses a jar-file</li>
<li>Add code to Play 2.0 to use the groovy engine.</li>
</ul>
<p>(<em>New feature: If you add &#8216;save-gttemplate-source-to-disk = true&#8217; to application.conf, the generated java and groovy source code is dumped to disk so you can step-debug it if you want.</em>)</p>
<p>The current <strong>source</strong> (Based on Play 1.2.4-RC2) can be found <a href="https://github.com/mbknor/play/tree/new_groovy_template_impl">https://github.com/mbknor/play/tree/new_groovy_template_impl</a> (UPDATE: Remember to use the correct <strong>branch &#8216;new_groovy_template_impl&#8217;</strong>).</p>
<p><strong><br />
Please try it out and report any problems or suggestions/thoughts.<br />
</strong></p>
<p>Some limitations regarding Groovy code snipits %{ ..code.. }%:</p>
<ul>
<li>You can no longer use partial-program-flow-code like this:
<pre>%{ if( expression) { }% or %{ myList.foreach() { }%</pre>
</li>
<li>Instead you have to use:
<pre>#{if expression} or #{list myList}</pre>
</li>
<li><del datetime="2011-11-18T10:03:04+00:00">Also you cannot use def or declare type when creating variables if you want it to be visible outside the script-block.</del><em> (Not a limitation anymore)</em></li>
</ul>
<h1>Benchmark</h1>
<p>The following benchmark results are not scientific at all but I made them just to try to show the difference between old and new implementation. It is based on Play 1.2.4-RC2.</p>
<p>The test application can be found <a href="https://github.com/mbknor/template_benchmark_app">at github</a></p>
<h3>This is how I performed the tests</h3>
<p>I started Play like this: play run &#8211;%prod -XX:CompileThreshold=10</p>
<p>I used CompileThreshold to shorten the needed jvm warm up time.</p>
<p>For each speed-benchmark i restarted play, ran 14000 request using ab (40 concurrent), then did another 14000 request and recorded the stats.</p>
<p>For memory-benchmarks I restarted Play, then recorded heap usage with jvisualvm during the first 14000 requests. All GC settings are default.</p>
<p>Detailed info about the speed benchmark can be found <a href="https://github.com/mbknor/template_benchmark_app/blob/master/template_benchmark.txt">here</a>.</p>
<p>Google spreadsheet with useful numbers can be found <a href="https://docs.google.com/spreadsheet/ccc?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc">here</a>.</p>
<p>Each test shows two numbers:</p>
<ul>
<li>requests pr second</li>
<li>total &#8220;rendering time&#8221; for all 14000 requests. (total time for test minus total time for noTemplate-test: Shows aprox time spent with rendering without time spent in framework itself)</li>
</ul>
<hr />
<h2>minimalTemplate</h2>
<pre>ab -k -c 40 -n 14000 http://localhost:9000/application/minimalTemplate</pre>
<p>&nbsp;</p>
<h3>Requests pr second</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>6526 r/s</td>
</tr>
<tr>
<td>new impl</td>
<td>7141 r/s</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.09X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=2&amp;zx=ehq0dz1ezolc" alt="" width="600" height="371" /></p>
<h3>Total &#8220;Rendering time&#8221;</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>0.362 seconds</td>
</tr>
<tr>
<td>new impl</td>
<td>0.208 seconds</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.74X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=3&amp;zx=roi25ned9igu" alt="" /></p>
<hr />
<h2>normalTemplate</h2>
<pre>ab -k -c 40 -n 14000 http://localhost:9000/application/normalTemplate</pre>
<h3>Requests pr second:</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>1674 r/s</td>
</tr>
<tr>
<td>new impl</td>
<td>2801 r/s</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.67X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=4&amp;zx=p0qp2c9xasup" alt="" /></p>
<h3>Total &#8220;Rendering time&#8221;</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>6.57 seconds</td>
</tr>
<tr>
<td>new impl</td>
<td>3.24 seconds</td>
</tr>
<tr>
<td>Improvement</td>
<td>2.03X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=5&amp;zx=uukseiowcg06" alt="" /></p>
<hr />
<h2>normalTemplateBigData</h2>
<pre>ab -k -c 40 -n 14000 http://localhost:9000/application/normalTemplateBigData</pre>
<h3>Requests pr second:</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>323 r/s</td>
</tr>
<tr>
<td>new impl</td>
<td>524 r/s</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.62X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=6&amp;zx=fquooryqvfa5" alt="" /></p>
<h3>Total &#8220;Rendering time&#8221;</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>41.438 seconds</td>
</tr>
<tr>
<td>new impl</td>
<td>24.935 seconds</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.66X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=7&amp;zx=d26ltx9awe7p" alt="" /></p>
<hr />
<h2>normalTemplateBigDataWithJavaExtensions</h2>
<pre>ab -k -c 40 -n 14000 http://localhost:9000/application/normalTemplateBigDataWithJavaExtensions</pre>
<h3>Requests pr second:</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>290 r/s</td>
</tr>
<tr>
<td>new impl</td>
<td>434 r/s</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.50X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=8&amp;zx=c97o9pey8l6p" alt="" /></p>
<h3>Total &#8220;Rendering time&#8221;</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>46.336 seconds</td>
</tr>
<tr>
<td>new impl</td>
<td>30.464 seconds</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.52X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=10&amp;zx=de3lrh95fmm0" alt="" /></p>
<hr />
<h2>normalTemplateBigDataInTag</h2>
<pre>ab -k -c 40 -n 14000 http://localhost:9000/application/normalTemplateBigDataInTag</pre>
<h3>Requests pr second:</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>310 r/s</td>
</tr>
<tr>
<td>new impl</td>
<td>460 r/s</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.48X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=11&amp;zx=xoncrkon93z0" alt="" /></p>
<h3>Total &#8220;Rendering time&#8221;</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>43.236 seconds</td>
</tr>
<tr>
<td>new impl</td>
<td>28.658 seconds</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.51X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=12&amp;zx=vydyvl30ur8p" alt="" /></p>
<hr />
<h2>normalTemplateBiggerData</h2>
<pre>ab -k -c 40 -n 14000 http://localhost:9000/application/normalTemplateBiggerData</pre>
<h3>Requests pr second:</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>35 r/s</td>
</tr>
<tr>
<td>new impl</td>
<td>56 r/s</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.60X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=13&amp;zx=czecekqvv7fc" alt="" /></p>
<h3>Total &#8220;Rendering time&#8221;</h3>
<table>
<tbody>
<tr>
<td>1.2.4-rc2</td>
<td>388.032 seconds</td>
</tr>
<tr>
<td>new impl</td>
<td>245.809 seconds</td>
</tr>
<tr>
<td>Improvement</td>
<td>1.58X</td>
</tr>
</tbody>
</table>
<p><img src="https://docs.google.com/spreadsheet/oimg?key=0Ahx0cFyaXWeLdEdqclY1Wm82Qm80X2s5YTAyYWtRTGc&amp;oid=14&amp;zx=a313qlm283zf" alt="" /></p>
<hr />
<h2>Memory info</h2>
<h3>normalTemplate</h3>
<p>1.2.4-rc2<br />
<img src="http://kjetland.com/blog/wp-content/uploads/1.2.4-rc2_normalTemplate.png" alt="" /></p>
<p>new impl:<br />
<img src="http://kjetland.com/blog/wp-content/uploads/new_normalTemplate.png" alt="" /></p>
<h3>normalTemplateBigData</h3>
<p>1.2.4-rc2<br />
<img src="http://kjetland.com/blog/wp-content/uploads/1.2.4-rc2_normalTemplateBigData.png" alt="" /></p>
<p>new impl:<br />
<img src="http://kjetland.com/blog/wp-content/uploads/new_normalTemplateBigData.png" alt="" /></p>
<h3>normalTemplateBigDataInTag</h3>
<p>1.2.4-rc2<br />
<img src="http://kjetland.com/blog/wp-content/uploads/1.2.4-rc2_normalTemplateBigDataInTag.png" alt="" /></p>
<p>new impl:<br />
<img src="http://kjetland.com/blog/wp-content/uploads/new_normalTemplateBigDataInTag.png" alt="" /></p>
<hr />
<h2>Some last words</h2>
<p>I hope this info was useful (It actually took a long time to perform the tests and write this blog <img src='http://kjetland.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). Also, I hope you <a href="https://github.com/mbknor/play/tree/new_groovy_template_impl">download the custom play version</a> and <strong>help me find problems not yet found</strong>.</p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=40&amp;md5=03091600b017b3ef990438744c2d8baa" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2011%2F11%2Fplayframework-new-faster-groovy-template-engine%2F&amp;language=en_GB&amp;category=text&amp;title=PlayFramework%3A+New+faster+Groovy+Template+Engine&amp;description=UPDATE%3A+Play+1+module+available+here%3A%C2%A0https%3A%2F%2Fgithub.com%2Fmbknor%2Ffaster-groovy-templates+Play+2+module+available+here%3A%C2%A0https%3A%2F%2Fgithub.com%2Fmbknor%2Fgt-engine-play2+Why+re-implement+the+Groovy+Template+Engine%3F+Play+Framework+version+1.x+default+template+engine+is+based+on+Groovy.+Play+2.0...&amp;tags=blog" type="text/html" />
	</item>
		<item>
		<title>Gamedev or Insurance? Which is best?</title>
		<link>http://kjetland.com/blog/2011/01/gamedev-or-insurance-which-is-best/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gamedev-or-insurance-which-is-best</link>
		<comments>http://kjetland.com/blog/2011/01/gamedev-or-insurance-which-is-best/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 21:04:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=35</guid>
		<description><![CDATA[Interesting read from a colleague of mine over at sickenger.com]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D35&count=none&related=&text=Gamedev%20or%20Insurance%3F%20Which%20is%20best%3F' class='twitter-share-button' data-text='Gamedev or Insurance? Which is best?' data-url='http://kjetland.com/blog/?p=35' data-counturl='http://kjetland.com/blog/2011/01/gamedev-or-insurance-which-is-best/' data-count='none' data-via='mbknor'></a><p>Interesting read from a colleague of mine over at <a href="http://www.sickenger.com/2011/01/game-developer-and-then-what/">sickenger.com</a></p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=35&amp;md5=a7bd4811732c791f8549bec365b230db" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2011/01/gamedev-or-insurance-which-is-best/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2011%2F01%2Fgamedev-or-insurance-which-is-best%2F&amp;language=en_GB&amp;category=text&amp;title=Gamedev+or+Insurance%3F+Which+is+best%3F&amp;description=Interesting+read+from+a%C2%A0colleague%C2%A0of+mine+over+at+sickenger.com&amp;tags=programming%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Preview: DDSL &#8211; Dynamic Distributed Service Locator</title>
		<link>http://kjetland.com/blog/2011/01/preview-ddsl-dynamic-distributed-service-locator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=preview-ddsl-dynamic-distributed-service-locator</link>
		<comments>http://kjetland.com/blog/2011/01/preview-ddsl-dynamic-distributed-service-locator/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 00:16:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ddsl]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=31</guid>
		<description><![CDATA[Have a look at DDSL &#8211; Dynamic Distributed Service Locator over at GitHub There you can find working code, README and example with step-by-step guide. Official post coming later when it is more complete..]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D31&count=none&related=&text=Preview%3A%20DDSL%20-%20Dynamic%20Distributed%20Service%20Locator%20' class='twitter-share-button' data-text='Preview: DDSL - Dynamic Distributed Service Locator ' data-url='http://kjetland.com/blog/?p=31' data-counturl='http://kjetland.com/blog/2011/01/preview-ddsl-dynamic-distributed-service-locator/' data-count='none' data-via='mbknor'></a><p>Have a look at DDSL &#8211; Dynamic Distributed Service Locator over at <a href="https://github.com/mbknor/ddsl">GitHub</a></p>
<p>There you can find working code, README and example with step-by-step guide.</p>
<p>Official post coming later when it is more complete..</p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=31&amp;md5=b89ca68ff03bfeb529c8583dfddfe0c9" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2011/01/preview-ddsl-dynamic-distributed-service-locator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2011%2F01%2Fpreview-ddsl-dynamic-distributed-service-locator%2F&amp;language=en_GB&amp;category=text&amp;title=Preview%3A+DDSL+%26%238211%3B+Dynamic+Distributed+Service+Locator&amp;description=Have+a+look+at+DDSL+%26%238211%3B+Dynamic+Distributed+Service+Locator+over+at+GitHub+There+you+can+find+working+code%2C+README+and+example+with+step-by-step+guide.+Official+post+coming+later+when...&amp;tags=ddsl%2Cscala%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Legacy app that Plays with the future..</title>
		<link>http://kjetland.com/blog/2011/01/legacy-app-that-plays-with-the-future/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=legacy-app-that-plays-with-the-future</link>
		<comments>http://kjetland.com/blog/2011/01/legacy-app-that-plays-with-the-future/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 22:14:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=22</guid>
		<description><![CDATA[Enabling our legacy web application for the Future using The Play Framework Some background At work we have an old big web application written in some strange language originally running on a mainframe web server. It’s kind of jsp-ish with &#8230; <a href="http://kjetland.com/blog/2011/01/legacy-app-that-plays-with-the-future/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D22&count=none&related=&text=Legacy%20app%20that%20Plays%20with%20the%20future..' class='twitter-share-button' data-text='Legacy app that Plays with the future..' data-url='http://kjetland.com/blog/?p=22' data-counturl='http://kjetland.com/blog/2011/01/legacy-app-that-plays-with-the-future/' data-count='none' data-via='mbknor'></a><div>
<p><em>Enabling our legacy web application for the Future using The Play Framework</em></p>
<p><strong>Some background<br />
</strong><br />
At work we have an old big web application written in some strange language originally running on a mainframe web server.</p>
<p>It’s kind of jsp-ish with just one big script for each page &#8211; not even close to MVC.</p>
<p>(Related post: <a href="http://kjetland.com/blog/2010/02/taking-control-over-legacy-code/">Taking control over legacy code</a>)</p>
<p>The application is constantly being extended so it has never been realistic to stop adding features while porting the hole application to a modern platform &#8211; and many of the developers like the JSP-feeling (just dump a new file and it works&#8230;)</p>
<p>Some years ago I wrote an emulator for that webserver in java (using extensive precompiling and an Open Source interpreterer). First the emulator had to be 100% backward compatible but then we switched off the mainframe webserver and only used the emulator &#8211; running in Tomcat on Windows (I know: Linux is better). We also added features to the language (like include files etc&#8230; <img src='http://kjetland.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) using precompiling.</p>
<p>The only solution I saw to make it possible to introduce modern technology in the application was to make it possible to gradually rewrite parts of the application &#8211; while the old and new parts of the app could communicate and work side by side.</p>
<p>Over the years I’ve created many solutions to enable our “script-kidies” to stop developing in the legacy language and start using java.. But I never got them to use it..</p>
<p><strong>The Solution<br />
</strong><br />
In the fall of 2010 after attending JavaZone I had a breakthrough: Writing the new code in Java using the Play Framework.</p>
<p>Earlier today we upgraded our production environment to use the new legacy-play-integrated solution.</p>
<p><strong>How we did it<br />
</strong><br />
As I said, all parts of the application has to be able to communicate &#8211; sharing state. The legacy application is statefull (read: session stored on server) &#8211; and the play part of the app is not.</p>
<p>I created an “external session store” (Lets call it ESS) &#8211; when the legacy app needs to store data in Session, it stores it in the ESS and only stores an ESS-id in the Real Session. This ESS-id is writen to a cookie.</p>
<p>Then when the browser accesses the play part of the application, either fullframe or using “DOM-injection” using JavaScript or using iframes, Play can read the ESS-id from the cookie (since both the legacy app-part and the play-app-part is using the same domain-namespace (fixed using reverse proxy)) &#8211; Then the play app can access the ESS server-side via REST and read/store data &#8211; In this way &#8211; both parts of the app can share data realtime server-side.</p>
<p>The “DOM-injection”-technique was the killer feature that made it possible to convince our Team leader that we should implement all the new functionality in Play.</p>
<p>It works like this: The legacy app renders the full page (with menus and stuff) leaving the “main part” empy with a &lt;div&gt;, then it uses JQuery to fetch a page from Play and injecting the returned DOM (read: HTML with embedded JavaScript) on that &lt;div&gt;. When the injected DOM is rendered, its embedded JavaScript/JQuery is executed. This way the page rendered in the users browser contains no iframes and it makes the “play-part” of the application/page totally contained. This resulted in the (partial) Play app being nice and simple using some java code server side and more HTML/JQuery client-side &#8211; since most of the backend systems served data as JSON via REST.</p>
<p><strong>Conclusion</strong></p>
<p>My feeling is that the development team is so happy with what the Play Framework gave us, that the only Legacy code being written in the future &#8211; is to disable old code &#8211; or linking to new functionality written in Play.</p>
<p><strong>In the Future?<br />
</strong><br />
Maybe they can be convinced to ditch Java for Scala? I hope so..</p>
</div>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=22&amp;md5=1ee076ad077d356b77d5208b5f91d9dd" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2011/01/legacy-app-that-plays-with-the-future/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2011%2F01%2Flegacy-app-that-plays-with-the-future%2F&amp;language=en_GB&amp;category=text&amp;title=Legacy+app+that+Plays+with+the+future..&amp;description=Enabling+our+legacy+web+application+for+the+Future+using+The+Play+Framework+Some+background+At+work+we+have+an+old+big+web+application+written+in+some+strange+language+originally+running...&amp;tags=programming%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Maven Dependency Management (Deptools)</title>
		<link>http://kjetland.com/blog/2010/11/maven-dependency-management-deptools/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=maven-dependency-management-deptools</link>
		<comments>http://kjetland.com/blog/2010/11/maven-dependency-management-deptools/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 22:09:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=20</guid>
		<description><![CDATA[A very good colleague of mine wrote an excellent post about my maven plugin called &#8216;deptools&#8217;. You can read it on his blog]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D20&count=none&related=&text=Maven%20Dependency%20Management%20%28Deptools%29' class='twitter-share-button' data-text='Maven Dependency Management (Deptools)' data-url='http://kjetland.com/blog/?p=20' data-counturl='http://kjetland.com/blog/2010/11/maven-dependency-management-deptools/' data-count='none' data-via='mbknor'></a><p>A very good colleague of mine wrote an excellent post about my maven plugin called &#8216;deptools&#8217;.</p>
<p>You can read it on his <a href="http://www.sickenger.com/2010/11/maven-dependency-management-deptools/">blog</a></p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=20&amp;md5=adc78050b59371896d54497fb8113a73" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2010/11/maven-dependency-management-deptools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2010%2F11%2Fmaven-dependency-management-deptools%2F&amp;language=en_GB&amp;category=text&amp;title=Maven+Dependency+Management+%28Deptools%29&amp;description=A+very+good+colleague+of+mine+wrote+an%C2%A0excellent%C2%A0post+about+my+maven+plugin+called+%26%238216%3Bdeptools%26%238217%3B.+You+can+read+it+on+his+blog&amp;tags=blog" type="text/html" />
	</item>
		<item>
		<title>Moved from blogger.com to WordPress</title>
		<link>http://kjetland.com/blog/2010/11/moved-from-blogger-com-to-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=moved-from-blogger-com-to-wordpress</link>
		<comments>http://kjetland.com/blog/2010/11/moved-from-blogger-com-to-wordpress/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 22:54:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://kjetland.com/blog/?p=3</guid>
		<description><![CDATA[I have now moved my blog away from moaxstuff.blogger.com to my own WordPress hosted by myself&#8230; Even though my posts is not that interesting, it was almost impossible to find it on google.com &#8211; You had to specific search in &#8230; <a href="http://kjetland.com/blog/2010/11/moved-from-blogger-com-to-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D3&count=none&related=&text=Moved%20from%20blogger.com%20to%20WordPress' class='twitter-share-button' data-text='Moved from blogger.com to WordPress' data-url='http://kjetland.com/blog/?p=3' data-counturl='http://kjetland.com/blog/2010/11/moved-from-blogger-com-to-wordpress/' data-count='none' data-via='mbknor'></a><p>I have now moved my blog away from moaxstuff.blogger.com to my own WordPress hosted by myself&#8230; Even though my posts is not that interesting, it was almost impossible to find it on google.com &#8211; You had to specific search in &#8220;blogs&#8221; to find it&#8230; </p>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=3&amp;md5=b3e2f9c28e7b31d9cb97d77fde9dfa25" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2010/11/moved-from-blogger-com-to-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2010%2F11%2Fmoved-from-blogger-com-to-wordpress%2F&amp;language=en_GB&amp;category=text&amp;title=Moved+from+blogger.com+to+WordPress&amp;description=I+have+now+moved+my+blog+away+from+moaxstuff.blogger.com+to+my+own+WordPress+hosted+by+myself%26%238230%3B+Even+though+my+posts+is+not+that+interesting%2C+it+was+almost+impossible+to+find...&amp;tags=blog" type="text/html" />
	</item>
		<item>
		<title>JVM: Solving OutOfMemoryError with less Memory</title>
		<link>http://kjetland.com/blog/2010/11/jvm-solving-outofmemoryerror-with-less-memory/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jvm-solving-outofmemoryerror-with-less-memory</link>
		<comments>http://kjetland.com/blog/2010/11/jvm-solving-outofmemoryerror-with-less-memory/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 21:26:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[At work we have 6 web applications (WAR) deployed in Glassfish v2. In production we experienced sporadic java.lang.OutOfMemoryError: Java heap space under high load. We where sure that we did not have a classic Java memory leak since the used &#8230; <a href="http://kjetland.com/blog/2010/11/jvm-solving-outofmemoryerror-with-less-memory/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fkjetland.com%2Fblog%2F%3Fp%3D8&count=none&related=&text=JVM%3A%20Solving%20OutOfMemoryError%20with%20less%20Memory' class='twitter-share-button' data-text='JVM: Solving OutOfMemoryError with less Memory' data-url='http://kjetland.com/blog/?p=8' data-counturl='http://kjetland.com/blog/2010/11/jvm-solving-outofmemoryerror-with-less-memory/' data-count='none' data-via='mbknor'></a><p><meta charset="utf-8">
</p>
<p><span class="Apple-style-span"  ><span class="Apple-style-span" style="font-size: 13px;"></span></span></p>
<blockquote></blockquote>
<p><span class="Apple-style-span"  >At work we have 6 web applications (WAR) deployed in Glassfish v2.</span>
</p>
<p><span class="Apple-style-span"  ><span class="Apple-style-span" style="font-size: 13px;"></span></span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">In production we experienced sporadic java.lang.OutOfMemoryError: Java heap space under high load. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We where sure that we did not have a classic Java memory leak since the used HEAP space decreased after some time and returned to normal. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We suspected that the problem was related to our use of EHCache (which stores cached objects in HEAP space).</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">(Note: This blog post is a summary of two days of research &#8211; we tried many things and many numbers &#8211; on several more or less identical servers &#8211; so the numbers and values in this post </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">is approximately correct &#8211; but you get the point)</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">The JVM, and therefor GlassFish, was running with max 768 MB of HEAP space and 385 MB of PermGEN space.</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">To reduce the possibility of getting OutOfMemoryError until we had worked out the issue, we decided to increase the maximum HEAP space the JVM could allocate (-Xmx).</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">GlassFish runs on a 4 core 32 bit server with Windows Server 2003 with 8 GB of RAM.</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We increased the the max HEAP memory size to 1 GB (-Xmx=1024M). </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We started GlassFish with no applications deployed. Then deployed one application after the other &#8211; 6 WARs. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">All applications where deployed without problem and our Apps run fine. After some time the JVM suddenly died.</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We found a crash JVM crashdump. We didn&#8217;t read it to carefully, but it talked about OutOfMemoryError. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We did some more research and found out that it had died before the HEAP space had reached 1GB. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We thought a solution was to set the initial HEAP size that the JVM should initialize. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We told the JVM to initialize all the HEAP at startup (-Xms=1024M).</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">So now we had 1024MB HEAP and 385MB PermGEN which is a total of 1409MB.</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">When we then again started GlassFish (with no apps deployed), The JVM and GlassFish started up just fine. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">So we started to deploy applications &#8211; one by one. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">When GlassFish was in the middle of deploying the second application the JVM died.. So by allocating more memory up front, the JVM died with OutOfMemoryError earlier..</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">After a lot of research and reading this great post: <a href="http://www.codingthearchitecture.com/2008/01/14/jvm_lies_the_outofmemory_myth.html">http://www.codingthearchitecture.com/2008/01/14/jvm_lies_the_outofmemory_myth.html</a>, this is how we concluded:</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We took a closer look at the JVM crash dump:</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; "></span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; "></span></p>
<blockquote></blockquote>
<blockquote><p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">java.lang.OutOfMemoryError: requested 884680 bytes for Chunk::new. Out of swap space?</span></p>
</blockquote>
<p><span class="Apple-style-span"  ><span class="Apple-style-span" style="font-size: 13px;">It also says that the JVM crashed in this thread:</span></span></p>
<p><span class="Apple-style-span"  ><span class="Apple-style-span" style="font-size: 13px;"></span></span></p>
<blockquote><p><span class="Apple-style-span"  ><span class="Apple-style-span" style="font-size: 13px;">0x5be76800 JavaThread &#8220;CompilerThread1&#8243; daemon [_thread_in_native, id=6764, stack(0x5c1a0000,0x5c1f0000)]</span></span></p>
</p>
</blockquote>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">We had configured the JVM to use a lot of memory for HEAP and PermGen. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">A Windows process can use max 2 GB total. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">The internals of the JVM (e.g its JIT compiler) needs its own memory, so do the DLLs loaded. </span><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">Since so much of those 2GB was already allocated for HEAP/Permgen, windows said NO when the JVM asked for more memory inside CompilerThread1. When this happened, the JVM crashed with <i>java.lang.OutOfMemoryError?: requested 884680 bytes for Chunk::new. Out of swap space?</i></span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">Solution:</span></p>
<p><span class="Apple-style-span" style="font-family: Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 13px; ">Tell the JVM to use LESS memory..</span></p>
</p>
<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7791682124053162440-4289467989347305946?l=moaxstuff.blogspot.com' alt='' /></div>
 <p><a href="http://kjetland.com/blog/?flattrss_redirect&amp;id=8&amp;md5=f1fb23217d2421209b54e6b948f2a5b8" title="Flattr" target="_blank"><img src="http://kjetland.com/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kjetland.com/blog/2010/11/jvm-solving-outofmemoryerror-with-less-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=mbknor&amp;popout=1&amp;url=http%3A%2F%2Fkjetland.com%2Fblog%2F2010%2F11%2Fjvm-solving-outofmemoryerror-with-less-memory%2F&amp;language=en_GB&amp;category=text&amp;title=JVM%3A+Solving+OutOfMemoryError+with+less+Memory&amp;description=At+work+we+have+6+web+applications+%28WAR%29+deployed+in+Glassfish+v2.+In+production+we+experienced+sporadic+java.lang.OutOfMemoryError%3A+Java+heap+space+under+high+load.+We+where+sure+that+we+did...&amp;tags=blog" type="text/html" />
	</item>
	</channel>
</rss>
