SlideShare a Scribd company logo
Open a Window, see the clouds




                          Rafael Dohms   photo credit: Denis Grzetic

Wednesday, May 25, 2011
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
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
WHAT IS THE CLOUD?
                          not just another buzzword bingo word

Wednesday, May 25, 2011
REGULAR HOSTING


   • Shared  account, VPS or Local
       Machine

   • One            machine, one place

   • Pay         by month



Wednesday, May 25, 2011
Self
                          REGULAR HOSTING


   • Shared  account, VPS or Local
       Machine

   • One            machine, one place

   • Pay         by month



Wednesday, May 25, 2011
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, SaaS

Wednesday, May 25, 2011
Data



                             Application



                              Software



                          Operating System



                          Hardware/Network


Wednesday, May 25, 2011
Storing         Data          Sharing


                Deploying       Application     Developing


                   MySQL         Software        Apache


          Configuring        Operating System   Upgrading


                   Cooling   Hardware/Network   Cabling

Wednesday, May 25, 2011
IaaS a Service”
                          “Infrastructure as

                                     Data

                                  Application

                                    Software

                                Operating System

                               Hardware/Network




Wednesday, May 25, 2011
IaaS a Service”
                          “Infrastructure as

                                     Data

                                  Application

                                    Software

                                Operating System     you
                                                     them
                               Hardware/Network




Wednesday, May 25, 2011
PaaS
                          “Platform as a Service”

                                    Data

                                 Application

                                  Software

                              Operating System

                             Hardware/Network




Wednesday, May 25, 2011
PaaS
                          “Platform as a Service”

                                    Data

                                 Application        you
                                                    them
                                  Software

                              Operating System

                             Hardware/Network




Wednesday, May 25, 2011
SaaS
                          “Software as a Service”

                                    Data

                                 Application

                                  Software

                              Operating System

                             Hardware/Network




Wednesday, May 25, 2011
SaaS
                          “Software as a Service”

                                    Data            you
                                                    them
                                 Application

                                  Software

                              Operating System

                             Hardware/Network




Wednesday, May 25, 2011
X
     WHY CHOOSE THE CLOUD?
                     What are the advantages of using the cloud?

Wednesday, May 25, 2011
traffic




                                              time




                          THE UTILITY MODEL
Wednesday, May 25, 2011
traffic




                                              time




                          THE UTILITY MODEL
Wednesday, May 25, 2011
traffic



            peak




                                              time




                          THE UTILITY MODEL
Wednesday, May 25, 2011
traffic



            peak




                                              time




                          THE UTILITY MODEL
Wednesday, May 25, 2011
traffic



            peak




                                              time




                          THE UTILITY MODEL
Wednesday, May 25, 2011
IaaS   Paas   SaaS

                            costs




            server managment.




     software management




                   product deploy



Wednesday, May 25, 2011
AVAILABILITY
Wednesday, May 25, 2011
AVAILABILITY
Wednesday, May 25, 2011
AVAILABILITY
Wednesday, May 25, 2011
SCALABILITY
                          Stateless Compute + Durable Storage
Wednesday, May 25, 2011
SCALABILITY
                          Stateless Compute + Durable Storage
Wednesday, May 25, 2011
LET’S LOOK INSIDE

Wednesday, May 25, 2011
Windows Azure Overview


                                     Fabric


                           Compute            Storage




Wednesday, May 25, 2011
Fabric
                          Middleware, used for developing, deploying and
                                   managing your applications




                                 AppFabric

        developer




Wednesday, May 25, 2011
Fabric


                          Compute            Storage




Wednesday, May 25, 2011
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
                                                     demand




Wednesday, May 25, 2011
Fabric


                          Compute            Storage




Wednesday, May 25, 2011
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 Worker




Wednesday, May 25, 2011
UP & RUNNING
                                for Development and Deployment



   • Requisites:

        • IIS7 Tools

        • Azure           SDK (install DevAppFabric, the azure emulator)

        • Command             Line Tools

             • Command          line tools for PHP


Wednesday, May 25, 2011
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 IDE


Wednesday, May 25, 2011
Developer Environment
                               Azure Emulator                   Code
                                (Dev fabric)



                                        Packaging tools
                                    (command line or eclipse)
           Package + Service
             Configuration



                                            Azure




                                                                       Window Azure
                                          (AppFabric)




                                 SQLAzure               Storage

Wednesday, May 25, 2011
Developer Environment
                               Azure Emulator                   Code
                                (Dev fabric)


                     PHP
                                        Packaging tools
                                    (command line or eclipse)
           Package + Service
             Configuration



                                            Azure




                                                                       Window Azure
                                          (AppFabric)




                                 SQLAzure               Storage

