SlideShare a Scribd company logo
Performance profiling and
testing of a Symfony
application
Performance profiling and testing of symfony application 2
About me
● Developer Advocate
● Release Manager
● Trainer
● Team Leader
● Software Engineer
at
Performance profiling
Finding bottlenecks in the code to make it work faster
Performance testing
- The process of evaluating the quality or capacity of a
product.
- Performance testing is vital in the software development
lifecycle.
The goal
To measure code quality
Profiling without testing
- Possible only when your project will not be changed.
- If the code is left tested, even one line can break
everything with the damage discovered by clients already
in production.
When do we need profiling?
- The website is down because of overload
- Website load takes more than 2 seconds (performance is
a mandatory feature of any website)
- How One Second Could Cost Amazon $1.6 Billion In
Sales
When we don’t need profiling?
- The customer said there would have a significant load in production without
giving any proof.
- Premature optimization is almost always a bad idea.
This doesn’t mean you should use $repo->findAll()->paginate(),
This means: don’t do profiling when there are no performance issues.
Step #1
At ORO we started with:
- A time limit for Behat tests
- A network tab in the Chrome Dev Toolbar
Issue #1
Time is a good but unreliable metric.
How to know when time goes up because of:
- VM load
- CPU throttling
- Network issues
- Unreliable external API
- Or bad code ?
If the website has slowed down, you can blame:
- A software developer
- A system administrator
- The Hardware
Blame someone else but don’t fix it
How to blame the PHP code?
Don’t measure the time, measure the code quality.
The quality from performance perspective, not OOD
Why is a PHP application slow?
- PHP
- PHP 7 twice as fast as the same code on PHP 5.6
- Framework
- Symfony 4 twice as fast as the same code on Symfony 3.4
because of
SQL
Step #2
Let’s measure bad SQL with Symfony toolbar extension
- Hydration time
- Slow with a lot of joins
- Queries count
- Duplicate queries count
- same queries with different params
- Identical queries count
- Same queries
- Performance tab
- time based
Performance tab metrics
Extend performance tab metrics
Extend performance tab metrics
@debug.stopwatch
Step #2.1
Repeat the same for all network operations if they affect
performance:
- External API calls count
- Redis cache requests count
- Filesystem access count
- Memory usage by application or better the method
- etc. count
Issue #2
Developers don’t check Toolbar
Step #3
Integrate query metrics with test framework
Test query metrics only on real or real-life data.
Issue #3
Now PHP and Framework usage is a bottleneck
Symfony Toolbar Main Issue
Symfony developer toolbar adds overhead by itself and
can’t be used in production
So it can’t be used for real precise profiling
Step #4
Choose the tool for profiling PHP code.
- xDebug
- good start, but it’s not a profiler
- Xhprof
- very basic functionality, only time and memory
- Blackfire
- fork of Xhprof, widely used, a lot of integrations
- free plan has all xhprof features in a fancy interface, paid plans bring a lot of features
- Tideways
- fork of Xhprof
- Very similar to blackfire by the feature list but not so common
Blackfire pros
- Low overhead *
- Can be used in production
- A lot of ways to use, from CURL to Player
- Profile comparing
- Sharing
- Cross platform support
- Testing by all the metrics
- Periodic builds on production
- Profile every N request on overloaded application
Blackfire cons
- Most of features only available with paid plans.
- The big overhead on new PHP versions.
- Interface not always intuitive.
- *Requires prod-like environment.
Blackfire graph view
Blackfire Timeline View
Blackfire Recorder
Blackfire Metrics
Defining custom metrics at Blackfire
Blackfire Tests
Can replace some generic Symfony profiler based tests
Blackfire SDK
PhpUnit integration
BlackfireBridgePhpUnitTestCaseTrait;
Behat Integration
Validate environment configuration
- bin/symfony_requirements
- bin/console doctrine:ensure-production-settings
- bin/console oro:check-requirements
- Blackfire configs
What else?
Xdebug extension to check Garbage Collector
efficiency
Logging
Monolog Processors to enrich log messages
● Elapsed memory
● Current memory
● Peak memory
● Time taken
● Channels
Reach log message
Collecting Logs
Logs Monitoring
To summarize
Metrics can be used for:
- Local profiling
- CI tests
- Production testing
- Load testing
To summarize
To make a developer follow metrics:
- Make every metric explicit and as small as possible
- Describe the value of all the metrics and how to fix them
- Don’t rely on time or other unstable metrics
- Don’t add tests to common metrics that you don’t know
how to fix
To summarize
- Symfony Toolbar and Blackfire are best friends of
profiling
- xDebug could help too but be carefull
- Logging helps to “profile” in production
Questions

