php and the cloud: the view from the bazaar

39
PHP and the Cloud The view from the bazaar Vito Chin June 2010

Upload: vitoc

Post on 18-May-2015

2.342 views

Category:

Technology


0 download

DESCRIPTION

This is used in my talk at MOSC 2010, GeekCamp Singapore 2010 and the Singapore PHP Meetup of July 2010.

TRANSCRIPT

Page 1: PHP and the Cloud: The view from the bazaar

PHP and the CloudThe view from the bazaar

Vito Chin

June 2010

Page 2: PHP and the Cloud: The view from the bazaar

2

About Me

• Vito Chin• Software Engineer

– Consultancy– Projects– Training, audits

• Open­source:– Gmagick PHP Extension

• Book– php|architect's Guide to PHP in the Cloud

Page 3: PHP and the Cloud: The view from the bazaar

3

About this talk

• Branch of Ivo Jansch's original “PHP and the Cloud”

• Co­author of php|architect's Guide to PHP in the Cloud

• This talk focuses on available open­source tools within PHP; in extensions and in userland.

Page 4: PHP and the Cloud: The view from the bazaar

4

PHP

• Standing on the shoulders of open­source giants:

Page 5: PHP and the Cloud: The view from the bazaar

5

PHP

• Used by many

Page 6: PHP and the Cloud: The view from the bazaar

6

Cloud

Page 7: PHP and the Cloud: The view from the bazaar

7

Cloud

• Gartner's Hype Cycle

Page 8: PHP and the Cloud: The view from the bazaar

8

Cloud

• Gartner's Hype Cycle

Page 9: PHP and the Cloud: The view from the bazaar

9

Cloud

“Cloud computing is a model for enabling convenient, on­demand    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/cloud­computing/

Page 10: PHP and the Cloud: The view from the bazaar

10

Cloud

“Cloud computing is a model for enabling convenient, on­demand    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/cloud­computing/

Page 11: PHP and the Cloud: The view from the bazaar

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)

Page 12: PHP and the Cloud: The view from the bazaar

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);

Page 13: PHP and the Cloud: The view from the bazaar

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");

Page 14: PHP and the Cloud: The view from the bazaar

14

Cloud

“Cloud computing is a model for enabling convenient, on­demand    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/cloud­computing/

Page 15: PHP and the Cloud: The view from the bazaar

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"];

Page 16: PHP and the Cloud: The view from the bazaar

16

PHP and the Cloud

• Configurable computing resources– JSON extension– json_encode() / json_decode()– Javascript Object Notation– Very popular interchange format:

• More compact• Interpret­able by Javascript• AJAX requests

Page 17: PHP and the Cloud: The view from the bazaar

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;

Page 18: PHP and the Cloud: The view from the bazaar

18

Cloud service models

• NIST states 3:– Infrastructure as a Service– Platform as a Service– Software as a Service

Page 19: PHP and the Cloud: The view from the bazaar

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

Page 20: PHP and the Cloud: The view from the bazaar

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!)

Page 21: PHP and the Cloud: The view from the bazaar

21

PHP and IaaS scenario

• Bottlenecks: The IaaS cloud is not a silver bullet

Page 22: PHP and the Cloud: The view from the bazaar

22

PHP and IaaS scenario

• Identifying bottlenecks (xdebug)

Page 23: PHP and the Cloud: The view from the bazaar

23

PHP and IaaS scenario

• Bottleneck resolution

Page 24: PHP and the Cloud: The view from the bazaar

24

PHP and IaaS scenario

• Cloud Advantages:– Low­cost scalability

• Economies of scale• Capital expense to • operational expense

– Utility­like flexibility

Page 25: PHP and the Cloud: The view from the bazaar

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

Page 26: PHP and the Cloud: The view from the bazaar

26

PHP and Google AppEngine

• Range of scalable services• Officially support only:

Page 27: PHP and the Cloud: The view from the bazaar

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?

?

Page 28: PHP and the Cloud: The view from the bazaar

28

PHP and Google AppEngine

• Pseudo­PHP via Quercus– Java implementation– Needs to keep up with PHP changes

Page 29: PHP and the Cloud: The view from the bazaar

29

PHP and Google AppEngine

• Pseudo­PHP via Quercus– Lacks community involvement:

• PHP core and PECL community consists of a large band of contributors from around the world

• Open­source solutions provided by the community (such as extensions) are well embraced

• Many extensions not available

Page 30: PHP and the Cloud: The view from the bazaar

30

PHP and Rackspace Sites

• PHP support (but not too perfect)• Automatic scalability• Virtual local storage routed to Cloud files

Page 31: PHP and the Cloud: The view from the bazaar

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

Page 32: PHP and the Cloud: The view from the bazaar

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:

Page 33: PHP and the Cloud: The view from the bazaar

33

PHP for SaaS

• PHP's Bread and Butter• Architectural considerations• Multi­tenancy• Be careful:

– Reliability– Security– Deployment– Maintenance

Page 34: PHP and the Cloud: The view from the bazaar

34

PHP for the Cloud

• Compatible philosophies– Not a binary Fort

X

Page 35: PHP and the Cloud: The view from the bazaar

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.

Page 36: PHP and the Cloud: The view from the bazaar

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

Page 37: PHP and the Cloud: The view from the bazaar

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)

Page 38: PHP and the Cloud: The view from the bazaar

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

Page 39: PHP and the Cloud: The view from the bazaar

Questions?

39