Open a Window, see the clouds                          Rafael Dohms   photo credit: Denis GrzeticWednesday, May 25, 2011
Rafael Dohms                                                          photo credit: Eli White        PHP Evangelist and ZC...
PEEKING OUT THE WINDOW   • What                  is the Cloud?   • Why                  choose the Cloud?   • Let’s       ...
WHAT IS THE CLOUD?                          not just another buzzword bingo wordWednesday, May 25, 2011
REGULAR HOSTING   • Shared  account, VPS or Local       Machine   • One            machine, one place   • Pay         by m...
Self                          REGULAR HOSTING   • Shared  account, VPS or Local       Machine   • One            machine, ...
CLOUD COMPUTING   •   Less “physical attachment”   •   One or multiple machines or       “instances”   •   Geologically sp...
Data                             Application                              Software                          Operating Syst...
Storing         Data          Sharing                Deploying       Application     Developing                   MySQL   ...
IaaS a Service”                          “Infrastructure as                                     Data                      ...
IaaS a Service”                          “Infrastructure as                                     Data                      ...
PaaS                          “Platform as a Service”                                    Data                             ...
PaaS                          “Platform as a Service”                                    Data                             ...
SaaS                          “Software as a Service”                                    Data                             ...
SaaS                          “Software as a Service”                                    Data            you              ...
X     WHY CHOOSE THE CLOUD?                     What are the advantages of using the cloud?Wednesday, May 25, 2011
traffic                                              time                          THE UTILITY MODELWednesday, May 25, 2011
traffic                                              time                          THE UTILITY MODELWednesday, May 25, 2011
traffic            peak                                              time                          THE UTILITY MODELWednesd...
traffic            peak                                              time                          THE UTILITY MODELWednesd...
traffic            peak                                              time                          THE UTILITY MODELWednesd...
IaaS   Paas   SaaS                            costs            server managment.     software management                  ...
AVAILABILITYWednesday, May 25, 2011
AVAILABILITYWednesday, May 25, 2011
AVAILABILITYWednesday, May 25, 2011
SCALABILITY                          Stateless Compute + Durable StorageWednesday, May 25, 2011
SCALABILITY                          Stateless Compute + Durable StorageWednesday, May 25, 2011
LET’S LOOK INSIDEWednesday, May 25, 2011
Windows Azure Overview                                     Fabric                           Compute            StorageWedn...
Fabric                          Middleware, used for developing, deploying and                                   managing ...
Fabric                          Compute            StorageWednesday, May 25, 2011
Compute                   Web Role        Worker Role      VM Role                                                  Window...
Fabric                          Compute            StorageWednesday, May 25, 2011
Cached version of                                                     CDN           any resource in                       ...
UP & RUNNING                                for Development and Deployment   • Requisites:        • IIS7 Tools        • Az...
BASIC TOOLSET   • Command                  Line tools for PHP        • Packages  applicationand runs in emulator, with sim...
Developer Environment                               Azure Emulator                   Code                                (...
Developer Environment                               Azure Emulator                   Code                                (...
Developer Environment                               Azure Emulator                   Code                                (...
Developer Environment                                           Azure Emulator                    Code                    ...
Developer Environment                               Azure Emulator                   Code                                (...
THE GOOD   • REST APIs        • Storage        • Diagnostics   • Relational           DB: SQL Azure   • Role ArchitectureW...
THE BAD   • Windows-only         Management        • No   Azure Emulator for            non-Windows OS        • No    Pack...
HOW DOES THAT AFFECT CODE?         What tools can we use and how should we design our appsWednesday, May 25, 2011
WHAT DO I WORRY ABOUT?Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?                CodeWednesday, May 25, 2011
WHAT DO I WORRY ABOUT?                Code      PHP on IIS/WindowsWednesday, May 25, 2011
WHAT DO I WORRY ABOUT?         Architecture                Code      PHP on IIS/WindowsWednesday, May 25, 2011
WHAT DO I WORRY ABOUT?              Scaling         Architecture                Code      PHP on IIS/WindowsWednesday, May...
WHAT DO I WORRY ABOUT?              Scaling     No Local Storage         Architecture                Code      PHP on IIS/...
WHAT DO I WORRY ABOUT?              Scaling     No Local Storage     Session sharing         Architecture                C...
WHAT DO I WORRY ABOUT?              Scaling     No Local Storage     Session sharing                          Worker Roles...
WHAT DO I WORRY ABOUT?              Scaling     No Local Storage        Session sharing                          Worker Ro...
WHAT DO I WORRY ABOUT?              Storage              Scaling     No Local Storage        Session sharing              ...
WHAT DO I WORRY ABOUT?               What kind?              Storage              Scaling       No Local Storage        Se...
WHAT DO I WORRY ABOUT?                              Table / Blob               What kind?              Storage            ...
WHAT DO I WORRY ABOUT?                              Table / Blob     Framework or PHP SDK               What kind?        ...
WHAT DO I WORRY ABOUT?                              Table / Blob     Framework or PHP SDK               What kind?        ...
WHAT DO I WORRY ABOUT?                              Table / Blob     Framework or PHP SDK               What kind?        ...
AZURE-READY FRAMEWORKSWednesday, May 25, 2011
WHAT MAKES IT COMPATIBLE?                    Code     Does it run on PHP on Windows?                    Tools       Does i...
Tools   •   Blobs, Tables and Queues       (CRUD operations)   •   Helper Classes for HTTP       transport, AuthN/AuthZ, R...
Database   • MS-SQL    Drivers* are       compatible with       SQLAzure    * Using pdo_sql_server, possibly pdo_dblib    ...
• PHP     code runs normally,            in Azure so any            framework will work.        • You     will need other ...
AZURE PHP SDK   • Services:        • Blob            Storage        • Table            Storage        • Queue             ...
GOING OUT THE WINDOW                                Sample migration to the cloud   • Sample Application: “Twitter        ...
GOING OUT THE WINDOW                                Sample migration to the cloud   • Sample Application: “Twitter        ...
Twitter OAuth                           Wait for it...Wednesday, May 25, 2011
Twitter OAuth                           Wait for it...Wednesday, May 25, 2011
Twitter OAuth                           Wait for it...Wednesday, May 25, 2011
Twitter OAuth                           Wait for it...                                            MySQLWednesday, May 25, ...
Twitter OAuth                           Wait for it...                                            MySQL                   ...
Twitter OAuth                           Wait for it...                                            MySQL                   ...
Twitter OAuth                           Wait for it...                                            MySQL                   ...
Twitter OAuth                          Don’t call me, i’ll                             call youWednesday, May 25, 2011
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
Twitter OAuth                                                Queue                          Don’t call me, i’ll           ...
USING SQLAZURE                                                                      PDO MSSQL Driver                      ...
LINE THEM UP IN THE QUEUE                          //Add user to our Queue                          $qItem = new stdClass(...
LINE THEM UP IN THE QUEUE                          //Add user to our Queue                          $qItem = new stdClass(...
LINE THEM UP IN THE QUEUE                          //Add user to our Queue                          $qItem = new stdClass(...
while (true){        try{               $this->logAction("Checking for messages...");          FIRST COME,               /...
while (true){        try{               $this->logAction("Checking for messages...");          FIRST COME,               /...
while (true){        try{               $this->logAction("Checking for messages...");          FIRST COME,               /...
while (true){        try{               $this->logAction("Checking for messages...");          FIRST COME,               /...
while (true){        try{               $this->logAction("Checking for messages...");          FIRST COME,               /...
while (true){        try{               $this->logAction("Checking for messages...");          FIRST COME,               /...
GOING OUT THE WINDOW   • See          all changes: github.com/rdohms/Sample-Azure-App   • Compare              these branc...
LOOKING BACK BEFORE                  CLOSING THE WINDOW   • Found                out what is the Cloud   • Looked         ...
FURTHER READING...       PHP Development in the       Cloud       ISBN: 9780981034522       Pages: 172       Authors: Ivo ...
GET STARTED, GET HELP   • Get          a free account: WindowsAzurePass.com   • Talk                 to the Microsoft guys...
twitter.com/rdohmshttp://doh.ms                           Questions?                           rafael@doh.ms              ...
Upcoming SlideShare
Loading in...5
×

Open a window, see the clouds - php|tek 2011

6,347

Published on

Is your application ready to take off into the cloud? What does this mean? What do you need to worry about? What frameworks and tools do you need to look at and what new concepts do you need to put in your PHP toolbox to prepare? Get acquainted with Microsoft Azure's platform and features, and discover what tools and frameworks are ready to benefit from this new paradigm.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,347
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
22
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Open a window, see the clouds - php|tek 2011

  1. 1. Open a Window, see the clouds Rafael Dohms photo credit: Denis GrzeticWednesday, May 25, 2011
  2. 2. Rafael Dohms photo credit: Eli White PHP Evangelist and ZCE in Brazil and a very active member of the PHP Community. He helped found two PHP User Groups over the years and currently shares the lead of PHPSP. Developer, gamer and lover of code he also hosts Brazil’s first PHP Podcast: PHPSPCast.  Currently he works for MIH SWAT Team, a group of experts that provides technical knowledge to the MIH group as well as working on R&D in search of the new and exciting niches of the web. His role as a Senior PHP Developer is to code, train and aid other companies and to have fun doing so.Wednesday, May 25, 2011
  3. 3. PEEKING OUT THE WINDOW • What is the Cloud? • Why choose the Cloud? • Let’s take a look at Windows Azure • How does that affect my code?Wednesday, May 25, 2011
  4. 4. WHAT IS THE CLOUD? not just another buzzword bingo wordWednesday, May 25, 2011
  5. 5. REGULAR HOSTING • Shared account, VPS or Local Machine • One machine, one place • Pay by monthWednesday, May 25, 2011
  6. 6. Self REGULAR HOSTING • Shared account, VPS or Local Machine • One machine, one place • Pay by monthWednesday, May 25, 2011
  7. 7. CLOUD COMPUTING • Less “physical attachment” • One or multiple machines or “instances” • Geologically spread • Pay per hour/usage/data • “abstraction” of resources • 3 Flavors: IaaS, PaaS, SaaSWednesday, May 25, 2011
  8. 8. Data Application Software Operating System Hardware/NetworkWednesday, May 25, 2011
  9. 9. Storing Data Sharing Deploying Application Developing MySQL Software Apache Configuring Operating System Upgrading Cooling Hardware/Network CablingWednesday, May 25, 2011
  10. 10. IaaS a Service” “Infrastructure as Data Application Software Operating System Hardware/NetworkWednesday, May 25, 2011
  11. 11. IaaS a Service” “Infrastructure as Data Application Software Operating System you them Hardware/NetworkWednesday, May 25, 2011
  12. 12. PaaS “Platform as a Service” Data Application Software Operating System Hardware/NetworkWednesday, May 25, 2011
  13. 13. PaaS “Platform as a Service” Data Application you them Software Operating System Hardware/NetworkWednesday, May 25, 2011
  14. 14. SaaS “Software as a Service” Data Application Software Operating System Hardware/NetworkWednesday, May 25, 2011
  15. 15. SaaS “Software as a Service” Data you them Application Software Operating System Hardware/NetworkWednesday, May 25, 2011
  16. 16. X WHY CHOOSE THE CLOUD? What are the advantages of using the cloud?Wednesday, May 25, 2011
  17. 17. traffic time THE UTILITY MODELWednesday, May 25, 2011
  18. 18. traffic time THE UTILITY MODELWednesday, May 25, 2011
  19. 19. traffic peak time THE UTILITY MODELWednesday, May 25, 2011
  20. 20. traffic peak time THE UTILITY MODELWednesday, May 25, 2011
  21. 21. traffic peak time THE UTILITY MODELWednesday, May 25, 2011
  22. 22. IaaS Paas SaaS costs server managment. software management product deployWednesday, May 25, 2011
  23. 23. AVAILABILITYWednesday, May 25, 2011
  24. 24. AVAILABILITYWednesday, May 25, 2011
  25. 25. AVAILABILITYWednesday, May 25, 2011
  26. 26. SCALABILITY Stateless Compute + Durable StorageWednesday, May 25, 2011
  27. 27. SCALABILITY Stateless Compute + Durable StorageWednesday, May 25, 2011
  28. 28. LET’S LOOK INSIDEWednesday, May 25, 2011
  29. 29. Windows Azure Overview Fabric Compute StorageWednesday, May 25, 2011
  30. 30. Fabric Middleware, used for developing, deploying and managing your applications AppFabric developerWednesday, May 25, 2011
  31. 31. Fabric Compute StorageWednesday, May 25, 2011
  32. 32. Compute Web Role Worker Role VM Role Windows Server Web application Background 2008 instance that running on top of processing can be loaded on IIS demandWednesday, May 25, 2011
  33. 33. Fabric Compute StorageWednesday, May 25, 2011
  34. 34. Cached version of CDN any resource in storage with a URI Storage Data Storage Table Storage Blob Storage SQL Azure Queue Text and binary Compatible with Messaging between Structured Storage data SQL Server Web and WorkerWednesday, May 25, 2011
  35. 35. UP & RUNNING for Development and Deployment • Requisites: • IIS7 Tools • Azure SDK (install DevAppFabric, the azure emulator) • Command Line Tools • Command line tools for PHPWednesday, May 25, 2011
  36. 36. BASIC TOOLSET • Command Line tools for PHP • Packages applicationand runs in emulator, with simulated compute and storage. • Azure Tools for Eclipse • Makes most processes a click-through process and gives you a nice IDEWednesday, May 25, 2011
  37. 37. Developer Environment Azure Emulator Code (Dev fabric) Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure StorageWednesday, May 25, 2011
  38. 38. Developer Environment Azure Emulator Code (Dev fabric) PHP Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure StorageWednesday, May 25, 2011
  39. 39. Developer Environment Azure Emulator Code (Dev fabric) PHP Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure StorageWednesday, May 25, 2011
  40. 40. Developer Environment Azure Emulator Code (Dev fabric) php package.php PHP --project="twitter-azure" Packaging tools --target="c:azure-build" (command line or eclipse) --source="C:twitter-azure" Package + Service --defaultDoc="public/index.php" Configuration --phpRuntime="C:Program Files (x86)PHPv5.3" --cleanRebuild --runDevFabric Azure Window Azure (AppFabric) SQLAzure StorageWednesday, May 25, 2011
  41. 41. Developer Environment Azure Emulator Code (Dev fabric) PHP Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure StorageWednesday, May 25, 2011
  42. 42. THE GOOD • REST APIs • Storage • Diagnostics • Relational DB: SQL Azure • Role ArchitectureWednesday, May 25, 2011
  43. 43. THE BAD • Windows-only Management • No Azure Emulator for non-Windows OS • No Packaging Command Line tools for non-Windows OSWednesday, May 25, 2011
  44. 44. HOW DOES THAT AFFECT CODE? What tools can we use and how should we design our appsWednesday, May 25, 2011
  45. 45. WHAT DO I WORRY ABOUT?Wednesday, May 25, 2011
  46. 46. WHAT DO I WORRY ABOUT? CodeWednesday, May 25, 2011
  47. 47. WHAT DO I WORRY ABOUT? Code PHP on IIS/WindowsWednesday, May 25, 2011
  48. 48. WHAT DO I WORRY ABOUT? Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  49. 49. WHAT DO I WORRY ABOUT? Scaling Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  50. 50. WHAT DO I WORRY ABOUT? Scaling No Local Storage Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  51. 51. WHAT DO I WORRY ABOUT? Scaling No Local Storage Session sharing Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  52. 52. WHAT DO I WORRY ABOUT? Scaling No Local Storage Session sharing Worker Roles Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  53. 53. WHAT DO I WORRY ABOUT? Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  54. 54. WHAT DO I WORRY ABOUT? Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  55. 55. WHAT DO I WORRY ABOUT? What kind? Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  56. 56. WHAT DO I WORRY ABOUT? Table / Blob What kind? Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  57. 57. WHAT DO I WORRY ABOUT? Table / Blob Framework or PHP SDK What kind? Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  58. 58. WHAT DO I WORRY ABOUT? Table / Blob Framework or PHP SDK What kind? Relational Database Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  59. 59. WHAT DO I WORRY ABOUT? Table / Blob Framework or PHP SDK What kind? Relational Migrate to SQL Azure Database Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/WindowsWednesday, May 25, 2011
  60. 60. AZURE-READY FRAMEWORKSWednesday, May 25, 2011
  61. 61. WHAT MAKES IT COMPATIBLE? Code Does it run on PHP on Windows? Tools Does it have API Handlers? Database Does it offer MS SQL Compatibility?Wednesday, May 25, 2011
  62. 62. Tools • Blobs, Tables and Queues (CRUD operations) • Helper Classes for HTTP transport, AuthN/AuthZ, REST and Error Management • Manageability, Instrumentation and Logging support Database • Not tested, but should work well.Wednesday, May 25, 2011
  63. 63. Database • MS-SQL Drivers* are compatible with SQLAzure * Using pdo_sql_server, possibly pdo_dblib Powered by Doctrine:Wednesday, May 25, 2011
  64. 64. • PHP code runs normally, in Azure so any framework will work. • You will need other tools to communicate with resources like: DB, Queue, etc... • These have been tested!Wednesday, May 25, 2011
  65. 65. AZURE PHP SDK • Services: • Blob Storage • Table Storage • Queue Storage • Diagnostic Tools • Compatible with PHP 5+Wednesday, May 25, 2011
  66. 66. GOING OUT THE WINDOW Sample migration to the cloud • Sample Application: “Twitter RT Calculator” • Objective: Analyse your latest tweets that were ReTweeted, and calculate stats based on locations and words. • Show how to migrate: • Database: MySQL > SQLAzure • Move processing into a worker role using the QueueWednesday, May 25, 2011
  67. 67. GOING OUT THE WINDOW Sample migration to the cloud • Sample Application: “Twitter RT Calculator” • Objective: Analyse your latest tweets that were ReTweeted, and calculate stats based on locations and words. • Show how to migrate: • Database: MySQL > SQLAzure • Move processing into a worker role using the QueueWednesday, May 25, 2011
  68. 68. Twitter OAuth Wait for it...Wednesday, May 25, 2011
  69. 69. Twitter OAuth Wait for it...Wednesday, May 25, 2011
  70. 70. Twitter OAuth Wait for it...Wednesday, May 25, 2011
  71. 71. Twitter OAuth Wait for it... MySQLWednesday, May 25, 2011
  72. 72. Twitter OAuth Wait for it... MySQL ResultsWednesday, May 25, 2011
  73. 73. Twitter OAuth Wait for it... MySQL ResultsWednesday, May 25, 2011
  74. 74. Twitter OAuth Wait for it... MySQL ResultsWednesday, May 25, 2011
  75. 75. Twitter OAuth Don’t call me, i’ll call youWednesday, May 25, 2011
  76. 76. Twitter OAuth Queue Don’t call me, i’ll call youWednesday, May 25, 2011
  77. 77. Twitter OAuth Queue Don’t call me, i’ll call you WorkerWednesday, May 25, 2011
  78. 78. Twitter OAuth Queue Don’t call me, i’ll call you WorkerWednesday, May 25, 2011
  79. 79. Twitter OAuth Queue Don’t call me, i’ll call you WorkerWednesday, May 25, 2011
  80. 80. Twitter OAuth Queue Don’t call me, i’ll call you Worker SQLAzureWednesday, May 25, 2011
  81. 81. Twitter OAuth Queue Don’t call me, i’ll call you Worker SQLAzureWednesday, May 25, 2011
  82. 82. Twitter OAuth Queue Don’t call me, i’ll call you Worker Results SQLAzureWednesday, May 25, 2011
  83. 83. Twitter OAuth Queue Don’t call me, i’ll call you Worker Worker Worker Worker Worker Worker Worker Worker Worker Worker Worker Results SQLAzureWednesday, May 25, 2011
  84. 84. USING SQLAZURE PDO MSSQL Driver doctrine.dbal.connection_options: driver: pdo_sqlsrv dbname: twitter-sample-app host: pl69qjwy8k.database.windows.net port: 1433 user: rdohmsDemo@pl69qjwy8k password: *password*Wednesday, May 25, 2011
  85. 85. LINE THEM UP IN THE QUEUE //Add user to our Queue $qItem = new stdClass(); $qItem->twitter_handle = $twitterInfo->screen_name; $qManager = new AzureQueue($this->getApp()->getConfig(azure)); $qManager->addToQueue($qItem);Wednesday, May 25, 2011
  86. 86. LINE THEM UP IN THE QUEUE //Add user to our Queue $qItem = new stdClass(); $qItem->twitter_handle = $twitterInfo->screen_name; $qManager = new AzureQueue($this->getApp()->getConfig(azure)); $qManager->addToQueue($qItem); $this->client = new Zend_Service_WindowsAzure_Storage_Queue( $qConfig[host], $qConfig[accountName], $qConfig[accountKey] ); $this->queue = $this->getQueueInstance($queueName); __contruct()Wednesday, May 25, 2011
  87. 87. LINE THEM UP IN THE QUEUE //Add user to our Queue $qItem = new stdClass(); $qItem->twitter_handle = $twitterInfo->screen_name; $qManager = new AzureQueue($this->getApp()->getConfig(azure)); $qManager->addToQueue($qItem); $this->client = new Zend_Service_WindowsAzure_Storage_Queue( $qConfig[host], $qConfig[accountName], $qConfig[accountKey] ); $this->queue = $this->getQueueInstance($queueName); __contruct() public function addToQueue($item) { $this->client->putMessage($this->queue->name, serialize($item)); }Wednesday, May 25, 2011
  88. 88. while (true){ try{ $this->logAction("Checking for messages..."); FIRST COME, //Read Queue $qMessage = $qManager->getMessage(); //If no message, sleep for 3 seconds and try again FIRST SERVED if ($qMessage === null){ $this->logAction("No pending messages..."); sleep(3); continue; } //Retrieve User {... doctrine query for stored twitter handle ...} //Clear Message $this->logAction("Removing message form queue..."); $qManager->deleteMessage($qMessage); //Process User $this->processUser($user); //Warn User $this->sendWarning($user); } catch (Exception $e) { $this->logAction("Exception found:" .$e->getMessage } $this->logAction("Initiating sleep for next loop."); sleep(2); }Wednesday, May 25, 2011
  89. 89. while (true){ try{ $this->logAction("Checking for messages..."); FIRST COME, //Read Queue $qMessage = $qManager->getMessage(); //If no message, sleep for 3 seconds and try again FIRST SERVED if ($qMessage === null){ $this->logAction("No pending messages..."); sleep(3); continue; } //Retrieve User {... doctrine query for stored twitter handle ...} //Clear Message $this->logAction("Removing message form queue..."); $qManager->deleteMessage($qMessage); //Process User $this->processUser($user); //Warn User $this->sendWarning($user); } catch (Exception $e) { $this->logAction("Exception found:" .$e->getMessage } $this->logAction("Initiating sleep for next loop."); sleep(2); }Wednesday, May 25, 2011
  90. 90. while (true){ try{ $this->logAction("Checking for messages..."); FIRST COME, //Read Queue $qMessage = $qManager->getMessage(); //If no message, sleep for 3 seconds and try again FIRST SERVED if ($qMessage === null){ $this->logAction("No getMessage() public function pending messages..."); { sleep(3); $messages = $this->client->getMessages($this->queue->name, 1); continue; } if (count($messages) > 0){ //Retrieve User $qMessage = array_shift($messages); {... doctrine query for stored twitter handle ...} $message = new stdClass(); //Clear Message $message->qMessage = $qMessage; $this->logAction("Removing message form queue..."); $message->decoded = unserialize($qMessage->messagetext); $qManager->deleteMessage($qMessage); return $message; //Process User } $this->processUser($user); return null; //Warn User $this->sendWarning($user); } } catch (Exception $e) { $this->logAction("Exception found:" .$e->getMessage } $this->logAction("Initiating sleep for next loop."); sleep(2); }Wednesday, May 25, 2011
  91. 91. while (true){ try{ $this->logAction("Checking for messages..."); FIRST COME, //Read Queue $qMessage = $qManager->getMessage(); //If no message, sleep for 3 seconds and try again FIRST SERVED if ($qMessage === null){ $this->logAction("No getMessage() public function pending messages..."); { sleep(3); $messages = $this->client->getMessages($this->queue->name, 1); continue; } if (count($messages) > 0){ //Retrieve User $qMessage = array_shift($messages); {... doctrine query for stored twitter handle ...} $message = new stdClass(); //Clear Message $message->qMessage = $qMessage; $this->logAction("Removing message form queue..."); $message->decoded = unserialize($qMessage->messagetext); $qManager->deleteMessage($qMessage); return $message; //Process User } $this->processUser($user); return null; //Warn User $this->sendWarning($user); array( } messageid => $messageId, insertiontime => $insertionTime, } catch (Exception $e) { expirationtime => $expirationTime, $this->logAction("Exception found:" .$e->getMessage popreceipt => $popReceipt, timenextvisible => $timeNextVisible, } dequeuecount => $dequeueCount, messagetext => $messageText $this->logAction("Initiating sleep for next loop."); ); sleep(2); }Wednesday, May 25, 2011
  92. 92. while (true){ try{ $this->logAction("Checking for messages..."); FIRST COME, //Read Queue $qMessage = $qManager->getMessage(); //If no message, sleep for 3 seconds and try again FIRST SERVED if ($qMessage === null){ $this->logAction("No pending messages..."); sleep(3); continue; } //Retrieve User {... doctrine query for stored twitter handle ...} //Clear Message $this->logAction("Removing message form queue..."); $qManager->deleteMessage($qMessage); //Process User $this->processUser($user); //Warn User $this->sendWarning($user); } catch (Exception $e) { $this->logAction("Exception found:" .$e->getMessage } $this->logAction("Initiating sleep for next loop."); sleep(2); }Wednesday, May 25, 2011
  93. 93. while (true){ try{ $this->logAction("Checking for messages..."); FIRST COME, //Read Queue $qMessage = $qManager->getMessage(); //If no message, sleep for 3 seconds and try again FIRST SERVED if ($qMessage === null){ $this->logAction("No pending messages..."); sleep(3); continue; } //Retrieve User {... doctrine query for stored twitter handle ...} //Clear Message $this->logAction("Removing message form queue..."); $qManager->deleteMessage($qMessage); After 20 seconds, message goes //Process User back into Queue $this->processUser($user); //Warn User $this->sendWarning($user); } catch (Exception $e) { $this->logAction("Exception found:" .$e->getMessage } $this->logAction("Initiating sleep for next loop."); sleep(2); }Wednesday, May 25, 2011
  94. 94. GOING OUT THE WINDOW • See all changes: github.com/rdohms/Sample-Azure-App • Compare these branches: non-cloud-version x cloud-designed-versionWednesday, May 25, 2011
  95. 95. LOOKING BACK BEFORE CLOSING THE WINDOW • Found out what is the Cloud • Looked at reasons on why to choose the Cloud • We took a look at Windows Azure • Peaked at how it affects our code?Wednesday, May 25, 2011
  96. 96. FURTHER READING... PHP Development in the Cloud ISBN: 9780981034522 Pages: 172 Authors: Ivo Jansch and Vito Chin http://bit.ly/i9Awk0Wednesday, May 25, 2011
  97. 97. GET STARTED, GET HELP • Get a free account: WindowsAzurePass.com • Talk to the Microsoft guys out in the Hall • Ask them about pricing options http://azurephp.com http://phpazure.codeplex.com/ http://azurephptools.codeplex.com/ http://www.ben-waine.co.uk/blog/php-azure http://marvelley.com/category/php/php-on-azure/Wednesday, May 25, 2011
  98. 98. twitter.com/rdohmshttp://doh.ms Questions? rafael@doh.ms THANK YOU! Feedback is very important, please visit: joind.in/3417Wednesday, May 25, 2011
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×