Developing apps faster

50
Building the perfect PHP app for the enterprise Episode 2 : Developing apps faster Maurice Kherlakian Twitter: @mkherlakian Email: [email protected]

Transcript of Developing apps faster

Page 1: Developing apps faster

Building the perfect PHP app for the enterprise

Episode 2 : Developing apps fasterMaurice KherlakianTwitter: @mkherlakianEmail: [email protected]

Page 2: Developing apps faster

2

Series overviewNow: Developing apps faster

September 28: Resolving problems and high availabilityYour reputation as a miracle worker is secure when using these principles to isolate faults, optimize scale, and synchronize sessions across clusters.

October 12: Optimizing performanceKeep users on your site by learning how to use background jobs and caching, measure performance, and make data-driven decisions.

Page 3: Developing apps faster

Maurice KherlakianDirector of professional servicesRogue Wave Software

Page 4: Developing apps faster

4

Enterprise PHP is mission-critical

• Built securely• Delivers optimal performance + scale• Always on• Meets release timelines• Modernizes legacy business logic• Clear support path (production + LTS)

Page 5: Developing apps faster

5

What does deployment automation look like?• Amazon – 1 deployments/second

- Werner Vogels. CTO Amazon

• Etsy – 40 – 50 deployments/day

• Netflix – highly automated deployments and testing (Simian Army)techblog.netflix.com/2016/03/how-we-build-code-at-netflix.htmltechblog.netflix.com/2013/08/deploying-netflix-api.htmlquora.com/How-fast-is-Netflixs-development-cycle-in-practice

Page 6: Developing apps faster

Poll #1:At what frequency do you deploy? • Multiple times a day• Once a day• Once a week• Once a quarter• Once a year

Page 7: Developing apps faster

7

Faster deployment

cycles

Faster application developme

nt=

Page 8: Developing apps faster

8

Faster deployment cycles benefits

• Faster feedback from your end users

• Faster development• More iterations• Better product overall

Faster deployment

cycles

Faster application

development=

Page 9: Developing apps faster

9

The traditional approach

Requirements

Design

Implementation

Verification

Maintenance

Page 10: Developing apps faster

10

WaterGile anyone?• Teams within an organization subscribing to Agile methodology• Teams often isolated – entire company didn’t buy into Agile

methodologies• Still gather requirements, but break the down into user stories

Page 11: Developing apps faster

Poll #2:What development practice do you follow?• Waterfall principles• A combination f waterfall and Agile

(WaterGile – AgileFall)• Mainly Agile principles

Page 12: Developing apps faster

12

You are always behind!

• Technical debt keeps increasing

Page 13: Developing apps faster

13

Faster deployment

cycles

Faster application developme

nt=

Page 14: Developing apps faster

Feedback loop and monitoring

Page 15: Developing apps faster

15

You’ve just released a feature

Add a map display of all available cars to rent in a 10 km radius Released to

everyone

Impact?

Overload – servers down, root cause

unknown

PANIC!

Page 16: Developing apps faster

16

You’ve just released a feature to some users

Add a map display of all available cars to rent in a 10 km radius Released to 20% of

users

Impact – compare with other 80%

through app monitoring system

Change in CPU consumption profiles for same amount of

users

Fix or turn feature off

Page 17: Developing apps faster

17

Tools that can help• Instrument your code

– PHP feature toggle (qandidate-toggle - ) – release to a subset of users

• Zend Server Monitoring – a complete solution to monitor the behavior of your application – so you will catch the 20% spike in CPU usage

Page 18: Developing apps faster

18

It’s working… ramp it up!

Add a map display of all available cars to rent in a 10 km radius Released to 50% of

users

10% more rentals per visitor on version with

map

Little to no change in performance

Release to everyone

Page 19: Developing apps faster

Release automation

Page 20: Developing apps faster

20

It worked fine on dev!• Environment consistency

Page 21: Developing apps faster

21

Git

Developer’s code for map

