Building the perfect PHP app for the enterprise
Episode 2 : Developing apps
faster
Maurice Kherlakian
Twitter: @mkherlakian
Email: maurice.kherlakian@roguewave.com
2
Series overview
Now: Developing apps faster
September 28: Resolving problems and high availability
Your reputation as a miracle worker is secure when using these principles to
isolate faults, optimize scale, and synchronize sessions across clusters.
October 12: Optimizing performance
Keep users on your site by learning how to use background jobs and caching,
measure performance, and make data-driven decisions.
Maurice Kherlakian
Director of professional services
Rogue Wave Software
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)
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.html
techblog.netflix.com/2013/08/deploying-netflix-api.html
quora.com/How-fast-is-Netflixs-development-cycle-in-practice
Poll #1:
At what frequency do
you deploy?
• Multiple times a day
• Once a day
• Once a week
• Once a quarter
• Once a year
7
Faster
deployment
cycles
Faster
application
development
=
8
Faster deployment cycles benefits
• Faster feedback from your
end users
• Faster development
• More iterations
• Better product overall
Faster
deployment
cycles
Faster
application
development
=
9
The traditional approach
Requirements
Design
Implementation
Verification
Maintenance
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
Poll #2:
What development
practice do you follow?
• Waterfall principles
• A combination f waterfall and Agile
(WaterGile – AgileFall)
• Mainly Agile principles
12
You are always behind!
• Technical debt keeps
increasing
13
Faster
deployment
cycles
Faster
application
development
=
Feedback loop and
monitoring
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!
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
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
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
Release automation
20
It worked fine on dev!
• Environment consistency
21
Git
Developer’s code for
map feature
C
h
e
c
k
i
n
Package
Packaged app
(parametrized)
Staging
TEST
Prod
Rollback
Packaging for release
22
Tools that can help
• VMs and consistency
– Vagrant
– Docker
• Deployment
– Zend Server (deployment)
– AWS code deploy
Continuous
integration
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
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
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
27
Tools that can help
Poll #3:
Do you use a CI
server?
• Yes
• No
Demo
Testing automation
31
Testing at different stages
• Unit testing
• Functional testing
• Integration testing
• Load testing
Reference: techblog.netflix.com/search/label/Integration%20Testing
32
Cost of bug fixing
Stefan Priebsch – Advanced OOP and design patterns
Credit: Stefan Priebsch
33
Test early, test often!
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
Poll #4:
Do you unit test?
• Yes
• No
36
Tools that can help
• ab, Jmeter, LoadRunner
• PHPUnit
• Behat – Mink
• PHPspec
Frameworks/libraries
Poll #5:
Do you use a
framework?
• Yes
• No
39
Evolution of frameworks
• Component frameworks
• MVC out, middleware in
• Microservices architecture
40
Tools that can help
So many…
• Zend Framework: ZF3, Expressive, Apigility
• Laravel, Symfony, Yii, and many more
Writing code and left
shifting
42
Catch bugs early
• Remember how a bug in prod can cost as much as 15X times the cost of a
bug in development?
43
How do you catch bugs early?
• Test early, test often – when
developing, test locally before
committing
• Peer reviews
• Code instrumentation tools
What about hardware
and infrastructure?
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
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
Q&A
49
Learn more
• Watch this webinar on demand
• Read the recap blog to see the results of
the polls and Q&A session
50
Stay tuned
September 28: Resolving problems and high availability
Your reputation as a miracle worker is secure when using these principles to
isolate faults, optimize scale, and synchronize sessions across clusters.
October 12: Optimizing performance
Keep users on your site by learning how to use background jobs and caching,
measure performance, and make data-driven decisions.
Building the perfect PHP app for the enterprise
Episode 2 : Developing apps
faster
Maurice Kherlakian
September 14, 2016

