SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
© 2015 Phase2
Performance Profiling Tools
& Tricks
19 October 2015
All Things Open 2015
© 2015 Phase2
About Me
● Brad Blake
● Software Architect
● bblake@phase2technology.com
● www.phase2technology.com
© 2015 Phase2
Profiling
© 2015 Phase2
Profiling is not
● Benchmarking
● Debugging
● A dark art
© 2015 Phase2
Profiling is
● Gathering data on performance of a system
○ CPU/Memory usage
○ Function calls/times
○ Many other metrics
● Find where system is spending its time
● Refactoring, not changing functionality
© 2015 Phase2
Profiling is
© 2015 Phase2
Types of Profiling
● Event-based
○ Triggered by specific events
○ Generally slower
○ More data and more accurate
● Statistical ( sampling )
○ Record data at specific intervals
○ Less accurate and specific
○ Less intrusive
© 2015 Phase2
Before you start
● Determine if you have a performance issue
● How big of an issue is it?
● Benchmark
○ ab, httperf, siege, JMeter
● Determine your goal
© 2015 Phase2
Do’s
● Get to a functional system quickly, then measure it
○ Needs to be a ‘real’ system
○ Alternative is to prematurely optimize
● Be data-driven
● tail (-f) (-n) is your friend
● Go after items with highest cost
○ Not necessarily the outliers
● Test after each change
© 2015 Phase2
© 2015 Phase2
Don’ts
● Don’t make assumptions, be empirical
● Don’t assume the data won’t change
● Don’t assume caching is working
○ Check HTTP headers
○ Check memcache, redis
○ Query cache
● Don’t prematurely optimize
© 2015 Phase2
Tips
● Don’t over-optimize
● Do data migration early
○ Or use realistic substitute data
● Have a good test suite
○ Record metrics, graphs
● Implement logging from the beginning
© 2015 Phase2
Tips (cont.)
● Increasing memory is NOT A FIX
● Understand bigO concepts
● Match production settings ( Vagrant, Chef, OpenStack, etc )
and configs ( production mode )
© 2015 Phase2
Tools
© 2015 Phase2
PHP
● xhprof
● xdebug
● New Relic
○ SaaS model for real-time monitoring
○ Ruby, Python, PHP, Node
○ Servers, even Docker containers
© 2015 Phase2
Xhprof
● Created by facebook, on PECL
● Gets basic stats
● Can do sampling
● Can compare runs or aggregate runs
○ Useful in production to run only X runs
● Modules/Plugins for Drupal and Wordpress
● GUI not great, pretty basic
○ Xhgui
© 2015 Phase2
XDebug
● Debugger and Profiler
● Gets a lot of data
● Output can be used in kcachegrind ( qcachegrind )
● phpStorm integration
brew install qcachegrind
brew install graphviz
qcachegrind path-to-file
© 2015 Phase2
Ruby
● Run with production settings
● Built-In Profiler__ module
○ Very basic, limited data
© 2015 Phase2
Ruby-Prof
● Event-based
● Lots of reports and options
○ Text/HTML reports
○ Flat profiles, call graphs, call stacks
● Can profile whole app or blocks of code
© 2015 Phase2
Ruby-Prof
© 2015 Phase2
Perftools.rb
● perftools.rb
○ Sampling profiler
○ gperftools for Ruby
○ Also many output modes, including Callgrind
● Rack::PerftoolsProfiler
○ More limited output modes
○ Outputs to browser ( ?profile=true )
○ Can change frequency or mode
© 2015 Phase2
Perftools.rb
© 2015 Phase2
Node.js
● Node-Webkit-Agent
● Webstorm
● StrongLoop Arc
● NodeSource
© 2015 Phase2
Flamegraphs
© 2015 Phase2
Pretty
© 2015 Phase2
What is a Flamegraph?
● Visual representation of profiled software
○ For our purposes, the call stack
● Each layer is a function
● Each column is the amount of time spent
© 2015 Phase2
Why use a Flamegraph?
● Easier for non-technical people
● Easy to diagnose the quick problems
○ What was on the CPU at each interval
● Low overhead
● Pretty
© 2015 Phase2
How to Generate
● https://github.com/brendangregg/FlameGraph
● Call stack data converted to right format
● PHP
○ https://github.com/msonnabaum/xhprof-flamegraphs
○ Xdebug
○ Drupal: xhprof_sample + xhprof_flamegraph
© 2015 Phase2
How to Generate
● Ruby
○ https://github.com/MiniProfiler/rack-mini-profiler
+
○ flamegraph gem
● Node
○ perf (perf_events)
○ http://github.com/davepacheco/node-stackvis
© 2015 Phase2
Healthy
© 2015 Phase2
Unhealthy
© 2015 Phase2
Unhealthy
© 2015 Phase2
Query Tuning
© 2015 Phase2
How to Diagnose
● Slow query log
● mysql: slow_query_log, slow_query_log_file
○ Logs all queries - X seconds and examine at least X rows
○ Except admin statements ( alter, drop, etc )
○ log_queries_not_using_indexes
● mongo: db.setProfilingLevel()
○ system.profile collection
© 2015 Phase2
How to Diagnose
● SHOW [FULL] PROCESSLIST
○ Sending data, Copying to tmp table, Locked, etc
● mysqldumpslow
● Percona: pt-query-digest
● Logging in your app
© 2015 Phase2
Why is my query slow?
● Too much data
○ Fetching too many columns/rows
○ Examining too many rows
● Poorly designed schema
○ Shorter rows generally better
● Lack of proper indexes
○ Or too many indexes
© 2015 Phase2
Why is my query slow?
● Inefficient SQL
○ Subqueries vs. Joins
○ COUNT(*)
○ High Offsets
○ Complex versus split queries
● Disk versus Memory
● Sorting
● Query Cache
© 2015 Phase2
EXPLAIN
● MySQL
○ Prefix SELECT query with EXPLAIN
● Postgres
○ EXPLAIN, EXPLAIN ANALYZE
● Mongo
○ db.collection.explain()
© 2015 Phase2
The Optimizer
● Chooses execution plan with lowest cost
○ Not necessarily the fastest
○ Looks at number of rows, indexes, cardinality, length of
keys
○ optimizer_trace ( 5.6 )
○ EXPLAIN FORMAT=JSON ( 5.7 )
● Can do things like reorder and convert JOINs
● Subquery optimization
© 2015 Phase2
EXPLAIN
EXPLAIN SELECT n.title, b.body_value FROM node n
INNER JOIN node_revision nr ON n.vid = nr.vid
INNER JOIN (SELECT entity_id, body_value FROM
field_data_body) as b ON n.nid = b.entity_id
WHERE n.nid > 1000
LIMIT 0,10
© 2015 Phase2
EXPLAIN
● id: The SELECT that the row belongs to. ( usually 1 )
● select_type: Whether row is SIMPLE or Complex
○ PRIMARY, DERIVED, UNION
● table: Generally table name or alias
● type: Access Type. How MySQL will access the rows
© 2015 Phase2
EXPLAIN ( Access Type )
● ALL: Generally full table scan
● index: Full index scan ( range: limited index scan )
● ref: Join two non-unique indexed fields
● eq_ref: Join unique non-null index and indexed field
● const: Returns 1 value from index with unique key
© 2015 Phase2
EXPLAIN
● possible_keys: Possible indexes
● key: Which index actually will be used
● key_len: Bytes of the index used
● ref: What it used to look up values in the index
© 2015 Phase2
EXPLAIN
● rows: ESTIMATE of rows MySQL will need to read
● Extra: Anything else
○ Using filesort
○ Using temporary
○ Using where
○ Using index
© 2015 Phase2
EXPLAIN
● Sometimes it lies or is inaccurate
○ Table stats wrong ( ANALYZE TABLE )
○ Can’t estimate every possible plan
● If you think optimizer is wrong:
○ STRAIGHT_JOIN
○ USE/IGNORE/FORCE {INDEXES}
© 2015 Phase2
Thank You
● bblake@phase2technology.com

Contenu connexe

Tendances

Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"Fwdays
 
How to write a Dockerfile
How to write a DockerfileHow to write a Dockerfile
How to write a DockerfileKnoldus Inc.
 
Delivering a bleeding edge community led open stack distribution- rdo
Delivering a bleeding edge community led open stack distribution- rdoDelivering a bleeding edge community led open stack distribution- rdo
Delivering a bleeding edge community led open stack distribution- rdoChandan Kumar
 
Scale Big With Docker — Moboom 2014
Scale Big With Docker — Moboom 2014Scale Big With Docker — Moboom 2014
Scale Big With Docker — Moboom 2014Jérôme Petazzoni
 
Building Good Containers for Python Applications
Building Good Containers for Python ApplicationsBuilding Good Containers for Python Applications
Building Good Containers for Python ApplicationsAll Things Open
 
Delivering a bleeding edge community-led openstack distribution: RDO
Delivering a bleeding edge community-led openstack distribution: RDO Delivering a bleeding edge community-led openstack distribution: RDO
Delivering a bleeding edge community-led openstack distribution: RDO Chandan Kumar
 
OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...
OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...
OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...NETWAYS
 
IstioD - From Microservices to Monolithic
IstioD - From Microservices to MonolithicIstioD - From Microservices to Monolithic
IstioD - From Microservices to MonolithicAll Things Open
 
Better delivery with DevOps Driven Development
Better delivery with DevOps Driven DevelopmentBetter delivery with DevOps Driven Development
Better delivery with DevOps Driven DevelopmentJirayut Nimsaeng
 
Learning Nagios module 1
Learning Nagios module 1Learning Nagios module 1
Learning Nagios module 1Jayant Chutke
 
Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)
Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)
Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)Red Hat Developers
 
Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftYaniv cohen
 
Dockerize magento 2 24.02.2016
Dockerize magento 2   24.02.2016Dockerize magento 2   24.02.2016
Dockerize magento 2 24.02.2016Andreas Pointner
 
.NET Core in the Real World
.NET Core in the Real World.NET Core in the Real World
.NET Core in the Real WorldNate Barbettini
 
Gitlab and Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and LingvokotLingvokot
 
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений" Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений" Fwdays
 
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of ContainerOSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of ContainerNETWAYS
 

Tendances (20)

Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"
 
How to write a Dockerfile
How to write a DockerfileHow to write a Dockerfile
How to write a Dockerfile
 
DevOps in realtime
DevOps in realtimeDevOps in realtime
DevOps in realtime
 
Delivering a bleeding edge community led open stack distribution- rdo
Delivering a bleeding edge community led open stack distribution- rdoDelivering a bleeding edge community led open stack distribution- rdo
Delivering a bleeding edge community led open stack distribution- rdo
 
Scale Big With Docker — Moboom 2014
Scale Big With Docker — Moboom 2014Scale Big With Docker — Moboom 2014
Scale Big With Docker — Moboom 2014
 
Docker in Production
Docker in ProductionDocker in Production
Docker in Production
 
Git+jenkins+rex presentation
Git+jenkins+rex presentationGit+jenkins+rex presentation
Git+jenkins+rex presentation
 
Building Good Containers for Python Applications
Building Good Containers for Python ApplicationsBuilding Good Containers for Python Applications
Building Good Containers for Python Applications
 
Delivering a bleeding edge community-led openstack distribution: RDO
Delivering a bleeding edge community-led openstack distribution: RDO Delivering a bleeding edge community-led openstack distribution: RDO
Delivering a bleeding edge community-led openstack distribution: RDO
 
OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...
OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...
OSDC 2016 - rkt and Kubernentes what's new with Container Runtimes and Orches...
 
IstioD - From Microservices to Monolithic
IstioD - From Microservices to MonolithicIstioD - From Microservices to Monolithic
IstioD - From Microservices to Monolithic
 
Better delivery with DevOps Driven Development
Better delivery with DevOps Driven DevelopmentBetter delivery with DevOps Driven Development
Better delivery with DevOps Driven Development
 
Learning Nagios module 1
Learning Nagios module 1Learning Nagios module 1
Learning Nagios module 1
 
Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)
Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)
Developing In Python On Red Hat Platforms (Nick Coghlan & Graham Dumpleton)
 
Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShift
 
Dockerize magento 2 24.02.2016
Dockerize magento 2   24.02.2016Dockerize magento 2   24.02.2016
Dockerize magento 2 24.02.2016
 
.NET Core in the Real World
.NET Core in the Real World.NET Core in the Real World
.NET Core in the Real World
 
Gitlab and Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and Lingvokot
 
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений" Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
 
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of ContainerOSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
 

En vedette

Factores de riesgo ergonomicos
Factores de riesgo ergonomicosFactores de riesgo ergonomicos
Factores de riesgo ergonomicosGPI Consultores
 
ІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІ
ІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІ
ІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІAnna Fedorova
 
Provisioning Servers Made Easy
Provisioning Servers Made EasyProvisioning Servers Made Easy
Provisioning Servers Made EasyAll Things Open
 
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014Endava
 
Security From The Big Data and Analytics Perspective
Security From The Big Data and Analytics PerspectiveSecurity From The Big Data and Analytics Perspective
Security From The Big Data and Analytics PerspectiveAll Things Open
 
How Companies can Effectively Work with Open Source Communities
How Companies can Effectively Work with Open Source CommunitiesHow Companies can Effectively Work with Open Source Communities
How Companies can Effectively Work with Open Source CommunitiesAll Things Open
 
Kashmir Conflict
Kashmir  ConflictKashmir  Conflict
Kashmir ConflictApurv Vivek
 
行政院會簡報:經濟部水利署:2017水情分析及因應作為
行政院會簡報:經濟部水利署:2017水情分析及因應作為行政院會簡報:經濟部水利署:2017水情分析及因應作為
行政院會簡報:經濟部水利署:2017水情分析及因應作為releaseey
 
Pengantar Bisnis - Materi perkuliahan oleh ARS
Pengantar Bisnis - Materi perkuliahan oleh ARSPengantar Bisnis - Materi perkuliahan oleh ARS
Pengantar Bisnis - Materi perkuliahan oleh ARS Andry R Sukma
 

En vedette (12)

CUNY Commons Tour
CUNY Commons TourCUNY Commons Tour
CUNY Commons Tour
 
Alan's Report2
Alan's Report2Alan's Report2
Alan's Report2
 
Climate
ClimateClimate
Climate
 
Factores de riesgo ergonomicos
Factores de riesgo ergonomicosFactores de riesgo ergonomicos
Factores de riesgo ergonomicos
 
ІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІ
ІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІ
ІННОВАЦІЙНІ ПЕРЕТВОРЕННЯ ВИЩОЇ ОСВІТИ В УКРАЇНІ
 
Provisioning Servers Made Easy
Provisioning Servers Made EasyProvisioning Servers Made Easy
Provisioning Servers Made Easy
 
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
 
Security From The Big Data and Analytics Perspective
Security From The Big Data and Analytics PerspectiveSecurity From The Big Data and Analytics Perspective
Security From The Big Data and Analytics Perspective
 
How Companies can Effectively Work with Open Source Communities
How Companies can Effectively Work with Open Source CommunitiesHow Companies can Effectively Work with Open Source Communities
How Companies can Effectively Work with Open Source Communities
 
Kashmir Conflict
Kashmir  ConflictKashmir  Conflict
Kashmir Conflict
 
行政院會簡報:經濟部水利署:2017水情分析及因應作為
行政院會簡報:經濟部水利署:2017水情分析及因應作為行政院會簡報:經濟部水利署:2017水情分析及因應作為
行政院會簡報:經濟部水利署:2017水情分析及因應作為
 
Pengantar Bisnis - Materi perkuliahan oleh ARS
Pengantar Bisnis - Materi perkuliahan oleh ARSPengantar Bisnis - Materi perkuliahan oleh ARS
Pengantar Bisnis - Materi perkuliahan oleh ARS
 

Similaire à Performance profiling tools and techniques for PHP, Ruby, and Node.js

ceph openstack dream team
ceph openstack dream teamceph openstack dream team
ceph openstack dream teamUdo Seidel
 
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Phase2
 
Query and audit logging in cassandra
Query and audit logging in cassandraQuery and audit logging in cassandra
Query and audit logging in cassandraVinay Kumar Chella
 
Continuous Deployment Applied at MyHeritage
Continuous Deployment Applied at MyHeritageContinuous Deployment Applied at MyHeritage
Continuous Deployment Applied at MyHeritageRan Levy
 
What's New in OpenLDAP
What's New in OpenLDAPWhat's New in OpenLDAP
What's New in OpenLDAPLDAPCon
 
OSMC 2012 | Shinken by Jean Gabès
OSMC 2012 | Shinken by Jean GabèsOSMC 2012 | Shinken by Jean Gabès
OSMC 2012 | Shinken by Jean GabèsNETWAYS
 
