SlideShare a Scribd company logo
1 of 32
Download to read offline
You cannot optimize
what you cannot measure
blackfire.io @blackfireio # blackfireio
How to measure PHP code
performance
● Microtime
● Benchmarking Libraries
● Application Performance Monitoring
● Load testing
● Profiling
https://blackfire.io/docs/24-days/03-what-is-blackfire
Measuring performance
impacts performance
blackfire.io @blackfireio # blackfireio
Understanding the overhead
● Instrumentation
● Tools ready for production vs tools made for
development only
● Instrumenting all requests vs specific requests
blackfire.io @blackfireio # blackfireio
Profiling is about measuring how much
resources your code is consuming
Wall time I/O CPU
Memory Network SQLHTTP Time
https://blackfire.io/docs/24-days/07-time-flavors
blackfire.io @blackfireio # blackfireio
Time is volatile
● Time is not a stable metric. External factors such as machine load can
have significant impacts on wall time between two profiles of identical
code.
● Time is just a consequence of what happened in the code
● Use time to identify the slow parts in your code and then:
○ iterate and compare
○ write assertions on the root cause
● Profiling is about understanding how code works at runtime
https://blackfire.io/docs/24-days/12-tests-best-pratices
blackfire.io @blackfireio # blackfireio
Callgraphs, timelines and more
● Find the function calls that
consume the most resources
● Know where to stop optimizing
● Trade-off time vs memory and
performance vs code complexity
● Profiling should not always be a
lonely activity
blackfire.io @blackfireio
#blackfireio
What are the issues
we encounter with
Magento 2
You cannot optimize
what you cannot measure
You cannot measure
what you don’t execute.
blackfire.io @blackfireio # blackfireio
Varnish, can you ignore me?
acl profile {
# Allowed IP
"111.112.113.114";
}
sub vcl_recv {
if (req.http.X-Blackfire-Query && client.ip ~ profile) {
if (req.esi_level > 0) {
unset req.http.X-Blackfire-Query;
} else {
return (pass);
}
}
}
blackfire.io @blackfireio # blackfireio
What about the Full Page Cache?
And all the others.
blackfire.io @blackfireio # blackfireio
You have to compare.
blackfire.io @blackfireio # blackfireio
The main issues
● SQL Queries
● Network
● CPU Time
● Memory
● I/O Wait
● External HTTP requests
● PHP & Bad PHP code
blackfire.io @blackfireio # blackfireio
SQL Queries
● Use indexes and correct types.
● Limit the number of results you need.
● Avoid SQL requests…
● If you can’t avoid them, cache the output or
use LocalStorage/CacheStorage if insensitive information.
● Use Magento Repositories.
SQL Requests are the main issue.
blackfire.io @blackfireio # blackfireio
● Use local networks with local IP addresses.
Network
blackfire.io @blackfireio # blackfireio
CPU Time
● Avoid consuming operations: loops, events…
● Use Magento Repositories.
● KISS : Keep It Simple Stupid.
blackfire.io @blackfireio # blackfireio
Memory
● Use the MagentoFrameworkModelResourceModelIterator for your
loops.
● Use PHP! Avoid creating so many objects when you can do the
operation with one function call.
● Use the Magento Dependency Injection.
● Use Magento Repositories.
blackfire.io @blackfireio # blackfireio
I/O Wait
● Use php://memory and php://temp. Because Memory is always faster
than I/O.
● Optimize composer: composer dump-autoload --optimize --no-dev
blackfire.io @blackfireio # blackfireio
External HTTP Requests
● Don’t do that.
● If you really have to: use RabbitMQ.
● And if you really have no choice: use asynchronous?
● And if you really really have no choice: use a small timeout and deal with
the errors properly.
blackfire.io @blackfireio # blackfireio
PHP & Bad PHP code
blackfire.io @blackfireio # blackfireio
PHP & Bad PHP code
● Upgrade to the latest version of PHP.
● Prefer a PHP core function to a lot of objects and methods.
●
Under the hood
blackfire.io @blackfireio # blackfireio
The metrics
● Is Magento 2 installed? CE or EE?
● Is the cache enabled?
● Cache manipulation.
● Product loads.
● Interceptors measurement.
● Mode detector: production/developer/default.
● …
blackfire.io @blackfireio # blackfireio
The metrics
magento2.all.cache.full_page.builtin.hit:
label: "Hit full page cache using builtin"
matching_calls:
php:
- callee: "=Magento[…]BuiltinPlugin::addDebugHeader"
caller: "=Magento[…]BuiltinPlugin::aroundDispatch"
blackfire.io @blackfireio # blackfireio
The metrics
mymetrics.image.operation:
matching_calls:
php:
- callee: "/.*image.*/"
Will match imagecreate, getimagesize etc.
blackfire.io @blackfireio # blackfireio
The recommendations
'The Magento 2 Full Page Cache should be enabled':
assertions:
- 'metrics.magento2.[…]full_page.builtin.hit.count == 1'
exclude:
- '.*/checkout.*'
- '.*/customer/section/load'
- '.*/catalogsearch'
[…]
blackfire.io @blackfireio # blackfireio
The recommendations
'Do not make any image operation':
assertions:
- 'metrics.mymetrics.image.operation.count == 0'
blackfire.io @blackfireio # blackfireio
Put some limits: .blackfire.yml
tests:
Pages should be fast enough:
path: /.*
assertions:
- main.wall_time < 850ms
- main.io < 500ms
- main.cpu_time < 500ms
Pages should not consume too much memory:
path: /.*
assertions:
- main.memory < 50M
- main.peak_memory < 75M
Homepage should not do too many SQL queries:
path: /
assertions:
- metrics.sql.queries.count <= 12
Checkout pages should be light:
path: /checkout/.*
assertions:
- metrics.output.network_out < 100KB
blackfire.io @blackfireio # blackfireio
Scenarios
scenarios:
Home:
- /
Cart:
- /checkout/cart/
Login:
- /customer/account/login/
blackfire.io @blackfireio # blackfireio
Profile Everywhere!

