Top Banner
1 Moving PHP to the Cloud München, 23. March 2016
28

Moving PHP to the Cloud

Jan 22, 2018

Download

Technology

Ingo Walz
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Moving PHP to the Cloud

1

Moving PHP to the Cloud

München, 23. March 2016

Page 2: Moving PHP to the Cloud

2

About me

29 year old

E-Commerce Architect

Joined Sixt in October 2015

> 10years of PHP experience as:

1) Administrator2) Developer3) DevOps4) Architect

Page 3: Moving PHP to the Cloud

3

Agenda

How it looks like todayA.

B. Motivations for Migration

C. Technologies used

D. Target Architecture

E. Let's see some Code!

Page 4: Moving PHP to the Cloud

4

How it looks today

Typo3SF2 RestMySQL

CDN

Page 5: Moving PHP to the Cloud

5

The used CDN only provides a limited set of caching capabilities

Managed server● Troubleshooting was

impossible● No tooling available● No way to install the required

tools

Flexibility Scalability Architecture

Only vertical scaling was available at previous hoster

Perfect showcase for auto scaling based on the load

Eliminate Single point of failures „One function per component“ Automation pipeline was already

available

Motivations for migration

Page 6: Moving PHP to the Cloud

6

Technologies to choose from

TerraformGolang

Gatling

Page 7: Moving PHP to the Cloud

7

Used Technologies

Terraform

Page 8: Moving PHP to the Cloud

8

AWS

A. EC2

D. Launch configuration

C. Auto scaling groups

B. S3

E. Elastic Load Balancer

AWS Glossary

Dynamic compute power

Simple persistent storage service

Scale number of EC2 instances automatically

Tell AWS how to spawn your instances

Route traffic to all scaled instances, don't care how much

F. RDS Managed relational database in AWS

Page 9: Moving PHP to the Cloud

9

Puppet

● Already in use at Sixt

● Well known in the industry

● Developer friendly

● Great tooling available

● Easy to use

Page 10: Moving PHP to the Cloud

10

Cloud Init

● Ready to use

● Incredibly easy to link cloud automation with service automation

● Control your boot process

● Hook into every required step

Page 11: Moving PHP to the Cloud

11

Varnish & nginx

● Outperform everything

● Easy to integrate & automate

● Very DEV friendly DSL for varnish

● Somehow standard

Page 12: Moving PHP to the Cloud

12

AWS

● Know how inhouse

● Offers the required flexibility

● Great automation support

● Cheap

Page 13: Moving PHP to the Cloud

13

PHP & Ecosystem

● No brainer

● They do what they promise

● Standards in web

Page 14: Moving PHP to the Cloud

14

Terraform

Terraform

● Provider independent technology(but the implementation is very closely bound to AWS)

● SDDC → Software defined data center

● AWS is very well supported

● Great tool, but young

Page 15: Moving PHP to the Cloud

15

The automation pipeline

Page 16: Moving PHP to the Cloud

16

The Build pipeline

github

jenkins

S3 BucketCode changes

Webhook

Build artifact (.

tar.gz)

Infrastructure

Fetch prepared artifact from upstream

Page 17: Moving PHP to the Cloud

17

Automation flow

100%Automation

Terraform

Cloudinit

Puppet

SoftwareInstallconfig

ServiceInstallconfig

5

1

23

4

1

2

3

4

5

TerraformSetup of the cloud data center

CloudinitBoothooks & custom startup script

PuppetConfiguration management

Service installation and configurationSetup of the required services to run the application

Software installation and configurationInstalls and configures the software components

Page 18: Moving PHP to the Cloud

18

The Architecture

AZ 1 AZ 2

NAT GW NAT GWELB

Varnish Varnish

ELB

Typo3

Service

Typo3

Service

ELB

BastionPublic

Private

MySQLRDS

AWS Region Frankfurt

Page 19: Moving PHP to the Cloud

19

Rules for Terraform

Never spin instances, only launch configurations linked to auto scaling groups1.

2. Don't destroy persistence layer

Achieve HA / DR

RDS backup & restore is terribly slow

3. Safe your .tfstate file for everyone (e.g. store it on S3 is nativly supported)

If you're working in a team, you want to share the state of terraform!

Page 20: Moving PHP to the Cloud

20

Terraform

Page 21: Moving PHP to the Cloud

21

Rules for Puppet

Puppet runs need to be agnostic1.

2. Software installation & configuration has to be part of puppet and available from the outside

Restarting services is not a good idea if you run frequently

1. Install software (correct version) on fresh instances2. Update software in existing infrastructure

Use puppet masterless for unlimited scale!3.

There is no „Single Point“ for failures

Page 22: Moving PHP to the Cloud

22

Puppet

Page 23: Moving PHP to the Cloud

23

Cloud Init

terraform/ ← SDDC project

cloudinit/ ← Cloudinit directory

boothooks/ ← Contains scripts that run as a boothook

z-01-packages.sh ← Check internet connectivity & install ruby, aws-sdk and puppet

shellscripts/ ← Contains scripts that run after the boot

z-10-ec2_tags_to_facts.rb ← Allows us to see the tags from terraform to control puppet run

z-19-puppet-apply.sh ← Run puppet with the exported tags from tags_to_facts

userdata/ ← Baked everything above as AWS user-data (available on every machine)

min-puppet-apply.txt.gz ← The „builded“ user-data contains the other dirs

userdata.conf ← Cloudinit configuration

cloud-config-default.txt ← Some defaults like locale, apt-behaviour and puppet tooling (hiera etc)

Page 24: Moving PHP to the Cloud

24

Cloud Init - configuration

Page 25: Moving PHP to the Cloud

25

Cloud Init

Page 26: Moving PHP to the Cloud

26

Cloud Init – z-01-packages.sh

Page 27: Moving PHP to the Cloud

27

Cloud Init – z-19-puppet-apply.sh

Page 28: Moving PHP to the Cloud

28

Questions?