SlideShare a Scribd company logo
1 of 44
Building the perfect PHP app for the enterprise
Episode 4: Optimizing
performance
Zeev Suraski
Twitter: @zeevs
Email: zeev@zend.com
2
Series overview
Keeping up with PHP
Developing apps faster
Resolving problems and high availability
Now: Optimizing performance ←
Zeev Suraski
CTO, Zend
Rogue Wave Software
4
• 3 daughters
• Photography enthusiast
• Crazy about spicy foods
• Programming since the age of 12
• Last thing I did before getting involved with PHP
was C++ CGIs (no!)
About me
5
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)
6
What is performance?
The effectiveness of a computer
system, as measured by agreed-
upon criteria, such as throughput,
response time and availability.
7
Performance is important
• F1000: Average annual cost of
application downtime per hour
$500K – $1M
• F1000: Average time to restore
an application failure
80% > 1 hour
25% > 12 hours
• F1000: Average annual cost of
application downtime
$125M - $250M
A 1 second delay in page response can result
in a 7% reduction in conversion.
IDC, “DevOps and the Cost of Downtime:
Fortune 1000 Best Practice Metrics Quantified”
Akamai research
8
What influences performance?
Almost Anything!
• Hardware (virtual/real)
• Network bandwidth
• Application complexity
• Memory consumption
• Response time of databases and service providers
• User/client load
• Time (of day, day of week, holidays, etc.)
Measuring & improving
performance
10
Performance isn’t a one-off process
Develop
Measure
Optimize
Monitor
11
Develop
13
Performance during development
• Three Rules of Code Optimization:
1. Don’t.
2. Don’t yet.
3. Profile first.
• Design for performance
• Pay attention to performance as you develop,
but don’t optimize prematurely
14
Additional tools
• IDE – PhpStorm, Zend Studio
• Code Tracing
• xhprof
Measure
16
Measuring performance
17
Measuring performance - It’s hard…
It’s dangerously easy to get results.
It’s remarkably difficult to get accurate results.
Challenges:
• Simulating real-world workloads
• Locking issues
• Hardware changes
• Underlying software changes
• Infrastructure fluctuations (software, hardware, network)
• Uncertainty principle
18
Measuring performance – How?
Common measurements:
• Requests per second (req/s)
• Response time
• Latency
Software:
Siege
19
Measuring performance - Tips
• Automate
• Use repeatable hardware
• Dedicated hardware
• Documented cloud/virtual instances
• Perform a ‘warmup’
• Look for cron jobs
• Simulate realistic scenarios
• Use separate load generating machines
• Must also be repeatable
• Have expectations & validate them
• If results are completely off, research why
• Conduct each individual benchmark at least 3 times
• Perform often
• Automate
Optimize
21
Web erver
PHP
Frameworks
Apps
App server services
Load balancer
End users
Database
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Service
backends
Load balancer
End users
Database
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Service
backends
24
Under The Hood
25
Opcode Caching
Zend
OPcache
26
Opcode caching
OPcache
• Turnkey
Requires absolutely no changes to your code
• Very substantial performance yields
Usually at least 2x better performance
• Free & integrated into PHP
Zend’s OPcache (formerly Optimizer+) donated to the community in 2012
• Very modest requirements
Typically requires only several dozen to a few hundred megabytes of
memory server-wide
• Verdict: Always use
Web server
PHP
Frameworks
Apps
App server services
End users
Database
Service
backends
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Load balancer
28
PHP 7 – The fastest PHP ever
29
PHP 7 – The fastest PHP ever
PHP 5 PHP 7
72
56
72
32
24
16
Hash Table Bucket zVal
PHP 5 PHP 7
20%
5%
Memory Manager CPU Overhead (WP)Memory Consumption of key Data Structures
(bytes)
30
Web server
PHP
Frameworks
Apps
App server services
End Users
Database
Service
Backends
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Load balancer
31
Web server software and setup
Different Web Server software have different
performance characteristics. Some are faster than
others.
Pay attention to:
• Apache vs. Nginx vs. IIS
• mod_php vs. FPM
• Concurrency settings
• KeepAlive settings
32
End Users
Database
Service
Backends
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Load balancer
33
Data caching
Save expensive ops, such as database queries, API calls,
filesystem access, etc. by caching and reusing results.
• Pros:
• Eliminates (or greatly reduces) time of costly calls
• Reduces load on the database, service provider, filesystem
• Time spent fetching from cache typically around zero
• Cons:
• Requires code modifications
• Only works if results don’t change for long periods of time (typically >10
seconds)
• Verdict: Greatly improves performance when used in the right places.
End users
Database
Service
backends
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Load balancer
35
Page caching
Eliminates the entire execution time of the page by caching
its entire content.
• Pros:
• Page execution time is reduced to zero
• Saves memory, resources, database and CPU load
• Cons:
• Only suitable in situations where an entire rendered page can be
repeatedly served more than once for long periods of time.
• Requires configuration
• Verdict: By far the best performance booster, use whenever possible.
36
What is performance?
The effectiveness of a computer
system, as measured by agreed-
upon criteria, such as throughput,
response time and availability.
37
Perceived performance
How quickly software appears
to perform its task.
Load balancer
End users
Database
Service
backends
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
Web server
PHP
Frameworks
Apps
App server services
39
Asynchronous processing
Perform long-running tasks asynchronously.
In other words, instead of waiting for them to
complete, perform them in the background and
notify the user once they’re done (if necessary)
• Pros:
• Radically improve perceived performance for use cases such as credit
card clearance, PDF generation, sending email
• Distribute load among servers
• Cons:
• Requires code changes
• Only suitable for specific use cases
Monitor
41
Monitoring
Monitoring is important:
• Things change when the rubber meets the road
• Enables SLA between ops & business owners
• Finger on the pulse
• Find performance issues that would otherwise go
unnoticed (by you, not your customer)
42
Recap
• Performance is important to your business
• Performance is a cycle, not a one-off investment
• Set expectations – both with yourself and your business owners
• Tools can greatly help
• Especially if they’re baked into your dev cycle
43
Learn more
• Watch this webinar on demand
• Read the recap blog
Thank you!