Wednesday, May 25, 2011
Developer Environment
                               Azure Emulator                   Code
                                (Dev fabric)


                     PHP
                                        Packaging tools
                                    (command line or eclipse)
           Package + Service
             Configuration



                                            Azure




                                                                       Window Azure
                                          (AppFabric)




                                 SQLAzure               Storage

Wednesday, May 25, 2011
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                Storage

Wednesday, May 25, 2011
Developer Environment
                               Azure Emulator                   Code
                                (Dev fabric)


                     PHP
                                        Packaging tools
                                    (command line or eclipse)
           Package + Service
             Configuration



                                            Azure




                                                                       Window Azure
                                          (AppFabric)




                                 SQLAzure               Storage

Wednesday, May 25, 2011
THE GOOD

   • REST APIs

        • Storage

        • Diagnostics

   • Relational           DB: SQL Azure

   • Role Architecture



Wednesday, May 25, 2011
THE BAD

   • Windows-only         Management

        • No   Azure Emulator for
            non-Windows OS

        • No    Packaging
            Command Line tools
            for non-Windows OS


Wednesday, May 25, 2011
HOW DOES THAT AFFECT CODE?
         What tools can we use and how should we design our apps

Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




                Code
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




         Architecture


                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




              Scaling

         Architecture


                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




              Scaling     No Local Storage


         Architecture


                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




              Scaling     No Local Storage     Session sharing



         Architecture


                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




              Scaling     No Local Storage     Session sharing

                          Worker Roles
         Architecture


                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?




              Scaling     No Local Storage        Session sharing

                          Worker Roles         Queues

         Architecture


                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?



              Storage


              Scaling     No Local Storage        Session sharing

                          Worker Roles         Queues

         Architecture


                Code      PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?


               What kind?

              Storage


              Scaling       No Local Storage        Session sharing

                            Worker Roles         Queues

         Architecture


                Code        PHP on IIS/Windows
Wednesday, May 25, 2011
WHAT DO I WORRY ABOUT?

                              Table / Blob
               What kind?

              Storage


              Scaling       No Local Storage        Session sharing

                            Worker Roles         Queues

         Architecture


                Code        PHP on IIS/Windows
Wednesday, May 25, 2011
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/Windows
Wednesday, May 25, 2011
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/Windows
Wednesday, May 25, 2011
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/Windows
Wednesday, May 25, 2011
AZURE-READY FRAMEWORKS
Wednesday, May 25, 2011
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
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
Database

   • MS-SQL    Drivers* are
       compatible with
       SQLAzure

    * Using pdo_sql_server, possibly pdo_dblib




                                                 Powered by Doctrine:



Wednesday, May 25, 2011
• 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
AZURE PHP SDK

   • Services:

        • Blob            Storage

        • Table            Storage

        • Queue             Storage

        • Diagnostic Tools

   • Compatible              with PHP 5+

Wednesday, May 25, 2011
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 Queue

Wednesday, May 25, 2011
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 Queue

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...




Wednesday, May 25, 2011
Twitter OAuth




                           Wait for it...




                                            MySQL




Wednesday, May 25, 2011
Twitter OAuth




                           Wait for it...




                                            MySQL


                             Results


Wednesday, May 25, 2011
Twitter OAuth




                           Wait for it...




                                            MySQL


                             Results


Wednesday, May 25, 2011
Twitter OAuth




                           Wait for it...




                                            MySQL


                             Results


Wednesday, May 25, 2011
Twitter OAuth




                          Don’t call me, i’ll
                             call you




Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you




Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you



                                                        Worker




Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you



                                                        Worker




Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you



                                                        Worker




Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you



                                                                   Worker




                                                        SQLAzure
Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you



                                                                   Worker




                                                        SQLAzure
Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you



                                                                   Worker




                               Results

                                                        SQLAzure
Wednesday, May 25, 2011
Twitter OAuth




                                                Queue

                          Don’t call me, i’ll
                             call you



                                                                   Worker
                                                                   Worker
                                                                    Worker
                                                                    Worker
                                                                     Worker
                                                                      Worker
                                                                       Worker
                                                                       Worker
                                                                        Worker
                                                                          Worker
                                                                          Worker




                               Results

                                                        SQLAzure
Wednesday, May 25, 2011
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
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
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
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
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
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
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
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
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
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
GOING OUT THE WINDOW


   • See          all changes: github.com/rdohms/Sample-Azure-App

   • Compare              these branches:

            non-cloud-version x cloud-designed-version