featureCheck in

PackagePackaged app (parametrized

)

Staging

TEST

Prod

Rollback

Packaging for release

Page 22: Developing apps faster

22

Tools that can help• VMs and consistency

– Vagrant– Docker

• Deployment– Zend Server (deployment)– AWS code deploy

Page 23: Developing apps faster

Continuous integration

Page 24: Developing apps faster

24

What is a CI server?• CI automates the various tasks of building,

packaging, testing and deploying

• If build breaks, up to developer that broke it to fix it

• If build passes, it CAN go all the way to production

Page 25: Developing apps faster

25

A typical CI pipeline

Git clone Composer install Unit test Package

Deploy to test

Functional test

Deploy to Staging

Deploy to prod

Add a map display of all available cars to rent in a 10 km radius

Page 26: Developing apps faster

26

Failure!

Git clone Composer install Unit test

FAIL Build 783 failed

Add a map display of all available cars to rent in a 10 km radius

Page 27: Developing apps faster

27

Tools that can help

Page 28: Developing apps faster

Poll #3:Do you use a CI server?• Yes• No

Page 29: Developing apps faster

Demo

Page 30: Developing apps faster

Testing automation

Page 31: Developing apps faster

31

Testing at different stages• Unit testing

• Functional testing

• Integration testing

• Load testing

Reference: techblog.netflix.com/search/label/Integration%20Testing

Page 33: Developing apps faster

33

Test early, test often!

Page 34: Developing apps faster

34

Add a map display of all available cars to rent in a 10 km radius

Simulate a browser request and ensure that a map loads, and that the map has the number of vehicles available for rent

Functional

getCars($criteria, $radius)

$map->plotCoordinates($cars)

$modelView->assign(‘map’, $map)

Unit

Load 1,000 concurrent search requests for cars from 1000 different locations

Load

Page 35: Developing apps faster

Poll #4:Do you unit test?• Yes• No

Page 36: Developing apps faster

36

Tools that can help• ab, Jmeter, LoadRunner• PHPUnit• Behat – Mink• PHPspec

Page 37: Developing apps faster

Frameworks/libraries

Page 38: Developing apps faster

Poll #5:Do you use a framework?• Yes• No

Page 39: Developing apps faster

39

Evolution of frameworks• Component frameworks

• MVC out, middleware in

• Microservices architecture

Page 40: Developing apps faster

40

Tools that can helpSo many…

• Zend Framework: ZF3, Expressive, Apigility

• Laravel, Symfony, Yii, and many more

Page 41: Developing apps faster

Writing code and left shifting

Page 42: Developing apps faster

42

Catch bugs early• Remember how a bug in prod can cost as much as 15X times the

cost of a bug in development?

Page 43: Developing apps faster

43

How do you catch bugs early?

• Test early, test often – when developing, test locally before committing

• Peer reviews

• Code instrumentation tools

Page 44: Developing apps faster

What about hardware and infrastructure?

Page 45: Developing apps faster

46

Infrastructure should also be automated• Automate server provisioning

• Source control your environment configurations

• The goal is to fully rebuild an environment automatically in case of failure

Page 46: Developing apps faster

47

Another example – dealnews.com• In the past 2 weeks

– Deployed web application 64 times – average 6.5 times a day– Deployed configuration management changes 12 times– Deployed MySQL schema changes 13 times

- Courtesy of Brian Moon

Page 47: Developing apps faster

Q&A

Page 49: Developing apps faster

50

Stay tunedSeptember 28: Resolving problems and high availabilityYour reputation as a miracle worker is secure when using these principles to isolate faults, optimize scale, and synchronize sessions across clusters.

October 12: Optimizing performanceKeep users on your site by learning how to use background jobs and caching, measure performance, and make data-driven decisions.

Page 50: Developing apps faster

Building the perfect PHP app for the enterprise

Episode 2 : Developing apps fasterMaurice KherlakianSeptember 14, 2016