More Related Content

What's hot (20)

PPTX
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
Weverton Timoteo
 
PPTX
Introduction to robot framework
Chonlasith Jucksriporn
 
PDF
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Peter Kofler
 
ODP
Behaviour Driven Development Hands-on
Hemmerling
 
PDF
Civilized Git Process
Tu Hoang
 
PPTX
Robot framework Gowthami Goli
Gowthami Buddi
 
PDF
Coding Dojo: Baby Steps Push Challenge (2021)
Peter Kofler
 
ODP
Test Driven Development (TDD) with Windows PowerShell
Hemmerling
 
PPTX
Framework
Seungjoon Lee
 
PDF
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Peter Kofler
 
PDF
Robot framework - Lord of the Rings
Asheesh Mehdiratta
 
PDF
Outside-in Test Driven Development - the London School of TDD
Peter Kofler
 
PPTX
Acceptance Test Driven Development and Robot Framework
Steve Zhang
 
ODP
Lighning Talk: PHP build process
Bryan Agee
 
PDF
Barcamp Bangkhen :: Robot Framework
Somkiat Puisungnoen
 
PDF
Continuous Integration In Php
Wilco Jansen
 
PDF
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Anatoliy Okhotnikov
 
PDF
Tracking and improving software quality with SonarQube
Patroklos Papapetrou (Pat)
 
PDF
Introduction to Robot Framework
Carl Su
 
PPTX
Automatic Test 2019-07-25
FedericoGuerinoni
 
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
Weverton Timoteo
 
Introduction to robot framework
Chonlasith Jucksriporn
 
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Peter Kofler
 
Behaviour Driven Development Hands-on
Hemmerling
 
Civilized Git Process
Tu Hoang
 
Robot framework Gowthami Goli
Gowthami Buddi
 
Coding Dojo: Baby Steps Push Challenge (2021)
Peter Kofler
 
Test Driven Development (TDD) with Windows PowerShell
Hemmerling
 
Framework
Seungjoon Lee
 
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Peter Kofler
 
Robot framework - Lord of the Rings
Asheesh Mehdiratta
 
Outside-in Test Driven Development - the London School of TDD
Peter Kofler
 
Acceptance Test Driven Development and Robot Framework
Steve Zhang
 
Lighning Talk: PHP build process
Bryan Agee
 
Barcamp Bangkhen :: Robot Framework
Somkiat Puisungnoen
 
Continuous Integration In Php
Wilco Jansen
 
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Anatoliy Okhotnikov
 
Tracking and improving software quality with SonarQube
Patroklos Papapetrou (Pat)
 
Introduction to Robot Framework
Carl Su
 
Automatic Test 2019-07-25
FedericoGuerinoni
 

Similar to Performance profiling and testing of symfony application 2 (20)

PDF
Profiling and inspection with Blackfire.io
Emir Beganović
 
PPTX
Performance Tuning with XHProf
Salesforce Engineering
 
PDF
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Dennis de Greef
 
PPTX
Profiling and Tuning a Web Application - The Dirty Details
Achievers Tech
 
PPTX
Performance tips for Symfony2 & PHP
Max Romanovsky
 
PPTX
Magento meetup lucknow blackfire
Anand Singh
 
PDF
Load testing and performance tracing
Hans Höchtl
 
PDF
Framework and Application Benchmarking
Paul Jones
 
PPTX
Optimizing performance
Zend by Rogue Wave Software
 
PPTX
PHP Profiling/performance
Nicolas Degardin
 
PPTX
Northeast PHP - High Performance PHP
Jonathan Klein
 
PDF
Performance and optimization CakeFest 2014
markstory
 
