hybrid cloud phpuk2012

96
Thijs Feryn Evangelist +32 (0)9 218 79 06 [email protected] Develop & deploy using hybrid cloud strategies

Upload: combell-group

Post on 06-Dec-2014

1.697 views

Category:

Technology


1 download

DESCRIPTION

Slides for my Hybrid Cloud talk at PHPUK 2012 in London

TRANSCRIPT

Page 1: Hybrid Cloud PHPUK2012

Thijs  FerynEvangelist+32  (0)9  218  79  [email protected]

Develop  &  deploy  using  hybrid  cloud  strategies

Page 2: Hybrid Cloud PHPUK2012

Very  excited  to  be  here  !

Page 3: Hybrid Cloud PHPUK2012

THIJS

Page 4: Hybrid Cloud PHPUK2012
Page 5: Hybrid Cloud PHPUK2012

TAZE

Page 6: Hybrid Cloud PHPUK2012

Evangelist

Page 7: Hybrid Cloud PHPUK2012
Page 8: Hybrid Cloud PHPUK2012
Page 9: Hybrid Cloud PHPUK2012
Page 10: Hybrid Cloud PHPUK2012

@ThijsFeryn

Page 11: Hybrid Cloud PHPUK2012

Please  rate  my  talk  on  

Joind.in

https://joind.in/4951

Page 12: Hybrid Cloud PHPUK2012

What  is  Cloud?

Page 13: Hybrid Cloud PHPUK2012

“That’s  where  rain  comes  from”

Andrei  Zmievski

Page 14: Hybrid Cloud PHPUK2012

Cloud=

Internet

Page 15: Hybrid Cloud PHPUK2012

DefiniIon

A  model  for  consumpIon  &  delivery  on  the  internet  where  flexibility  is  essenIal  &  can  be  

guaranteed  through  abstracIon

Page 16: Hybrid Cloud PHPUK2012

Internet  as  a  uIlity

Page 17: Hybrid Cloud PHPUK2012

Translated  to  what  we  know  &  need

Page 18: Hybrid Cloud PHPUK2012

Always  available

Page 19: Hybrid Cloud PHPUK2012

Fast  (enough)

Page 20: Hybrid Cloud PHPUK2012

Scalability

Up  &  down  vs  out  &  in

Page 21: Hybrid Cloud PHPUK2012

Focus  on  using,  do  what  you’re  good  at

Page 22: Hybrid Cloud PHPUK2012

Leave  the  rest  to  others

Page 23: Hybrid Cloud PHPUK2012
Page 24: Hybrid Cloud PHPUK2012

Higher  up  the  stack

Page 25: Hybrid Cloud PHPUK2012

Economic  advantages

Page 26: Hybrid Cloud PHPUK2012

Less  moneyLess  effortLess  risk

Less  worries

Page 27: Hybrid Cloud PHPUK2012

Hybrid  let’s  you  do  that

Page 28: Hybrid Cloud PHPUK2012

Hybrid  is  just  a  fancy  way  of  saying

Page 29: Hybrid Cloud PHPUK2012

Pick  the  pieces  of  the  puzzle  yourself

Page 30: Hybrid Cloud PHPUK2012
Page 31: Hybrid Cloud PHPUK2012

Amazon  web  services

✓CompuIng–EC2–ELB–Auto  scaling

✓Storage–S3–EBS

✓Database–RDS–DynamoDB–SimpleDB–ElasIcache–SQS✓CDN–CloudFront

Self-­‐service  Iaas

Page 32: Hybrid Cloud PHPUK2012

Windows  Azure

✓CompuIng✓Storage–Blog  storage–Table  storage✓CDN✓SQL  Azure✓Data  sync✓Service  Bus

Self-­‐service  Paas

Page 33: Hybrid Cloud PHPUK2012

Orchestra

✓CompuLng✓Database

–Memcached–MySQL  &  RDS–CouchDB–MongoDB–Redis

PHP  Paas  on  top  of  AWS

Page 34: Hybrid Cloud PHPUK2012

CloudFlare

✓CDN✓DNS✓DDOS  security✓Traffic  analyIcs

ProtecIon  SaaS

Page 35: Hybrid Cloud PHPUK2012

Combell

Fully  customized  &  managed  soluIons

