Weitere ähnliche Inhalte Ähnlich wie Windows Azure - Cloud Service Development Best Practices (20) Kürzlich hochgeladen (20) Windows Azure - Cloud Service Development Best Practices1. Windows Azure: Cloud service development best practices Sriram Krishnan Program Manager Microsoft Corporation sriramk@microsoft.com 4. void quicksort(int* array, int left, int right) { if(left >= right) return; int index = partition(array, left, right); quicksort(array, left, index - 1); quicksort(array, index + 1, right); } 18. What do you do about that pesky thing called state? 23. Session state provider <system.web>... <sessionStatemode="Custom"customProvider="TableStorageSessionStateProvider"> <providers> <addname="TableStorageSessionStateProvider“ type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider" applicationName=“Foo” /> </providers> </sessionState> </system.web> 29. Tight coupling : Default.aspx.cs publicpartialclass_Default : System.Web.UI.Page { protectedvoid Button1_Click(objectsender,EventArgs e) { var order = txtOrder.Text; ProcessOrder(order); } protectedvoidProcessOrder(string order) { //Make some coffee! ... } } 31. Loose coupling : Default.aspx.cs publicpartialclass_Default : System.Web.UI.Page { protectedvoid Button1_Click(objectsender,EventArgs e) { var order = txtOrder.Text; QueueStorageqStore = QueueStorage.Create(_account); MessageQueueorderQ = qStore.GetQueue("OrderQueue"); orderQ.PutMessage(newMessage(order)); } } 32. Loose coupling : WorkerRole.cs public class WorkerRole : RoleEntryPoint { public override void Start() { QueueStorageqStore = QueueStorage.Create(_account); MessageQueueorderQ = qStore.GetQueue("OrderQueue"); while (true) { Message msg=orderQ.GetMessage(); if( msg != null) ProcessOrder(msg.ContentAsString()); } } protected void ProcessOrder(string order) { //Make some coffee! ... } 46. When is ‘good enough’ good enough? 48. Do all apps need the same guarantees? 63. If it looks like a duck and walks like a duck… http://www.flickr.com/photos/gaetanlee/298160415/ 65. } Schema without versioning classEmployee : TableStorageEntity { public Employee(stringfirstName, stringlastName) : base(firstName, lastName) //partition key, row key {} publicstringJobTitle { get; set; } } ... varqResult = fromempin svc.CreateQuery<Employee>(EmployeeDataServiceContext.EmployeeTable) whereemp.PartitionKey == "Steve" && emp.RowKey == "Marx selectemp; 66. } Schema *with* versioning classEmployee : TableStorageEntity { public Employee(stringfirstName, stringlastName) : base(firstName, lastName) {} publicstringJobTitle { get; set; } publicint Version { get; set; } } ... varqResult = fromempin svc.CreateQuery<Employee>(EmployeeDataServiceContext.EmployeeTable) whereemp.PartitionKey == "Steve" && emp.RowKey == "Marx && emp.Version == 1 selectemp; 70. + Stop + start for big changes or if downtime isn’t an issue 75. Update code or data Maintain compat Versioning in schemas Rolling upgrades Recap 90. Configuration files ServiceDefinition.csdef <ServiceDefinitionname="DemoService"> <WebRolename="WebRole"> <ConfigurationSettings> <Setting name="Color"/> </ConfigurationSettings> </WebRole> </ServiceDefinition> ServiceConfiguration.cscfg <ServiceConfigurationserviceName="DemoService"> <Rolename="WebRole"> <ConfigurationSettings> <Setting name ="Color" value ="Red"/> </ConfigurationSettings> </Role> </ServiceConfiguration> 94. Configurable logging <?xmlversion="1.0"?> <ServiceConfigurationserviceName=“DemoService”> <Rolename="WebRole"> <Instancescount="1"/> <ConfigurationSettings> <Settingname ="LogLevel"value ="Verbose"/> </ConfigurationSettings> </Role> </ServiceConfiguration> ... if (RoleManager.GetConfigurationSetting("LogLevel") == "Verbose") RoleManager.WriteToLog("Information", "Some log message"); 96. How do I get notified when something bad happens? 100. Use the SDK Separate code and config Configurable logging Alerts The Big Red Button Recap 102. Credits & Acknowledgements James Hamilton http://research.microsoft.com/~jamesrh/ Emre Kicimanhttp://research.microsoft.com/~emrek/ Pat Hellandhttp://blogs.msdn.com/pathelland/ What really happened on Mars http://research.microsoft.com/~mbj/mars_pathfinder/ Flickr blog post http://code.flickr.com/blog/2008/09/26/flickr-engineers-do-it-offline/ Don MacAskillhttp://blogs.smugmug.com/don/ 104. William of Ockhamc. 1288 - c. 1348 109. © 2008 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.