More Related Content

What's hot

Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014Jon Milsom
 
SAP TechEd 2013 session Tec118 managing your-environment
SAP TechEd 2013 session Tec118 managing your-environmentSAP TechEd 2013 session Tec118 managing your-environment
SAP TechEd 2013 session Tec118 managing your-environmentChris Kernaghan
 
Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016
Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016
Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016Jon Milsom
 
Scaling wix with microservices and multi cloud - 2015
Scaling wix with microservices and multi cloud - 2015Scaling wix with microservices and multi cloud - 2015
Scaling wix with microservices and multi cloud - 2015Aviran Mordo
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsAchievers Tech
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsAchievers Tech
 
IBM Maximo Performance Tuning
IBM Maximo Performance TuningIBM Maximo Performance Tuning
IBM Maximo Performance TuningFMMUG
 
LandsEnd TechEd2016 (1)
LandsEnd TechEd2016 (1)LandsEnd TechEd2016 (1)
LandsEnd TechEd2016 (1)Lisa Lawver
 
Life In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesLife In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesUlrich Krause
 
Building a Scalable Architecture for web apps
Building a Scalable Architecture for web appsBuilding a Scalable Architecture for web apps
Building a Scalable Architecture for web appsDirecti Group
 
Service-Level Objective for Serverless Applications
Service-Level Objective for Serverless ApplicationsService-Level Objective for Serverless Applications
Service-Level Objective for Serverless Applicationsalekn
 
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...VMworld
 
FileMaker + RESTfm + Laravel
FileMaker + RESTfm + LaravelFileMaker + RESTfm + Laravel
FileMaker + RESTfm + LaravelJohnnie Eerlings
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHPJohn Coggeshall
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFxThomas Daly
 
DrupalCamp LA 2014 - A Perfect Launch, Every Time
DrupalCamp LA 2014 - A Perfect Launch, Every TimeDrupalCamp LA 2014 - A Perfect Launch, Every Time
DrupalCamp LA 2014 - A Perfect Launch, Every TimeSuzanne Aldrich
 
Evolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deploymentsEvolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deploymentsRakuten Group, Inc.
 