Page 36: Hybrid Cloud PHPUK2012

Easy  peasy,  right?

Page 37: Hybrid Cloud PHPUK2012
Page 38: Hybrid Cloud PHPUK2012

Single  point  of  failure

Page 39: Hybrid Cloud PHPUK2012

Shared  nothing

Page 40: Hybrid Cloud PHPUK2012

Nothing  is  local

Page 41: Hybrid Cloud PHPUK2012

Distributed  systems

Page 42: Hybrid Cloud PHPUK2012

Easy  to  deploy  &  manage?

Page 43: Hybrid Cloud PHPUK2012

How  do  you  deal  with

$_SESSIONS?

Page 44: Hybrid Cloud PHPUK2012

ReplicaIonR/W  splibng

Page 45: Hybrid Cloud PHPUK2012
Page 46: Hybrid Cloud PHPUK2012

“Cloud  is  for  green  field  projects”

Maarten  Balliauw

Page 47: Hybrid Cloud PHPUK2012

Let’s  do  it  !

Page 48: Hybrid Cloud PHPUK2012

Infrastructure

✓Basics–Webservers–MySQL  servers–File  servers✓AddiIonal  servers–Caching  servers–Reverse  proxy  servers✓External  CDN

Page 49: Hybrid Cloud PHPUK2012

Single  server  setup

Page 50: Hybrid Cloud PHPUK2012

Single  server  setup

✓Developer–Everything  is  local•Files•Databases

✓Sysadmin–Sits  back,  drinks  some  coffee

Page 51: Hybrid Cloud PHPUK2012

Single  server  setup

✓Amazon–1  EC2  instance–Local  MySQL  or  RDS  (as  a  service)–Local  files✓Azure–Single  App  deployment–Include  PHP  &  MySQL  in  package  script✓Orchestra–Single  App  deployment–Request  MySQL  database  or  RDS

What  about  the  Cloud?

Page 52: Hybrid Cloud PHPUK2012

Separate  MySQL

Page 53: Hybrid Cloud PHPUK2012

Separate  MySQL

✓Developer–Change  connecIonstring(s)✓Sysadmin–Sets  up  separate  server–Tunes  for  MySQL

Page 54: Hybrid Cloud PHPUK2012

Separate  MySQL

✓Amazon–Extra  EC2  instance  for  MySQL–RDS✓Azure–MySQL  deployment  with  worker  role–Doesn’t  scale  well–Use  SQL  Azure  instead✓Orchestra–By  default  separate–Create  separate  MySQL  database–RDS

What  about  the  Cloud?

Page 55: Hybrid Cloud PHPUK2012

MulIple  MySQL’s

Page 56: Hybrid Cloud PHPUK2012

MulIple  MySQL’s

✓Developer–Read  write  spliUng  in  code–Connect  to  loadbalanced  hostname

✓Sysadmin–Setup  servers–Configure  replicaLon•Master/master•Master/slave

–Add  to  loadbalancing

Page 57: Hybrid Cloud PHPUK2012

MulIple  MySQL’s

Use  mysqlnd_ms  for  R/W  splibng  in  case  of  crappy  code{        "myapp":  {                "master":  {                        "write_group":  {                                "host":  "master.db.myapp.ext",                                "port":  "3306"                        }                },                "slave":  {                        "read_group":  {                                "host":  "slave.db.myapp.ext",                                "port":  "3306"                        }                }        }}

mysqlnd_ms_plugin.ini

Page 58: Hybrid Cloud PHPUK2012

mysqlnd_ms.enable=1mysqlnd_ms.ini_file=/path/to/mysqlnd_ms_plugin.ini

php.ini

<?php$mysqli = new mysqli("myapp", "username", "password", "database");$pdo = new PDO('mysql:host=myapp;dbname=database', 'username', 'password');$mysql = mysql_connect("myapp", "username", "password");

ConnecIon  string

Page 59: Hybrid Cloud PHPUK2012

MulIple  MySQL’s

✓Amazon–MulLple  EC2  instances  with  replicaLon  and  loadbalancing–RDS  with  read  replica

✓Azure–Include  PHP  &  MySQL  in  package  script–Doesn’t  scale–Use  SQL  Azure

✓Orchestra–RDS–Xeround

What  about  the  Cloud?

