PHP in the Cloud: Achieving True High AvailabilityJoshua SolominSenior Product Marketing Manager, Zend Technologiesjoshua.s@zend.com
Who is Zend?Leader in software and services for development, deployment and management of enterprise PHP applicationsRightScale Partner jointly producing the RightScaleZendDev & Test Pack  (2010) and RightScaleZend Solution Pack (2011)Co-founders Andi Gutmans and Zeev Suraski created PHP3PHP community leader & contributor through PHP advisory boards, core dev contributions, Zend Framework, SimpleCloudZendsolutions are deployed at more than 40,000 organizations
Realizing IaaS scalability at the platform levelWe all love the cloud!Particularly for  platforms…  But IaaS doesn’t automatically handle application-level HA
What does high availability require?No single points of failureMultiple web serversMultiple load balancersDatabase replicationProvided by the cloud, managed by RightScaleGraceful failover when individual components DO fail	But how does the PHP platform fail over – what about running applications?
A closer look at application user sessionsHTTP is a stateless protocol – there is no “user session”The good news: this makes HTTP highly scalable and versatileThe bad news: representing user state is left to the implementationA basic use case: identifying logged in usersIf I get two consecutive HTTP requests, how can I know that they are from the same user?How can I know if that user has logged in or not, before I authorize some actions?PHP sessions to the rescue!
Session Handling in PHP
But when a node fails, how do you prevent session loss?
Different Session Handling MechanismsDefault: stored in local files…  but doesn’t easily scale >1 nodeA sticky load balancer can help, but has downsidesNFS is a bad ideaCan switch to other save handlers DatabaseMemcachedor …
Zend’s Session ClusteringA PHP Session storage mechanism designed to be:ScalableFault-tolerantFastCloud readySessions stored either in memory or on diskDaemons in a cluster talk to each other to share sessionsEach session stored on two servers: master and backup
Architectural Overview
How does it work?New session created on the server that receives request (master)Master server picks a backup, and copies the session to itSession IDs identify the session’s master and backup serversIf the request ends up at any non-master server, session is requested from the master
Normal Operation
Failure Handling
Scalability & Cloud ReadinessSession Clustering provides a Graceful Shutdown mechanismAt shut down, a node transfers all its sessions to a different serverAll cluster members notified to use the replacement serverRarely takes more than 30 secondsGraceful Shutdown allows spinning down machines without losing sessionsAllows simple scaling down as well as scale up – ideal for the cloud!
Enterprise PHP in the Cloud: IaaS + PaaSNew service co-developed by RightScale and ZendInstant provisioning of a pre-configured, multi-server PHP runtime environment in the cloudPortable across cloud providers – Amazon, Rackspace, Cloud.comAutomated scaling at the server and PHP levelsManagement, monitoring and diagnosticsUsage-based pricing
High Availability PHP Solutionfrom RightScale & Zend
Application MonitoringWatches your application for:PHP Errors (including warnings, notices, uncaught exceptions...)Failing functionsFailing DB queries Slow functions or DB queriesSlow request executionsHigh memory consumptionWhen an issue is detected, an event is reported
Diagnostics: Code TracingReproducing problems is often difficult and time-consumingZend Server captures the full execution flow in testing or productionAllows the developer to “step back in time” and quickly determine root causeIntegrated with Zend Studio
Demo
Next StepsLearn more about Zend Server:http://www.zend.com/serverLearn more about the Rightscale-Zend solution:http://www.rightscale.com/products/plans-pricing/zend-solution-pack.phpWatch the RightScale-Zendwebinar: http://www.rightscale.com/info_center/webinars/paas-in-a-box-zend.php
Q&A

