Wednesday, November 18, 2009

@PDC09 – Day 2 – Developing Advanced Applications with Windows Azure

                                                                   (Rough notes from the session)
By Steve Marx, Technical Strategist, Microsoft Corporation

LB –> Web Role + Worker Role

Official shipping version of the Table Storage SDK is available now

What we’ll Build – Search application using IIS + SMTP  + Web and Worker Roles
  • Three role architecture
    • Web UI (ASP.net MVC)
    • SMTP Server (TCPListener)
    • Search (Lucene.NET)
  • New Features we’ll take advantage of
    • Inter-role communication
    • Non-HTTP endpoints
    • Role instance lifecycle
    • VM sizes
    • Local storage
HOW TO: Model your application
  • Draw the boxes and arrows
  • Each box is a role
    • Which receive traffic from the internet
    • Which need IIS?
    • Which receive internal communication?
Receiving Traffic. Input Endpoints
  • Different ports on the same domain
  • Always load balanced
  • Declared in ServiceDefinition.csdef
  • Handled by IIS in web roles
  • Handled by your code in worker roles
  • API to find
The instance could should always be atleast 2 or else SLA isn’t valid.
Azure Storage Explorer in codeplex

Input Endpoints Demo :  Set the configurations in the xml file
As an Aside about Email
  • Spammers will use Windows Azure. (sending email should not be done via azure as the IP is not trusted)
Asynchronous work without a Queue
  • Queues deliver messages to one worker
  • We need every worker to see the messages
  • Use a table instead
    • build your own secondary index
    • order references
    • (Beware of clock drift!!)
HOW TI: DO Initialization
  • don’t want traffic until we are listening
  • role instance lifecycle lets us prepare
    • both web roles and worker roles
    • OnStart() - “busy” state, initialization
    • Run() – do work
    • OnStop() – traffic stops, graceful shutdown
HOW TO: Internal Endpoints
  • Declare endpoints in servicedefinition.csdef
  • API to find out what port to listen on:
    RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[“”]
For internal endpoints always rely on the API to provide the port number, do not assign any port number.
HOW TO: Get more RAM
  • RAMDirectory puts everything in memory
  • If we have lots of data, we need lots of RAM
  • Choose among four VM sizes:
    • Small
    • Medium
    • Large
    • Extra Large
  • Simple edit to servicedefinition.csdef
    <WorkerRole  vmsize=”ExraLarge” />
HOW TO: Save the Index
  • Lucene.NET writes files to the local system
  • Preserve those across reboots/upgrades : 
    <LocalStorage cleanOnRoleRecycle=”false” />
  • Consider writing state on OnStop()
    (this is the to write I was on record XX and save the last state)
Using In-Place Upgrade
  • Rolling Upgrade
  • Specify which roles to upgrade
  • Keep local storage intact
  • Great for stateful roles

Call of Action:
  • Any instance can talk to any other
  • Don’t need IIS to listen for traffic
  • Use the role instance lifecycle
  • Choose different VM sizes
  • In-Place upgrades

No comments:

AddIn