Page 60: Hybrid Cloud PHPUK2012

MulIple  web  

servers

Page 61: Hybrid Cloud PHPUK2012

MulIple  web  servers

✓Developer–MulLple  places  to  deploy–Where  are  my  staLc  assets?–Sessions?

✓Sysadmin–MulLple  servers  behind  loadbalancer–$_SESSION  clustering  via  Memcached  or  sLcky  sessions–Shared  storage

Page 62: Hybrid Cloud PHPUK2012

Memcached  session  handler

session.save_handler  =  memcachedsession.save_path=  “mc1.myapp.ext:11211,mc2.myapp.ext:11211”

php.ini

Page 63: Hybrid Cloud PHPUK2012

MulIple  Web  servers

✓Amazon–MulLple  EC2  instances  –Use  ELB  for  loadbalancing–AMI  for  easy  setup–Config  management  (puppet,  chef,  ...)

✓Azure–Out  of  the  box–Tuning  possible

✓Orchestra–Out  of  the  box

What  about  the  Cloud?

Page 64: Hybrid Cloud PHPUK2012

Offload  staIc  files

Page 65: Hybrid Cloud PHPUK2012

Offload  staIc  files

✓Developer–Sync  current  assets–Store  new  files  on  external  servers–Use  external  hostname  when  referencing  files

✓Sysadmin–Tune  external  servers  for  staLc  content–CDN,  perhaps?

Page 66: Hybrid Cloud PHPUK2012

Offload  staIc  files

✓Amazon–EC2  instances  for  storage  with  clustered  file  system–S3  buckets

✓Azure–Blog  storage

What  about  the  Cloud?

Page 67: Hybrid Cloud PHPUK2012

When  the  

pressure  is  on

Page 68: Hybrid Cloud PHPUK2012

Auto  scaling  &  load  balancing

Page 69: Hybrid Cloud PHPUK2012

CDN  &  asset  offloading

Page 70: Hybrid Cloud PHPUK2012

Reverse  (caching)  proxy

Page 71: Hybrid Cloud PHPUK2012

Memcached

Page 72: Hybrid Cloud PHPUK2012

Adaptyourcode

Page 73: Hybrid Cloud PHPUK2012

Storage

Page 74: Hybrid Cloud PHPUK2012

require_once  'Zend/Service/WindowsAzure/Storage/Blob.php';  $storageClient  =  new  Zend_Service_WindowsAzure_Storage_Blob();$result  =  $storageClient-­‐>putBlob('testcontainer',  'example.txt',  '/example.txt');  echo  'Blob  name  is:  '  .  $result-­‐>Name;

require_once  'Zend/Service/Amazon/S3.php';  $s3  =  new  Zend_Service_Amazon_S3($my_aws_key,  $my_aws_secret_key);  $s3-­‐>createBucket("my-­‐own-­‐bucket");  $s3-­‐>putObject("my-­‐own-­‐bucket/myobject",  "somedata");echo  $s3-­‐>getObject("my-­‐own-­‐bucket/myobject");

Azure  Blog  storage

Amazon  S3

Page 75: Hybrid Cloud PHPUK2012

<?php$storage = Zend_Cloud_StorageService_Factory::getAdapter(array(    Zend_Cloud_StorageService_Factory::STORAGE_ADAPTER_KEY => 'Zend_Cloud_StorageService_Adapter_S3',    Zend_Cloud_StorageService_Adapter_S3::AWS_ACCESS_KEY   => $amazonKey,    Zend_Cloud_StorageService_Adapter_S3::AWS_SECRET_KEY   => $amazonSecret,));$data = file_get_contents('/my/local/dir/picture.jpg');$returnedData = $storage->storeItem('/my/remote/path/picture.jpg', $data);

Supports  Azure  &  AWS

Page 76: Hybrid Cloud PHPUK2012

<?php$storage = Zend_Cloud_StorageService_Factory::getAdapter(array(    Zend_Cloud_StorageService_Factory::STORAGE_ADAPTER_KEY => 'Zend_Cloud_StorageService_Adapter_FileSystem',    Zend_Cloud_StorageService_Adapter_FileSystem::LOCAL_DIRECTORY   => $localDirectory,));$data = file_get_contents('/my/local/dir/picture.jpg');$returnedData = $storage->storeItem('/my/remote/path/picture.jpg', $data);