Wednesday, May 25, 2011
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
FURTHER READING...


       PHP Development in the
       Cloud

       ISBN: 9780981034522
       Pages: 172
       Authors: Ivo Jansch and Vito Chin

             http://bit.ly/i9Awk0



Wednesday, May 25, 2011
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
twitter.com/rdohms
http://doh.ms



                           Questions?


                           rafael@doh.ms

                          THANK YOU!
  Feedback is very important, please visit: joind.in/3417
Wednesday, May 25, 2011

More Related Content

PPTX
Window Azure Cache
PPT
Realtime Communication Techniques with PHP
PDF
The Layman's Guide to Microsoft Azure
PDF
PHP Development In The Cloud (php|tek edition)
PDF
Introduction to Cloud Computing
PPTX
Cloud computing 101
PDF
Evolution of Cloud Computing - a Global Impact
PPT
Intro cloud-1
Window Azure Cache
Realtime Communication Techniques with PHP
The Layman's Guide to Microsoft Azure
PHP Development In The Cloud (php|tek edition)
Introduction to Cloud Computing
Cloud computing 101
Evolution of Cloud Computing - a Global Impact
Intro cloud-1

Similar to Open a window, see the clouds - php|tek 2011 (20)

PPT
Intro cloud-1
PDF
To infinity and beyond!
PPT
Cloud Computing Webinar
PDF
CMPE 297 Lecture: Building Infrastructure Clouds with OpenStack
PPTX
Introduction to cloud computing
PDF
Cloud Foundry and Ubuntu - 2012
PDF
Business computing survey
PDF
What's After Cloud Computing?
PPTX
Cloud computing by Luqman
PDF
Community Clouds - Shared Infrastructure as a Service
PPT
cloud computing
PPTX
Cloud computing NIC 2012
PDF
Cloud Computing by Dindo Fernando
PDF
Egypt Cloud Day, May2011--Hello Cloud Computing
PDF
Lam Chee Keong
PDF
What is After Cloud Computing?
PPT
Cloud basics
PPT
Cloud Computing Final1
PDF
Day 3 p4 - cloud strategy
PDF
Day 3 p4 - cloud strategy
Intro cloud-1
To infinity and beyond!
Cloud Computing Webinar
CMPE 297 Lecture: Building Infrastructure Clouds with OpenStack
Introduction to cloud computing
Cloud Foundry and Ubuntu - 2012
Business computing survey
What's After Cloud Computing?
Cloud computing by Luqman
Community Clouds - Shared Infrastructure as a Service
cloud computing
Cloud computing NIC 2012
Cloud Computing by Dindo Fernando
Egypt Cloud Day, May2011--Hello Cloud Computing
Lam Chee Keong
What is After Cloud Computing?
Cloud basics
Cloud Computing Final1
Day 3 p4 - cloud strategy
Day 3 p4 - cloud strategy
Ad

More from Rafael Dohms (20)

