<?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>Mrinal Wadhwa &#187; Erlang</title>
	<atom:link href="http://weblog.mrinalwadhwa.com/category/erlang/feed/" rel="self" type="application/rss+xml" />
	<link>http://weblog.mrinalwadhwa.com</link>
	<description>en route to a richer Internet</description>
	<lastBuildDate>Wed, 12 Oct 2011 09:30:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SWF Machine: generating SWF binary from Erlang</title>
		<link>http://weblog.mrinalwadhwa.com/2010/03/17/swfmachine/</link>
		<comments>http://weblog.mrinalwadhwa.com/2010/03/17/swfmachine/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 22:38:27 +0000</pubDate>
		<dc:creator>Mrinal Wadhwa</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[bit-syntax]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[instructions]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[swf-format]]></category>
		<category><![CDATA[swfmachine]]></category>

		<guid isPermaLink="false">http://weblog.mrinalwadhwa.com/?p=1409</guid>
		<description><![CDATA[<p>SWF Machine is an Erlang program I&#8217;ve been writing, to generate SWF files from Erlang. This program takes a custom instruction set as input and generates SWF binary instructions, which once saved in an SWF file can be  run in the Flash Player, here&#8217;s a quick demo of SWFMachine in action &#8230;</p>
<p><embed src="http://blip.tv/play/AYHN80oA" type="application/x-shockwave-flash" width="640" height="510" allowscriptaccess="always" allowfullscreen="true"></embed></p>
<p>A similar <a href="http://propella.blogspot.com/2009/03/learning-erlang-and-adobe-flash-format.html">attempt by Takashi Yamamiya</a> and the <a href="http://code.google.com/p/eswf/">eswf</a> library on google code  were quite helpful in getting me started, so thanks to them for sharing.</p>
]]></description>
		<wfw:commentRss>http://weblog.mrinalwadhwa.com/2010/03/17/swfmachine/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Erlang Web Server Benchmarks</title>
		<link>http://weblog.mrinalwadhwa.com/2010/02/12/erlang-web-server-benchmarks/</link>
		<comments>http://weblog.mrinalwadhwa.com/2010/02/12/erlang-web-server-benchmarks/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 04:58:04 +0000</pubDate>
		<dc:creator>Mrinal Wadhwa</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://weblog.mrinalwadhwa.com/?p=1362</guid>
		<description><![CDATA[<p>Over the last few weeks I&#8217;ve been writing a server side web application framework for Erlang. Essentially, I looked at various available erlang frameworks like <a href="http://bitbucket.org/justin/webmachine/wiki/Home">WebMachine</a>, <a href="http://nitrogenproject.com/">Nitrogen</a>, <a href="http://github.com/davebryson/beepbeep">BeepBeep</a>, <a href="http://yaws.hyber.org/">Yaws</a>, <a href="http://erlyweb.org/">ErlyWeb</a> etc. and pulled out and assembled my own little framework with features I needed. I&#8217;ve also been writing an <a href="http://github.com/mrinalwadhwa/eamf">Erlang library for encoding/decoding AMF</a> which will help me add some interesting Flash/Flex specific features to this framework.    </p>
<p>Among other things this framework provides web server library specific request/response format abstraction similar to <a href="http://github.com/rklophaus/SimpleBridge">SimpleBridge</a>, A Django templates implementation using <a href="http://code.google.com/p/erlydtl/">ErlyDTL</a>, an MVC implementation inspired from ErlyWeb and a lot more. Even with all this functionality I&#8217;m quite happy with the performance we&#8217;re able to achieve, so I thought I&#8217;d share some benchmarks with everyone.</p>
<p>Since the framework completely abstracts out the web server library used, I was able to try out various web options, but I think we&#8217;ll stick with <a href="http://code.google.com/p/misultin/">Misultin</a> for our production enviornment since it seems to perform significantly better than other implementations. Here are the results of running <a href="http://www.xenoclast.org/autobench/">AutoBench</a> on our framework powered by Misultin. </p>
<p>The server was running on an m1.large amazon instance running ubuntu and the tests was run from an m1.small amazon instance.</p>
<p><code><br />
$ autobench --single_host --host1 xyz.com  --quiet --low_rate 20 --high_rate 200 --rate_step 20 --num_call 100 -num_conn 5000 --timeout 5 --file results.tsv<br />
</code></p>
<p><img src="http://weblog.mrinalwadhwa.com/wp-content/uploads/2010/02/Picture-2.png" alt="Misultin-Autobench" title="Misultin-Autobench" width="640" height="440" class="alignnone size-full wp-image-1363" /><br />
<!--more--><br />
Here are some more tests using a different tool <a href="http://httpd.apache.org/docs/2.0/programs/ab.html">Apache Bench</a><br />
<code><br />
$ ab -k -n 500000 -c 1000 http://xyz.com/</p>
<p>Document Path:          /<br />
Document Length:        27 bytes</p>
<p>Concurrency Level:      1000<br />
Time taken for tests:   39.937 seconds<br />
Complete requests:      500000<br />
Failed requests:        0<br />
Write errors:           0<br />
Keep-Alive requests:    500000<br />
Total transferred:      57510350 bytes<br />
HTML transferred:       13502430 bytes<br />
Requests per second:   <strong> 12519.82 [#/sec] (mean)</strong><br />
Time per request:       <strong>79.873 [ms] (mean)</strong><br />
Time per request:       0.080 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          1406.29 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
              min  mean[+/-sd] median   max<br />
Connect:        0    2  71.8      0    3005<br />
Processing:     1   78  25.9     77     732<br />
Waiting:        1   78  25.9     77     732<br />
Total:          1   80  79.3     77    3427</p>
<p>Percentage of the requests served within a certain time (ms)<br />
  50%     77<br />
  66%     87<br />
  75%     94<br />
  80%     98<br />
  90%    110<br />
  95%    119<br />
  98%    132<br />
  99%    144<br />
 100%   3427 (longest request)</p>
<p></code></p>
<p>Running the ab test without the keep alive (-k) option, causes the request rate to fall drastically to around the 3600 r/sec level but looking at the <a href="http://www.tornadoweb.org/documentation#performance">Tornado performance tests here</a>, 3600 seems reasonably good. I haven&#8217;t tried adding <a href="http://nginx.org/">nginx</a> similar to that <a href="http://www.tornadoweb.org/documentation#performance">Tornado setup</a>, not sure if that would help.</p>
]]></description>
		<wfw:commentRss>http://weblog.mrinalwadhwa.com/2010/02/12/erlang-web-server-benchmarks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flash, Erlang and Realtime Collaborative Interfaces</title>
		<link>http://weblog.mrinalwadhwa.com/2009/11/28/flash-erlang-and-realtime-collaborative-interfaces/</link>
		<comments>http://weblog.mrinalwadhwa.com/2009/11/28/flash-erlang-and-realtime-collaborative-interfaces/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 02:49:20 +0000</pubDate>
		<dc:creator>Mrinal Wadhwa</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[amf]]></category>
		<category><![CDATA[bangalore]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flash player]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[sapteched09]]></category>
		<category><![CDATA[teched]]></category>

		<guid isPermaLink="false">http://weblog.mrinalwadhwa.com/?p=1215</guid>
		<description><![CDATA[<p>I&#8217;ve been learning <a href="http://www.erlang.org/">Erlang</a> for the past few weeks and loving the simplicity and beauty of the language. As part of <a href="http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/16881">a discussion at SAP TechEd</a>, last week, I ended up creating a simple, rather rudimentary prototype of a realtime messaging server that enables collaborative user interfaces where multiple users can simultaneously work with the same interface &#8230; </p>
<p>Here&#8217;s a video of the code in action &#8230; </p>
<p><embed src="http://blip.tv/play/AYGysw4C" type="application/x-shockwave-flash" width="650" height="396" allowscriptaccess="always" allowfullscreen="true"></embed> </p>
<p>As you watch the above video, note as I drag a rectangle in any one Flash application, its sends AMF encoded binary messages to the server and the server multicasts these messages to other connected clients and those clients update in almost realtime. While in the example above all the application instances are running on the same system, they could just as easily be running on different systems and still communicate via the server.</p>
<p>Here the code for the Erlang server &#8230;</p>
<pre>
<span style="color:#90a729">0001 </span><span style="color:#0000de">-</span><span style="color:#000000; font-weight:bold">module</span><span style="color:#0000de">(</span>server<span style="color:#0000de">)</span>.
<span style="color:#90a729">0002 </span><span style="color:#0000de">-</span><span style="color:#000000; font-weight:bold">export</span><span style="color:#0000de">([</span>start<span style="color:#0000de">/</span><span style="color:#0da344">1</span><span style="color:#0000de">,</span>stop<span style="color:#0000de">/</span><span style="color:#0da344">0</span><span style="color:#0000de">])</span>.
<span style="color:#90a729">0003 </span>
<span style="color:#90a729">0004 </span><span style="color:#0000de">-</span><span style="color:#000000; font-weight:bold">define</span><span style="color:#0000de">(</span>TCP_OPTIONS<span style="color:#0000de">,[</span><span style="color:#c42638; font-weight:bold">binary</span><span style="color:#0000de">,</span>
<span style="color:#90a729">0005 </span>                     <span style="color:#0000de">{</span>packet<span style="color:#0000de">,</span> <span style="color:#0da344">0</span><span style="color:#0000de">},</span>
<span style="color:#90a729">0006 </span>                     <span style="color:#0000de">{</span>active<span style="color:#0000de">,</span> false<span style="color:#0000de">},</span>
<span style="color:#90a729">0007 </span>                     <span style="color:#0000de">{</span>reuseaddr<span style="color:#0000de">,</span> true<span style="color:#0000de">}])</span>.
<span style="color:#90a729">0008 </span>
<span style="color:#90a729">0009 </span><span style="color:#000000; font-weight:bold">start</span><span style="color:#0000de">(</span>Port<span style="color:#0000de">) -&gt;</span>
<span style="color:#90a729">0010 </span>	 Pid <span style="color:#0000de">=</span> <span style="color:#c42638; font-weight:bold">spawn</span><span style="color:#0000de">(</span><span style="color:#0a7f6d; font-weight:bold">fun</span><span style="color:#0000de">() -&gt;</span> <span style="color:#000000; font-weight:bold">manage</span><span style="color:#0000de">([])</span> <span style="color:#0a7f6d; font-weight:bold">end</span><span style="color:#0000de">),</span>
<span style="color:#90a729">0011 </span>    <span style="color:#c42638; font-weight:bold">register</span><span style="color:#0000de">(</span>client_manager<span style="color:#0000de">,</span> Pid<span style="color:#0000de">),</span>
<span style="color:#90a729">0012 </span>	 <span style="color:#0000de">{</span>ok<span style="color:#0000de">,</span> Socket<span style="color:#0000de">} =</span> gen_tcp<span style="color:#0000de">:</span><span style="color:#000000; font-weight:bold">listen</span><span style="color:#0000de">(</span>Port<span style="color:#0000de">,</span> ?TCP_OPTIONS<span style="color:#0000de">),</span>
<span style="color:#90a729">0013 </span>    <span style="color:#000000; font-weight:bold">accept</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">)</span>.
<span style="color:#90a729">0014 </span>
<span style="color:#90a729">0015 </span><span style="color:#000000; font-weight:bold">stop</span><span style="color:#0000de">() -&gt;</span> todo.
<span style="color:#90a729">0016 </span>
<span style="color:#90a729">0017 </span><span style="color:#000000; font-weight:bold">accept</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">) -&gt;</span>
<span style="color:#90a729">0018 </span>  	 <span style="color:#0000de">{</span>ok<span style="color:#0000de">,</span> NewSocket<span style="color:#0000de">} =</span> gen_tcp<span style="color:#0000de">:</span><span style="color:#000000; font-weight:bold">accept</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">),</span>
<span style="color:#90a729">0019 </span>    <span style="color:#c42638; font-weight:bold">spawn</span><span style="color:#0000de">(</span><span style="color:#0a7f6d; font-weight:bold">fun</span><span style="color:#0000de">() -&gt;</span> <span style="color:#000000; font-weight:bold">recieve</span><span style="color:#0000de">(</span>NewSocket<span style="color:#0000de">)</span> <span style="color:#0a7f6d; font-weight:bold">end</span><span style="color:#0000de">),</span>
<span style="color:#90a729">0020 </span>    client_manager <span style="color:#0000de">! {</span>connected<span style="color:#0000de">,</span> NewSocket<span style="color:#0000de">},</span>
<span style="color:#90a729">0021 </span>    <span style="color:#000000; font-weight:bold">accept</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">)</span>.
<span style="color:#90a729">0022 </span>
<span style="color:#90a729">0023 </span><span style="color:#000000; font-weight:bold">recieve</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">) -&gt;</span>
<span style="color:#90a729">0024 </span>    <span style="color:#0a7f6d; font-weight:bold">case</span> gen_tcp<span style="color:#0000de">:</span><span style="color:#000000; font-weight:bold">recv</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">,</span> <span style="color:#0da344">0</span><span style="color:#0000de">)</span> <span style="color:#0a7f6d; font-weight:bold">of</span>
<span style="color:#90a729">0025 </span>        <span style="color:#0000de">{</span>ok<span style="color:#0000de">,</span> Data<span style="color:#0000de">} -&gt;</span>
<span style="color:#90a729">0026 </span>            client_manager <span style="color:#0000de">! {</span>multicast<span style="color:#0000de">,</span>Socket<span style="color:#0000de">,</span>Data<span style="color:#0000de">},</span>
<span style="color:#90a729">0027 </span>            <span style="color:#000000; font-weight:bold">recieve</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">);</span>
<span style="color:#90a729">0028 </span>        <span style="color:#0000de">{</span>error<span style="color:#0000de">,</span> closed<span style="color:#0000de">} -&gt;</span>
<span style="color:#90a729">0029 </span> 		 client_manager <span style="color:#0000de">! {</span>disconnect<span style="color:#0000de">,</span> Socket<span style="color:#0000de">}</span>
<span style="color:#90a729">0030 </span>    <span style="color:#0a7f6d; font-weight:bold">end</span>.
<span style="color:#90a729">0031 </span>
<span style="color:#90a729">0032 </span><span style="color:#000000; font-weight:bold">manage</span><span style="color:#0000de">(</span>Sockets<span style="color:#0000de">) -&gt;</span>
<span style="color:#90a729">0033 </span>    <span style="color:#0a7f6d; font-weight:bold">receive</span>
<span style="color:#90a729">0034 </span>        <span style="color:#0000de">{</span>connected<span style="color:#0000de">,</span> Socket<span style="color:#0000de">} -&gt;</span>
<span style="color:#90a729">0035 </span>            NewSockets <span style="color:#0000de">= [</span>Socket <span style="color:#0000de">|</span> Sockets<span style="color:#0000de">];</span>
<span style="color:#90a729">0036 </span>        <span style="color:#0000de">{</span>disconnected<span style="color:#0000de">,</span> Socket<span style="color:#0000de">} -&gt;</span>
<span style="color:#90a729">0037 </span>            NewSockets <span style="color:#0000de">=</span> lists<span style="color:#0000de">:</span><span style="color:#000000; font-weight:bold">delete</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">,</span> Sockets<span style="color:#0000de">);</span>
<span style="color:#90a729">0038 </span>        <span style="color:#0000de">{</span>multicast<span style="color:#0000de">,</span>Socket<span style="color:#0000de">,</span> Data<span style="color:#0000de">} -&gt;</span>
<span style="color:#90a729">0039 </span>            <span style="color:#000000; font-weight:bold">multicast</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">,</span> Sockets<span style="color:#0000de">,</span> Data<span style="color:#0000de">),</span>
<span style="color:#90a729">0040 </span>            NewSockets <span style="color:#0000de">=</span> Sockets
<span style="color:#90a729">0041 </span>    <span style="color:#0a7f6d; font-weight:bold">end</span><span style="color:#0000de">,</span>
<span style="color:#90a729">0042 </span>    <span style="color:#000000; font-weight:bold">manage</span><span style="color:#0000de">(</span>NewSockets<span style="color:#0000de">)</span>.
<span style="color:#90a729">0043 </span>
<span style="color:#90a729">0044 </span><span style="color:#000000; font-weight:bold">multicast</span><span style="color:#0000de">(</span>FromSocket<span style="color:#0000de">,</span> ToSockets<span style="color:#0000de">,</span> Data<span style="color:#0000de">) -&gt;</span>
<span style="color:#90a729">0045 </span>    SendData <span style="color:#0000de">=</span> <span style="color:#0a7f6d; font-weight:bold">fun</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">) -&gt;</span> gen_tcp<span style="color:#0000de">:</span><span style="color:#000000; font-weight:bold">send</span><span style="color:#0000de">(</span>Socket<span style="color:#0000de">,</span> Data<span style="color:#0000de">)</span> <span style="color:#0a7f6d; font-weight:bold">end</span><span style="color:#0000de">,</span>
<span style="color:#90a729">0046 </span>    Sockets <span style="color:#0000de">= [</span> S <span style="color:#0000de">||</span> S <span style="color:#0000de">&lt;-</span> ToSockets<span style="color:#0000de">,</span> S <span style="color:#0000de">/=</span> FromSocket<span style="color:#0000de">],</span>
<span style="color:#90a729">0047 </span>    lists<span style="color:#0000de">:</span><span style="color:#000000; font-weight:bold">foreach</span><span style="color:#0000de">(</span>SendData<span style="color:#0000de">,</span> Sockets<span style="color:#0000de">)</span>.
</pre>
]]></description>
		<wfw:commentRss>http://weblog.mrinalwadhwa.com/2009/11/28/flash-erlang-and-realtime-collaborative-interfaces/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

