Hybrid Cloud PHPUK2012
- 1. Develop
&
deploy
using
hybrid
cloud
strategies
Thijs
Feryn
Evangelist
+32
(0)9
218
79
06
thijs@combellgroup.com
- 11. Please
rate
my
talk
on
Joind.in
https://joind.in/4951
- 15. DefiniIon
A
model
for
consumpIon
&
delivery
on
the
internet
where
flexibility
is
essenIal
&
can
be
guaranteed
through
abstracIon
- 31. Amazon
web
services
✓CompuIng ✓Database
–EC2 –RDS
–ELB –DynamoDB
–Auto
–SimpleDB
scaling –ElasIcache
✓Storage –SQS
–S3 ✓CDN
–EBS –CloudFront
Self-‐service
Iaas
- 32. Windows
Azure
✓CompuIng
✓Storage
–Blog
storage
–Table
storage
✓CDN
✓SQL
Azure
✓Data
sync
✓Service
Bus
Self-‐service
Paas
- 33. Orchestra
✓CompuLng
✓Database
–Memcached
–MySQL
&
RDS
–CouchDB
–MongoDB
–Redis
PHP
Paas
on
top
of
AWS
- 34. CloudFlare
✓CDN
✓DNS
✓DDOS
security
✓Traffic
analyIcs
ProtecIon
SaaS
- 48. Infrastructure
✓Basics
–Webservers
–MySQL
servers
–File
servers
✓AddiIonal
servers
–Caching
servers
–Reverse
proxy
servers
✓External
CDN
- 50. Single
server
setup
✓Developer
–Everything
is
local
•Files
•Databases
✓Sysadmin
–Sits
back,
drinks
some
coffee
- 51. Single
server
setup
What
✓Amazon about
the
–1
EC2
instance Cloud?
–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
- 54. Separate
MySQL
What
✓Amazon about
the
–Extra
EC2
instance
for
MySQL Cloud?
–RDS
✓Azure
–MySQL
deployment
with
worker
role
–Doesn’t
scale
well
–Use
SQL
Azure
instead
✓Orchestra
–By
default
separate
–Create
separate
MySQL
database
–RDS
- 56. 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
- 57. MulIple
Use
mysqlnd_ms
for
R/W
splibng
in
case
of
crappy
code
MySQL’s
{
"myapp":
{
"master":
{
"write_group":
{
"host":
"master.db.myapp.ext",
"port":
"3306"
} mysqlnd_ms_plugin.ini
},
"slave":
{
"read_group":
{
"host":
"slave.db.myapp.ext",
"port":
"3306"
}
}
}
}
- 59. MulIple
MySQL’s
What
✓Amazon about
the
–MulLple
EC2
instances
Cloud?
with
replicaLon
and
loadbalancing
–RDS
with
read
replica
✓Azure
–Include
PHP
&
MySQL
in
package
script
–Doesn’t
scale
–Use
SQL
Azure
✓Orchestra
–RDS
–Xeround
- 61. 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
- 63. MulIple
Web
servers
What
✓Amazon about
the
–MulLple
EC2
instances
Cloud?
–Use
ELB
for
loadbalancing
–AMI
for
easy
setup
–Config
management
(puppet,
chef,
...)
✓Azure
–Out
of
the
box
–Tuning
possible
✓Orchestra
–Out
of
the
box
- 65. 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?
- 66. Offload
staIc
files
What
✓Amazon about
the
–EC2
instances
for
storage
with
Cloud?
clustered
file
system
–S3
buckets
✓Azure
–Blog
storage
- 67. When
the
pressure
is
on
- 74. 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;
Azure
Blog
storage
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");
Amazon
S3
- 77. Design
pajerns
Modular
e.g.
AbstracIon
design
Dependency
injecLon layers
- 79. 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
- 84. 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
- 86. About
Azure
deployment
scaffolder
run
-‐out="c:tempHelloAzureProject"
package
create
-‐in="C:tempHelloAzureProject"
-‐out="C:tempHelloAzureDeployDev"
-‐dev=true
package
package
for
deployment and
run
on
emulator
package
create
-‐in="C:tempHelloAzureProject"
-‐out="C:tempHelloAzureDeployProduction"
-‐
dev=false
- 87. About
Azure
deployment
Sebngs.ini
Certificate=XXXXXXXX
SubscriptionId=XXXXX
Passphrase=XXXXXXXXX
StorageAccount=XXXXX
PackageLocation=_filesPhpOnAzure.cspkg
ServiceConfigLocation=_files
ServiceConfiguration.cscfg
- 88. About
Azure
deployment
deployment.php
CreateFromLocal
-‐-‐
ConfigFile="settings.ini"
-‐-‐Name="mysubdomain"
-‐-‐DeploymentName="testdeploy"
-‐-‐
Label="testdeploy"
-‐-‐BySlot="staging"
-‐-‐
StartImmediately
-‐-‐WaitFor
Deploy
to
staging
- 89. About
Azure
deployment
deployment.php
Swap
-‐-‐ConfigFile="settings.ini"
-‐-‐Name="mysubdomain"
-‐-‐WaitFor
Scale
Swap
out to
producLon
deployment.php
EditInstanceNumber
-‐-‐
ConfigFile="settings.ini"
-‐-‐Name="subdomain"
-‐-‐
ByName="testdeploy"
-‐-‐RoleName="PhpOnAzure.Web"
-‐-‐NewInstanceNumber=2
- 92. Management
models
(oAen
forgoBen)
Managed
Cloud
is
the
new
dedicated
server
Unmanaged
Cloud
is
virtual
colocaIon