php and the cloud: the view from the bazaar
DESCRIPTION
This is used in my talk at MOSC 2010, GeekCamp Singapore 2010 and the Singapore PHP Meetup of July 2010.TRANSCRIPT
PHP and the CloudThe view from the bazaar
Vito Chin
June 2010
2
About Me
• Vito Chin• Software Engineer
– Consultancy– Projects– Training, audits
• Opensource:– Gmagick PHP Extension
• Book– php|architect's Guide to PHP in the Cloud
3
About this talk
• Branch of Ivo Jansch's original “PHP and the Cloud”
• Coauthor of php|architect's Guide to PHP in the Cloud
• This talk focuses on available opensource tools within PHP; in extensions and in userland.
4
PHP
• Standing on the shoulders of opensource giants:
5
PHP
• Used by many
6
Cloud
7
Cloud
• Gartner's Hype Cycle
8
Cloud
• Gartner's Hype Cycle
9
Cloud
“Cloud computing is a model for enabling convenient, ondemand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, and
services) that can be rapidly provisioned and released with minimal management effort or service provider interaction.
This cloud model promotes availability and is composed of five essential characteristics, three service models, and four
deployment models.”
http://csrc.nist.gov/groups/SNS/cloudcomputing/
10
Cloud
“Cloud computing is a model for enabling convenient, ondemand network access to a shared pool of configurable computing
resources (e.g., networks, servers, storage, applications, andservices) that can be rapidly provisioned and released with minimal management effort or service provider interaction.
This cloud model promotes availability and is composed of five essential characteristics, three service models, and four
deployment models.”
http://csrc.nist.gov/groups/SNS/cloudcomputing/
11
PHP and the Cloud
• Convenient network access– CURL extension
• Connect and communicate to many different types of servers
• http, https, ftp, gopher, telnet, dict, file, and ldap protocols
• Most prevalent within the cloud: HTTP• RESTful services (POST, GET, PUT, DELETE)
12
PHP and the Cloud
• Convenient network access– CURL extension
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://api.cloudphp.net/");curl_setopt($ch, CURLOPT_HEADER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
curl_close($ch);
13
PHP and the Cloud
• Convenient network access– SOAP extension
• SoapClient, SoapServer• Simple Object Access Protocol• WSDL: Web Services Description Language
$hello = new SoapClient("http://api.cloudphp.net/Hello.wsdl"); $hello->sayHello("world");
14
Cloud
“Cloud computing is a model for enabling convenient, ondemand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, andservices) that can be rapidly provisioned and released with minimal management effort or service provider interaction.
This cloud model promotes availability and is composed of five essential characteristics, three service models, and four
deployment models.”
http://csrc.nist.gov/groups/SNS/cloudcomputing/
15
PHP and the Cloud
• Configurable computing resources– Usually, requests sent as POST– Obtain options available– XML with SimpleXML or DOM extension
<?xml version="1.0" encoding="UTF-8"?><books> <book title="PHP in the Cloud" pages="100" /></books>
$xml = simplexml_load_string($content);$title = $xml->book["title"];$title = $xml->book["pages"];
16
PHP and the Cloud
• Configurable computing resources– JSON extension– json_encode() / json_decode()– Javascript Object Notation– Very popular interchange format:
• More compact• Interpretable by Javascript• AJAX requests
17
PHP and the Cloud
• Configurable computing resources– JSON extension
{ "book":{ "title":"PHP in the Cloud", "pages":"100" }}
$json = json_decode($jcontent);echo $json->book->title;echo $json->book->pages;
18
Cloud service models
• NIST states 3:– Infrastructure as a Service– Platform as a Service– Software as a Service
19
Infrastructure as a Service
• Typically VM instances• Choice of OS• Freedom within the OS• Some custom network features• Instances controlled via API• Specialised or custom Machine Images
20
Infrastructure as a Service
• Publicly available examples:– Amazon Elastic Compute Cloud– Rackspace Cloud Servers– Microsoft Azure
• PHP API provided by each vendor• Open source PHP alternatives are abundant
(and sometimes better!)
21
PHP and IaaS scenario
• Bottlenecks: The IaaS cloud is not a silver bullet
22
PHP and IaaS scenario
• Identifying bottlenecks (xdebug)
23
PHP and IaaS scenario
• Bottleneck resolution
24
PHP and IaaS scenario
• Cloud Advantages:– Lowcost scalability
• Economies of scale• Capital expense to • operational expense
– Utilitylike flexibility
25
Platform as a Service
• A platform to deploy your application• Scales up and down automatically• Convenient tools and services
– Memcache– Mail– Image Processing– Authentication & Authorisation– Task queues
26
PHP and Google AppEngine
• Range of scalable services• Officially support only:
27
PHP and Google AppEngine
• PHP developers are not really missing out on features on the GAE.
• The question to ask: How important is Google's scalability to your application?
?
28
PHP and Google AppEngine
• PseudoPHP via Quercus– Java implementation– Needs to keep up with PHP changes
29
PHP and Google AppEngine
• PseudoPHP via Quercus– Lacks community involvement:
• PHP core and PECL community consists of a large band of contributors from around the world
• Opensource solutions provided by the community (such as extensions) are well embraced
• Many extensions not available
30
PHP and Rackspace Sites
• PHP support (but not too perfect)• Automatic scalability• Virtual local storage routed to Cloud files
31
PHP and Rackspace Sites
• Downside:– No instant control over supported version– Unsuitable for custom requirements
• No shell access• Not able to build custom libraries
– No API
32
Software as a Service
• GUI and API– Google Apps– Salesforce– Twitter– Google Maps– Google Search
• API Only: PayflowPro
“There is a PHP wrapper for that”
Almost always:
33
PHP for SaaS
• PHP's Bread and Butter• Architectural considerations• Multitenancy• Be careful:
– Reliability– Security– Deployment– Maintenance
34
PHP for the Cloud
• Compatible philosophies– Not a binary Fort
X
35
PHP for the Cloud
• Compatible philosophies– The Unix Philosophy: Write programs that do
one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
36
What PHP is?
• Do one thing and do it well– An easier interface (wrapper) to C (and other)
libraries
“Rails is like a rounded rectangle and PHP is like a ball of nails.”
Terry Chay
37
What PHP is?
• Work together – Extensions
• Gmagick → GraphicsMagick• CURL → libcurl• memcached → libmemcached• See pecl.php.net
– Web servers• httpd
– Browsers and UIs (e.g. GTK)
38
Credits and sources
Photos and Images
Gartner's Hype Cycle illustrative diagram on slide 7 & 8 by Jeremy Kemp on Wikipedia
Trees on slide 18 by Gerald_G on http://www.openclipart.org/
Cachegrind generated 22 from xdebug (by Derick Rethans) used to generate visualisation created with xdebugtoolkit and dot
Rack on slide 28 by Steve Jurvetson. Source: http://flickr.com/photos/jurvetson/157722937/
Fort on slide 34 by Jan F. on Wikipedia
UNIX License plate on slide 35 from http://www.unix.org/
Old images on slide 28, 30, 33 from http://www.oldbookillustrations.com
All other organisational logos are trademark of the respective organisations
Questions?
39