the continuous php pipeline

57
Continuous PHP Pipeline in it 2 PROFESSIONAL PHP SERVICES

Upload: michelangelo-van-dam

Post on 19-Jul-2015

739 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: The Continuous PHP Pipeline

Continuous PHP Pipeline

in it2PROFESSIONAL PHP SERVICES

Page 2: The Continuous PHP Pipeline

Michelangelo van DamPHP Consultant, Community Leader & Trainer

http

s://w

ww.

flick

r.com

/pho

tos/

akra

bat/8

7843

1881

3

Page 3: The Continuous PHP Pipeline

Schedule

• Development processes

• Automation first

• Continuous Integration

• The PHP Pipeline

• Do what you do best: code

• Round up http

s://w

ww.

flick

r.com

/pho

tos/

wen

zday

01/3

0052

9735

5

Page 4: The Continuous PHP Pipeline

Knowledge Check

• What’s PHP?

• What’s a SCM?

• What’s unit testing?

• What are distributed systems?

• What is provisioning?

• What are merge conflicts? http

s://w

ww.

flick

r.com

/pho

tos/

didm

ysel

f/653

0383

417

Page 5: The Continuous PHP Pipeline

Development Management

http

s://w

ww.

flick

r.com

/pho

tos/

2743

3628

@N

05/2

5973

0832

8

Page 6: The Continuous PHP Pipeline

WaterfallProject Start

Kick-off meetingDefining Approach

Meeting Execs

Project Initiate

Business CasesProject ControlsRisk Definition

Project Control

Progress Monitoring

Project Delivery

Project finalisation

Maintenance

Ongoing process

Page 7: The Continuous PHP Pipeline

ScrumWeekly

backlog review

Dailystandups

Product Backlog

AcceptanceCriteria

Sprint Backlog Prototype Delivery

Product Backlog

Product BacklogProduct

Backlog

Sprint

Page 8: The Continuous PHP Pipeline

Something (ad-hock)Project

Requirements

Ad-hockIssues

TaskAssignment Delivery

Page 9: The Continuous PHP Pipeline

Need to deliver

Weeklybacklog review

Dailystandups

Product Backlog

AcceptanceCriteria

Sprint Backlog Prototype Delivery

Product Backlog

Product BacklogProduct

Backlog

Sprint

Project Start

Kick-off meetingDefining Approach

Meeting Execs

Project Initiate

Business CasesProject ControlsRisk Definition

Project Control

Progress Monitoring

Project Delivery

Project finalisation

Maintenance

Ongoing process

Project Requirements

Ad-hockIssues

TaskAssignment Delivery

Delivery

Page 10: The Continuous PHP Pipeline

Delivery “event”• Off-hours release planning • Set up a maintenance page • Pre-release actions (backups, stopping crons, …) • Release checklist -> manual deployment • Post-release actions (crons, caches, …) • Removing maintenance page • Manually verify everything is working (old & new) • If lucky, going home for the night/morning

Page 11: The Continuous PHP Pipeline

A nightmare

http

s://w

ww.

flick

r.com

/pho

tos/

bern

atcg

/223

1649

285

Page 12: The Continuous PHP Pipeline

Automation First

http

s://w

ww.

flick

r.com

/pho

tos/

freef

oto/

5982

5499

38

Page 13: The Continuous PHP Pipeline

Computers are great at doing repetitive task very well

Page 14: The Continuous PHP Pipeline

Development

Source Code

Static Files

Database Deltas

Platform

Monitoring Database

Storage Workers Caches

Web Server

Infrastructure

Bare Metal

Virtual Machines Cloud

Page 15: The Continuous PHP Pipeline

Infrastructure

Bare Metal

Virtual Machines Cloud

Page 16: The Continuous PHP Pipeline

Infrastructure

https://www.gnu.org/graphics/heckert_gnu.small.png

Hosting Providers

On PremiseCloud Solution Providers

Page 17: The Continuous PHP Pipeline

A “simple” architecture

Web Web

Proxy Proxy Proxy

DB Slave DB Slave DB Slave DB Slave

DB Master DB Master

NoSQL NoSQL NoSQL

0MQ

Mai

lShared IO

Web

Database

Page 18: The Continuous PHP Pipeline

Are you ready?Things get very complex very fast

http

s://w

ww.

flick

r.com

/pho

tos/

mar

iano

-man

tel/9

1943

4426

8

Page 19: The Continuous PHP Pipeline

Platform

Monitoring Database

Storage Workers Caches

Web Server

Page 20: The Continuous PHP Pipeline

Automation tools

https://www.gnu.org/graphics/heckert_gnu.small.png

Page 21: The Continuous PHP Pipeline

Why automate platform?• It should be optimised to run your application

• Continuous updates and tweaks possible

• Setting up your architecture in a consistent way

• For production

• For staging

• For testing

• For development

Page 22: The Continuous PHP Pipeline

Choose wisely

http

s://w

ww.

flick

r.com

/pho

tos/

keep

itsur

real

/610

7919

083

Page 23: The Continuous PHP Pipeline

Give Docker a try

• Requires no virtualisation software • Saves on resources!