SQL Server In-Memory OLTP Migration Overview
SQL Server In-Memory OLTP Migration OverviewSQL Server In-Memory OLTP Migration Overview
SQL Server In-Memory OLTP Migration OverviewJose Rivera Miranda
 

What's hot (20)

Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
 
SAP TechEd 2013 session Tec118 managing your-environment
SAP TechEd 2013 session Tec118 managing your-environmentSAP TechEd 2013 session Tec118 managing your-environment
SAP TechEd 2013 session Tec118 managing your-environment
 
Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016
Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016
Pitchero - Increasing agility through DevOps - Leeds DevOps November 2016
 
Scaling wix with microservices and multi cloud - 2015
Scaling wix with microservices and multi cloud - 2015Scaling wix with microservices and multi cloud - 2015
Scaling wix with microservices and multi cloud - 2015
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
 
IBM Maximo Performance Tuning
IBM Maximo Performance TuningIBM Maximo Performance Tuning
IBM Maximo Performance Tuning
 
Scalability Design Principles - Internal Session
Scalability Design Principles - Internal SessionScalability Design Principles - Internal Session
Scalability Design Principles - Internal Session
 
LandsEnd TechEd2016 (1)
LandsEnd TechEd2016 (1)LandsEnd TechEd2016 (1)
LandsEnd TechEd2016 (1)
 
Life In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesLife In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPages
 
Sapuki sig 2013
Sapuki sig 2013Sapuki sig 2013
Sapuki sig 2013
 
Building a Scalable Architecture for web apps
Building a Scalable Architecture for web appsBuilding a Scalable Architecture for web apps
Building a Scalable Architecture for web apps
 
Service-Level Objective for Serverless Applications
Service-Level Objective for Serverless ApplicationsService-Level Objective for Serverless Applications
Service-Level Objective for Serverless Applications
 
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
 
FileMaker + RESTfm + Laravel
FileMaker + RESTfm + LaravelFileMaker + RESTfm + Laravel
FileMaker + RESTfm + Laravel
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHP
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFx
 
DrupalCamp LA 2014 - A Perfect Launch, Every Time
DrupalCamp LA 2014 - A Perfect Launch, Every TimeDrupalCamp LA 2014 - A Perfect Launch, Every Time
DrupalCamp LA 2014 - A Perfect Launch, Every Time
 
Evolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deploymentsEvolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deployments
 
SQL Server In-Memory OLTP Migration Overview
SQL Server In-Memory OLTP Migration OverviewSQL Server In-Memory OLTP Migration Overview
SQL Server In-Memory OLTP Migration Overview
 

Similar to Optimizing performance

Adding Real-time Features to PHP Applications
Adding Real-time Features to PHP ApplicationsAdding Real-time Features to PHP Applications
Adding Real-time Features to PHP ApplicationsRonny López
 
Architecting with power vm
Architecting with power vmArchitecting with power vm
Architecting with power vmCharlie Cler
 
Cognos Performance Tuning Tips & Tricks
Cognos Performance Tuning Tips & TricksCognos Performance Tuning Tips & Tricks
Cognos Performance Tuning Tips & TricksSenturus
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructuremkherlakian
 
Bitfusion Nimbix Dev Summit Heterogeneous Architectures
Bitfusion Nimbix Dev Summit Heterogeneous Architectures Bitfusion Nimbix Dev Summit Heterogeneous Architectures
Bitfusion Nimbix Dev Summit Heterogeneous Architectures Subbu Rama
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHPJonathan Klein
 
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!Teamstudio
 
Adding Value in the Cloud with Performance Test
Adding Value in the Cloud with Performance TestAdding Value in the Cloud with Performance Test
Adding Value in the Cloud with Performance TestRodolfo Kohn
 
Scaling habits of ASP.NET
Scaling habits of ASP.NETScaling habits of ASP.NET
Scaling habits of ASP.NETDavid Giard
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesJonathan Klein
 
AOUG_11Nov2016_Challenges_with_EBS12_2
AOUG_11Nov2016_Challenges_with_EBS12_2AOUG_11Nov2016_Challenges_with_EBS12_2
AOUG_11Nov2016_Challenges_with_EBS12_2Sean Braymen
 