GlusterD - Daemon refactoring
GlusterD - Daemon refactoringGlusterD - Daemon refactoring
GlusterD - Daemon refactoringAtin Mukherjee
 
Best Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, IndiaBest Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, IndiaN Benchmark IT Solutions
 
FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6FromDual GmbH
 
Upgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeUpgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeOlivier DASINI
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHPRogério Vicente
 
How to build TiDB
How to build TiDBHow to build TiDB
How to build TiDBPingCAP
 
NODE JS OC Meetup 1
NODE JS OC Meetup 1NODE JS OC Meetup 1
NODE JS OC Meetup 1eddify
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code cleanBrett Child
 
Monitoring your VM's at Scale
Monitoring your VM's at ScaleMonitoring your VM's at Scale
Monitoring your VM's at ScaleKris Buytaert
 

Similaire à Performance profiling tools and techniques for PHP, Ruby, and Node.js (20)

ceph openstack dream team
ceph openstack dream teamceph openstack dream team
ceph openstack dream team
 
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
 
Query and audit logging in cassandra
Query and audit logging in cassandraQuery and audit logging in cassandra
Query and audit logging in cassandra
 
kpatch.kgraft
kpatch.kgraftkpatch.kgraft
kpatch.kgraft
 
Continuous Deployment Applied at MyHeritage
Continuous Deployment Applied at MyHeritageContinuous Deployment Applied at MyHeritage
Continuous Deployment Applied at MyHeritage
 
What's New in OpenLDAP
What's New in OpenLDAPWhat's New in OpenLDAP
What's New in OpenLDAP
 
Sprint 15
Sprint 15Sprint 15
Sprint 15
 
OSMC 2012 | Shinken by Jean Gabès
OSMC 2012 | Shinken by Jean GabèsOSMC 2012 | Shinken by Jean Gabès
OSMC 2012 | Shinken by Jean Gabès
 
GlusterD - Daemon refactoring
GlusterD - Daemon refactoringGlusterD - Daemon refactoring
GlusterD - Daemon refactoring
 
nebulaconf
nebulaconfnebulaconf
nebulaconf
 
Drools & jBPM Workshop Barcelona 2013
Drools & jBPM Workshop  Barcelona 2013Drools & jBPM Workshop  Barcelona 2013
Drools & jBPM Workshop Barcelona 2013
 
Best Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, IndiaBest Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, India
 
FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6
 
Neo4j Graph Database, from PHP
Neo4j Graph Database, from PHPNeo4j Graph Database, from PHP
Neo4j Graph Database, from PHP
 
Upgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeUpgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtime
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
 
How to build TiDB
How to build TiDBHow to build TiDB
How to build TiDB
 
NODE JS OC Meetup 1
NODE JS OC Meetup 1NODE JS OC Meetup 1
NODE JS OC Meetup 1
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
Monitoring your VM's at Scale
Monitoring your VM's at ScaleMonitoring your VM's at Scale
Monitoring your VM's at Scale
 

Plus de All Things Open

Building Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityBuilding Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityAll Things Open
 
Modern Database Best Practices
Modern Database Best PracticesModern Database Best Practices
Modern Database Best PracticesAll Things Open
 
Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public PolicyAll Things Open
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...All Things Open
 
The State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashAll Things Open
 
Total ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptAll Things Open
 
What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?All Things Open
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractAll Things Open
 
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlowAll Things Open
 
DEI Challenges and Success
DEI Challenges and SuccessDEI Challenges and Success
DEI Challenges and SuccessAll Things Open
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with BackgroundAll Things Open
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblyAll Things Open
 
Using SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksUsing SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksAll Things Open
 
Configuration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptConfiguration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptAll Things Open
 
Scaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramScaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramAll Things Open
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceAll Things Open
 
Deploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamDeploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamAll Things Open
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in controlAll Things Open
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsAll Things Open
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...All Things Open
 

Plus de All Things Open (20)

Building Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityBuilding Reliability - The Realities of Observability
Building Reliability - The Realities of Observability
 
Modern Database Best Practices
Modern Database Best PracticesModern Database Best Practices
Modern Database Best Practices
 
Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public Policy
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
 
The State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil Nash
 
Total ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScript
 
