The World’s Leading Microsoft .NET Magazine
   
 
The .NET Addict's Blog

My Top Tags

                                                           

My RSS Feeds








I heart FeedBurner

Latest Diggs - Programming

Computers Blogs - Blog Top Sites

Site Hits

Total: 4,881,741
since: 19 Jan 2005

Silverlight Polling Duplex Channel is NOT a Scalable Solution

posted Wed 01 Jul 09

First, let's talk about the problem that Polling Duplex solves. Polling Duplex is a special WCF channel that is available only to Silverlight. When your Silverlight application needs data from the server, it needs it in one of two different ways:

  • On-Demand : Something in your application happens and it needs data. It specifically asks the server for that data upon encountering the need for that data. This is what most people think of as "pull" data.
  • Push : This is where you need data sent to your application as the data becomes available and the overhead of setting up a timer on which you pull (or poll) for data is unacceptable to you. The main reason why this is unacceptable to people is because there may be frequent periods of time where the pull/poll has no data, which means your app will be occupying server resources every X seconds even when there is nothing to do.

The Polling Duplex channel is a solution to the push problem. It allows server-side code to "push" data down to the Silverlight application. Under the hood the channel is using "Comet"-style tricks keeping HTTP connections open in much the same way that the Gmail application is able to receive push notifications of new mail.

This is great and the programming model for communicating with the Polling Duplex channel is brain-dead simple. It does NOT get any easier to implement push data to a RIA - not in Flash, not in AIR, and certainly not in JavaFX. The problem is that this solution doesn't scale. On the server side, for each concurrently running Silverlight application (so probably one per concurrent user), there is a full live socket being consumed that will not be relinquished until the client disconnects/closes their browser.

Worse is that the Polling Duplex channel defaults to only allowing 10 concurrent connections. You can programmatically tweak that by configuring the throttling behavior (as shown in this blog post here ).Even if you do increase the amount of concurrent connections allowed, those concurrent connections are still going to beat the crap out of your servers and good luck getting that to work seamlessly in a cluster/farm scenario.

If you need more than a handful of concurrent users and you want to do it in a way that scales and doesn't abuse your servers, then I highly, highly recommend looking into some kind of messaging / open gateway server. The only one I've played with for more than a few minutes is Kaazing , but I have nothing but good things to say about it. It's based on HTML 5 Web Sockets so you will be in good shape for the future.

Web Sockets are freaking awesome but that's a topic for another post.

Bottom line here is that if you're looking at any of the Polling Duplex samples online like the "stock ticker" sample, don't be fooled. It looks easy, but especially in the financial industry, you need high concurrency, high speed, low latency - and you're not going to get that with the polling duplex channel. If there was one place where I see it fitting is in the creation of intranet applications internal to an organization with a limited number of concurrent users.

tags:          

links: digg this    del.icio.us    technorati    reddit

AddThis Social Bookmark Button




1. Ken Smith left...
Fri 10 Jul 09 10:53 pm :: http://blog.wouldbetheologian.com/

I'd be curious if you've run actual scalability tests using Silverlight and the PDBE, and compared those results to the other solutions you've mentioned. (It's on my list to do, but I haven't gotten to it yet.) From what I understand about how Silverlight implements the PDBE, I *thought* it was very similar to how HTML 5 web sockets (aka "comet") works, i.e., it's basically the same as repeatedly requesting a web page that (almost) never returns any data: you send the TCP handshake, and then wait and do nothing until the timeout period expires, and then do it all over again. It seems to me like this would have a slightly higher overhead than, say, standard TCP sockets (since you have to periodically re-open the connection), but not dramatically so.

At any rate, just curious as to any real-world tests that you or anyone else has done.


2. Wayne B left...
Sun 12 Jul 09 12:44 pm

"there is a full live socket being consumed"

Not according to Scott Guthrie who says:

"It initiates a network request, and then the request is effectively "put to sleep" waiting for the server to respond (it doesn't come back immediately). The server then keeps the connection open but not active until it has something to send back (or the connection times out after 90 seconds"


3. Harry M left...
Wed 15 Jul 09 6:38 am

yeah, i think iis 7 can keep loads of connections open simultaneously without using a thread for each one


4. lattimoregay left...
Tue 21 Jul 09 10:48 am :: http://eikospartners.net

we have been using kaazing for a while now, and its great, solid solution, and scales, I have used the Duplex Channel in the past, but since using KaaZing, have found it wanting.


5. Karl Waclawek left...
Thu 06 Aug 09 10:28 am

Bidirectional connections for event notifications/call-backs have been available through ICE (http://zeroc.com) for a long time on a variety of platforms, and for a shorter time even for Silverlight. And this technology is not a hack like polling or Comet.


6. Tomasz Janczuk left...
Thu 17 Sep 09 1:29 am :: http://tomasz.janczuk.org

The server side out of the box implementation of the Silverlight polling dulpex protocol indeed has scalability challanges. However, there is a way to scale-out the protocol in a web farm scenario, which is described at htt p://tomasz.janczuk.org/2009/09/scale-out-of-silverlight-http-polling.html.

Additionally, performance characteristics of the protocol is described at http://tomasz.janczuk.org/2009/08/performance-of-http-polling-duplex.html.


Tag Related Posts

What's New in Silverlight 3

Fri 20 Mar 09 2:38 P GMT-05

Building RESTful Java Web Services with JAX-RS

Mon 23 Feb 09 8:42 P GMT-05
tags:                    

Know thine Enemy: RESTful Web Services in ... Java!

Sun 11 Jan 09 2:08 P GMT-05
tags:                    

Live Mesh Tutorial 1 - Hello Live Mesh

Thu 06 Nov 08 2:33 P GMT-05

CLINQ v1 Demo - Network Message Filtering

Wed 09 Jan 08 7:47 P GMT-05
tags:        

My Silverlight Plugin has expired - WTF?!?

Thu 08 Nov 07 7:34 P GMT-05
tags:    

Silverlight 1.1 Alpha Refresh

Fri 10 Aug 07 2:09 P GMT-05
tags:    

My Appearance in the RIA Shootout on sys-con.tv

Tue 05 Jun 07 11:41 A GMT-05
tags:              

Silverlight and Astoria - First Impressions

Mon 04 Jun 07 1:40 A GMT-05
tags:    

I'm going to be on TV (sort of)

Sat 02 Jun 07 12:19 P GMT-05
tags:              

Orcas' Hidden Gem - The managed PNRP stack

Fri 11 May 07 6:45 P GMT-05
tags:        

Silverlight Revisited

Sat 21 Apr 07 9:48 P GMT-05
tags:    

Will Silverlight be DOA?

Mon 16 Apr 07 8:02 P GMT-05

On MUDs

Thu 08 Mar 07 5:00 A GMT-05
tags:                    

What I think is a bug in WCF POX messaging

Thu 04 Jan 07 4:58 P GMT-05
tags:      

Ulysses Agenda Makes Redmond Developer News

Wed 29 Nov 06 7:10 P GMT-05
tags:                

Ulysses Agenda - Network Engine Test 1

Mon 09 Oct 06 2:26 A GMT-05
tags:              

Ulysses Agenda : First Cut Networking Design

Thu 14 Sep 06 12:46 A GMT-05
tags:                  

First Impressions of Windows Vista RC1

Thu 07 Sep 06 1:30 P GMT-05
tags:                      

.NET Framework 3.0 June CTP is out!

Fri 23 Jun 06 6:23 P GMT-05
tags:                

Tech-Ed 2006 - Session Reviews

Tue 13 Jun 06 6:22 P GMT-05
tags: