<?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>Platformability &#187; WebSocket</title>
	<atom:link href="http://blog.caplin.com/tag/websocket/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.caplin.com</link>
	<description>SWIMMING WITH TECHNOLOGY</description>
	<lastBuildDate>Thu, 09 Sep 2010 09:20:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>London Ajax Comet Panel</title>
		<link>http://blog.caplin.com/2010/07/14/london-ajax-comet-panel/</link>
		<comments>http://blog.caplin.com/2010/07/14/london-ajax-comet-panel/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 08:09:45 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=3109</guid>
		<description><![CDATA[An interesting event last night that I mentioned recently. Thanks to Dylan for organising the event, and thanks to the other panelists for taking part. It was good to finally meet Alessandro from Lightstreamer, and its good to see the various open projects talking about their technology too. A couple of guys from Nirvana were [...]]]></description>
			<content:encoded><![CDATA[<p>An interesting event last night that I <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzA2LzMwL2xvbmRvbi1hamF4LXVzZXItZ3JvdXAtbWVldHVwLWNvbWV0LXBhbmVsLw==">mentioned recently</a>.</p>
<p>Thanks to Dylan for organising the event, and thanks to the other panelists for taking part. It was good to finally meet Alessandro from Lightstreamer, and its good to see the various open projects talking about their technology too. A couple of guys from Nirvana were in the audience and we had a good chat down the pub afterwards.</p>
<p>Everyone on the panel seemed to have similar views on WebSocket, although some have implemented it and some have not.</p>
<p>I&#8217;ll post a link to the video and slides when they are available soon.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=3109" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/07/14/london-ajax-comet-panel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apple releases Safari 5 with HTML 5 WebSocket support</title>
		<link>http://blog.caplin.com/2010/06/08/apple-releases-safari-5-with-html-5-websocket-support/</link>
		<comments>http://blog.caplin.com/2010/06/08/apple-releases-safari-5-with-html-5-websocket-support/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 08:07:32 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=2666</guid>
		<description><![CDATA[The iPhone 4 announcement obviously trumped this at WWDC 2010, but Apple have also released Safari 5. If you read about what&#8217;s new you will see lots of HTML5 stuff, including WebSocket. But as I wrote about last week, which version of HTML WebSocket? Is it the same as the latest version of Google Chrome? [...]]]></description>
			<content:encoded><![CDATA[<p>The iPhone 4 announcement obviously trumped this at <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RldmVsb3Blci5hcHBsZS5jb20vd3dkYy8=">WWDC 2010</a>, but Apple have also released Safari 5. If you read about <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hcHBsZS5jb20vc2FmYXJpL3doYXRzLW5ldy5odG1s">what&#8217;s new</a> you will see lots of HTML5 stuff, including WebSocket.</p>
<p>But as I wrote about last week, <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzA2LzAzL3doaWNoLXZlcnNpb24tb2YtaHRtbDUtd2Vic29ja2V0Lw==">which version of HTML WebSocket?</a> Is it the same as the latest version of Google Chrome? Google made a clear statement about the version and how it will not maintain compatibility until the specification is more stable, but I cannot find any info from Apple on this. Is it the same code base since they are both WebKit browsers?</p>
<p>So that&#8217;s the two smaller browsers (market share) with some support for WebSocket, when will IE and Firefox join the party?</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2666" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/06/08/apple-releases-safari-5-with-html-5-websocket-support/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comet server message sizes, Bandwidth considerations</title>
		<link>http://blog.caplin.com/2010/05/28/comet-server-message-sizes-bandwidth-considerations/</link>
		<comments>http://blog.caplin.com/2010/05/28/comet-server-message-sizes-bandwidth-considerations/#comments</comments>
		<pubDate>Fri, 28 May 2010 14:03:39 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[messaging]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=2551</guid>
		<description><![CDATA[One of the questions I brought up on a previous blog &#8211; Comet servers for a Single-Dealer Platform &#8211; was that of bandwidth. The main thing that affects bandwidth that a Comet server has some control over is message size. At the time of that blog I hadn&#8217;t looked into this issue with all the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the questions I brought up on a previous blog &#8211; <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzA0LzI3L2NvbWV0LXNlcnZlcnMtZm9yLWEtc2luZ2xlLWRlYWxlci1wbGF0Zm9ybS1zZHAv">Comet servers for a Single-Dealer Platform</a> &#8211; was that of bandwidth. The main thing that affects bandwidth that a Comet server has some control over is message size. At the time of that blog I hadn&#8217;t looked into this issue with all the servers in much detail, so I decided to dive a little deeper and look at the protocols of some of the Comet servers written about on that blog.</p>
<p>A question that a customer once asked was about message sizes, but the question was wrong, they asked what performance Liberator could handle with 1K messages &#8211; they wanted to compare Liberator to another Comet server sending 1K messages. I pointed out that they should let us know what the payload they want to send is and we can see the size of the message in our protocol, and they should do the same with the other Comet server. Maybe we could represent a much bigger payload in a 1K message than the other server could.</p>
<p>I have looked at four servers for this blog &#8211; <a  href="http://www.caplin.com/caplin_liberator.php">Liberator</a>, <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5saWdodHN0cmVhbWVyLmNvbS8=">Lightstreamer</a>, <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hZG9iZS5jb20vcHJvZHVjdHMvbGl2ZWN5Y2xlL2RhdGFzZXJ2aWNlcy8=">Adobe LCDS</a> and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5teS1jaGFubmVscy5jb20vcHJvZHVjdHMvbmlydmFuYS5odG1s">my-Channels Nirvana</a>. They all take slightly different approaches, but can all be used to achieve similar results. My test case is a single message payload, but I am showing the structure of the messages and will comment on how different payloads may be represented better or worse in the different servers.<br />
<span id="more-2551"></span><br />
The payload I am looking at is a fairly typical financial data update. To help highlight a few problems I am looking at what is often called an &#8216;image&#8217; and an &#8216;update&#8217;. An image is an initial update, containing all the data about the instrument, the update is the subsequent updates where only a subset of all the fields will be updating.</p>
<p>The image is:</p>
<table border=1 cellpadding=5 bgcolor="#dddddd">
<tr>
<td>Field1</td>
<td>123456</td>
</tr>
<tr>
<td>Field2</td>
<td>234567</td>
</tr>
<tr>
<td>Time1</td>
<td>1274181389019</td>
</tr>
<tr>
<td>Low</td>
<td>100000</td>
</tr>
<tr>
<td>High</td>
<td>200000</td>
</tr>
<tr>
<td>FullName</td>
<td>Company Name Ltd</td>
</tr>
</table>
<p>The update is:</p>
<table border=1 cellpadding=5 bgcolor="#dddddd">
<tr>
<td>Field1</td>
<td>123459</td>
</tr>
<tr>
<td>Field2</td>
<td>234569</td>
</tr>
<tr>
<td>Time1</td>
<td>1274181389999</td>
</tr>
</table>
<p>These may seem like small messages, but they are fairly typical, and it should be easy to see how a few more fields will affect the message sizes. Lets first look at the summary of results, and if you are interested, further down is the detail of the messages.</p>
<p>The table shows the size of the message in bytes that each server will send. For LCDS and Nirvana there are two entries as they implement different protocols with quite different message sizes. I assume anyone using LCDS would be using the binary AMF protocol, you get to choose. With Nirvana, if you want a native web client you have to use the web protocol, but the protocol available to other technologies has far smaller message sizes.</p>
<table border=1 cellpadding=5 bgcolor="#dddddd">
<tr>
<td>Server</td>
<td>Protocol</td>
<td>Image Message Size</td>
<td>Update Message Size</td>
</tr>
<tr>
<td>Liberator</td>
<td>Web</td>
<td>101</td>
<td>64</td>
</tr>
<tr>
<td>Liberator</td>
<td>Other</td>
<td>80</td>
<td>43</td>
</tr>
<tr>
<td>Lightstreamer</td>
<td>Web</td>
<td>95</td>
<td>67</td>
</tr>
<tr>
<td>Lightstreamer</td>
<td>Other</td>
<td>64</td>
<td>36</td>
</tr>
<tr>
<td>Nirvana</td>
<td>NHP (Web clients)</td>
<td>760</td>
<td>675</td>
</tr>
<tr>
<td>Nirvana</td>
<td>NSP (Java/Other clients)</td>
<td>154</td>
<td>102</td>
</tr>
<tr>
<td>LCDS</td>
<td>AMF binary</td>
<td>403</td>
<td>403</td>
</tr>
<tr>
<td>LCDS</td>
<td>AMF XML</td>
<td>937</td>
<td>937</td>
</tr>
</table>
<p>Lets now look at the actual message structure and how they might differ with other payloads.</p>
<p><strong>Liberator</strong></p>
<p>Liberator is sending a script tag wrapped Javascript function call, with a single argument containing its own protocol. The messages do not contain the subject (or channel), and field names are mapped onto single characters (for the first 64 fields, then 2 characters etc..) This is quite compact with not much overhead. As more fields or larger field values are added there is little overhead.</p>
<p>Web Image message = 101 bytes</p>
<blockquote><p><code><br />
&lt;script&gt;a("7O5W0001 a=123456 b=234567 c=1274181389019 d=100000 e=200000 f=Company+Name+Ltd")&lt;/script&gt;<br />
</code></p></blockquote>
<p>Web Update message = 64 bytes</p>
<blockquote><p><code><br />
&lt;script&gt;a("6c5W0002 a=123459 b=234569 c=1274181389999")&lt;/script&gt;<br />
</code></p></blockquote>
<p>Other APIs such as Java and .Net don&#8217;t need the script wrapper, which makes the messages that much smaller.</p>
<p>Other Image message = 80 bytes</p>
<blockquote><p><code><br />
7O5W0001 a=123456 b=234567 c=1274181389019 d=100000 e=200000 f=Company+Name+Ltd\n<br />
</code></p></blockquote>
<p>Other Update message = 43 bytes</p>
<blockquote><p><code><br />
6c5W0002 a=123459 b=234569 c=1274181389999\n<br />
</code></p></blockquote>
<p><strong>Lightstreamer</strong></p>
<p>Lightstreamer is similar to Liberator in that it is also sending a single Javascript function call. Again, no subject name needed, and field names are not used at all. The fields are known by the subscriber, so the order the values come back in is significant &#8211; this has the benefit that it doesn&#8217;t need to send field names, but it does mean that fields that have not updated still need to be sent, albeit as an empty string. This is illustrated by the three empty strings at the end of the update message. Worst case scenario where a subscription to lots of fields where not many updated very often would have a bit of an overhead, but it is not that significant.</p>
<p>Web Image message = 95 bytes</p>
<blockquote><p><code><br />
&lt;script&gt;z(0,1,"123456","234567","1274181389019","100000","200000", "Company Name Ltd");&lt;/script&gt;<br />
</code></p></blockquote>
<p>Web Update message = 67 bytes</p>
<blockquote><p><code><br />
&lt;script&gt;d(0,1,"123459","234569","1274181389999","","","");&lt;/script&gt;<br />
</code></p></blockquote>
<p>For non web APIs the messages are again smaller.</p>
<p>Other Image update = 64 bytes</p>
<blockquote><p><code><br />
0,1|123456|234567|1274181389019|100000|200000|Company Name Ltd\r\n<br />
</code></p></blockquote>
<p>Other Update message = 36 bytes</p>
<blockquote><p><code><br />
0,1|123459|234569|1274181389999|||\r\n<br />
</code></p></blockquote>
<p><strong>Nirvana</strong></p>
<p>Nirvana&#8217;s NHP protocol used by browser Javascript clients is quite verbose. Once again it is Javascript being streamed directly, but it is not that optimised for size. The channel name is sent, twice, and field names are sent both as part of the map and as a list. There is also some extra data in there, which may be useful to some of the features of Nirvana, but seems like quite an overhead.</p>
<p>Note that this is a message using the properties style message (the &#8216;fprops&#8217; section), it is also possible to send an opaque message (or a combination of the two) &#8211; an opaque message uses the &#8216;badata&#8217; part of the message and would then not need all the fprops information &#8211; but you would have to pack some of that into your opaque message.</p>
<p>Since you can send what data/fields you want, the update message is smaller, not containing anything about the fields that haven&#8217;t updated.</p>
<p>With much larger payloads, the overhead will become less significant.</p>
<p>The messages below have been formatted a bit for easier readability, adding line breaks, the sizes reflect the actual message sizes though.</p>
<p>Image message = 760 bytes</p>
<blockquote><p><code><br />
&lt;script&gt;<br />
try{<br />
window.parent.handleNVLLastEID("/PATH/TO/CHANNEL1","28");<br />
window.parent.handleNVLEvents({ eid : 29,<br />
                                cname : "/PATH/TO/CHANNEL1",<br />
                                tag : "notag",<br />
                                badata : "",<br />
                                hasData : true,<br />
                                hasDictionary : true,<br />
                                'fprops': {<br />
                                'Field1':"123456",<br />
                                'Field2':"234567",<br />
                                'Time1':1274181389019,<br />
                                'Low':"100000",<br />
                                'High':"200000",<br />
                                'FullName':"Company Name Ltd",<br />
                                'nrvpub.time':1274187070518,<br />
                                'nrvpub.host':"host.domain.com",<br />
                                'nrvpub.name':"username",<br />
                                'JMSMessageID':"My Message Id",<br />
                                'JMSXUserID':"My User id",<br />
                                'JMSDeliveryMode':"NON_PERSISTENT",<br />
                                nrvkeys : ['Field1','Field2','Time1','Low','High',<br />
                                'FullName','nrvpub.time','nrvpub.host','nrvpub.name',<br />
                                'JMSMessageID','JMSXUserID','JMSDeliveryMode'],<br />
                                nrvprops : "",<br />
                                nrvproparrays : "" }<br />
                                },<br />
                                "eventHandlerCallbackFunc");<br />
}catch(Exception){}<br />
&lt;/script&gt;<br />
&lt;i&gt;&lt;/i&gt;<br />
</code></p></blockquote>
<p>Update message = 675 bytes</p>
<blockquote><p><code><br />
&lt;script&gt;<br />
try{<br />
window.parent.handleNVLLastEID("/PATH/TO/CHANNEL1","28");<br />
window.parent.handleNVLEvents({ eid : 29,<br />
                                cname : "/PATH/TO/CHANNEL1",<br />
                                tag : "notag",<br />
                                badata : "",<br />
                                hasData : true,<br />
                                hasDictionary : true,<br />
                                'fprops': {<br />
                                'Field1':"123459",<br />
                                'Field2':"234569",<br />
                                'Time1':1274181389999,<br />
                                'nrvpub.time':1274187070518,<br />
                                'nrvpub.host':"host.domain.com",<br />
                                'nrvpub.name':"username",<br />
                                'JMSMessageID':"My Message Id",<br />
                                'JMSXUserID':"My User id",<br />
                                'JMSDeliveryMode':"NON_PERSISTENT",<br />
                                nrvkeys : ['Field1','Field2','Time1',<br />
                                'nrvpub.time','nrvpub.host','nrvpub.name',<br />
                                'JMSMessageID','JMSXUserID','JMSDeliveryMode'],<br />
                                nrvprops : "",<br />
                                nrvproparrays : "" }<br />
                                },<br />
                                "eventHandlerCallbackFunc");<br />
}catch(Exception){}<br />
&lt;/script&gt;<br />
&lt;i&gt;&lt;/i&gt;<br />
</code></p></blockquote>
<p>Nirvana&#8217;s NSP protocol is used by the Java API (and other Enterprise APIs), this is a binary protocol and much smaller in message size. Field names are sent but channel names are not.</p>
<p>Image message = 154 bytes</p>
<blockquote><p><code><br />
..............Field1..123456.Field2..234567.Time1......J.<br />
Low..100000.High..200000.FullName..Company Name Ltd.........J.<br />
.......host.domain.com.username....<br />
</code></p></blockquote>
<p>Update message = 102 bytes</p>
<blockquote><p><code><br />
..............Field1..123459.Field2..234569.Time1......J.<br />
........J........host.domain.com.username....<br />
</code></p></blockquote>
<p><strong>Adobe LCDS</strong></p>
<p>LCDS sends serialised representations of objects, which means it sends all the fields whether they have changed or not. You could probably construct objects to only contain changed fields, but it doesn&#8217;t play to the strengths of the intended ease of use of sending objects and object remoting.</p>
<p>The XML version of the message is very verbose, but I don&#8217;t think there is a reason to use it, so it is only here to show the data more clearly than the binary version of the message. Class names, channel names, field names, XML tags, they are all sent and makes the message very large. Again, line breaks and indentation have been added for readability.</p>
<p>AMF XML message = 937 bytes</p>
<blockquote><p><code><br />
&lt;object type="flex.messaging.messages.AsyncMessage"&gt;<br />
  &lt;traits&gt;<br />
    &lt;string&gt;destination&lt;/string&gt;<br />
    &lt;string&gt;headers&lt;/string&gt;<br />
    &lt;string&gt;correlationId&lt;/string&gt;<br />
    &lt;string&gt;messageId&lt;/string&gt;<br />
    &lt;string&gt;timestamp&lt;/string&gt;<br />
    &lt;string&gt;clientId&lt;/string&gt;<br />
    &lt;string&gt;timeToLive&lt;/string&gt;<br />
    &lt;string&gt;body&lt;/string&gt;<br />
  &lt;/traits&gt;<br />
  &lt;string&gt;market-data-feed&lt;/string&gt;<br />
  &lt;object&gt;<br />
    &lt;traits&gt;<br />
      &lt;string&gt;DSSubtopic&lt;/string&gt;<br />
    &lt;/traits&gt;<br />
    &lt;string&gt;PATH.TO.INSTRUMENT&lt;/string&gt;<br />
  &lt;/object&gt;<br />
  &lt;null/&gt;<br />
  &lt;string&gt;DCE35EDA-AF0F-B3B5-3ECC-DA2D0F7BE56B&lt;/string&gt;<br />
  &lt;double&gt;1.243526266655E12&lt;/double&gt;<br />
  &lt;string&gt;DCE25D41-DC0A-6A55-8F54-E7E2C34D1B07&lt;/string&gt;<br />
  &lt;double&gt;0.0&lt;/double&gt;<br />
  &lt;object type="flex.samples.marketdata.Stock"&gt;<br />
    &lt;traits&gt;<br />
      &lt;string&gt;Field1&lt;/string&gt;<br />
      &lt;string&gt;Field2&lt;/string&gt;<br />
      &lt;string&gt;Time1&lt;/string&gt;<br />
      &lt;string&gt;Low&lt;/string&gt;<br />
      &lt;string&gt;High&lt;/string&gt;<br />
      &lt;string&gt;FullName&lt;/string&gt;<br />
    &lt;/traits&gt;<br />
    &lt;double&gt;123456&lt;/double&gt;<br />
    &lt;double&gt;234567&lt;/double&gt;<br />
    &lt;date&gt;1274181389019&lt;/date&gt;<br />
    &lt;double&gt;100000&lt;/double&gt;<br />
    &lt;double&gt;200000&lt;/double&gt;<br />
    &lt;string&gt;Company Name Ltd&lt;/string&gt;<br />
  &lt;/object&gt;<br />
&lt;/object&gt;<br />
</code></p></blockquote>
<p>The binary AMF protocol strips out the XML tags which are replaced by single byte type markers (shown by the percent symbol in the message below). This cuts the message size a lot, but it is still pretty big.</p>
<p>AMF binary message = 403 bytes</p>
<blockquote><p><code><br />
1ae%%<br />
1a7%%<br />
%%%<br />
%flex.messaging.messages.AsyncMessage<br />
%destination<br />
%headers<br />
%correlationId<br />
%messageId<br />
%timestamp<br />
%clientId<br />
%timeToLive<br />
%body<br />
%market-data-feed<br />
%%%<br />
%DSSubtopic<br />
%PATH.TO.INSTRUMENT<br />
%<br />
%IC49204A4-D0D5-6C35-476C-B0170F6444AA<br />
%%%%%%%%%<br />
%IC47E1B72-01DF-9FE4-6EEE-D7D230F6A28E<br />
%%%%%%%%%<br />
%%%<br />
%flex.samples.marketdata.Stock<br />
%Field1<br />
%Field2<br />
%Time1<br />
%Low<br />
%High<br />
%FullName<br />
%123456<br />
%234567<br />
%%%%%%%%%<br />
%100000<br />
%200000<br />
%Company Name Ltd<br />
%%%%%<br />
</code></p></blockquote>
<p><strong>Conclusions</strong></p>
<p>As you can see, message sizes can differ a lot, even when they are representing the same data payload. Message size may not seem that important at first, but if you want to deliver real time data to a lot of clients it quickly adds up to a large bandwidth bill and saturated networks which can affect hosting costs. Bandwidth on the client end may also be an issue and latency can be affected in some situations. Smaller is better!</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2551" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/05/28/comet-server-message-sizes-bandwidth-considerations/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Google Comet?</title>
		<link>http://blog.caplin.com/2010/05/20/google-comet/</link>
		<comments>http://blog.caplin.com/2010/05/20/google-comet/#comments</comments>
		<pubDate>Thu, 20 May 2010 08:07:21 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=2442</guid>
		<description><![CDATA[At the Google I/O developer event a few interesting things have been announced. I blogged earlier this week about Google going real real-time with its Feed API and yesterday they announced some new features in Google App Engine. The interesting part is this: Channel API &#8211; The Channel API lets you build applications that can [...]]]></description>
			<content:encoded><![CDATA[<p>At the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9ldmVudHMvaW8vMjAxMC8=">Google I/O</a> developer event a few interesting things have been announced. I blogged earlier this week about <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzA1LzE4L2dvb2dsZS1nb2luZy1yZWFsLXJlYWwtdGltZS8=">Google going real real-time</a> with its Feed API and yesterday they announced some new features in <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvb2dsZWFwcGVuZ2luZS5ibG9nc3BvdC5jb20vMjAxMC8wNS9hcHAtZW5naW5lLWF0LWdvb2dsZS1pby0yMDEwLmh0bWw=">Google App Engine</a>.</p>
<p>The interesting part is this:</p>
<blockquote><p>Channel API &#8211; The Channel API lets you build applications that can push content directly to your user’s browser (aka “Comet”). No more polling for updates!</p></blockquote>
<p>Google have done things with Comet before, some of which are probably just polling, but others such as <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3dhdmUuZ29vZ2xlLmNvbQ==">Google Wave</a> are fully live updating.</p>
<p>With the feed API and the App Engine Channel API Google are opening up their Comet capabilities to outside developers. I look forward to more details on the Channel API and maybe dissecting how it works. Most Comet solutions implement a number of techniques, mainly for different browsers, so it will be interesting to see what Google have done.</p>
<p>Google have announced a number of other things at this event which I found interesting and look forward to trying out..</p>
<ul>
<li><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvb2dsZWNvZGUuYmxvZ3Nwb3QuY29tLzIwMTAvMDUvZ29vZ2xlLXN0b3JhZ2UtZm9yLWRldmVsb3BlcnMtcHJldmlldy5odG1s">Google Storage</a></li>
<li><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvb2dsZWNvZGUuYmxvZ3Nwb3QuY29tLzIwMTAvMDUvYmlncXVlcnktYW5kLXByZWRpY3Rpb24tYXBpLWdldC1tb3JlLmh0bWw=">BigQuery and Prediction API</a></li>
<li><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvb2dsZWNvZGUuYmxvZ3Nwb3QuY29tLzIwMTAvMDUvZW5hYmxpbmctY2xvdWQtcG9ydGFiaWxpdHktd2l0aC1nb29nbGUuaHRtbA==">Cloud Portability</a> &#8211; including some impressive Rapid Application Development with <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcHJpbmdzb3VyY2Uub3JnL3Jvbw==">Spring Roo</a></li>
</ul>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2442" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/05/20/google-comet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google going real real-time</title>
		<link>http://blog.caplin.com/2010/05/18/google-going-real-real-time/</link>
		<comments>http://blog.caplin.com/2010/05/18/google-going-real-real-time/#comments</comments>
		<pubDate>Tue, 18 May 2010 08:34:59 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=2434</guid>
		<description><![CDATA[There&#8217;s a log of talk about the real-time web these days, but most of it is talking about stuff that isn&#8217;t really real-time at all. Most of it just means when you access the data it is up to date, or in some cases it means things update for you every few minutes or seconds. [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a log of talk about the real-time web these days, but most of it is talking about stuff that isn&#8217;t really real-time at all. Most of it just means when you access the data it is up to date, or in some cases it means things update for you every few minutes or seconds.</p>
<p>Google&#8217;s <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9hcGlzL2FqYXhmZWVkcy8=">Feed API</a> gives you access to any public Atom/RSS like data, including lots of Google&#8217;s own data. There was a lot of fuss recently about <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9wL3B1YnN1Ymh1YmJ1Yi8=">PubSubHubbub</a> and I blogged about  how <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzAzLzA4L3B1YnN1Ymh1YmJ1Yi10aGUtbm90LXF1aXRlLXJlYWwtdGltZS13ZWIv">PubSubHubbub is the not quite real-time web</a>.</p>
<p>At <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9ldmVudHMvaW8vMjAxMC8=">Google I/O</a> this week, Google will be announcing some changes to the Feeds API that enable updates to be pushed to browsers. <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5yZWFkd3JpdGV3ZWIuY29tLw==">ReadWriteWeb</a> got the scoop on this posting that <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5yZWFkd3JpdGV3ZWIuY29tL2FyY2hpdmVzL2dvb2dsZV93aWxsX3B1c2hfcmVhbC10aW1lX2ZlZWRzX3RvX2Jyb3dzZXIucGhw">Google will push real-time feeds to browsers</a>. Not just in terms of details yet, the video shows the code changes are minimal, but what is going on under the covers is what interests me. Is is really real-time? is it polling? Will they pick one, works for all, solution, or try out WebSocket for those that support it. For most things the Feed API will be used for the speed of polling is probably fine, but high frequency polling is just inefficient compared to true streaming. Long polling would sit somewhere between polling and streaming and a good compromise for the client end. What I am interested in is what implementation Google thinks is best for what could be the largest deployment of a web push service yet.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2434" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/05/18/google-going-real-real-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evolution of Comet at Caplin</title>
		<link>http://blog.caplin.com/2010/04/16/evolution-of-comet-at-caplin/</link>
		<comments>http://blog.caplin.com/2010/04/16/evolution-of-comet-at-caplin/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 11:45:26 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=2069</guid>
		<description><![CDATA[I have been blogging on CometDaily since before we started Platformability so thought I would take a look back and see if there was anything there that might be of interest to our Platformability audience. Early on in CometDaily&#8217;s lifetime I wrote a piece on the Evolution of Comet at Caplin which covers how Caplin&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I have been blogging on <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvbWV0ZGFpbHkuY29t">CometDaily</a> since before we started Platformability so thought I would take a look back and see if there was anything there that might be of interest to our Platformability audience.</p>
<p>Early on in CometDaily&#8217;s lifetime I wrote a piece on the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvbWV0ZGFpbHkuY29tLzIwMDcvMTEvMzAvdGhlLWV2b2x1dGlvbi1vZi1jb21ldC1hdC1jYXBsaW4v">Evolution of Comet at Caplin</a> which covers how Caplin&#8217;s core technology has evolved since the start in 1997. The article was written in 2007, so I thought I would say how things have moved on since then.</p>
<p>The article finishes off talking about <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jYXBsaW4uY29tL2NhcGxpbi10cmFkZXIucGhw">Caplin Trader</a> our Ajax trading front end framework. This is still a large focus for Caplin, but we have also expanded out. There is a lot of extra functionality on the backend that was developed along with Caplin Trader &#8211; higher level integration to Trading and Permissions for example. Although Caplin Trader allows you to host other RIA technologies within it, we also wanted to more openly support other client side technologies in their own right. So we worked on these APIs to create <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jYXBsaW4uY29tL2NhcGxpbl94YXF1YS5waHA=">Caplin Xaqua</a> which is the full stack of our software, from backend integration APIs, through Liberator (and Comet) out to our StreamLink client APIs, which we expanded to include .Net, Silverlight and Flex.</p>
<p>Coming back to Comet, with the new client APIs and also new browsers and browser versions, we improved our coverage of Comet techniques to ensure the best possible connection is made for each scenario.</p>
<p>And the future? Well I have <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzA0LzEzL2h0bWw1LXdlYnNvY2tldC1mYWlsdXJlLXJhdGVzLw==">blogged about HTML 5 WebSockets</a> <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzAzLzAyL3doeS13ZS1kb250LW5lZWQtaHRtbDUtd2Vic29ja2V0Lw==">more than once</a> and to reiterate, it is a good new tool for Comet server implementers (rather than people developing web applications themselves) and i&#8217;m sure when the market share for browsers supporting WebSocket grows we will be adding the capability to <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jYXBsaW4uY29tL2NhcGxpbl9saWJlcmF0b3IucGhw">Liberator</a> and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jYXBsaW4uY29tL1N0cmVhbUxpbmsucGhw">Streamlink</a>.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2069" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/04/16/evolution-of-comet-at-caplin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 WebSocket Failure Rates</title>
		<link>http://blog.caplin.com/2010/04/13/html5-websocket-failure-rates/</link>
		<comments>http://blog.caplin.com/2010/04/13/html5-websocket-failure-rates/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 14:09:42 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=1998</guid>
		<description><![CDATA[Some interesting information on WebSockets recently came to my attention. Greg Wilkins posted to the hybi mailing list about Websocket success rates and TLS extension which links to some original research done by Google employees here while looking at their SPDY protocol, but they used WebSocket for their tests. I have always been suspect of [...]]]></description>
			<content:encoded><![CDATA[<p>Some interesting information on WebSockets recently came to my attention. <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2dzLndlYnRpZGUuY29tL2dyZWd3Lw==">Greg Wilkins</a> posted to the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly93d3cuaWV0Zi5vcmcvbWFpbG1hbi9saXN0aW5mby9oeWJp">hybi</a> mailing list about <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5pZXRmLm9yZy9tYWlsLWFyY2hpdmUvd2ViL2h5YmkvY3VycmVudC9tc2cwMTYwNS5odG1s">Websocket success rates and TLS extension</a> which links to some original research done by Google employees <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5pZXRmLm9yZy9tYWlsLWFyY2hpdmUvd2ViL3Rscy9jdXJyZW50L21zZzA1NTkzLmh0bWw=">here</a> while looking at their SPDY protocol, but they used WebSocket for their tests.</p>
<p>I have always been suspect of WebSocket through proxies. Most people seemed to either not understand the issues or try to ignore them. An article on InfoQ on <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5pbmZvcS5jb20vYXJ0aWNsZXMvV2ViLVNvY2tldHMtUHJveHktU2VydmVycw==">How HTML5 Web Sockets Interact With Proxy Servers</a> was the first thing I had read that even addressed it at all.</p>
<p>If you did not read the links, it basically says that WebSocket over HTTP will fail for 37% of users, over HTTPS it should work ok. Of course that is only for people with WebSocket capable browsers (About 7% of people at the moment)</p>
<p>As I have said before, WebSocket is a step in the right direction, but it is just the latest tool in the Comet Server implementers tool box, for everyone else &#8211; come back in a few years time!</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1998" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/04/13/html5-websocket-failure-rates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why we don&#8217;t need HTML5 WebSocket</title>
		<link>http://blog.caplin.com/2010/03/02/why-we-dont-need-html5-websocket/</link>
		<comments>http://blog.caplin.com/2010/03/02/why-we-dont-need-html5-websocket/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 16:28:32 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=1461</guid>
		<description><![CDATA[I was going to blog about HTML5 WebSocket last week, but got side tracked. In the meantime Greg Wilkins wrote an excellent piece covering some of what I wanted to say &#8211; http://blogs.webtide.com/gregw/entry/websocket_chat The idea of WebSocket is sound &#8211; it should get past some of the limitations of the various Comet techniques used today [...]]]></description>
			<content:encoded><![CDATA[<p>I was going to blog about HTML5 WebSocket last week, but got side tracked. In the meantime Greg Wilkins wrote an excellent piece covering some of what I wanted to say &#8211; <a  href="http://blogs.webtide.com/gregw/entry/websocket_chat" rel="nofollow">http://blogs.webtide.com/gregw/entry/websocket_chat</a></p>
<p>The idea of WebSocket is sound &#8211; it should get past some of the limitations of the various Comet techniques used today on various real time websites. It gives you full duplex communication between a browser and a server &#8211; Comet fakes this somewhat, but in most cases it is sufficient.</p>
<p>Some people seem to think that WebSocket is going to mean no more Comet servers and no more frameworks for real time data. But as Greg points out, WebSocket just doesn&#8217;t give you enough.<br />
<span id="more-1461"></span><br />
<strong>I see three main issues with WebSocket, or rather its uptake by web developers.</strong></p>
<p><strong>1. Browser support</strong></p>
<p>We still have to deal with IE6 at the moment and WebSocket is not supported yet in the current browsers (apart from Chrome). So when can a web developer realistically rely on WebSocket being available for the majority of his users? This is likely to remain an issue for a long time.</p>
<p><strong>2. Proxy support</strong></p>
<p>WebSocket through proxies are a fairly unknown quantity &#8211; WebSocket is designed to fail cleanly so falling back to another mechanism is possible. However we don&#8217;t really know how many proxies will work with WebSocket. This includes server side proxies, which are often overlooked and are usually out of the control of the server side developer.</p>
<p><strong>3. Features</strong></p>
<p>What I am referring to here are the low level features that Greg talks about. His blog demonstrates that you cannot just take the simple WebSocket API and write a real time application (other than a demo) without taking into account the kind of edge cases he describes. Without this a web application could appear unstable for many users.</p>
<p>Taking all this into account, what is WebSocket good for? Who should use it? </p>
<p><strong>Conclusion</strong></p>
<p>Application developers use frameworks that hide issues and allow them to concentrate on their application, not the infrastructure. Frameworks can handle the error cases and implement various fallback methods for when WebSocket doesn&#8217;t work or an old browser is being used &#8211; there are free and commercial frameworks offering this. </p>
<p>So in this sense while Websocket will not improve web applications directly, it is something that framework developers can use to improve their frameworks &#8211; consequently improving those web applications that use the frameworks.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1461" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/03/02/why-we-dont-need-html5-websocket/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Sockets, Messages and the Pub Sub Paradigm: Approaches to Streaming</title>
		<link>http://blog.caplin.com/2009/10/20/approaches-to-streaming/</link>
		<comments>http://blog.caplin.com/2009/10/20/approaches-to-streaming/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 13:40:32 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[Object Remoting]]></category>
		<category><![CDATA[PubSub]]></category>
		<category><![CDATA[Sockets]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=454</guid>
		<description><![CDATA[There are many products and projects out there that allow you to stream data to clients from a server, and most letting you send data back to a server too. There are various approaches that have been taken to achieve this which will be explored in this article. In a followup to this post I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>There are many products and projects out there that allow you to stream data to clients from a server, and most letting you send data back to a server too. There are various approaches that have been taken to achieve this which will be explored in this article.</p>
<p>In a followup to this post I&#8217;ll explore some of the advantages and disadvantages of the methods discussed here further and talk a bit about domain driven design.</p>
<p>The term <a  0="title="What" 1="is" 2="Comet?"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5mcmVlbGliZXJhdG9yLmNvbS9jb21ldC8=">Comet</a> came along a few years ago as a general term to describe the case where the client is a web browser and there are no visible page reloads. Many servers in this space support other client side technologies too, but the focus is often web browser clients.</p>
<p><span id="more-454"></span></p>
<p>When designing a product in this category there are various decisions to make. Many commercial products have target audiences in mind at this stage, whereas some projects are trying to solve a technical problem and the real world use cases will come later. In both cases technical decisions need to be made regarding how the product will look to the user (the developer) and how it will be implemented under the covers.</p>
<p>The complexity of the client API is a key aspect. There is a big trade off here between how much work a client coder has to do and how open what he can do is. This isn&#8217;t a simple scale though and the trick is to have something that is very easy to use without losing out on any flexibility in what can be achieved. A socket like API leaves a reasonable amount of work for the client coder, but also means he is free to implement almost anything. Conversely, many products in this space provide a publish/subscribe like API, which gives the client coder some basic building blocks that a good proportion of applications are likely to find helpful.</p>
<h1>Publish/Subscribe</h1>
<p>The use of the pub/sub paradigm has become very common in this space. It is a natural fit. The client chooses what it wants to see on its screen and subscribes to it from the server. Clients, or other server components, publish data and the server pushes that data to all subscribed clients. Many applications fit into this template, and some that do not can often still make use of the pub/sub API in a simple way without too much of an overhead.</p>
<p>Pub/sub may be a common, however it is implemented differently by different products. <a  0="title="Java" 1="Message" 2="Service"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2phdmEuc3VuLmNvbS9wcm9kdWN0cy9qbXMv">JMS</a> like systems can be fairly static, you configure topics/destinations and these are used for a class of message or a specific application. Other systems are more dynamic, and to use an example from the finance world, the topic would represent a stock or other financial instrument and are created dynamically as they are needed. Some products that use the first, more static, method will have a sub topic which is more suited for use as the stock name.</p>
<p>Another way that pub/sub implementations can differ is in what happens when you first subscribe. In pure pub/sub, which may be based on multicast technology, when you subscribe you will get a message the next time there is a message on that topic. This is not always that useful, to use an example from the finance world again, when you subscribe to a stock you want to know its current value along with subsequent changes. Some older pub/sub systems add this capability in, but the initial value comes from a different place, introducing a nasty race condition.</p>
<h1>Messages</h1>
<p>The format of the messages, both on the wire and how they are presented to the client coder, can differ a lot between products. Not all products will present what they do as messaging, but at some level that is what they are doing, something is being sent from the server to the client or vice versa.</p>
<h2>Sockets</h2>
<p>The most basic method here is a socket-like API. The client coder is left to implement a protocol using this API. This gives maximum flexibility at the expense of possible complexity of the client coders implementation. With a browser client, a Socket-like API (see WebSocket) does a bit more for you compared to a true socket, it will most likely present you with whole messages, which avoids tricky code to handle partial reads etc.</p>
<p>Using sockets means you do not have any features like pub/sub or structured messages, it all has to be implemented by the client coder.</p>
<p>This approach is good for the hardcore coders who want maximum flexibility. It can also more easily integrate with existing backend servers that have differing protocols.</p>
<h2>Simple Pub/Sub</h2>
<p>A simple pub/sub approach with basic message structures can be very useful and solve a lot of use cases. Pub/sub means your messages have a subject (or topic) to identify it and a message body. The message body can vary between products, field/value pairs, structured data types, opaque data types etc.</p>
<p>This is an area that many products fall into and it&#8217;s the message body and the API that differentiates them at this level.</p>
<h3>Field/Value pairs</h3>
<p>This is a very simple, but powerful, structure. It is basically a hashtable or a map structure, often ordered. Most things can be represented in this format, but sometimes more complex structures are needed to avoid extra encoding being used by the client coder.</p>
<h3>Structured data types</h3>
<p>A reasonably common approach here is to use a format such as <a  0="title="JavaScript" 1="Object" 2="Notation"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2pzb24ub3JnLw==">JSON</a> for the message body. JSON allows simple data structures and objects to be represented in a textual human readable format. This gives a bit more flexibility over a field/value pair message type.</p>
<h3>Object Conversion</h3>
<p>Another approach is to send objects as the message body. This is similar to the JSON approach in many ways, but the object is converted from one languages representation of an object into a serialised form and then back again into an object in the language of the receiving end. For example this could be a Java object being converted to a wire format and then being converted to a Javascript object or an ActionScript object. Technologies like Flex/LCDS use this with AMF wire protocol to good effect, which can reduce bandwidth and processing compared to sending complex objects a formats such as XML.</p>
<h2>Object Remoting</h2>
<p>Object conversion is most likely used within a pub/sub like system, the object being the message body, whereas object remoting is more like conventional object oriented programming.</p>
<p>Object remoting tries to abstract away the fact that a client is talking to a server over a network. The client has an object that is a proxy for an object on the server (or vice versa) and allows method calls to be made on the remote objects. This means once setup, the client code can be written much like a normal application, making method calls on objects as if they were local. If there are return values for the method calls then there can be issues that complicate the apparent simplicity, as you will have to block for the call to return, or have a callback mechanism.</p>
<p>My followup article will cover why some of these approaches can be improved upon if your product is targeting a specific domain and how this can lead to faster time to market and a better final solution.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=454" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2009/10/20/approaches-to-streaming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