Even  supports  local  file  system

Put  opIons  in  config  file

Page 77: Hybrid Cloud PHPUK2012

Design  pajernse.g.

Dependency  injecLon

Modular  designAbstracIon  

layers

Page 78: Hybrid Cloud PHPUK2012

+  W3  Total  Cache

Page 79: Hybrid Cloud PHPUK2012

W3  Total  Cache

✓Page  caching  -­‐Memcached  (loadbalanced)-­‐ Varnish  (loadbalanced)

✓Database  &  object  cache-­‐Memcached  (loadbalanced)

✓CDN-­‐ Push  to  S3  or  Azure  Blog  storage  buckets-­‐ Pull  from  CDN  (CloudFront  or  Azure)-­‐ Custom  hostnames

✓Scale  across  EC2  nodes  with  ELB

Page 80: Hybrid Cloud PHPUK2012
Page 81: Hybrid Cloud PHPUK2012
Page 82: Hybrid Cloud PHPUK2012
Page 83: Hybrid Cloud PHPUK2012

Deploy  your  code

Page 84: Hybrid Cloud PHPUK2012

Deploy  your  code

✓General  deployment  methods–Capistrano–Phing–Puppet  (config  is  code  too)–Version  control  tools

✓Amazon  specific–AMI’s

✓Azure  specific–Scaffolding  &  packaging    command  line  tool–Upload  packages  in  control  panel

✓Orchestra  specific–Git

Page 85: Hybrid Cloud PHPUK2012

About  Azure  deployment

Page 86: Hybrid Cloud PHPUK2012

About  Azure  deployment

scaffolder  run  -­‐out="c:\temp\HelloAzure\Project"

package  create  -­‐in="C:\temp\HelloAzure\Project"  -­‐out="C:\temp\HelloAzure\DeployDev"  -­‐dev=true

package  create  -­‐in="C:\temp\HelloAzure\Project"  -­‐out="C:\temp\HelloAzure\DeployProduction"  -­‐dev=false

package  and  run  on  emulator

package  for  deployment

Page 87: Hybrid Cloud PHPUK2012

About  Azure  deployment

Certificate=XXXXXXXXSubscriptionId=XXXXXPassphrase=XXXXXXXXXStorageAccount=XXXXXPackageLocation=_files\PhpOnAzure.cspkgServiceConfigLocation=_files\ServiceConfiguration.cscfg

Sebngs.ini

Page 88: Hybrid Cloud PHPUK2012

About  Azure  deployment

deployment.php  CreateFromLocal  -­‐-­‐ConfigFile="settings.ini"  -­‐-­‐Name="mysubdomain"  -­‐-­‐DeploymentName="testdeploy"  -­‐-­‐Label="testdeploy"  -­‐-­‐BySlot="staging"  -­‐-­‐StartImmediately  -­‐-­‐WaitFor

Deploy  to  staging

Page 89: Hybrid Cloud PHPUK2012

About  Azure  deployment

deployment.php  Swap  -­‐-­‐ConfigFile="settings.ini"  -­‐-­‐Name="mysubdomain"  -­‐-­‐WaitFor

deployment.php  EditInstanceNumber  -­‐-­‐ConfigFile="settings.ini"  -­‐-­‐Name="subdomain"  -­‐-­‐ByName="testdeploy"  -­‐-­‐RoleName="PhpOnAzure.Web"  -­‐-­‐NewInstanceNumber=2

Swap  to  producLon

Scale  out

Page 90: Hybrid Cloud PHPUK2012

Mix  &  match

Page 91: Hybrid Cloud PHPUK2012

Management  models  (oAen  forgoBen)

Page 92: Hybrid Cloud PHPUK2012

Management  models  (oAen  forgoBen)

Managed  Cloud  is  the  new  dedicated  server

Unmanaged  Cloud  is  virtual  colocaIon

Page 93: Hybrid Cloud PHPUK2012

Management  models  (oAen  forgoBen)

Custom  soluIon  at  hoster  under  heavy  SLA

Burst  model  at  unmanaged  vendor

Page 94: Hybrid Cloud PHPUK2012

When  to  choose  what?

Page 95: Hybrid Cloud PHPUK2012
Page 96: Hybrid Cloud PHPUK2012