Impact2014: Practical Performance Troubleshooting
Impact2014: Practical Performance TroubleshootingImpact2014: Practical Performance Troubleshooting
Impact2014: Practical Performance TroubleshootingChris Bailey
 
Testing in the Cloud using Panda
Testing in the Cloud using PandaTesting in the Cloud using Panda
Testing in the Cloud using PandaTao Jiang
 
Performance Testing
Performance TestingPerformance Testing
Performance TestingAnu Shaji
 
Open source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesOpen source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesRogue Wave Software
 
Node.js BFFs - our way to the better/micro frontends
Node.js BFFs - our way to the better/micro frontendsNode.js BFFs - our way to the better/micro frontends
Node.js BFFs - our way to the better/micro frontendsEugene Fidelin
 

Similar to Optimizing performance (20)

Adding Real-time Features to PHP Applications
Adding Real-time Features to PHP ApplicationsAdding Real-time Features to PHP Applications
Adding Real-time Features to PHP Applications
 
Architecting with power vm
Architecting with power vmArchitecting with power vm
Architecting with power vm
 
Cognos Performance Tuning Tips & Tricks
Cognos Performance Tuning Tips & TricksCognos Performance Tuning Tips & Tricks
Cognos Performance Tuning Tips & Tricks
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructure
 
Bitfusion Nimbix Dev Summit Heterogeneous Architectures
Bitfusion Nimbix Dev Summit Heterogeneous Architectures Bitfusion Nimbix Dev Summit Heterogeneous Architectures
Bitfusion Nimbix Dev Summit Heterogeneous Architectures
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
 
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
 
Adding Value in the Cloud with Performance Test
Adding Value in the Cloud with Performance TestAdding Value in the Cloud with Performance Test
Adding Value in the Cloud with Performance Test
 
Scaling habits of ASP.NET
Scaling habits of ASP.NETScaling habits of ASP.NET
Scaling habits of ASP.NET
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
 
AOUG_11Nov2016_Challenges_with_EBS12_2
AOUG_11Nov2016_Challenges_with_EBS12_2AOUG_11Nov2016_Challenges_with_EBS12_2
AOUG_11Nov2016_Challenges_with_EBS12_2
 
Impact2014: Practical Performance Troubleshooting
Impact2014: Practical Performance TroubleshootingImpact2014: Practical Performance Troubleshooting
Impact2014: Practical Performance Troubleshooting
 
Web Performance Optimization (WPO)
Web Performance Optimization (WPO)Web Performance Optimization (WPO)
Web Performance Optimization (WPO)
 
Testing in the Cloud using Panda
Testing in the Cloud using PandaTesting in the Cloud using Panda
Testing in the Cloud using Panda
 
JBUG.be jBPM4
JBUG.be jBPM4JBUG.be jBPM4
JBUG.be jBPM4
 
Performance tuning PHP on IBMi
Performance tuning PHP on IBMiPerformance tuning PHP on IBMi
Performance tuning PHP on IBMi
 
Performance Testing
Performance TestingPerformance Testing
Performance Testing
 
demo
demo demo
demo
 
Open source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesOpen source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packages
 
Node.js BFFs - our way to the better/micro frontends
Node.js BFFs - our way to the better/micro frontendsNode.js BFFs - our way to the better/micro frontends
Node.js BFFs - our way to the better/micro frontends
 

More from Zend by Rogue Wave Software

Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM iZend by Rogue Wave Software
 
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018) Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018) Zend by Rogue Wave Software
 
The Sodium crypto library of PHP 7.2 (PHP Day 2018)
The Sodium crypto library of PHP 7.2 (PHP Day 2018)The Sodium crypto library of PHP 7.2 (PHP Day 2018)
The Sodium crypto library of PHP 7.2 (PHP Day 2018)Zend by Rogue Wave Software
 
Develop web APIs in PHP using middleware with Expressive (Code Europe)
Develop web APIs in PHP using middleware with Expressive (Code Europe)Develop web APIs in PHP using middleware with Expressive (Code Europe)
Develop web APIs in PHP using middleware with Expressive (Code Europe)Zend by Rogue Wave Software
 
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i  Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i Zend by Rogue Wave Software
 