Achieving Massive Scalability and High Availability for PHP Applications in the Cloud

  • 1.
    PHP in theCloud: Achieving True High AvailabilityJoshua SolominSenior Product Marketing Manager, Zend Technologiesjoshua.s@zend.com
  • 2.
    Who is Zend?Leaderin software and services for development, deployment and management of enterprise PHP applicationsRightScale Partner jointly producing the RightScaleZendDev & Test Pack (2010) and RightScaleZend Solution Pack (2011)Co-founders Andi Gutmans and Zeev Suraski created PHP3PHP community leader & contributor through PHP advisory boards, core dev contributions, Zend Framework, SimpleCloudZendsolutions are deployed at more than 40,000 organizations
  • 3.
    Realizing IaaS scalabilityat the platform levelWe all love the cloud!Particularly for platforms… But IaaS doesn’t automatically handle application-level HA
  • 4.
    What does highavailability require?No single points of failureMultiple web serversMultiple load balancersDatabase replicationProvided by the cloud, managed by RightScaleGraceful failover when individual components DO fail But how does the PHP platform fail over – what about running applications?
  • 5.
    A closer lookat application user sessionsHTTP is a stateless protocol – there is no “user session”The good news: this makes HTTP highly scalable and versatileThe bad news: representing user state is left to the implementationA basic use case: identifying logged in usersIf I get two consecutive HTTP requests, how can I know that they are from the same user?How can I know if that user has logged in or not, before I authorize some actions?PHP sessions to the rescue!
  • 6.
  • 7.
    But when anode fails, how do you prevent session loss?
  • 8.
    Different Session HandlingMechanismsDefault: stored in local files… but doesn’t easily scale >1 nodeA sticky load balancer can help, but has downsidesNFS is a bad ideaCan switch to other save handlers DatabaseMemcachedor …
  • 9.
    Zend’s Session ClusteringAPHP Session storage mechanism designed to be:ScalableFault-tolerantFastCloud readySessions stored either in memory or on diskDaemons in a cluster talk to each other to share sessionsEach session stored on two servers: master and backup
  • 10.
  • 11.
    How does itwork?New session created on the server that receives request (master)Master server picks a backup, and copies the session to itSession IDs identify the session’s master and backup serversIf the request ends up at any non-master server, session is requested from the master
  • 12.
  • 13.
  • 14.
    Scalability & CloudReadinessSession Clustering provides a Graceful Shutdown mechanismAt shut down, a node transfers all its sessions to a different serverAll cluster members notified to use the replacement serverRarely takes more than 30 secondsGraceful Shutdown allows spinning down machines without losing sessionsAllows simple scaling down as well as scale up – ideal for the cloud!
  • 15.
    Enterprise PHP inthe Cloud: IaaS + PaaSNew service co-developed by RightScale and ZendInstant provisioning of a pre-configured, multi-server PHP runtime environment in the cloudPortable across cloud providers – Amazon, Rackspace, Cloud.comAutomated scaling at the server and PHP levelsManagement, monitoring and diagnosticsUsage-based pricing
  • 16.
    High Availability PHPSolutionfrom RightScale & Zend
  • 17.
    Application MonitoringWatches yourapplication for:PHP Errors (including warnings, notices, uncaught exceptions...)Failing functionsFailing DB queries Slow functions or DB queriesSlow request executionsHigh memory consumptionWhen an issue is detected, an event is reported
  • 18.
    Diagnostics: Code TracingReproducingproblems is often difficult and time-consumingZend Server captures the full execution flow in testing or productionAllows the developer to “step back in time” and quickly determine root causeIntegrated with Zend Studio
  • 19.
  • 20.
    Next StepsLearn moreabout Zend Server:http://www.zend.com/serverLearn more about the Rightscale-Zend solution:http://www.rightscale.com/products/plans-pricing/zend-solution-pack.phpWatch the RightScale-Zendwebinar: http://www.rightscale.com/info_center/webinars/paas-in-a-box-zend.php
  • 21.

Editor's Notes

  • #9 Downsides of sticky LB: Performance and load distribution, according to many high-load users Redundancy (server goes down, sessions are lost) Ability to scale down (sessions are removed along with server)
  • #10 Why “almost” any? Some apps hard-code the session storage mechanism, for whatever reason (for example Drupal, requires special plugins or code modifications to use other session save handlers) Some apps modify the session ID. This is usually a bad idea, with SC it will not work (we will later see why)
  • #12 Demo: show how a Session Clustering Session ID looks like
  • #26 May skip to the next slide and talk about this when showing the diagram
  • #27 Can skip to next slide and talk about this slide without showing it