PDF
Profiling PHP with Xdebug / Webgrind
Sam Keen
 
PDF
You Were Lied To About Optimization
Chris Tankersley
 
PPTX
Magento Meetup New Delhi- Performance Optimization
Webkul Software Pvt. Ltd.
 
PDF
Optimizing Symfony Application Performance
Valerio Barbera
 
PDF
Developing PHP Applications Faster
Adam Culp
 
PDF
2019 StartIT - Boosting your performance with Blackfire
Marko Mitranić
 
PDF
Profiling PHP - PHPAmersfoort Meetup 2015-03-10
Dennis de Greef
 
PDF
Web Application Performance Audit and Optimization
Zyxware Technologies
 
Profiling and inspection with Blackfire.io
Emir Beganović
 
Performance Tuning with XHProf
Salesforce Engineering
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Dennis de Greef
 
Profiling and Tuning a Web Application - The Dirty Details
Achievers Tech
 
Performance tips for Symfony2 & PHP
Max Romanovsky
 
Magento meetup lucknow blackfire
Anand Singh
 
Load testing and performance tracing
Hans Höchtl
 
Framework and Application Benchmarking
Paul Jones
 
Optimizing performance
Zend by Rogue Wave Software
 
PHP Profiling/performance
Nicolas Degardin
 
Northeast PHP - High Performance PHP
Jonathan Klein
 
Performance and optimization CakeFest 2014
markstory
 
Profiling PHP with Xdebug / Webgrind
Sam Keen
 
You Were Lied To About Optimization
Chris Tankersley
 
Magento Meetup New Delhi- Performance Optimization
Webkul Software Pvt. Ltd.
 
Optimizing Symfony Application Performance
Valerio Barbera
 
Developing PHP Applications Faster
Adam Culp
 
2019 StartIT - Boosting your performance with Blackfire
Marko Mitranić
 
Profiling PHP - PHPAmersfoort Meetup 2015-03-10
Dennis de Greef
 
Web Application Performance Audit and Optimization
Zyxware Technologies
 
Ad

More from Andrew Yatsenko (8)

PDF
OroCommerce Storefront Design. Non-standard Layout Customisation.
Andrew Yatsenko
 
PDF
Gear Up for OroPlatform 4.1 LTS. Dependency Injection Improvements Overview ...
Andrew Yatsenko
 
PDF
Make the most of twig
Andrew Yatsenko
 
PDF
Using Oro layouts
Andrew Yatsenko
 
PDF
Data cache management in php
Andrew Yatsenko
 
PDF
Doctrine Internals. UnitOfWork
Andrew Yatsenko
 
PDF
Writing extensible applications
Andrew Yatsenko
 
PDF
Symfony Form Basics - OroMeetup #3 Cherkassy
Andrew Yatsenko
 
OroCommerce Storefront Design. Non-standard Layout Customisation.
Andrew Yatsenko
 
Gear Up for OroPlatform 4.1 LTS. Dependency Injection Improvements Overview ...
Andrew Yatsenko
 
Make the most of twig
Andrew Yatsenko
 
Using Oro layouts
Andrew Yatsenko
 
Data cache management in php
Andrew Yatsenko
 
Doctrine Internals. UnitOfWork
Andrew Yatsenko
 
Writing extensible applications
Andrew Yatsenko
 
Symfony Form Basics - OroMeetup #3 Cherkassy
Andrew Yatsenko
 
Ad

Recently uploaded (20)

PDF
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
PPTX
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
PDF
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
PDF
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
PDF
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
PDF
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
 
PDF
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
PDF
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
PDF
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
PPTX
darshai cross section and river section analysis
muk7971
 
PPT
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PPTX
Artificial Intelligence jejeiejj3iriejrjifirirjdjeie
VikingsGaming2
 
PDF
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
PDF
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
Computer network Computer network Computer network Computer network
Shrikant317689
 
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
darshai cross section and river section analysis
muk7971
 
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Artificial Intelligence jejeiejj3iriejrjifirirjdjeie
VikingsGaming2
 
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 