What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart Contract
 
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 
DEI Challenges and Success
DEI Challenges and SuccessDEI Challenges and Success
DEI Challenges and Success
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with Background
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssembly
 
Using SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksUsing SQL to Find Needles in Haystacks
Using SQL to Find Needles in Haystacks
 
Configuration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptConfiguration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit Intercept
 
Scaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramScaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship Program
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open Source
 
Deploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamDeploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache Beam
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in control
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
 

Dernier

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Dernier (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Performance profiling tools and techniques for PHP, Ruby, and Node.js

  • 1. © 2015 Phase2 Performance Profiling Tools & Tricks 19 October 2015 All Things Open 2015
  • 2. © 2015 Phase2 About Me ● Brad Blake ● Software Architect ● bblake@phase2technology.com ● www.phase2technology.com
  • 4. © 2015 Phase2 Profiling is not ● Benchmarking ● Debugging ● A dark art
  • 5. © 2015 Phase2 Profiling is ● Gathering data on performance of a system ○ CPU/Memory usage ○ Function calls/times ○ Many other metrics ● Find where system is spending its time ● Refactoring, not changing functionality
  • 7. © 2015 Phase2 Types of Profiling ● Event-based ○ Triggered by specific events ○ Generally slower ○ More data and more accurate ● Statistical ( sampling ) ○ Record data at specific intervals ○ Less accurate and specific ○ Less intrusive
  • 8. © 2015 Phase2 Before you start ● Determine if you have a performance issue ● How big of an issue is it? ● Benchmark ○ ab, httperf, siege, JMeter ● Determine your goal
  • 9. © 2015 Phase2 Do’s ● Get to a functional system quickly, then measure it ○ Needs to be a ‘real’ system ○ Alternative is to prematurely optimize ● Be data-driven ● tail (-f) (-n) is your friend ● Go after items with highest cost ○ Not necessarily the outliers ● Test after each change
  • 11. © 2015 Phase2 Don’ts ● Don’t make assumptions, be empirical ● Don’t assume the data won’t change ● Don’t assume caching is working ○ Check HTTP headers ○ Check memcache, redis ○ Query cache ● Don’t prematurely optimize
  • 12. © 2015 Phase2 Tips ● Don’t over-optimize ● Do data migration early ○ Or use realistic substitute data ● Have a good test suite ○ Record metrics, graphs ● Implement logging from the beginning
  • 13. © 2015 Phase2 Tips (cont.) ● Increasing memory is NOT A FIX ● Understand bigO concepts ● Match production settings ( Vagrant, Chef, OpenStack, etc ) and configs ( production mode )
  • 15. © 2015 Phase2 PHP ● xhprof ● xdebug ● New Relic ○ SaaS model for real-time monitoring ○ Ruby, Python, PHP, Node ○ Servers, even Docker containers
  • 16. © 2015 Phase2 Xhprof ● Created by facebook, on PECL ● Gets basic stats ● Can do sampling ● Can compare runs or aggregate runs ○ Useful in production to run only X runs ● Modules/Plugins for Drupal and Wordpress ● GUI not great, pretty basic ○ Xhgui
  • 17. © 2015 Phase2 XDebug ● Debugger and Profiler ● Gets a lot of data ● Output can be used in kcachegrind ( qcachegrind ) ● phpStorm integration brew install qcachegrind brew install graphviz qcachegrind path-to-file
  • 18. © 2015 Phase2 Ruby ● Run with production settings ● Built-In Profiler__ module ○ Very basic, limited data
  • 19. © 2015 Phase2 Ruby-Prof ● Event-based ● Lots of reports and options ○ Text/HTML reports ○ Flat profiles, call graphs, call stacks ● Can profile whole app or blocks of code
  • 21. © 2015 Phase2 Perftools.rb ● perftools.rb ○ Sampling profiler ○ gperftools for Ruby ○ Also many output modes, including Callgrind ● Rack::PerftoolsProfiler ○ More limited output modes ○ Outputs to browser ( ?profile=true ) ○ Can change frequency or mode
  • 23. © 2015 Phase2 Node.js ● Node-Webkit-Agent ● Webstorm ● StrongLoop Arc ● NodeSource
  • 26. © 2015 Phase2 What is a Flamegraph? ● Visual representation of profiled software ○ For our purposes, the call stack ● Each layer is a function ● Each column is the amount of time spent
  • 27. © 2015 Phase2 Why use a Flamegraph? ● Easier for non-technical people ● Easy to diagnose the quick problems ○ What was on the CPU at each interval ● Low overhead ● Pretty
  • 28. © 2015 Phase2 How to Generate ● https://github.com/brendangregg/FlameGraph ● Call stack data converted to right format ● PHP ○ https://github.com/msonnabaum/xhprof-flamegraphs ○ Xdebug ○ Drupal: xhprof_sample + xhprof_flamegraph
  • 29. © 2015 Phase2 How to Generate ● Ruby ○ https://github.com/MiniProfiler/rack-mini-profiler + ○ flamegraph gem ● Node ○ perf (perf_events) ○ http://github.com/davepacheco/node-stackvis
  • 34. © 2015 Phase2 How to Diagnose ● Slow query log ● mysql: slow_query_log, slow_query_log_file ○ Logs all queries - X seconds and examine at least X rows ○ Except admin statements ( alter, drop, etc ) ○ log_queries_not_using_indexes ● mongo: db.setProfilingLevel() ○ system.profile collection
  • 35. © 2015 Phase2 How to Diagnose ● SHOW [FULL] PROCESSLIST ○ Sending data, Copying to tmp table, Locked, etc ● mysqldumpslow ● Percona: pt-query-digest ● Logging in your app
  • 36. © 2015 Phase2 Why is my query slow? ● Too much data ○ Fetching too many columns/rows ○ Examining too many rows ● Poorly designed schema ○ Shorter rows generally better ● Lack of proper indexes ○ Or too many indexes
  • 37. © 2015 Phase2 Why is my query slow? ● Inefficient SQL ○ Subqueries vs. Joins ○ COUNT(*) ○ High Offsets ○ Complex versus split queries ● Disk versus Memory ● Sorting ● Query Cache
  • 38. © 2015 Phase2 EXPLAIN ● MySQL ○ Prefix SELECT query with EXPLAIN ● Postgres ○ EXPLAIN, EXPLAIN ANALYZE ● Mongo ○ db.collection.explain()
  • 39. © 2015 Phase2 The Optimizer ● Chooses execution plan with lowest cost ○ Not necessarily the fastest ○ Looks at number of rows, indexes, cardinality, length of keys ○ optimizer_trace ( 5.6 ) ○ EXPLAIN FORMAT=JSON ( 5.7 ) ● Can do things like reorder and convert JOINs ● Subquery optimization
  • 40. © 2015 Phase2 EXPLAIN EXPLAIN SELECT n.title, b.body_value FROM node n INNER JOIN node_revision nr ON n.vid = nr.vid INNER JOIN (SELECT entity_id, body_value FROM field_data_body) as b ON n.nid = b.entity_id WHERE n.nid > 1000 LIMIT 0,10
  • 41. © 2015 Phase2 EXPLAIN ● id: The SELECT that the row belongs to. ( usually 1 ) ● select_type: Whether row is SIMPLE or Complex ○ PRIMARY, DERIVED, UNION ● table: Generally table name or alias ● type: Access Type. How MySQL will access the rows
  • 42. © 2015 Phase2 EXPLAIN ( Access Type ) ● ALL: Generally full table scan ● index: Full index scan ( range: limited index scan ) ● ref: Join two non-unique indexed fields ● eq_ref: Join unique non-null index and indexed field ● const: Returns 1 value from index with unique key
  • 43. © 2015 Phase2 EXPLAIN ● possible_keys: Possible indexes ● key: Which index actually will be used ● key_len: Bytes of the index used ● ref: What it used to look up values in the index
  • 44. © 2015 Phase2 EXPLAIN ● rows: ESTIMATE of rows MySQL will need to read ● Extra: Anything else ○ Using filesort ○ Using temporary ○ Using where ○ Using index
  • 45. © 2015 Phase2 EXPLAIN ● Sometimes it lies or is inaccurate ○ Table stats wrong ( ANALYZE TABLE ) ○ Can’t estimate every possible plan ● If you think optimizer is wrong: ○ STRAIGHT_JOIN ○ USE/IGNORE/FORCE {INDEXES}
  • 46. © 2015 Phase2 Thank You ● bblake@phase2technology.com