More Related Content

What's hot

Multi-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSMulti-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSVõ Duy Tuấn
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API PlatformJohannes Ridderstedt
 
Successfully Implementing DEV-SEC-OPS in the Cloud
Successfully Implementing DEV-SEC-OPS in the CloudSuccessfully Implementing DEV-SEC-OPS in the Cloud
Successfully Implementing DEV-SEC-OPS in the CloudAmazon Web Services
 
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...confluent
 
Application Management Services
Application Management ServicesApplication Management Services
Application Management Servicesvenu1506
 
Real Time Test Data with Grafana
Real Time Test Data with GrafanaReal Time Test Data with Grafana
Real Time Test Data with GrafanaIoannis Papadakis
 
Comparing IaaS: VMware vs OpenStack vs Google’s Ganeti
Comparing IaaS: VMware vs OpenStack vs Google’s GanetiComparing IaaS: VMware vs OpenStack vs Google’s Ganeti
Comparing IaaS: VMware vs OpenStack vs Google’s GanetiGiuseppe Paterno'
 
Low code platform and Outsystems
Low code platform and Outsystems Low code platform and Outsystems
Low code platform and Outsystems Dzung Nguyen
 
Devops Devops Devops, at Froscon
Devops Devops Devops, at FrosconDevops Devops Devops, at Froscon
Devops Devops Devops, at FrosconKris Buytaert
 
Benefits of Stream Processing and Apache Kafka Use Cases
Benefits of Stream Processing and Apache Kafka Use CasesBenefits of Stream Processing and Apache Kafka Use Cases
Benefits of Stream Processing and Apache Kafka Use Casesconfluent
 
Apache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart CityApache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart CityKai Wähner
 
Apache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and ArchitecturesApache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and ArchitecturesKai Wähner
 
Event Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache KafkaEvent Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache KafkaKai Wähner
 
Airflow at lyft
Airflow at lyftAirflow at lyft
Airflow at lyftTao Feng
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice ArchitectureWSO2
 
Kubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemKubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemSreenivas Makam
 

What's hot (20)

