Building the perfect PHP app for the enterprise
Developing apps faster
Adam Culp
@adamculp
Adam Culp
@adamculp
Senior Professional Services Consultant
Rogue Wave Software
3
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)
4
Deployment automation is key
• 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
Poll #1
6
Poll #1 related DevOps responses
• DevOps maturity assessment poll
• Satisfied with deployment process
– 62% somewhat satisfied
– 40% dissatisfied
7
Faster
deployment
cycles
Faster
development=
8
Benefits
• Faster feedback from end
users
• Faster feature requirements
• More iterations
• Less waste (time, code)
• Better product overall
Faster
deployment
cycles
Faster
development=
9
The traditional waterfall 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, development broken down into iterations to
build according to user stories
Poll #2
12
Poll #2 related Tech Beacon
responses
• Deployment practice (600 devs)
– 65% pure Agile
– 9% Waterfall
13
Result of not iterating fast
• Technical debt increases
• Always in catchup
• “Nice to have” items forgotten
14
Faster
deployment
cycles
Faster
development=
Feedback loop and
monitoring
16
Typical release (many features to all)
Add a map
displaying available
cars to rent within
10 km radius
Released to all
Impact?
Which new feature
caused it?
PANIC!
Overload – servers
down, root cause
unknown
17
Release single feature to some users
Add a map
displaying available
cars to rent within
10 km radius
Release to 20%
of users
Compare with 80%
Change in a query,
or amount of data
returned
Fix
or
turn of
Overloaded CPU –
some servers down
18
Tools to use
• Instrument your code
– PHP feature toggle (qandidate-toggle) – release to a subset of users
• Zend Server Monitoring – complete solution to monitor behavior an
application – will catches the 20% spike in CPU usage quickly and easily
19
It’s working… ramp it up!
10% more rentals
per visitor on
version with map
Little to no change
in performance
Release to
everyone
Add a map
displaying available
cars to rent within
10 km radius
Release to 50%
more users
Demo #1
Monitoring System
Release automation
22
Worked fine in development
• Environment consistency
23
Develop map
feature
Package Packaged app
(parametrized) Staging
TEST
Prod
Commit
Rollback
Consistency
24
Tools that can help
• Dependency Management
– Composer (json, lock)
– Packagist (public, private)
• VMs and consistency
– Vagrant
– Docker
– Others…
• Deployment
– Zend Server (deployment)
– AWS code deploy
– Others…
Continuous
integration
26
What is it?
• CI automates:
– Building
– Packaging
– Testing
– Deploying
• If build breaks, developer who broke it fixes it
• If build passes, it’s production ready
27
Typical CI pipeline
Git clone
Composer
install
Unit test
Static
Analysis
Deploy to
test
Functional
test
Deploy to
Staging
Deploy to
prod
Add a map
displaying available
cars to rent within
10 km radius
Package
28
Failure!
Git clone
Composer
install
Unit test
FAIL Build n
failed
Add a map
displaying available
cars to rent within
10 km radius
29
Tools that can help
Many
Others…
Poll #3
31
Poll #3 related DevOps responses
• DevOps maturity assessment poll used
practices
– 76% code deployment
– 62% Continuous Integration
– 31% automation and provisioning
Demo #2
CI Server
Testing automation
34
Testing at different stages
• Unit testing
• Functional testing
• Integration testing (regression)
• Load testing
35
Cost of bug fixing
Stefan Priebsh – Advanced OOP and design patterns
Credit: Stefan Priebsh thePHP.cc
36
Test early, test often!
Takeaway
37
Simulate a browser request and ensure
that a map loads, and that the map has
the number of vehicles available for rent
Functiona
l
getCars($criteria, $radius)
$map->plotCoordinates($cars)
$modelView->assign(‘map’, $map)
Unit
Load 1,000 concurrent search requests
for cars from 1000 different locations Load
Testing Steps
Add a map
displaying available
cars to rent within
10 km radius
Poll #4
39
Poll #4 typical related responses
• Do you unit test?
– 65% Yes
– 36% No
40
Tools that can help
• ab, Jmeter, LoadRunner (performance and load testing)
• PHPUnit (unit testing)
• Behat – Mink (behavioral)
• PHPspec (unit testing)
Frameworks/libraries
Poll #5
43
Poll #5 related DevOps responses
• DevOps maturity survey poll – What
simplified software development the
most in past year
– 35% some type of framework
44
Evolution of frameworks
• MVC full functionality
– All or nothing
• Component frameworks
– No lock-in
– Choose your stack
• MVC out, middleware in
• Microservice architecture
45
Tools that can help
So many…
• Zend Framework: ZF3, Expressive, Apigility
• Laravel, Symfony, Slim, and many more
Writing code and left
shifting
47
Catch bugs early
• Remember how a bug in prod can cost as much as 15X times the cost of
a bug in development?
48
How do you catch bugs early?
• Test early, test often – during
development, local before
commit
• Static Analysis
• Peer reviews
• Code instrumentation tools
Demo
Toolbars
What about hardware
and infrastructure?
51
Infrastructure should also be
automated
• Automate server provisioning
– Chef, Puppet, Ansible, Salt, others…
• Version environment build configs
• Goal = fully rebuild environment automatically on fail
52
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
Future?
54
What it may look like
• Container-ize all the things
– No longer push code to servers
– Push new servers containing code/application
• Environment templates
– Traditional hardware or VM
– Provision with new code, destroy old when users
moved
– Netflix does their interpretation of this
Q&A
Building the perfect PHP app for the enterprise
Developing apps faster
Adam Culp
@adamculp

