sriram krishnan program manager microsoft corporation [email protected] es03
TRANSCRIPT
Windows Azure: Cloud service development best practices
Sriram KrishnanProgram ManagerMicrosoft Corporation
ES03
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);
}
Session state provider
<system.web>
...<sessionState mode="Custom"
customProvider="TableStorageSessionStateProvider"> <providers>
<add name="TableStorageSessionStateProvider“
type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider"
applicationName=“Foo” />
</providers></sessionState>
</system.web>
Tight coupling : Default.aspx.cs
public partial class _Default : System.Web.UI.Page { protected void Button1_Click(object sender,EventArgs e) { var order = txtOrder.Text; ProcessOrder(order); }
protected void ProcessOrder(string order) { //Make some coffee!
... }
}
Loose coupling : Default.aspx.cs
public partial class _Default : System.Web.UI.Page { protected void Button1_Click(object sender,EventArgs e) { var order = txtOrder.Text;
QueueStorage qStore = QueueStorage.Create(_account);
MessageQueue orderQ = qStore.GetQueue("OrderQueue");
orderQ.PutMessage(new Message(order)); }
}
Loose coupling : WorkerRole.cs
public class WorkerRole : RoleEntryPoint { public override void Start() {
QueueStorage qStore = QueueStorage.Create(_account); MessageQueue orderQ = qStore.GetQueue("OrderQueue"); while (true) { Message msg = orderQ.GetMessage();
if( msg != null) ProcessOrder(msg.ContentAsString()); } } protected void ProcessOrder(string order) {
//Make some coffee! ...
}
Stateless front-endsLoose couplingBuilding a thermostatRetrying on failuresLoosening consistency
Recap
class Employee : TableStorageEntity { public Employee(string firstName, string lastName) : base(firstName, lastName) //partition key, row key {} public string JobTitle { get; set; } }
... var qResult = from emp in
svc.CreateQuery<Employee>(EmployeeDataServiceContext.EmployeeTable)
where emp.PartitionKey == "Steve" && emp.RowKey == "Marx select emp;
Schema without versioning }
class Employee : TableStorageEntity { public Employee(string firstName, string lastName) : base(firstName, lastName) {} public string JobTitle { get; set; }
public int Version { get; set;
}
} ... var qResult = from emp in
svc.CreateQuery<Employee>(EmployeeDataServiceContext.EmployeeTable)
where emp.PartitionKey == "Steve" && emp.RowKey == "Marx
&& emp.Version == 1 select emp;
Schema *with* versioning }
ServiceDefinition.csdef
<ServiceDefinition name="DemoService"> <WebRole name="WebRole"> <ConfigurationSettings>
<Setting name="Color"/>
</ConfigurationSettings> </WebRole></ServiceDefinition>
ServiceConfiguration.cscfg
<ServiceConfiguration serviceName="DemoService"> <Role name="WebRole"> <ConfigurationSettings>
<Setting name ="Color" value ="Red"/>
</ConfigurationSettings> </Role></ServiceConfiguration>
Configuration files
<?xml version="1.0"?><ServiceConfiguration serviceName=“DemoService”>
<Role name="WebRole">
<Instances count="1"/> <ConfigurationSettings>
<Setting name ="LogLevel" value ="Verbose"/>
</ConfigurationSettings> </Role></ServiceConfiguration>
...
Configurable logging
if (RoleManager.GetConfigurationSetting("LogLevel") == "Verbose") RoleManager.WriteToLog("Information", "Some log message");
James Hamilton http://research.microsoft.com/~jamesrh/
Emre Kiciman http://research.microsoft.com/~emrek/
Pat Helland http://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 MacAskill http://blogs.smugmug.com/don/
Credits & Acknowledgements
Evals & Recordings
Please fill
out your
evaluation for
this session at:
This session will be available as a recording at:
www.microsoftpdc.com
© 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.