Kafka: Internals
Kafka: InternalsKafka: Internals
Kafka: Internals
 
Multi-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSMulti-tenant Database Design for SaaS
Multi-tenant Database Design for SaaS
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 
Successfully Implementing DEV-SEC-OPS in the Cloud
Successfully Implementing DEV-SEC-OPS in the CloudSuccessfully Implementing DEV-SEC-OPS in the Cloud
Successfully Implementing DEV-SEC-OPS in the Cloud
 
Azure DevOps
Azure DevOpsAzure DevOps
Azure DevOps
 
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
 
Application Management Services
Application Management ServicesApplication Management Services
Application Management Services
 
Industry EC & O
Industry EC & OIndustry EC & O
Industry EC & O
 
Real Time Test Data with Grafana
Real Time Test Data with GrafanaReal Time Test Data with Grafana
Real Time Test Data with Grafana
 
Comparing IaaS: VMware vs OpenStack vs Google’s Ganeti
Comparing IaaS: VMware vs OpenStack vs Google’s GanetiComparing IaaS: VMware vs OpenStack vs Google’s Ganeti
Comparing IaaS: VMware vs OpenStack vs Google’s Ganeti
 
Low code platform and Outsystems
Low code platform and Outsystems Low code platform and Outsystems
Low code platform and Outsystems
 
DevOps seminar ppt
DevOps seminar ppt DevOps seminar ppt
DevOps seminar ppt
 
Devops Devops Devops, at Froscon
Devops Devops Devops, at FrosconDevops Devops Devops, at Froscon
Devops Devops Devops, at Froscon
 
Benefits of Stream Processing and Apache Kafka Use Cases
Benefits of Stream Processing and Apache Kafka Use CasesBenefits of Stream Processing and Apache Kafka Use Cases
Benefits of Stream Processing and Apache Kafka Use Cases
 
Apache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart CityApache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart City
 
Apache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and ArchitecturesApache Kafka in Financial Services - Use Cases and Architectures
Apache Kafka in Financial Services - Use Cases and Architectures
 
Event Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache KafkaEvent Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache Kafka
 
Airflow at lyft
Airflow at lyftAirflow at lyft
Airflow at lyft
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice Architecture
 
Kubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemKubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystem
 

Similar to Magento 2 performance profiling and best practices

Bodin - Hullin & Potencier - Magento Performance Profiling and Best Practices
Bodin - Hullin & Potencier - Magento Performance Profiling and Best PracticesBodin - Hullin & Potencier - Magento Performance Profiling and Best Practices
Bodin - Hullin & Potencier - Magento Performance Profiling and Best PracticesMeet Magento Italy
 
Pentester++
Pentester++Pentester++
Pentester++CTruncer
 
Pen Testing Development
Pen Testing DevelopmentPen Testing Development
Pen Testing DevelopmentCTruncer
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplateStanislav Petrov
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testingRoman Ananev
 
Debugging (Django) application in PyCharm
Debugging (Django) application in PyCharmDebugging (Django) application in PyCharm
Debugging (Django) application in PyCharmpavelkoci
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
Scraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHPScraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHPPaul Redmond
 
The New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by PythonThe New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by PythonAll Things Open
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in DjangoLakshman Prasad
 
Create Your First "Native" Mobile App with JavaScript + PhoneGap
Create Your First "Native" Mobile App with JavaScript + PhoneGapCreate Your First "Native" Mobile App with JavaScript + PhoneGap
Create Your First "Native" Mobile App with JavaScript + PhoneGapSteve Phillips
 
Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingShyam Sunder Verma
 
Fluent 2018: Tracking Performance of the Web with HTTP Archive
Fluent 2018: Tracking Performance of the Web with HTTP ArchiveFluent 2018: Tracking Performance of the Web with HTTP Archive
Fluent 2018: Tracking Performance of the Web with HTTP ArchivePaul Calvano
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Pantheon
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsDECK36
 
Doctrine Project
Doctrine ProjectDoctrine Project
Doctrine ProjectDaniel Lima
 
How to get started with Site Reliability Engineering
How to get started with Site Reliability EngineeringHow to get started with Site Reliability Engineering
How to get started with Site Reliability EngineeringAndrew Kirkpatrick
 
20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash contentElad Elrom
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Andrew Yatsenko
 

Similar to Magento 2 performance profiling and best practices (20)

Bodin - Hullin & Potencier - Magento Performance Profiling and Best Practices
Bodin - Hullin & Potencier - Magento Performance Profiling and Best PracticesBodin - Hullin & Potencier - Magento Performance Profiling and Best Practices
Bodin - Hullin & Potencier - Magento Performance Profiling and Best Practices
 
Pentester++
Pentester++Pentester++
Pentester++
 
Pen Testing Development
Pen Testing DevelopmentPen Testing Development
Pen Testing Development
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testing
 
Debugging (Django) application in PyCharm
Debugging (Django) application in PyCharmDebugging (Django) application in PyCharm
Debugging (Django) application in PyCharm
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
Scraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHPScraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHP
 
The New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by PythonThe New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by Python
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
Create Your First "Native" Mobile App with JavaScript + PhoneGap
Create Your First "Native" Mobile App with JavaScript + PhoneGapCreate Your First "Native" Mobile App with JavaScript + PhoneGap
Create Your First "Native" Mobile App with JavaScript + PhoneGap
 
Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation Testing
 
Introduce Django
Introduce DjangoIntroduce Django
Introduce Django
 
Fluent 2018: Tracking Performance of the Web with HTTP Archive
Fluent 2018: Tracking Performance of the Web with HTTP ArchiveFluent 2018: Tracking Performance of the Web with HTTP Archive
Fluent 2018: Tracking Performance of the Web with HTTP Archive
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
Doctrine Project
Doctrine ProjectDoctrine Project
Doctrine Project
 
How to get started with Site Reliability Engineering
How to get started with Site Reliability EngineeringHow to get started with Site Reliability Engineering
How to get started with Site Reliability Engineering
 
20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
 

Recently uploaded

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 

Recently uploaded (20)

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 

Magento 2 performance profiling and best practices

  • 1.
  • 2. You cannot optimize what you cannot measure
  • 3. blackfire.io @blackfireio # blackfireio How to measure PHP code performance ● Microtime ● Benchmarking Libraries ● Application Performance Monitoring ● Load testing ● Profiling https://blackfire.io/docs/24-days/03-what-is-blackfire
  • 5. blackfire.io @blackfireio # blackfireio Understanding the overhead ● Instrumentation ● Tools ready for production vs tools made for development only ● Instrumenting all requests vs specific requests
  • 6. blackfire.io @blackfireio # blackfireio Profiling is about measuring how much resources your code is consuming Wall time I/O CPU Memory Network SQLHTTP Time https://blackfire.io/docs/24-days/07-time-flavors
  • 7. blackfire.io @blackfireio # blackfireio Time is volatile ● Time is not a stable metric. External factors such as machine load can have significant impacts on wall time between two profiles of identical code. ● Time is just a consequence of what happened in the code ● Use time to identify the slow parts in your code and then: ○ iterate and compare ○ write assertions on the root cause ● Profiling is about understanding how code works at runtime https://blackfire.io/docs/24-days/12-tests-best-pratices
  • 8. blackfire.io @blackfireio # blackfireio Callgraphs, timelines and more ● Find the function calls that consume the most resources ● Know where to stop optimizing ● Trade-off time vs memory and performance vs code complexity ● Profiling should not always be a lonely activity
  • 9. blackfire.io @blackfireio #blackfireio What are the issues we encounter with Magento 2
  • 10. You cannot optimize what you cannot measure
  • 11. You cannot measure what you don’t execute.
  • 12. blackfire.io @blackfireio # blackfireio Varnish, can you ignore me? acl profile { # Allowed IP "111.112.113.114"; } sub vcl_recv { if (req.http.X-Blackfire-Query && client.ip ~ profile) { if (req.esi_level > 0) { unset req.http.X-Blackfire-Query; } else { return (pass); } } }
  • 13. blackfire.io @blackfireio # blackfireio What about the Full Page Cache? And all the others.
  • 14. blackfire.io @blackfireio # blackfireio You have to compare.
  • 15. blackfire.io @blackfireio # blackfireio The main issues ● SQL Queries ● Network ● CPU Time ● Memory ● I/O Wait ● External HTTP requests ● PHP & Bad PHP code
  • 16. blackfire.io @blackfireio # blackfireio SQL Queries ● Use indexes and correct types. ● Limit the number of results you need. ● Avoid SQL requests… ● If you can’t avoid them, cache the output or use LocalStorage/CacheStorage if insensitive information. ● Use Magento Repositories. SQL Requests are the main issue.
  • 17. blackfire.io @blackfireio # blackfireio ● Use local networks with local IP addresses. Network
  • 18. blackfire.io @blackfireio # blackfireio CPU Time ● Avoid consuming operations: loops, events… ● Use Magento Repositories. ● KISS : Keep It Simple Stupid.
  • 19. blackfire.io @blackfireio # blackfireio Memory ● Use the MagentoFrameworkModelResourceModelIterator for your loops. ● Use PHP! Avoid creating so many objects when you can do the operation with one function call. ● Use the Magento Dependency Injection. ● Use Magento Repositories.
  • 20. blackfire.io @blackfireio # blackfireio I/O Wait ● Use php://memory and php://temp. Because Memory is always faster than I/O. ● Optimize composer: composer dump-autoload --optimize --no-dev
  • 21. blackfire.io @blackfireio # blackfireio External HTTP Requests ● Don’t do that. ● If you really have to: use RabbitMQ. ● And if you really have no choice: use asynchronous? ● And if you really really have no choice: use a small timeout and deal with the errors properly.
  • 22. blackfire.io @blackfireio # blackfireio PHP & Bad PHP code
  • 23. blackfire.io @blackfireio # blackfireio PHP & Bad PHP code ● Upgrade to the latest version of PHP. ● Prefer a PHP core function to a lot of objects and methods. ●
  • 25. blackfire.io @blackfireio # blackfireio The metrics ● Is Magento 2 installed? CE or EE? ● Is the cache enabled? ● Cache manipulation. ● Product loads. ● Interceptors measurement. ● Mode detector: production/developer/default. ● …
  • 26. blackfire.io @blackfireio # blackfireio The metrics magento2.all.cache.full_page.builtin.hit: label: "Hit full page cache using builtin" matching_calls: php: - callee: "=Magento[…]BuiltinPlugin::addDebugHeader" caller: "=Magento[…]BuiltinPlugin::aroundDispatch"
  • 27. blackfire.io @blackfireio # blackfireio The metrics mymetrics.image.operation: matching_calls: php: - callee: "/.*image.*/" Will match imagecreate, getimagesize etc.
  • 28. blackfire.io @blackfireio # blackfireio The recommendations 'The Magento 2 Full Page Cache should be enabled': assertions: - 'metrics.magento2.[…]full_page.builtin.hit.count == 1' exclude: - '.*/checkout.*' - '.*/customer/section/load' - '.*/catalogsearch' […]
  • 29. blackfire.io @blackfireio # blackfireio The recommendations 'Do not make any image operation': assertions: - 'metrics.mymetrics.image.operation.count == 0'
  • 30. blackfire.io @blackfireio # blackfireio Put some limits: .blackfire.yml tests: Pages should be fast enough: path: /.* assertions: - main.wall_time < 850ms - main.io < 500ms - main.cpu_time < 500ms Pages should not consume too much memory: path: /.* assertions: - main.memory < 50M - main.peak_memory < 75M Homepage should not do too many SQL queries: path: / assertions: - metrics.sql.queries.count <= 12 Checkout pages should be light: path: /checkout/.* assertions: - metrics.output.network_out < 100KB
  • 31. blackfire.io @blackfireio # blackfireio Scenarios scenarios: Home: - / Cart: - /checkout/cart/ Login: - /customer/account/login/
  • 32. blackfire.io @blackfireio # blackfireio Profile Everywhere!