PDF
The Individual Contributor Path - DPC2024
PDF
Application Metrics - IPC2023
PDF
How'd we get here? A guide to Architectural Decision Records
PDF
Architectural Decision Records - PHPConfBR
PDF
Application Metrics (with Prometheus examples)
PDF
Application metrics - Confoo 2019
PDF
Writing code you won’t hate tomorrow - PHPCE18
PDF
Application Metrics (with Prometheus examples) #PHPDD18
PDF
Application metrics with Prometheus - DPC18
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
PDF
Composer The Right Way - 010PHP
PDF
Writing Code That Lasts - #Magento2Seminar, Utrecht
PDF
Composer the Right Way - PHPSRB16
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16
PDF
Composer the Right Way - MM16NL
PDF
Composer The Right Way - PHPUGMRN
PDF
Composer the Right Way - PHPBNL16
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow.
PDF
A Journey into your Lizard Brain - PHP Conference Brasil 2015
The Individual Contributor Path - DPC2024
Application Metrics - IPC2023
How'd we get here? A guide to Architectural Decision Records
Architectural Decision Records - PHPConfBR
Application Metrics (with Prometheus examples)
Application metrics - Confoo 2019
Writing code you won’t hate tomorrow - PHPCE18
Application Metrics (with Prometheus examples) #PHPDD18
Application metrics with Prometheus - DPC18
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
Composer The Right Way - 010PHP
Writing Code That Lasts - #Magento2Seminar, Utrecht
Composer the Right Way - PHPSRB16
“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16
Composer the Right Way - MM16NL
Composer The Right Way - PHPUGMRN
Composer the Right Way - PHPBNL16
“Writing code that lasts” … or writing code you won’t hate tomorrow.
A Journey into your Lizard Brain - PHP Conference Brasil 2015
Ad

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Tartificialntelligence_presentation.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
A comparative study of natural language inference in Swahili using monolingua...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
Reach Out and Touch Someone: Haptics and Empathic Computing
SOPHOS-XG Firewall Administrator PPT.pptx
Assigned Numbers - 2025 - Bluetooth® Document
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
NewMind AI Weekly Chronicles - August'25-Week II
OMC Textile Division Presentation 2021.pptx
Encapsulation_ Review paper, used for researhc scholars
Tartificialntelligence_presentation.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Building Integrated photovoltaic BIPV_UPV.pdf

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

  • 1. Open a Window, see the clouds Rafael Dohms photo credit: Denis Grzetic Wednesday, May 25, 2011
  • 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. 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. WHAT IS THE CLOUD? not just another buzzword bingo word Wednesday, May 25, 2011
  • 5. REGULAR HOSTING • Shared account, VPS or Local Machine • One machine, one place • Pay by month Wednesday, May 25, 2011
  • 6. Self REGULAR HOSTING • Shared account, VPS or Local Machine • One machine, one place • Pay by month Wednesday, May 25, 2011
  • 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, SaaS Wednesday, May 25, 2011
  • 8. Data Application Software Operating System Hardware/Network Wednesday, May 25, 2011
  • 9. Storing Data Sharing Deploying Application Developing MySQL Software Apache Configuring Operating System Upgrading Cooling Hardware/Network Cabling Wednesday, May 25, 2011
  • 10. IaaS a Service” “Infrastructure as Data Application Software Operating System Hardware/Network Wednesday, May 25, 2011
  • 11. IaaS a Service” “Infrastructure as Data Application Software Operating System you them Hardware/Network Wednesday, May 25, 2011
  • 12. PaaS “Platform as a Service” Data Application Software Operating System Hardware/Network Wednesday, May 25, 2011
  • 13. PaaS “Platform as a Service” Data Application you them Software Operating System Hardware/Network Wednesday, May 25, 2011
  • 14. SaaS “Software as a Service” Data Application Software Operating System Hardware/Network Wednesday, May 25, 2011
  • 15. SaaS “Software as a Service” Data you them Application Software Operating System Hardware/Network Wednesday, May 25, 2011
  • 16. X WHY CHOOSE THE CLOUD? What are the advantages of using the cloud? Wednesday, May 25, 2011
  • 17. traffic time THE UTILITY MODEL Wednesday, May 25, 2011
  • 18. traffic time THE UTILITY MODEL Wednesday, May 25, 2011
  • 19. traffic peak time THE UTILITY MODEL Wednesday, May 25, 2011
  • 20. traffic peak time THE UTILITY MODEL Wednesday, May 25, 2011
  • 21. traffic peak time THE UTILITY MODEL Wednesday, May 25, 2011
  • 22. IaaS Paas SaaS costs server managment. software management product deploy Wednesday, May 25, 2011
  • 26. SCALABILITY Stateless Compute + Durable Storage Wednesday, May 25, 2011
  • 27. SCALABILITY Stateless Compute + Durable Storage Wednesday, May 25, 2011
  • 29. Windows Azure Overview Fabric Compute Storage Wednesday, May 25, 2011
  • 30. Fabric Middleware, used for developing, deploying and managing your applications AppFabric developer Wednesday, May 25, 2011
  • 31. Fabric Compute Storage Wednesday, May 25, 2011
  • 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 demand Wednesday, May 25, 2011
  • 33. Fabric Compute Storage Wednesday, May 25, 2011
  • 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 Worker Wednesday, May 25, 2011
  • 35. UP & RUNNING for Development and Deployment • Requisites: • IIS7 Tools • Azure SDK (install DevAppFabric, the azure emulator) • Command Line Tools • Command line tools for PHP Wednesday, May 25, 2011
  • 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 IDE Wednesday, May 25, 2011
  • 37. Developer Environment Azure Emulator Code (Dev fabric) Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure Storage Wednesday, May 25, 2011
  • 38. Developer Environment Azure Emulator Code (Dev fabric) PHP Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure Storage Wednesday, May 25, 2011
  • 39. Developer Environment Azure Emulator Code (Dev fabric) PHP Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure Storage Wednesday, May 25, 2011
  • 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 Storage Wednesday, May 25, 2011
  • 41. Developer Environment Azure Emulator Code (Dev fabric) PHP Packaging tools (command line or eclipse) Package + Service Configuration Azure Window Azure (AppFabric) SQLAzure Storage Wednesday, May 25, 2011
  • 42. THE GOOD • REST APIs • Storage • Diagnostics • Relational DB: SQL Azure • Role Architecture Wednesday, May 25, 2011
  • 43. THE BAD • Windows-only Management • No Azure Emulator for non-Windows OS • No Packaging Command Line tools for non-Windows OS Wednesday, May 25, 2011
  • 44. HOW DOES THAT AFFECT CODE? What tools can we use and how should we design our apps Wednesday, May 25, 2011
  • 45. WHAT DO I WORRY ABOUT? Wednesday, May 25, 2011
  • 46. WHAT DO I WORRY ABOUT? Code Wednesday, May 25, 2011
  • 47. WHAT DO I WORRY ABOUT? Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 48. WHAT DO I WORRY ABOUT? Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 49. WHAT DO I WORRY ABOUT? Scaling Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 50. WHAT DO I WORRY ABOUT? Scaling No Local Storage Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 51. WHAT DO I WORRY ABOUT? Scaling No Local Storage Session sharing Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 52. WHAT DO I WORRY ABOUT? Scaling No Local Storage Session sharing Worker Roles Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 53. WHAT DO I WORRY ABOUT? Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 54. WHAT DO I WORRY ABOUT? Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 55. WHAT DO I WORRY ABOUT? What kind? Storage Scaling No Local Storage Session sharing Worker Roles Queues Architecture Code PHP on IIS/Windows Wednesday, May 25, 2011
  • 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/Windows Wednesday, May 25, 2011
  • 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/Windows Wednesday, May 25, 2011
  • 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/Windows Wednesday, May 25, 2011
  • 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/Windows Wednesday, May 25, 2011
  • 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. 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. Database • MS-SQL Drivers* are compatible with SQLAzure * Using pdo_sql_server, possibly pdo_dblib Powered by Doctrine: Wednesday, May 25, 2011
  • 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. AZURE PHP SDK • Services: • Blob Storage • Table Storage • Queue Storage • Diagnostic Tools • Compatible with PHP 5+ Wednesday, May 25, 2011
  • 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 Queue Wednesday, May 25, 2011
  • 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 Queue Wednesday, May 25, 2011
  • 68. Twitter OAuth Wait for it... Wednesday, May 25, 2011
  • 69. Twitter OAuth Wait for it... Wednesday, May 25, 2011
  • 70. Twitter OAuth Wait for it... Wednesday, May 25, 2011
  • 71. Twitter OAuth Wait for it... MySQL Wednesday, May 25, 2011
  • 72. Twitter OAuth Wait for it... MySQL Results Wednesday, May 25, 2011
  • 73. Twitter OAuth Wait for it... MySQL Results Wednesday, May 25, 2011
  • 74. Twitter OAuth Wait for it... MySQL Results Wednesday, May 25, 2011
  • 75. Twitter OAuth Don’t call me, i’ll call you Wednesday, May 25, 2011
  • 76. Twitter OAuth Queue Don’t call me, i’ll call you Wednesday, May 25, 2011
  • 77. Twitter OAuth Queue Don’t call me, i’ll call you Worker Wednesday, May 25, 2011
  • 78. Twitter OAuth Queue Don’t call me, i’ll call you Worker Wednesday, May 25, 2011
  • 79. Twitter OAuth Queue Don’t call me, i’ll call you Worker Wednesday, May 25, 2011
  • 80. Twitter OAuth Queue Don’t call me, i’ll call you Worker SQLAzure Wednesday, May 25, 2011
  • 81. Twitter OAuth Queue Don’t call me, i’ll call you Worker SQLAzure Wednesday, May 25, 2011
  • 82. Twitter OAuth Queue Don’t call me, i’ll call you Worker Results SQLAzure Wednesday, May 25, 2011
  • 83. Twitter OAuth Queue Don’t call me, i’ll call you Worker Worker Worker Worker Worker Worker Worker Worker Worker Worker Worker Results SQLAzure Wednesday, May 25, 2011
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. GOING OUT THE WINDOW • See all changes: github.com/rdohms/Sample-Azure-App • Compare these branches: non-cloud-version x cloud-designed-version Wednesday, May 25, 2011
  • 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. FURTHER READING... PHP Development in the Cloud ISBN: 9780981034522 Pages: 172 Authors: Ivo Jansch and Vito Chin http://bit.ly/i9Awk0 Wednesday, May 25, 2011
  • 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. twitter.com/rdohms http://doh.ms Questions? rafael@doh.ms THANK YOU! Feedback is very important, please visit: joind.in/3417 Wednesday, May 25, 2011