• Allows to set up a distributed architecture • Even for development purposes

• Isolates processes in a container • Helps with securing infrastructure

Page 24: The Continuous PHP Pipeline

Vagrant up

Monitoring Database

Storage Workers Caches

Web Server

Page 25: The Continuous PHP Pipeline

Development

Source Code

Static Files

Database Deltas

Page 26: The Continuous PHP Pipeline

SCM is a must!

Page 27: The Continuous PHP Pipeline

FTP is not a SCM

Page 28: The Continuous PHP Pipeline

Commit and push

Page 29: The Continuous PHP Pipeline

http

s://w

ww.

flick

r.com

/pho

tos/

mab

i/383

0712

4

Page 30: The Continuous PHP Pipeline

Why CI?

• Monitors continuously

• Executes directly after change

• Gives feedback

• Has dashboards

• Automate post-development processes

http

s://w

ww.

flick

r.com

/pho

tos/

ambe

rand

clin

t/326

6859

324

Page 31: The Continuous PHP Pipeline

CI takes care of your codePre build steps!

- Stop crons, queues and workers - Remove target from load balancer

Build steps!- Check out new changes - Run unit tests - Provision target(s) - Provision databases

Post build steps!- Warm up caches - Reactivate crons, queues and workers - Add target back into loadbalancer - Sent status out

Page 32: The Continuous PHP Pipeline

Common CI systems

Page 33: The Continuous PHP Pipeline

Online CI systems

Page 34: The Continuous PHP Pipeline
Page 35: The Continuous PHP Pipeline
Page 36: The Continuous PHP Pipeline
Page 37: The Continuous PHP Pipeline
Page 38: The Continuous PHP Pipeline

The PHP Pipeline

http

s://w

ww.

flick

r.com

/pho

tos/

mm

mav

ocad

o/45

9739

7875

Page 39: The Continuous PHP Pipeline

Prioritise build steps

Unit tests Metrics

Provisioningnew target

Provisioningdatabases

Provisioningworkers

Integrationtests

Promotebranch

CI

Page 40: The Continuous PHP Pipeline

Stop execution at first fail

Unit tests Metrics

Provisioningnew target

Provisioningdatabases

Provisioningworkers

Integrationtests

Promotebranch

CI

Page 41: The Continuous PHP Pipeline

When good, promote!Unit tests Metrics

Provisioningnew target

Provisioningdatabases

Provisioningworkers

Integrationtests

Promotebranch

CI

Unit tests Metrics

Provisioningnew target

Provisioningdatabases

Provisioningworkers

Integrationtests

Promotebranch

CI

Page 42: The Continuous PHP Pipeline

Delivery vs Deployment

Source: http://blog.crisp.se/2013/02/05/yassalsundman/continuous-delivery-vs-continuous-deployment

Page 43: The Continuous PHP Pipeline

Continuous Delivery

Build Feedback

Build Feedback

SCMCommits SCM Change

Polling

Deployment ManagementDashboard

test

staging

production

Page 44: The Continuous PHP Pipeline

Continuous Deployment

Build Feedback

Execute Delivery

SCMCommits SCM Change

Pollingtest

staging

production

Page 45: The Continuous PHP Pipeline

All code is live!

    if ($application->getFeature('myawesomefeature')->isComplete()) { "!        // Here comes the new feature functionality "!    }

Page 46: The Continuous PHP Pipeline

Other usages• A/B Testing

• Partial based roll-out (GeoLocation, Age, Gender)

• SaaS premium features

• Automated assisted training programs

• Netflix Chaos Monkey Testing

• See http://in2.se/nfchaosmonkey for details

• April’s fools day fun!

Page 47: The Continuous PHP Pipeline

http

s://w

ww.

flick

r.com

/pho

tos/

ihta

tho/

6272

2631

5

Page 48: The Continuous PHP Pipeline

Benefits

Page 49: The Continuous PHP Pipeline

Failures do happen

Page 50: The Continuous PHP Pipeline

Our tools

Page 51: The Continuous PHP Pipeline

Our Stats

Total commits today 129Total releases 118Total failures 11Total DB deployments 4Average failure resolution time (minutes) 5Average release time (minutes) 3

Page 52: The Continuous PHP Pipeline

http

s://w

ww.

flick

r.com

/pho

tos/

timyp

enbu

rg/5

1720

4200

7

Page 53: The Continuous PHP Pipeline

Your turn now!• Automate everything that’s not coding • Create repeatable, reliable processes • Fail as quickly as possible

• If it hurts, do it more frequently • Communicate each step

• Everyone is responsible! • Continuously improve

• On your code • On your processes

Page 54: The Continuous PHP Pipeline

Recommended Reading

Page 55: The Continuous PHP Pipeline
Page 56: The Continuous PHP Pipeline

in it2PROFESSIONAL PHP SERVICES

Michelangelo van Dam!Zend Certified Engineer

PHP Consulting - Training - Quality Assurance

www.in2it.be | [email protected]

Page 57: The Continuous PHP Pipeline

http

s://w

ww.

flick

r.com

/pho

tos/

5621

8409

@N

03/1

5371

2624

55