• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet

DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet






Total Views
Views on SlideShare
Embed Views



8 Embeds 1,162

http://www.richard-banks.org 1075
http://feeds.feedburner.com 64
http://coderwall.com 16
http://translate.googleusercontent.com 2
http://translate.googleusercontent.com 2
http://www.google.com.au 1
http://www.codeplex.com 1
http://feeds2.feedburner.com 1



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • We want the perf counter to be zero.
  • Demo:Copy deployment to \\\\webserver\\DeploymentsSwitch to server and run the deployment – use the batch command with /Y optionRun TailspinSpyworks (port 8080!) – use VS web load testShow perf counters:ASP.NET\\Requests in Application QueueASP.NET\\Requests CurrentShow IIS session diagnostics (via IIS mgr) and request queue states
  • Means page executes asynchronouslyCan run async tasks, but only until pre-render completesWithout Async=True errors get thrownDemo:Async pagesRun load test againNOTE – no real difference. If anything a little worse.Only apply where multiple activities being performed, and where activity is not CPU boundEach async == extra threadDon’t manually create threads!Web service calls use CLR threads as does QueueUserWorkItem – tune thread pool
  • Show glimpse in action: http://getglimpse.com/
  • Demo:RSS AggregatorSynchronous fetching == slow Async = better, but async on main threadParallels = best – spawns multiple threads, but leads to thread starvation in a web farmTurn offAsync in page directive and check the error
  • IIS is still threaded so the issues from earlier still applyLong polling reduces the issue somewhat
  • Show web chat workingShow long polling in chromedev toolshttp://webserver:8082/jquery.aspxStep through some of the server side code (from the processrequest method onwards) Show JSON content of messageWalkthrough of some of the codeCometHttpHandler. IHttpAsyncHandlerMessage comes in, converted from JSONPushed onto message busDone!Your code?Clients subscribeBack end pushes onto message busASPComet also supports callback messages, not just long polling

DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet Presentation Transcript

  • server-side web trackbrought to you by
  • Getting out of Sync with IISand Riding a COMET
    Richard Banks
    richard-banks.org @rbanks54
  • Goal: Improve your Server Side Performance
  • WebForms,
    MVC &
  • Client side Things we already know(hopefully!)
  • Fewer requests == more performance!
  • View State Is EVIL!!! 
  • CDN’s, css sprites, minification, YSLOW, etc, etc
  • Server side?
  • Minimal DB calls,
    Cache usage, AJAX, and so forth
  • But what if you’ve done all that already?!
  • What if you have “Hanging” Requests?
  • Poor performance with very little load?
  • Some IIS Internals
  • IIS 6.0: 12request threads per CPU
    Also IIS 7.0 in Classic pipeline mode
  • 20worker & 20 IO threads per CPU
  • No free threads?
    The request gets queued
    PerfMon Counter:
    ASP.NETRequests in Application Queue
  • Limit is 5000 requests. Over that? 503 errors
    PerfMon Counter:
    ASP.NETRequests Current
  • IIS 7.0 (Intg):
    12 concurrent requests per CPU
    Applies to .NET 2.0
  • In .NET 4.0: 5000 per CPU!
  • MS says do same in ASP.NET 2.0. Add registry key or edit aspnet.config
  • Note: App Pool Queue Length is 1000
  • Before messing with configs… Get Async!
  • Time For some Demo
  • ASP.NET Web Forms
  • Async=“true”
    in page directive.
  • Howz about USING that new ASYNC Keyword?!
  • Now for the new Hawtness!
  • COMET!
    Aka “Reverse AJAX”
  • Practical uses:
    Stock ticker
    Sports scores
    Auction bidding
    Bus Service GPS updates
    Warehouse movements & logistics
    Anything broadcasting events/msgs
  • Canonical Demo:
    Web Chat
  • Implement Via UpdatePanel?
    Ajax Request on Enter:
    • No live update
    • Need to send full chat history each time
    • Uses Update Panel!
  • AJAX && JSON
    (aka wOOtage!)
    Use a jssetTimeout() call
    Only ask for messages after msgId
    Regular polling to get messages
  • Long Polling or StREAMING
    (no, not web sockets)
  • Bayeux Protocol
    Dojo & Jquery Bindings
  • Lots of other Comet servers. I want TO USE IIS
    IIS threading means no streaming support, only long polling.
  • CHAT Demo: AspComet
    (on Appharbor)
  • For better Comet go Threadless: Manos de Mono or Node.js
    Just Remember Mordac will likely need bribing to deploy it
  • Faye is a Bayeaux server for Node.JS
  • Resources
    Contention, poor performance, and deadlocks: http://support.microsoft.com/kb/821268
    ASP.NET Thread Usage on IIS 6.0 and IIS 7.0: http://blogs.msdn.com/b/tmarq/archive/2007/07/21/asp-net-thread-usage-on-iis-7-0-and-6-0.aspx
    Improving ASP.NET Performance: http://msdn.microsoft.com/en-us/library/ff647787.aspx
    PageAsyncTask: http://msdn.microsoft.com/en-us/library/system.web.ui.pageasynctask.aspx
    MVC Async Controllers: http://msdn.microsoft.com/en-us/library/ee728598.aspx
    Should DB Calls be Async? http://blogs.msdn.com/b/rickandy/archive/2009/11/14/should-my-database-calls-be-asynchronous.aspx
    AspComet: http://github.com/nmosafi/aspcomet
    Bayeux and Cometd: http://svn.cometd.com/trunk/bayeux/bayeux.html
    Manos De Mono: http://github.com/jacksonh/manos
    Node.JS: http://nodejs.org/
    FAYE: http://faye.jcoglan.com/
  • We would like to thank our sponsors and supporters for helping us bring you this event
  • Please complete the feedback form in your delegate pack for a chance to win some great prizes.
    Please remember to return the form before you enter the lock note, or leave the event.