More from Zend by Rogue Wave Software (20)

Develop microservices in php
Develop microservices in phpDevelop microservices in php
Develop microservices in php
 
Speed and security for your PHP application
Speed and security for your PHP applicationSpeed and security for your PHP application
Speed and security for your PHP application
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM i
 
Building web APIs in PHP with Zend Expressive
Building web APIs in PHP with Zend ExpressiveBuilding web APIs in PHP with Zend Expressive
Building web APIs in PHP with Zend Expressive
 
To PHP 7 and beyond
To PHP 7 and beyondTo PHP 7 and beyond
To PHP 7 and beyond
 
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018) Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
 
The Sodium crypto library of PHP 7.2 (PHP Day 2018)
The Sodium crypto library of PHP 7.2 (PHP Day 2018)The Sodium crypto library of PHP 7.2 (PHP Day 2018)
The Sodium crypto library of PHP 7.2 (PHP Day 2018)
 
Develop web APIs in PHP using middleware with Expressive (Code Europe)
Develop web APIs in PHP using middleware with Expressive (Code Europe)Develop web APIs in PHP using middleware with Expressive (Code Europe)
Develop web APIs in PHP using middleware with Expressive (Code Europe)
 
Middleware web APIs in PHP 7.x
Middleware web APIs in PHP 7.xMiddleware web APIs in PHP 7.x
Middleware web APIs in PHP 7.x
 
Ongoing management of your PHP 7 application
Ongoing management of your PHP 7 applicationOngoing management of your PHP 7 application
Ongoing management of your PHP 7 application
 
Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7
 
The Docker development template for PHP
The Docker development template for PHPThe Docker development template for PHP
The Docker development template for PHP
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
 
Unit testing for project managers
Unit testing for project managersUnit testing for project managers
Unit testing for project managers
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
Data is dead. Long live data!
Data is dead. Long live data! Data is dead. Long live data!
Data is dead. Long live data!
 
Developing apps faster
Developing apps fasterDeveloping apps faster
Developing apps faster
 
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i  Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i
 
Getting started with PHP on IBM i
Getting started with PHP on IBM iGetting started with PHP on IBM i
Getting started with PHP on IBM i
 
Continuous Delivery e-book
Continuous Delivery e-bookContinuous Delivery e-book
Continuous Delivery e-book
 

Recently uploaded

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 

Recently uploaded (20)

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 

