310 likes | 523 Views
Windows Azure Compute. Name Title Microsoft Corporation. Session Objectives and Takeaways. Describe Windows Azure Compute Understand Model and Terminology. Windows Azure. Windows Azure is a foundation of Microsoft’s Cloud Platform for Developers Operating System for the Cloud
E N D
Windows Azure Compute Name Title Microsoft Corporation
Session Objectives and Takeaways • Describe Windows Azure Compute • Understand Model and Terminology
Windows Azure • Windows Azure is a foundation of Microsoft’s Cloud Platform for Developers • Operating System for the Cloud • Runs applications in the cloud • Provides Storage • Application Management • Developer SDK • Windows Azure ideal for applications needing • Scalability • Availability • Fault Tolerance
Windows Azure, In One Picture Business Portal Developer Portal REST Service Management Service User Code … … Runtime API Storage Cluster VS Tools Compute Cluster … WA SDK VM Setup REST MSFT Datacenters Desktop Cloud VM
Subscriptions and Services • A subscription contains a collection of up to 6 services • Determines the billing model • May include a level of bundled usage • A service consists of • An isolation boundary and ca public URL • A set of component roles (up to 5), each with endpoints • At runtime; one or more identical instances of each role • Services are defined in a service model
Roles and Instances • Roles are defined in a Service Model • May define one or more Roles per Service • A role definition specifies • VM size • Communication Endpoints • Local storage resources • Etc… • At runtime each Role will execute on one or more instances (up to 20 per subscription) • A role instance is a set of code, configuration, and local data, deployed in a dedicated VM
The High Scale Application Archetype Windows Azure provides a ‘pay-as-you-go’ scale out application platform Intelligent Network Load Balancer Network Activation Stateless Web and/or Application Servers Stateless ‘Worker’ Machines Async Activation State Tier Queues Key/ValueDatastores Partitioned RDBMS Shared Filesystem
Windows Azure Service Architecture The Internet The Internet via TCP or HTTP Tables LB LB LB Storage Queues Web Site (ASPX, ASMX, WCF) Worker Service Web Site (ASPX, ASMX, WCF) Worker Service Web Role IIS as Host Worker Role Managed Interface Call Blobs Windows Azure Data Center
Windows Azure Tooling Windows Azure Tools for Visual Studio • Visual Studio 2008 • Visual Studio 2010 • Project Templates • Model & Config Tooling • Package & 1 Click Deploy • Debugging Support • Storage Explorer • Server Explorer • IntelliTrace Support Windows Azure SDK • Windows Server 2008 or Windows 7 • SQL Express 2005+ • .NET 3.5 SP1+ • Development Fabric • Development Storage • .NET APIs
Role Programming Model • Inherits RoleEntryPoint • OnStart() Method • Called by Fabric on startup, allows you to perform initialization tasks. • Reports Busy status to load balancer until you return true. • Run() Method • Main logic is here – can do anything, typically infinite loop. Should never exit. • OnStop() Method • Called when role is to be shutdown, graceful exit. • 30 Seconds to tidy up
Role Lifecycle All roles may extend RoleEntryPoint Roles report status via RoleEnvironment Events Methods Status Role Lifetime Busy OnStart StatusCheck Requests Routed Fabric Calls StatusCheck Ready Run Busy OnStop StatusCheck Stopping
Worker Role Patterns • Queue Polling Worker • Poll and Pop Messages within while(true) loop • E.g. Map/Reduce pattern, background image processing • Listening Worker Role • Create TcpListener or WCF Service Host • E.g. Run a .NET SMTP server or WCF Service • External Process Worker Role • OnStart or Run method executes Process.Start() • E.g. Run a database server, web server, distributed cache
Web Role • All features of a worker role + IIS • ASP.NET 3.5 SP1 or 4.0 – 64bit • IIS7 Hostable Web Core • Hosts • Webforms or MVC • FastCGI applications (e.g. PHP) • Http(s) • Web/Worker Hybrid • Can optionally implement RoleEntryPoint
The Service Model • Defines the shape of each role • Internal and External Endpoints • Configuration setting definitions <WebRole name="WebRole1"> <InputEndpoints> <InputEndpoint name="HttpIn" protocol="http" port="80" /> </InputEndpoints> <ConfigurationSettings> <Setting name="DiagnosticsConnectionString" /> <Setting name="HelloMessage"/> </ConfigurationSettings> </WebRole>
The Service Configuration • Defines the scale of each role • Instance count • Configuration values <Role name="WebRole1"> <Instances count="1" /> <ConfigurationSettings> <Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" /> <Setting name="HelloMessage" value="Hello World!" /> </ConfigurationSettings> </Role>
A Service Example Port 8090Http Port 80Http WA-GUEST-OS-1.3 Customer Web Site Thumbnail Worker WebDav Height 200px 500MB Width 200px StatusSvcHTTP XL S M Service Configuration Service Definition
VM Size in Windows Azure • Windows Azure • Supports Various VM Sizes • Size set on Role in Service Definition • Service can have multiple roles • Balance of Performance per node vs. High Availability from multiple nodes • Set in Service Model definitionAll instances of role will be of equal size
Choosing Your VM Size • Don’t just throw big VMs at every problem • Scale out architectures have natural parallelism • Test various configurations under load • More small instances == more redundancy • Some scenarios will benefit from more cores • Where moving data >$ parallel overhead • E.g. Video processing, Stateful services (DBMS)
.NET 4 Parallelism Support • Parallelism is a key trend • Availability of multi-core processors • Task parallel library • High level “threading” model • Parallel Extensions • Parallel Loops • Task Parallel Library • High level in threaded tasks • Parallel LINQ • Automatically parallelize LINQ to Objects queries
Inter-Role Communications • High performance sync calls between instances • Define Internal Endpoints in model • Enumerate Running Instances within Role • Enumerate endpoints in each role • Communicate on internal endpoint for each (RoleInstance ri in RoleEnvironment.CurrentRoleInstance.Role.Instances) { Trace.WriteLine("Instance ID: " + ri.Id); for each (RoleInstanceEndpoint ep in ri.InstanceEndpoints.Values) { Trace.WriteLine("Instance endpoint IP address” + “and port: " + ep.IPEndpoint); } }
Local Storage • Role instances have available disk storage • Use LocalStorage element in service definition • Name • CleanOnRoleRecycle • Size • Persistent but not guaranteed durableGood for cached resources • Windows Azure Storage Drives provide guaranteed durable storage
Local Storage Define in Config <LocalResources> <LocalStorage name=“myLocalDisk" sizeInMB="10" cleanOnRoleRecycle="false" /> </LocalResources> Use in Code string rootPath = RoleEnvironment.GetLocalResource[“myLocalDisk”] .RootPath; DirectoryInfo di = new DirectoryInfo(rootPath); foreach(di.EnumerateFiles()) ….
Configuration Values • Store arbitrary configuration string values • Define in model • Populate in configuration • RoleEnvironment • .GetConfigurationSettingValue() • Don’t use web.config for values you wish to change at runtime • App/Web.config is packaged with deployment change requires re-deploy • *.cscfg supports change tracking and notification to running role instances
Handling Config Changes • RoleEnvironment.Changing • Occurs before configuration is changed • Can be cancelled – causes a recycle • RoleEnvironment.Changed • Occurs after config change has been applied • RoleEnvironmentConfigurationSettingChange • Provides config value that was changed • RoleEnvironmentTopologyChange • When role count is changed
Handling Config Changes Port 8090HTTP Port 80Http Customer Web Site Thumbnail Worker Web Dav Changed OnStart StatusSvcHTTP EnumerateInstances in WebDav Role StatusSvcHTTP Regular Polling for Status 73984 Regular Polling for Status 83425
demo Configuration Name Title Group
Monitoring • More in Lifecycle Session on Day 3 • Limited Debugging in Cloud (Intellitrace) • Instrument your application using Trace, Debug • DiagnosticMonitorTraceListener • Use Diagnostics API to Configure and Collect • Event Logs • Performance Counters • Trace/Debug information (logging) • IIS Logs, Failed Request Logs • Crash Dumps or Arbitrary files • Request data on demand or scheduled • Transferred into your table and/or blob storage
Upgrading Your Application • More in Lifecycle Session on Day 3 • VIP Swap: • Uses Staging and Production environments. • Allows to quickly swap environments. • Production: v1 Staging: v2, after swap then Production: v2 Staging: v1. • In-Place Upgrade • Performs a rolling upgrade on live service. • Entire service or a single role • Manual or Automatic across update domains • Cannot change Service Model
Challenges • Stateless Role Instances • Session state • Local storage • AJAX requests may callback different instance • Non-Admin Rights • Cannot easily register COM components • Registration free COMhttp://tinyurl.com/Reg-Free-COM
Summary • Service model defines service shape • Service configuration defines service scale • Selectable VM Sizes • Windows Azure provides specific configuration capability • Scale out aware • Allows event based change subscription • Monitoring • Upgrading and Deployment
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.