270 likes | 382 Views
Developing Advanced Applications with Windows Azure. Steve Marx Technical Strategist Microsoft Corporation. Asynchronous Web/Worker Architecture. Worker Role. Worker Role. Worker Role. Web Role. Web Role. Web Role. LB. Storage. More Complex Architectures. LB. HTTP. XMPP. Web Role.
E N D
Developing Advanced Applications with Windows Azure Steve Marx Technical Strategist Microsoft Corporation
Asynchronous Web/Worker Architecture Worker Role Worker Role Worker Role Web Role Web Role Web Role LB Storage
More Complex Architectures LB HTTP XMPP Web Role Web Role Web Role Web Role Web Role Web Role Web Role Web Role Web Role Web Role Web Role Web Role Role F Role E Role A Role B Role D Role C Storage
What We’ll Build Web Role Web Role IIS Port 80 Web Role Web Role Search LB Web Role Web Role SMTP Server Port 25 Storage
Mindchive demo
What We’ll Build • 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 IIS Search LB SMTP Storage
HOWTO: 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? IIS Search LB SMTP Storage
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 out what port to listen on
Input Endpoints demo Web and SMTP
An Aside About Email • Spammers will use Windows Azure • IP ranges can get blacklisted • Send mail via a relay • Receiving mail is fine
Searching • Lucene.NET • Popular search API • .NET port of original Java implementation • Index data • Bring index up to speed on startup • Continually update index • Serve searches (via WCF)
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!)
HOWTO: Do Initialization • Don’t want traffic until we’re 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
HOWTO: Internal Endpoints • Declare endpoints in ServiceDefinition.csdef • API to find out what port to listen on:RoleEnvironment.CurrentRoleInstance .InstanceEndpoints["SearchIn"].IPEndpoint • API to find IP addresses of role instancesRoleEnvironment.Roles["Mindchive_Search"] .Instances[i].InstanceEndpoints["SearchIn"]
HOWTO: 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= "ExtraLarge"/>
HOWTO: Save the Index • Lucene.NET writes files to the local system • Preserve those across reboots/upgrades:<LocalStoragecleanOnRoleRecycle="false"/> • Consider writing state on OnStop()
Using In-Place Upgrade • Rolling upgrade • Specify which roles to upgrade • Keep local storage intact • Great for stateful roles
What We Built Web Role Web Role IIS Port 80 Web Role Web Role Search LB Web Role Web Role SMTP Server Port 25 Storage
Recap • 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
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation forms online at MicrosoftPDC.com
Learn More On Channel 9 • Expand your PDC experience through Channel 9 • Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses channel9.msdn.com/learn Built by Developers for Developers….
Questions? • Developer resources:http://dev.windowsazure.com/ • Me:http://blog.smarx.com (get the source!)http://twitter.com/smarx • Patterns for Building Scalable, Reliable Applications with Windows AzureBrad Calder (8:30am tomorrow)