Developing apps faster

  • 1.
    Building the perfectPHP app for the enterprise Episode 2 : Developing apps faster Maurice Kherlakian Twitter: @mkherlakian Email: maurice.kherlakian@roguewave.com
  • 2.
    2 Series overview Now: Developingapps faster September 28: Resolving problems and high availability Your reputation as a miracle worker is secure when using these principles to isolate faults, optimize scale, and synchronize sessions across clusters. October 12: Optimizing performance Keep users on your site by learning how to use background jobs and caching, measure performance, and make data-driven decisions.
  • 3.
    Maurice Kherlakian Director ofprofessional services Rogue Wave Software
  • 4.
    4 Enterprise PHP ismission-critical • Built securely • Delivers optimal performance + scale • Always on • Meets release timelines • Modernizes legacy business logic • Clear support path (production + LTS)
  • 5.
    5 What does deploymentautomation 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.html techblog.netflix.com/2013/08/deploying-netflix-api.html quora.com/How-fast-is-Netflixs-development-cycle-in-practice
  • 6.
    Poll #1: At whatfrequency do you deploy? • Multiple times a day • Once a day • Once a week • Once a quarter • Once a year
  • 7.
  • 8.
    8 Faster deployment cyclesbenefits • Faster feedback from your end users • Faster development • More iterations • Better product overall Faster deployment cycles Faster application development =
  • 9.
  • 10.
    10 WaterGile anyone? • Teamswithin 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
  • 11.
    Poll #2: What development practicedo you follow? • Waterfall principles • A combination f waterfall and Agile (WaterGile – AgileFall) • Mainly Agile principles
  • 12.
    12 You are alwaysbehind! • Technical debt keeps increasing
  • 13.
  • 14.
  • 15.
    15 You’ve just releaseda 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!
  • 16.
    16 You’ve just releaseda 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
  • 17.
    17 Tools that canhelp • 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
  • 18.
    18 It’s working… rampit 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
  • 19.
  • 20.
    20 It worked fineon dev! • Environment consistency
  • 21.
    21 Git Developer’s code for mapfeature C h e c k i n Package Packaged app (parametrized) Staging TEST Prod Rollback Packaging for release
  • 22.
    22 Tools that canhelp • VMs and consistency – Vagrant – Docker • Deployment – Zend Server (deployment) – AWS code deploy
  • 23.
  • 24.
    24 What is aCI 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
  • 25.
    25 A typical CIpipeline 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
  • 26.
    26 Failure! Git clone Composer install Unit test FAIL Build783 failed Add a map display of all available cars to rent in a 10 km radius
  • 27.
  • 28.
    Poll #3: Do youuse a CI server? • Yes • No
  • 29.
  • 30.
  • 31.
    31 Testing at differentstages • Unit testing • Functional testing • Integration testing • Load testing Reference: techblog.netflix.com/search/label/Integration%20Testing
  • 32.
    32 Cost of bugfixing Stefan Priebsch – Advanced OOP and design patterns Credit: Stefan Priebsch
  • 33.
  • 34.
    34 Add a mapdisplay 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
  • 35.
    Poll #4: Do youunit test? • Yes • No
  • 36.
    36 Tools that canhelp • ab, Jmeter, LoadRunner • PHPUnit • Behat – Mink • PHPspec
  • 37.
  • 38.
    Poll #5: Do youuse a framework? • Yes • No
  • 39.
    39 Evolution of frameworks •Component frameworks • MVC out, middleware in • Microservices architecture
  • 40.
    40 Tools that canhelp So many… • Zend Framework: ZF3, Expressive, Apigility • Laravel, Symfony, Yii, and many more
  • 41.
    Writing code andleft shifting
  • 42.
    42 Catch bugs early •Remember how a bug in prod can cost as much as 15X times the cost of a bug in development?
  • 43.
    43 How do youcatch bugs early? • Test early, test often – when developing, test locally before committing • Peer reviews • Code instrumentation tools
  • 44.
    What about hardware andinfrastructure?
  • 45.
    46 Infrastructure should alsobe automated • Automate server provisioning • Source control your environment configurations • The goal is to fully rebuild an environment automatically in case of failure
  • 46.
    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
  • 47.
  • 48.
    49 Learn more • Watchthis webinar on demand • Read the recap blog to see the results of the polls and Q&A session
  • 49.
    50 Stay tuned September 28:Resolving problems and high availability Your reputation as a miracle worker is secure when using these principles to isolate faults, optimize scale, and synchronize sessions across clusters. October 12: Optimizing performance Keep users on your site by learning how to use background jobs and caching, measure performance, and make data-driven decisions.
  • 50.
    Building the perfectPHP app for the enterprise Episode 2 : Developing apps faster Maurice Kherlakian September 14, 2016

Editor's Notes

  • #7 At what frequency do you deploy? Multiple times in a day Once a day Once a week Once a month Once a quarter Once a year