Performance profiling and testing of symfony application 2

  • 1. Performance profiling and testing of a Symfony application
  • 3. About me ● Developer Advocate ● Release Manager ● Trainer ● Team Leader ● Software Engineer at
  • 4. Performance profiling Finding bottlenecks in the code to make it work faster
  • 5. Performance testing - The process of evaluating the quality or capacity of a product. - Performance testing is vital in the software development lifecycle.
  • 6. The goal To measure code quality
  • 7. Profiling without testing - Possible only when your project will not be changed. - If the code is left tested, even one line can break everything with the damage discovered by clients already in production.
  • 8. When do we need profiling? - The website is down because of overload - Website load takes more than 2 seconds (performance is a mandatory feature of any website) - How One Second Could Cost Amazon $1.6 Billion In Sales
  • 9. When we don’t need profiling? - The customer said there would have a significant load in production without giving any proof. - Premature optimization is almost always a bad idea. This doesn’t mean you should use $repo->findAll()->paginate(), This means: don’t do profiling when there are no performance issues.
  • 10. Step #1 At ORO we started with: - A time limit for Behat tests - A network tab in the Chrome Dev Toolbar
  • 11. Issue #1 Time is a good but unreliable metric. How to know when time goes up because of: - VM load - CPU throttling - Network issues - Unreliable external API - Or bad code ?
  • 12. If the website has slowed down, you can blame: - A software developer - A system administrator - The Hardware Blame someone else but don’t fix it
  • 13. How to blame the PHP code? Don’t measure the time, measure the code quality. The quality from performance perspective, not OOD
  • 14. Why is a PHP application slow? - PHP - PHP 7 twice as fast as the same code on PHP 5.6 - Framework - Symfony 4 twice as fast as the same code on Symfony 3.4
  • 16. Step #2 Let’s measure bad SQL with Symfony toolbar extension - Hydration time - Slow with a lot of joins - Queries count - Duplicate queries count - same queries with different params - Identical queries count - Same queries - Performance tab - time based
  • 19. Extend performance tab metrics @debug.stopwatch
  • 20. Step #2.1 Repeat the same for all network operations if they affect performance: - External API calls count - Redis cache requests count - Filesystem access count - Memory usage by application or better the method - etc. count
  • 22. Step #3 Integrate query metrics with test framework
  • 23. Test query metrics only on real or real-life data.
  • 24. Issue #3 Now PHP and Framework usage is a bottleneck
  • 25. Symfony Toolbar Main Issue Symfony developer toolbar adds overhead by itself and can’t be used in production So it can’t be used for real precise profiling
  • 26. Step #4 Choose the tool for profiling PHP code. - xDebug - good start, but it’s not a profiler - Xhprof - very basic functionality, only time and memory - Blackfire - fork of Xhprof, widely used, a lot of integrations - free plan has all xhprof features in a fancy interface, paid plans bring a lot of features - Tideways - fork of Xhprof - Very similar to blackfire by the feature list but not so common
  • 27. Blackfire pros - Low overhead * - Can be used in production - A lot of ways to use, from CURL to Player - Profile comparing - Sharing - Cross platform support - Testing by all the metrics - Periodic builds on production - Profile every N request on overloaded application
  • 28. Blackfire cons - Most of features only available with paid plans. - The big overhead on new PHP versions. - Interface not always intuitive. - *Requires prod-like environment.
  • 33. Defining custom metrics at Blackfire
  • 34. Blackfire Tests Can replace some generic Symfony profiler based tests
  • 38. Validate environment configuration - bin/symfony_requirements - bin/console doctrine:ensure-production-settings - bin/console oro:check-requirements - Blackfire configs
  • 40. Xdebug extension to check Garbage Collector efficiency
  • 41. Logging Monolog Processors to enrich log messages ● Elapsed memory ● Current memory ● Peak memory ● Time taken ● Channels
  • 45. To summarize Metrics can be used for: - Local profiling - CI tests - Production testing - Load testing
  • 46. To summarize To make a developer follow metrics: - Make every metric explicit and as small as possible - Describe the value of all the metrics and how to fix them - Don’t rely on time or other unstable metrics - Don’t add tests to common metrics that you don’t know how to fix
  • 47. To summarize - Symfony Toolbar and Blackfire are best friends of profiling - xDebug could help too but be carefull - Logging helps to “profile” in production