Optimizing performance

  • 1. Building the perfect PHP app for the enterprise Episode 4: Optimizing performance Zeev Suraski Twitter: @zeevs Email: zeev@zend.com
  • 2. 2 Series overview Keeping up with PHP Developing apps faster Resolving problems and high availability Now: Optimizing performance ←
  • 4. 4 • 3 daughters • Photography enthusiast • Crazy about spicy foods • Programming since the age of 12 • Last thing I did before getting involved with PHP was C++ CGIs (no!) About me
  • 5. 5 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)
  • 6. 6 What is performance? The effectiveness of a computer system, as measured by agreed- upon criteria, such as throughput, response time and availability.
  • 7. 7 Performance is important • F1000: Average annual cost of application downtime per hour $500K – $1M • F1000: Average time to restore an application failure 80% > 1 hour 25% > 12 hours • F1000: Average annual cost of application downtime $125M - $250M A 1 second delay in page response can result in a 7% reduction in conversion. IDC, “DevOps and the Cost of Downtime: Fortune 1000 Best Practice Metrics Quantified” Akamai research
  • 8. 8 What influences performance? Almost Anything! • Hardware (virtual/real) • Network bandwidth • Application complexity • Memory consumption • Response time of databases and service providers • User/client load • Time (of day, day of week, holidays, etc.)
  • 10. 10 Performance isn’t a one-off process Develop Measure Optimize Monitor
  • 11. 11
  • 13. 13 Performance during development • Three Rules of Code Optimization: 1. Don’t. 2. Don’t yet. 3. Profile first. • Design for performance • Pay attention to performance as you develop, but don’t optimize prematurely
  • 14. 14 Additional tools • IDE – PhpStorm, Zend Studio • Code Tracing • xhprof
  • 17. 17 Measuring performance - It’s hard… It’s dangerously easy to get results. It’s remarkably difficult to get accurate results. Challenges: • Simulating real-world workloads • Locking issues • Hardware changes • Underlying software changes • Infrastructure fluctuations (software, hardware, network) • Uncertainty principle
  • 18. 18 Measuring performance – How? Common measurements: • Requests per second (req/s) • Response time • Latency Software: Siege
  • 19. 19 Measuring performance - Tips • Automate • Use repeatable hardware • Dedicated hardware • Documented cloud/virtual instances • Perform a ‘warmup’ • Look for cron jobs • Simulate realistic scenarios • Use separate load generating machines • Must also be repeatable • Have expectations & validate them • If results are completely off, research why • Conduct each individual benchmark at least 3 times • Perform often • Automate
  • 22. Load balancer End users Database Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Service backends
  • 23. Load balancer End users Database Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Service backends
  • 26. 26 Opcode caching OPcache • Turnkey Requires absolutely no changes to your code • Very substantial performance yields Usually at least 2x better performance • Free & integrated into PHP Zend’s OPcache (formerly Optimizer+) donated to the community in 2012 • Very modest requirements Typically requires only several dozen to a few hundred megabytes of memory server-wide • Verdict: Always use
  • 27. Web server PHP Frameworks Apps App server services End users Database Service backends Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Load balancer
  • 28. 28 PHP 7 – The fastest PHP ever
  • 29. 29 PHP 7 – The fastest PHP ever PHP 5 PHP 7 72 56 72 32 24 16 Hash Table Bucket zVal PHP 5 PHP 7 20% 5% Memory Manager CPU Overhead (WP)Memory Consumption of key Data Structures (bytes)
  • 30. 30 Web server PHP Frameworks Apps App server services End Users Database Service Backends Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Load balancer
  • 31. 31 Web server software and setup Different Web Server software have different performance characteristics. Some are faster than others. Pay attention to: • Apache vs. Nginx vs. IIS • mod_php vs. FPM • Concurrency settings • KeepAlive settings
  • 32. 32 End Users Database Service Backends Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Load balancer
  • 33. 33 Data caching Save expensive ops, such as database queries, API calls, filesystem access, etc. by caching and reusing results. • Pros: • Eliminates (or greatly reduces) time of costly calls • Reduces load on the database, service provider, filesystem • Time spent fetching from cache typically around zero • Cons: • Requires code modifications • Only works if results don’t change for long periods of time (typically >10 seconds) • Verdict: Greatly improves performance when used in the right places.
  • 34. End users Database Service backends Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Load balancer
  • 35. 35 Page caching Eliminates the entire execution time of the page by caching its entire content. • Pros: • Page execution time is reduced to zero • Saves memory, resources, database and CPU load • Cons: • Only suitable in situations where an entire rendered page can be repeatedly served more than once for long periods of time. • Requires configuration • Verdict: By far the best performance booster, use whenever possible.
  • 36. 36 What is performance? The effectiveness of a computer system, as measured by agreed- upon criteria, such as throughput, response time and availability.
  • 37. 37 Perceived performance How quickly software appears to perform its task.
  • 38. Load balancer End users Database Service backends Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services Web server PHP Frameworks Apps App server services
  • 39. 39 Asynchronous processing Perform long-running tasks asynchronously. In other words, instead of waiting for them to complete, perform them in the background and notify the user once they’re done (if necessary) • Pros: • Radically improve perceived performance for use cases such as credit card clearance, PDF generation, sending email • Distribute load among servers • Cons: • Requires code changes • Only suitable for specific use cases
  • 41. 41 Monitoring Monitoring is important: • Things change when the rubber meets the road • Enables SLA between ops & business owners • Finger on the pulse • Find performance issues that would otherwise go unnoticed (by you, not your customer)
  • 42. 42 Recap • Performance is important to your business • Performance is a cycle, not a one-off investment • Set expectations – both with yourself and your business owners • Tools can greatly help • Especially if they’re baked into your dev cycle
  • 43. 43 Learn more • Watch this webinar on demand • Read the recap blog

Editor's Notes

  1. In other words, the worse your code is, the better