Your SlideShare is downloading. ×
0
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Windows Azure - Cloud Service Development Best Practices

3,744

Published on

Talk from PDC 2008

Talk from PDC 2008

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,744
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
88
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Windows Azure: Cloud service development best practices<br /> Sriram Krishnan<br /> Program Manager<br /> Microsoft Corporation<br /> sriramk@microsoft.com<br />
  • 2. 1980<br />
  • 3.
  • 4. void quicksort(int* array, int left, int right)<br />{<br />if(left &gt;= right)<br />return;<br />int index = partition(array, left, right);<br />quicksort(array, left, index - 1);<br />quicksort(array, index + 1, right);<br />}<br />
  • 5.
  • 6.
  • 7. simplicity<br />
  • 8. Act I<br />Architecture<br />
  • 9. Networks are unreliable<br />
  • 10. Hardware fails<br />
  • 11.
  • 12.
  • 13. A few design choices<br />
  • 14. Big, reliable, expensive machine<br />
  • 15. Several commodity machines<br />
  • 16. Lots and lots of commodity machines<br />
  • 17. A few challenges<br />
  • 18. What do you do about that pesky thing called state?<br />
  • 19.
  • 20. Go horizontal<br />Go stateless<br />
  • 21. Store state in Windows Azure storage<br />
  • 22. And it is the default out of the box!<br />
  • 23. Session state provider<br />&lt;system.web&gt;...<br /> &lt;sessionStatemode=&quot;Custom&quot;customProvider=&quot;TableStorageSessionStateProvider&quot;&gt;<br />            &lt;providers&gt;<br />                &lt;addname=&quot;TableStorageSessionStateProvider“<br />        type=&quot;Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider&quot;<br />                     <br />applicationName=“Foo” /&gt;<br />            &lt;/providers&gt;<br /> &lt;/sessionState&gt;<br />&lt;/system.web&gt;<br />
  • 24. How do you deal with unreliable components?<br />
  • 25.
  • 26. Be loosely coupled<br />
  • 27. Use Windows Azure queues for separation of work<br />
  • 28. Default.aspx(Input + Making Coffee)<br />LB<br />
  • 29. Tight coupling : Default.aspx.cs<br />publicpartialclass_Default : System.Web.UI.Page<br />    {<br />         <br />        protectedvoid Button1_Click(objectsender,EventArgs e)<br />        {<br />            var order = txtOrder.Text;<br />            ProcessOrder(order);<br />        }<br /> protectedvoidProcessOrder(string order)<br />        {<br />  //Make some coffee! ...<br />        }<br />     }<br />
  • 30. LB<br />Default.aspx(Input)<br />Worker.cs(Make Coffee)<br />Windows Azure Queues<br />
  • 31. Loose coupling : Default.aspx.cs<br />publicpartialclass_Default : System.Web.UI.Page<br />    {<br />         <br />        protectedvoid Button1_Click(objectsender,EventArgs e)<br />        {<br />            var order = txtOrder.Text;<br />            QueueStorageqStore = QueueStorage.Create(_account);<br />            MessageQueueorderQ = qStore.GetQueue(&quot;OrderQueue&quot;);<br />            orderQ.PutMessage(newMessage(order));       <br /> }<br />     }<br />
  • 32. Loose coupling : WorkerRole.cs<br />public class WorkerRole : RoleEntryPoint<br />    {<br />        public override void Start()<br />        {<br />            QueueStorageqStore = QueueStorage.Create(_account);<br />            MessageQueueorderQ = qStore.GetQueue(&quot;OrderQueue&quot;);<br />            while (true)<br />            {<br />               Message msg=orderQ.GetMessage();<br />if( msg != null)<br />                ProcessOrder(msg.ContentAsString());<br />            }<br />        }<br />       <br />        protected void ProcessOrder(string order)<br />        {<br />//Make some coffee! ...<br />        }<br />
  • 33. How do you deal with varying load?<br />
  • 34. Build a thermostat for your service<br />
  • 35. How do you deal with failures?<br />
  • 36. Use Windows Azure storage for valuable data<br />
  • 37. Be prepared to reconstruct local state…<br />
  • 38. …since it can disappear any time<br />
  • 39. Retry on transient failuresBut…<br />
  • 40. Be idempotent<br />
  • 41. Don’t launch a DoS attack on yourself<br />
  • 42. Be predictable<br />
  • 43. Avoid shutdown code<br />
  • 44. Know when to throttle and shed load<br />
  • 45. Case study: SmugMug and SkyNet<br />
  • 46. When is ‘good enough’ good enough?<br />
  • 47. The resiliency of email<br />
  • 48. Do all apps need the same guarantees?<br />
  • 49. It&apos;s a knob<br />
  • 50.
  • 51.
  • 52. Stateless front-ends<br />Loose coupling<br />Building a thermostat<br />Retrying on failures<br />Loosening consistency<br />Recap<br />
  • 53. End of Act I<br />
  • 54. Act II<br />Updates<br />
  • 55. Updates are hard<br />
  • 56. Hard to ‘undo’ a failed deployment<br />
  • 57. Need to deal with both code and schema changes<br />
  • 58. Code + data<br />Update only one at a time<br />
  • 59. Code vN<br />Data vN<br />
  • 60. Code vN +1 <br />Data vN<br />Code vN<br />
  • 61. Data vN+1<br />Code vN<br />Data vN<br />
  • 62. Be compatible<br />
  • 63. If it looks like a duck and walks like a duck…<br />http://www.flickr.com/photos/gaetanlee/298160415/<br />
  • 64. Use version numbers in schema<br />
  • 65.            <br />           <br />            }<br />Schema without versioning<br />  classEmployee : TableStorageEntity<br />    {        public Employee(stringfirstName, stringlastName) :<br />            base(firstName, lastName) //partition key, row key<br />        {}<br /> <br />        publicstringJobTitle<br />        { <br />            get; <br />            set; <br />        }<br /> <br />    }  ...<br />       varqResult = fromempin<br />svc.CreateQuery&lt;Employee&gt;(EmployeeDataServiceContext.EmployeeTable)<br />       whereemp.PartitionKey == &quot;Steve&quot; && emp.RowKey == &quot;Marx<br />       <br /> selectemp;<br />
  • 66.            <br />           <br />            }<br />Schema *with* versioning<br />  classEmployee : TableStorageEntity<br />    {        public Employee(stringfirstName, stringlastName) :<br />            base(firstName, lastName)<br />        {}<br /> <br />        publicstringJobTitle<br />        { <br />            get; set; <br />        }         publicint Version<br />        {<br />            get; set;<br />        } <br />    }  ...<br />       varqResult = fromempin<br />svc.CreateQuery&lt;Employee&gt;(EmployeeDataServiceContext.EmployeeTable)<br />       whereemp.PartitionKey == &quot;Steve&quot; && emp.RowKey == &quot;Marx <br />&& emp.Version == 1       <br /> selectemp;<br />
  • 67. How do you do upgrades without downtime?<br />
  • 68. Windows Azure’s rolling upgrades<br />
  • 69. Stage Deployment<br />Production Deployment<br />Swap for zero downtime upgrade<br />
  • 70. +<br />Stop + start for big changes or if downtime isn’t an issue<br />
  • 71. Future: Precise control<br />
  • 72. When is the best time to update a service?<br />
  • 73. Use the Pacific Ocean<br />
  • 74. Case study: Windows Live ID<br />
  • 75. Update code or data<br />Maintain compat<br />Versioning in schemas<br />Rolling upgrades<br />Recap<br />
  • 76. End of Act II<br />
  • 77. December 4th, 1996<br />
  • 78.
  • 79.
  • 80.
  • 81. Oh Oh!<br />
  • 82.
  • 83. Trace logs<br />
  • 84. Trickiest patch ever<br />
  • 85.
  • 86. Act III<br />When things go wrong…<br />
  • 87. How do I debug?<br />
  • 88. Use the Windows Azure SDK and debug locally to find bugs<br />
  • 89. Separate code and config<br />
  • 90.            <br />Configuration files<br /> <br />ServiceDefinition.csdef<br />&lt;ServiceDefinitionname=&quot;DemoService&quot;&gt;<br />  &lt;WebRolename=&quot;WebRole&quot;&gt;    &lt;ConfigurationSettings&gt;<br />      &lt;Setting name=&quot;Color&quot;/&gt;<br />    &lt;/ConfigurationSettings&gt;<br />  &lt;/WebRole&gt;<br />&lt;/ServiceDefinition&gt;<br />ServiceConfiguration.cscfg<br />&lt;ServiceConfigurationserviceName=&quot;DemoService&quot;&gt;<br />  &lt;Rolename=&quot;WebRole&quot;&gt;<br />    &lt;ConfigurationSettings&gt;<br />      &lt;Setting name =&quot;Color&quot; value =&quot;Red&quot;/&gt;<br />    &lt;/ConfigurationSettings&gt;<br />  &lt;/Role&gt;<br />&lt;/ServiceConfiguration&gt;<br />
  • 91. Windows Azure’s configuration update mechanism <br />
  • 92. How do I debug the cloud?<br />
  • 93. Logging<br />
  • 94.            <br />Configurable logging<br />  &lt;?xmlversion=&quot;1.0&quot;?&gt;<br />&lt;ServiceConfigurationserviceName=“DemoService”&gt;<br />  &lt;Rolename=&quot;WebRole&quot;&gt;<br />    &lt;Instancescount=&quot;1&quot;/&gt;<br />    &lt;ConfigurationSettings&gt;<br />      &lt;Settingname =&quot;LogLevel&quot;value =&quot;Verbose&quot;/&gt;<br />    &lt;/ConfigurationSettings&gt;<br />  &lt;/Role&gt;<br />&lt;/ServiceConfiguration&gt;<br />...<br />if (RoleManager.GetConfigurationSetting(&quot;LogLevel&quot;) == &quot;Verbose&quot;)<br />       RoleManager.WriteToLog(&quot;Information&quot;, &quot;Some log message&quot;);<br />
  • 95. {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}<br />Tag data with unique ID to track across the system<br />
  • 96. How do I get notified when something bad happens?<br />
  • 97. !<br />Windows Azure’s alerts<br />
  • 98. !<br />Email / IM / Phone<br />
  • 99. The Big Red Button<br />
  • 100. Use the SDK<br />Separate code and config<br />Configurable logging<br />Alerts<br />The Big Red Button<br />Recap<br />
  • 101. End of Act III<br />
  • 102. Credits & Acknowledgements <br />James Hamilton http://research.microsoft.com/~jamesrh/<br />Emre Kicimanhttp://research.microsoft.com/~emrek/<br />Pat Hellandhttp://blogs.msdn.com/pathelland/<br />What really happened on Mars http://research.microsoft.com/~mbj/mars_pathfinder/<br />Flickr blog post http://code.flickr.com/blog/2008/09/26/flickr-engineers-do-it-offline/<br />Don MacAskillhttp://blogs.smugmug.com/don/<br />
  • 103. One final story<br />
  • 104. William of Ockhamc. 1288 - c. 1348<br />
  • 105. Numquamponendaestpluralitas sine necessitate<br />Plurality ought never be posited without necessity <br />
  • 106. KISS<br />
  • 107. simplicity<br />
  • 108. sriramk@microsoft.comwww.sriramkrishnan.com<br />
  • 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.<br />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.<br />

×