Developing PHP Applications Faster

  • 1.
    Building the perfectPHP app for the enterprise Developing apps faster Adam Culp @adamculp
  • 2.
    Adam Culp @adamculp Senior ProfessionalServices Consultant Rogue Wave Software
  • 3.
    3 Enterprise PHP ismission-critical • Built securely • Delivers optimal performance + scale • Always on • Meets release timelines • Modernizes legacy business logic • Clear support path (production + LTS)
  • 4.
    4 Deployment automation iskey • 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
  • 5.
  • 6.
    6 Poll #1 relatedDevOps responses • DevOps maturity assessment poll • Satisfied with deployment process – 62% somewhat satisfied – 40% dissatisfied
  • 7.
  • 8.
    8 Benefits • Faster feedbackfrom end users • Faster feature requirements • More iterations • Less waste (time, code) • Better product overall Faster deployment cycles Faster development=
  • 9.
    9 The traditional waterfallapproach Requirements Design Implementation Verification Maintenance
  • 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, development broken down into iterations to build according to user stories
  • 11.
  • 12.
    12 Poll #2 relatedTech Beacon responses • Deployment practice (600 devs) – 65% pure Agile – 9% Waterfall
  • 13.
    13 Result of notiterating fast • Technical debt increases • Always in catchup • “Nice to have” items forgotten
  • 14.
  • 15.
  • 16.
    16 Typical release (manyfeatures to all) Add a map displaying available cars to rent within 10 km radius Released to all Impact? Which new feature caused it? PANIC! Overload – servers down, root cause unknown
  • 17.
    17 Release single featureto some users Add a map displaying available cars to rent within 10 km radius Release to 20% of users Compare with 80% Change in a query, or amount of data returned Fix or turn of Overloaded CPU – some servers down
  • 18.
    18 Tools to use •Instrument your code – PHP feature toggle (qandidate-toggle) – release to a subset of users • Zend Server Monitoring – complete solution to monitor behavior an application – will catches the 20% spike in CPU usage quickly and easily
  • 19.
    19 It’s working… rampit up! 10% more rentals per visitor on version with map Little to no change in performance Release to everyone Add a map displaying available cars to rent within 10 km radius Release to 50% more users
  • 20.
  • 21.
  • 22.
    22 Worked fine indevelopment • Environment consistency
  • 23.
    23 Develop map feature Package Packagedapp (parametrized) Staging TEST Prod Commit Rollback Consistency
  • 24.
    24 Tools that canhelp • Dependency Management – Composer (json, lock) – Packagist (public, private) • VMs and consistency – Vagrant – Docker – Others… • Deployment – Zend Server (deployment) – AWS code deploy – Others…
  • 25.
  • 26.
    26 What is it? •CI automates: – Building – Packaging – Testing – Deploying • If build breaks, developer who broke it fixes it • If build passes, it’s production ready
  • 27.
    27 Typical CI pipeline Gitclone Composer install Unit test Static Analysis Deploy to test Functional test Deploy to Staging Deploy to prod Add a map displaying available cars to rent within 10 km radius Package
  • 28.
    28 Failure! Git clone Composer install Unit test FAILBuild n failed Add a map displaying available cars to rent within 10 km radius
  • 29.
    29 Tools that canhelp Many Others…
  • 30.
  • 31.
    31 Poll #3 relatedDevOps responses • DevOps maturity assessment poll used practices – 76% code deployment – 62% Continuous Integration – 31% automation and provisioning
  • 32.
  • 33.
  • 34.
    34 Testing at differentstages • Unit testing • Functional testing • Integration testing (regression) • Load testing
  • 35.
    35 Cost of bugfixing Stefan Priebsh – Advanced OOP and design patterns Credit: Stefan Priebsh thePHP.cc
  • 36.
    36 Test early, testoften! Takeaway
  • 37.
    37 Simulate a browserrequest and ensure that a map loads, and that the map has the number of vehicles available for rent Functiona l getCars($criteria, $radius) $map->plotCoordinates($cars) $modelView->assign(‘map’, $map) Unit Load 1,000 concurrent search requests for cars from 1000 different locations Load Testing Steps Add a map displaying available cars to rent within 10 km radius
  • 38.
  • 39.
    39 Poll #4 typicalrelated responses • Do you unit test? – 65% Yes – 36% No
  • 40.
    40 Tools that canhelp • ab, Jmeter, LoadRunner (performance and load testing) • PHPUnit (unit testing) • Behat – Mink (behavioral) • PHPspec (unit testing)
  • 41.
  • 42.
  • 43.
    43 Poll #5 relatedDevOps responses • DevOps maturity survey poll – What simplified software development the most in past year – 35% some type of framework
  • 44.
    44 Evolution of frameworks •MVC full functionality – All or nothing • Component frameworks – No lock-in – Choose your stack • MVC out, middleware in • Microservice architecture
  • 45.
    45 Tools that canhelp So many… • Zend Framework: ZF3, Expressive, Apigility • Laravel, Symfony, Slim, and many more
  • 46.
    Writing code andleft shifting
  • 47.
    47 Catch bugs early •Remember how a bug in prod can cost as much as 15X times the cost of a bug in development?
  • 48.
    48 How do youcatch bugs early? • Test early, test often – during development, local before commit • Static Analysis • Peer reviews • Code instrumentation tools
  • 49.
  • 50.
    What about hardware andinfrastructure?
  • 51.
    51 Infrastructure should alsobe automated • Automate server provisioning – Chef, Puppet, Ansible, Salt, others… • Version environment build configs • Goal = fully rebuild environment automatically on fail
  • 52.
    52 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
  • 53.
  • 54.
    54 What it maylook like • Container-ize all the things – No longer push code to servers – Push new servers containing code/application • Environment templates – Traditional hardware or VM – Provision with new code, destroy old when users moved – Netflix does their interpretation of this
  • 55.
  • 56.
    Building the perfectPHP app for the enterprise Developing apps faster Adam Culp @adamculp