Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Scaling Big While Sleeping Well


Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Scaling Big While Sleeping Well

  1. 1. Scaling Big while Sleeping Well<br />Josh Holmes<br />@joshholmes<br /><br /><br />
  2. 2. Agenda<br />Testing the Waters<br />What is cloud computing?<br />What are the advantages of cloud computing?<br />How’s Azure fit in?<br />Diving Deep<br />Digging into PHP/Ruby on Azure<br />Leveraging FastCGI<br />Leveraging Azure Storage<br />Leveraging SQL Azure<br />
  3. 3. We are all excited about the cloud<br />
  4. 4. Cloud-Addressable Challenges<br />1<br />1<br />5<br />Maintaining security while increasing access and transparency—within and outside the organization<br />Infrastructure costs are fixed and ongoing, and distract from the mission of reducing business process friction<br />2<br />6<br />Leveraging past investments to provide future value<br />Security, access, and transparency across the value chain: suppliers, partners, etc.<br />3<br />Many data centers at limit—real estate, capacity, cooling and power<br />7<br />Lack of a common platform<br />4<br />Matching capacity to demand<br />
  5. 5. In House or Hosted Servers<br />Allocated IT-capacities<br />Load Forecast<br />“Under-supply“ of capacities<br />“Waste“ of capacities<br />Fixed cost of IT-capacities<br />IT CAPACITY<br />Barrier for<br />innovations<br />ActualLoad<br />TIME<br />
  6. 6. Cloud Computing<br />Load Forecast<br />Allocated IT capacities<br />No “under-supply“<br />IT CAPACITY<br />Reduction of “over-supply“<br />Possible reduction of IT-capacities in case of reduced load<br />Reduction of initial investments<br />ActualLoad<br />Time<br />
  7. 7. Types of Clouds<br />Platform<br />(as a Service)<br />Private<br />(On-Premise)<br />Infrastructure<br />(as a Service)<br />You manage<br />Applications<br />Applications<br />Applications<br />You manage<br />Runtimes<br />Runtimes<br />Runtimes<br />Security & Integration<br />Security & Integration<br />Security & Integration<br />Managed by vendor<br />Databases<br />Databases<br />Databases<br />You manage<br />Servers<br />Servers<br />Servers<br />Managed by vendor<br />Virtualization<br />Virtualization<br />Virtualization<br />Server HW<br />Server HW<br />Server HW<br />Storage<br />Storage<br />Storage<br />Networking<br />Networking<br />Networking<br />
  8. 8. The Microsoft Cloud<br />~100 Globally Distributed Data Centers<br />Quincy, WA<br />Chicago, IL<br />San Antonio, TX<br />Dublin, Ireland<br />Generation 4 DCs<br />
  9. 9.
  10. 10. Categories of Services<br />Application Services<br />Software Services<br />Platform Services<br />The Microsoft Cloud<br />Infrastructure Services<br />
  11. 11. The trick is knowing what your systems need,<br />and how the cloud can help.<br />
  12. 12. Not everything has to or can live in the cloud<br />
  13. 13. Only move to the cloud that which can benefit<br />
  14. 14. The core strategy is ‘hybrid’<br />
  15. 15. Take an À la carteapproach<br />
  16. 16. We call this Software + Services<br />
  17. 17. An Example…<br />
  18. 18. “Packaged”<br />Application<br />Big Pharmaceutical Example<br />Hosted <br />“Packaged”<br />“Packaged”<br />using cloud <br />“Software as a Service”<br />Buy<br />ERP<br />“Too costly to run this myself, but I’ve made too many customizations”<br />CRM<br />Email<br />Build vs. Buy<br />“Home Built”<br />Application<br />Hosted <br />“Home Built”<br />“Home Built”<br />using cloud <br />“Platform as a Service”<br />HR System<br />Molecule Research<br />Build<br />Clinical Trial<br />Hoster<br />Vendor<br />On Premise<br />Cloud<br />
  19. 19. “Packaged”<br />Application<br />Big Pharmaceutical Example<br />Hosted <br />“Packaged”<br />“Packaged”<br />using cloud <br />“Software as a Service”<br />Buy<br />ERP<br />CRM<br />“CRM and Email are commodity services – They have no customizations, and it’s cheaper for someone else to run these”<br />Email<br />Build vs. Buy<br />“Home Built”<br />Application<br />Hosted <br />“Home Built”<br />“Home Built”<br />using cloud <br />“Platform as a Service”<br />HR System<br />Molecule Research<br />Build<br />Clinical Trial<br />Hoster<br />Vendor<br />On Premise<br />Cloud<br />
  20. 20. Big Pharmaceutical Example<br />“Packaged”<br />Application<br />Hosted <br />“Packaged”<br />“Packaged”<br />using cloud <br />“Software as a Service”<br />Buy<br />ERP<br />CRM<br />Email<br />Build vs. Buy<br />“Home Built”<br />Application<br />Hosted <br />“Home Built”<br />“Home Built”<br />using cloud <br />“Platform as a Service”<br />“I can’t afford to maintain this old HR application written in VB4 – it’s driving me mad!”<br />HR System<br />“…but due to regulatory issues, I cannot store my HR data off-premise”<br />Molecule Research<br />Build<br />Clinical Trial<br />Hoster<br />Vendor<br />On Premise<br />Cloud<br />
  21. 21. “Packaged”<br />Application<br />Big Pharmaceutical Example<br />Hosted <br />“Packaged”<br />“Packaged”<br />using cloud <br />“Software as a Service”<br />Buy<br />ERP<br />CRM<br />Email<br />HR System<br />Build vs. Buy<br />“Home Built”<br />Application<br />Hosted <br />“Home Built”<br />“Home Built”<br />using cloud <br />“Platform as a Service”<br />“I wish I had access to cheaper compute and storage when I need it”<br />Molecule Research<br />Build<br />Clinical Trial<br />Hoster<br />Vendor<br />On Premise<br />Cloud<br />
  22. 22. “Packaged”<br />Application<br />Big Pharmaceutical Example<br />Hosted <br />“Packaged”<br />“Packaged”<br />using cloud <br />“Software as a Service”<br />Buy<br />ERP<br />CRM<br />Email<br />HR System<br />Build vs. Buy<br />“Home Built”<br />Application<br />Hosted <br />“Home Built”<br />“Home Built”<br />using cloud <br />“Platform as a Service”<br />Molecule Research<br />Build<br />“THIS is where I want to spend my IT resources – I’m going to double down on this application!”<br />Clinical Trial<br />Hoster<br />Vendor<br />On Premise<br />Cloud<br />
  23. 23. Where the Cloud is Compelling<br />
  24. 24. Only 2 reasons to use the cloud<br />
  25. 25. Windows Azure VMs<br />Small<br />Medium<br />Large <br />X Large<br />$0.12 <br />$0.24 <br />$0.48 <br />$0.96 <br />Per service hour<br />Per service hour<br />Per service hour<br />Per service hour<br />1 x 1.6Ghz <br />2 x 1.6Ghz <br />4 x 1.6Ghz <br />8 x 1.6Ghz<br />(moderate IO) <br />(high IO)<br />(high IO) <br />(high IO)<br />1.75 GB memory <br />3.5 GB memory <br />7.0 GB memory<br />14 GB memory<br />
  26. 26. Windows Azure, In One Picture<br />Business Portal<br />Developer Portal<br />Service Management Service<br />REST<br />User Code<br />…<br />…<br />Runtime API<br />Storage Cluster<br />VS Tools<br />Compute Cluster<br />…<br />WA SDK<br />VM Setup<br />REST<br />MSFT Datacenters<br />Desktop<br />Cloud VM<br />
  27. 27. Determine an ROI<br />Consider:<br /><ul><li>Current hosting costs
  28. 28. Current staff costs
  29. 29. Cooling/power/space
  30. 30. Migration costs
  31. 31. Licensing</li></ul><br />
  32. 32.
  33. 33. ZENDFRAMEWORK<br />
  34. 34. Digging into Azure with PHP/Ruby<br />
  35. 35. Windows Azure, In One Picture<br />Business Portal<br />Developer Portal<br />Service Management Service<br />REST<br />User Code<br />…<br />…<br />Runtime API<br />Storage Cluster<br />VS Tools<br />Compute Cluster<br />…<br />WA SDK<br />VM Setup<br />REST<br />MSFT Datacenters<br />Desktop<br />Cloud VM<br />
  36. 36. Windows Azure Roles<br />WorkerRole<br /><ul><li>Internal Facing
  37. 37. TCP/HTTP Endpoint
  38. 38. Long running processes
  39. 39. Think Service or Deamon</li></ul>WebRole<br /><ul><li>External Facing
  40. 40. HTTP/HTTPS Endpoint
  41. 41. Short lived calls
  42. 42. Think Web Server</li></li></ul><li>Running PHP in Windows Azure<br />How to Do It<br />Host in Web role (like .NET)<br />Supply PHP runtime<br />Point to runtime via FastCGI configuration in<br />Web.config<br />Web.roleConfig<br />PHP <br />Web Role<br />Instance 1<br />VIP<br />Load Balancer<br />PHP <br />Web Role<br />Instance 2<br />
  43. 43. Windows Azure 4 Eclipse<br />Does a lot of the heavy lifting for you<br />Creates the Web.config, Web.roleConfig, PHP implementation and debugs in the dev fabric<br /><br />
  44. 44. Running EXEs in the Worker Process<br />Start with a Worker Role Process to <br />Copy the exes to the worker role’s app directory<br />Execute the process<br />Monitor the health of the process<br />Other auxiliary tasks…<br />
  45. 45. Running Ruby in the Worker Process<br /><br />Download and extract the solution <br />Copy the Ruby bin and lib folders to the Ruby folder in the RR project <br />Copy your rails application to the RailsApp folder in the RR project <br />Open the solution in Visual Studio <br />Run in the Dev Fabric<br />Navigate to<br />
  46. 46. Data Storage<br />
  47. 47. Storage options<br />Windows Azure Data<br />Sql Azure<br />
  48. 48. Windows Azure Data Storage<br />Queue<br />Blob<br />Account<br />Tables<br />Drives<br />
  49. 49. Azure Platform Data Storage Options<br /><ul><li>Windows Azure Data Storage
  50. 50. Blobs
  51. 51. Unstructured data storage
  52. 52. Tables
  53. 53. Semi-structured or tabular data storage
  54. 54. Queues
  55. 55. Buffered delivery data storage
  56. 56. Drives
  57. 57. Durable NTFS volumes that Windows Azure applications can use. See:</li></ul>SQL Azure<br /><ul><li>Relational data storage</li></li></ul><li>Admin Windows Azure Data Storage<br />
  58. 58. Windows Azure Data Storage<br />
  59. 59. PHP with Windows Azure Storage<br />Windows Azure SDK for PHP @<br />PHP programming model for Windows Azure Storage<br />Features <br />PHP classes for Blobs, Tables & Queues<br />Store PHP sessions in Table Storage<br />
  60. 60. Windows Azure Data Storage - Blobs<br />Unstructured data storage<br />Partitioned by container<br />Unlimited containers<br />
  61. 61. Blobs Sample<br />$blobStorage= new Microsoft_WindowsAzure_Storage_Blob();<br />// Create<br />if (!$blobStorage->containerExists($containerName))<br />{<br />$blobStorage->createContainer($containerName);<br />$blobStorage->setContainerAcl($containerName, <br />Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC);<br />}<br />// Store<br />$blob = $blobStorage->putBlob($containerName, $blobName, <br />$localFilename, $metadata);<br />/* @var $blob Microsoft_WindowsAzure_Storage_BlobInstance */<br />
  62. 62. Blobs Sample Cont…<br />// Copy<br />$result = $blobStorage->copyBlob(<br /> $containerName, $blobName, $containerName, $blob2Name);<br />// Retrieve<br />$tempStore= azure_getlocalresourcepath('tempstore');<br />$tempPath= $tempStore. 'apos; . $imageId;<br />$blobStorage->getBlob($containerName, $blobName, $tempPath);<br />// Delete<br />$result = $blobStorage->deleteBlob($containerName, $blobName);<br />$result = $blobStorage->deleteContainer($containerName);<br />
  63. 63. Blob Stream Wrapper<br />$blobStorage= new Microsoft_WindowsAzure_Storage_Blob();<br />// Register:<br />$blobStorage->registerStreamWrapper(); // registers azure://<br />// or<br />$blobStorage->registerStreamWrapper('blob://'); // use blob://<br />// Use<br />$fp= fopen('azure://mycontainer/myfile.txt', 'r');<br />// ...<br />fclose($fp);<br />
  64. 64. Storage: XDrive<br />NTFS drive in the cloud: X:<br />Fixed size between 16MB and 1TB<br />Max 8 drives on your VM<br />Implemented as a page blob<br />Single instance write<br />Multiple instance read<br />
  65. 65. Queue Workflow Concepts<br />Windows Azure Queue Provides<br />Guarantee delivery (two-step consumption)<br />Worker Dequeues Message and mark it as Invisible<br />Worker Deletes Message when finished processing it<br />If Worker role crashes, message becomes visible for another Worker to process<br />Doesn’t guarantee “only once” delivery<br />Doesn’t guarantee ordering<br />Best effort FIFO<br />Worker Role<br />Web Role<br />Input Queue (Work Items)<br />Worker Role<br />Azure Queue<br />Web Role<br />Worker Role<br />Web Role<br />Worker Role<br />
  66. 66. Azure Queues<br />RemoveMessage<br />GetMessage (Timeout)<br />Worker Role<br />PutMessage<br />Queue<br />Msg 1<br />Msg 2<br />Msg 2<br />Msg 1<br />Web Role<br />Worker Role<br />Worker Role<br />Msg 3<br />Msg 4<br />Msg 2<br />
  67. 67. Loosely Coupled Work with Queues<br />Worker-Queue Model<br />Load work in a queue<br />Many workers consume the queue<br />Input Queue (Work Items)<br />Azure Queue<br />Worker Role<br />Web Role<br />Worker Role<br />Web Role<br />Worker Role<br />Web Role<br />Worker Role<br />
  68. 68. Queues<br />$queueClient= new Microsoft_WindowsAzure_Storage_Queue();<br />// Create<br />$result = $queueClient->createQueue('imageQueue');<br />// Delete<br />$queueClient->deleteQueue('imageQueue');<br />// Add message<br />$queueClient->putMessage('imageQueue', $message, $ttl);<br />// Retrieve Messages<br />$messages = $queueClient->getMessages('imageQueue', 10);<br />foreach($messages as $message) {<br />// Do work here...<br />$queueClient->deleteMessage('imageQueue', $message);<br />}<br />
  69. 69. Windows Azure Data Storage - Tables<br />Semi-Structured data<br />Tables contain entities<br />Entities contain properties<br />May be partitioned across thousands of servers.<br />Support ACID transactions over single entities<br />Queries over entire table<br />.NET and REST interfaces<br />
  70. 70. Windows Azure Data Storage – Tables (Terms Part 1)<br />Table<br />Contains a set of entities. <br />Entity (Row) <br />Basic data items stored in a table. <br />Property (Column)<br />Single value in an entity. <br />RowKey<br />Unique ID of the entity within a partition<br />Timestamp<br />Time it was created<br />
  71. 71. Windows Azure Data Storage – Tables (Terms Part 2)<br />Partition <br />Entities in a table with the same partition key<br />PartitionKey<br />Segments entities in to partitions to automatically distribute the table’s entities over many storage nodes.<br />Sort Order<br />There is a single index provided for the CTP, where all entities in a table are sorted by PartitionKey and then RowKey<br />
  72. 72. Key Example – Blog Posts<br />Partition 1<br />Partition 2<br />Getting all of dunnry’s blog posts is fast<br />Single partition<br />Getting all posts after 2008-03-27 is slow<br />Traverse all partitions<br />
  73. 73. Table Sample<br />$tableStorage= new Microsoft_WindowsAzure_Storage_Table(<br />'', 'myaccount', 'myauthkey');<br />// Create<br />$result = $tableStorage->createTable($tableName);<br />// List <br />$result = $tableStorage->listTables();<br />foreach($result as $table) {<br />echo 'Table name is: ' . $table->Name . " ";<br />}<br />// Delete<br />$tableStorage->deleteTable($tableName);<br />
  74. 74. Tables with Entities<br />// Structured entity<br />class ImageEntityextends <br />Microsoft_WindowsAzure_Storage_TableEntity<br />{<br />/**<br /> * @azure filename<br /> */<br />public $filename;<br />/**<br /> * @azure size Edm.Int64<br /> */<br />public $size;<br />}<br />// Unstructured entity<br />// Microsoft_WindowsAzure_Storage_DynamicTableEntity<br />
  75. 75. Tables with Entities Cont…<br />// Insert<br />$image = new ImageEntity($partitionKey, $rowKey);<br />$image->filename = $_FILES['imageUpload']['name'];<br />$image->size = $_FILES['imageUpload']['size'];<br />$image = $tableStorageClient->insertEntity($tableName, $image);<br />// Retrieve<br />$image = $tableStorage->retrieveEntityById($tableName, <br />$partitionKey, $rowKey, 'ImageEntity');<br />// Update<br />$image->filename = 'newname.jpg';<br />$result = $tableStorage->updateEntity($tableName, $image);<br />// Delete<br />$result = $tableStorage->deleteEntity($tableName, $image);<br />
  76. 76. Table Queries<br />// Filter condition<br />$select = "filesizegt 1024 and PartitionKeyeq '$partitionKey'";<br />// Or fluent interface<br />$select = $tableStorage->select()->from($tableName)<br /> ->where('filesizegt 1024')<br /> ->andWhere('PartitionKeyeq ?', $partitionKey);<br />// Run query<br />$images = $tableStorage->storageClient->retrieveEntities(<br />'testtable', $select, 'ImageEntity'<br />);<br />foreach($images as $image) {<br />echo 'Name: ' . $image->filename . " ";<br />}<br />
  77. 77. Batching Operations<br />// Start batch<br />$batch = $tableStorage->startBatch();<br />// Insert multiple<br />$images = generateEntities();<br />foreach($images as $image) {<br />$tableStorage->insertEntity($tableName, $image);<br />}<br />// Commit<br />$batch->commit();<br />
  78. 78. Table session handler<br />$sessionHandler<br /> = new Microsoft_WindowsAzure_SessionHandler($tableStorage);<br />$sessionHandler->register();<br />session_start();<br />if (!isset($_SESSION['start'])) {<br />$_SESSION['start'] = time();<br />}<br />
  79. 79. SQL Azure and Windows Azure Table Comparison<br />Windows Azure Tables<br />SQL Azure Tables<br />Semi-structured<br />Loosely typed<br />Non-Relational (Not RDMS)<br />Massively scalable<br />Fully structured<br />Strongly typed<br />Relational (RDMS)<br />Highly scalable<br />
  80. 80. MySQL: Simple Configuration<br />VIP<br />Load Balancer<br />Web Role<br />MySQL<br />Worker Role<br />
  81. 81. MySQL in a Windows Azure Application<br />Running MySQL in a worker role<br />Copy MySQL to the worker role sub-directory<br />Copy to read-write local storage<br />Configure MySQL to listen on the right port<br />Monitor MySQL health<br />Consuming MySQL<br />Discover IP address and port<br />Normal access from then on<br />Handle topology changes<br />
  82. 82. Simple Configuration<br />VIP<br />Load Balancer<br />MySQL<br />
  83. 83. Replication<br />VIP<br />Load Balancer<br />M<br />S<br />S<br />MySQL<br />MySQL<br />MySQL<br />
  84. 84. Windows Azure Drive with Hot Spare<br />VIP<br />Load Balancer<br />MySQL<br />MySQL<br />
  85. 85. Windows Azure Drive with Hot Spare<br />VIP<br />Load Balancer<br />MySQL<br />MySQL<br />
  86. 86. SQL Azure<br />
  87. 87. SQL Azure Features<br />Supported<br />Tables, Indexes, Views<br />Stored Procedures<br />Triggers<br />Constraints<br />Table Variables<br />Temp Tables (#Name)<br />Not Supported<br />Physical Server Access <br />Catalog DDL<br />Common Language Runtime<br />Service Broker<br />Reporting Services<br />Analysis Services<br />Distributed Transactions and Queries<br />
  88. 88. SQL AzureDeployment<br />Web Portal<br />(API)<br />DB Script<br />SQL Azure<br />TDS<br />
  89. 89. SQL AzureAccessing databases<br />Web Portal<br />(API)<br />Your App<br />SQL Azure<br />TDS<br />Change Connection String<br />
  90. 90. Database Replicas<br />Single Database<br />Multiple Replicas<br />Replica 1<br />Single Primary<br />Replica 2<br />DB<br />Replica 3<br />
  91. 91. SQL AzureDatabase Monitoring & Recovery<br />Web Portal<br />(API)<br />!<br />Your App<br />SQL Azure<br />TDS<br />
  92. 92. SQL Azure Server Creation<br />
  93. 93. SQL Azure Firewall Maintenance<br /><ul><li>Simple rules
  94. 94. Easy one-screen portal maintenance</li></li></ul><li>SQL Azure Database Connection String<br />An administrative user is created with the server<br />User has system administrator permissions likesa”<br />; Database=FabrikamAzureDB;User ID=SaPaulM;Password=myPassword;Trusted_Connection=False;Encrypt=True;<br />
  95. 95. Database Migrations<br />Scripts<br />Transfer Schema<br />BCP<br />Transfer Data<br />SSIS (SQL Server Integration Service)<br />Transfer Schema and Data<br />
  96. 96. Database Migrations (Cont.)<br />The SQL Azure Migration Wizard helps you migrate your local SQL Server 2005 / 2008 databases into SQL Azure. The wizard walks you through the selection of your SQL objects, creates SQL scripts suitable for SQL Azure, and allows you to migrate your data.”<br /><br />
  97. 97. Database Management using SQL Management Studio<br />
  98. 98. PHP with SQL Azure<br />SQL Server Driver for PHP @<br />Supports PHP access to SQL Azure<br />Features<br />Choose between SQL Server and SQL Azure by changing connection string<br />Use from on-premises or in Windows Azure<br />
  99. 99.
  100. 100. More resources<br />Microsoft Windows Azure Interop<br /><br />Interop Bridges<br /><br />
  101. 101. More resources<br />PHP<br /><br /><br />MySQL<br />Windows Azure MySQL PHP Solution Accelerator<br /><br />
  102. 102. More resources<br />Python<br />Sriram Krishnan<br /><br />Ruby<br />Simon Davies<br /><br /><br />Johnny Halife<br /><br /><br />
  103. 103. And of course<br />Josh Holmes<br /><br />
  104. 104. Scaling Big while Sleeping Well<br />Josh Holmes<br />@joshholmes<br /><br /><br />