Transcript
Page 1: Managing and Monitoring Application Performance

Sebastian Marek, Internal Systems Technical Architect

MANAGING AND MONITORING APPLICATION

PERFORMANCEhttp://www.flickr.com/photos/wraith34/9377593973/

Page 2: Managing and Monitoring Application Performance

a Pole living in Sheffield

over 12 years in software development

big fan of process automation

TDD and CI

occasionally contributes to open-source projects

wants to be a knight @proofek

h"ps://joind.in/9301

Page 3: Managing and Monitoring Application Performance

HTTPS://WWW.CODECLUB.ORG.UK/

A nationwide network of volunteer-led after school coding clubs for children aged 9-11

Volunteer Code Club Projects Venue Children

+ + +

Page 4: Managing and Monitoring Application Performance

PERFORMANCE MONITORINGOverview

network level

system level

application level

End-user level

http://www.flickr.com/photos/global-jet/483825828/

Page 5: Managing and Monitoring Application Performance

PERFORMANCE MONITORINGNetwork level

failed TCP connections and packet losses

bandwidth usage

firewalls and loadbalancers

connectivity to external serviceshttp://www.flickr.com/photos/sbrown6079/2038502257/

Page 6: Managing and Monitoring Application Performance

PERFORMANCE MONITORINGSystem level

CPU load

memory consumption

disk space

http://www.flickr.com/photos/viagallery/3178699697/

Page 7: Managing and Monitoring Application Performance

PERFORMANCE MONITORINGApplication level

new deployments

response time

key transactions

memory usage

http://www.flickr.com/photos/qualityfrog/3546657245/

Page 8: Managing and Monitoring Application Performance

PERFORMANCE MONITORINGEnd-user level

response time

user experience

http://www.flickr.com/photos/alesk/356136498/

Page 9: Managing and Monitoring Application Performance

remote debugging

code coverage

tracing

profiling

Xdebug

Page 10: Managing and Monitoring Application Performance

Installation

XDEBUG

# pecl install xdebug

zend_extension=”/usr/lib/php/extensions/xdebug.so”

configure in xdebug.ini

web server restart (optional)

Page 11: Managing and Monitoring Application Performance

Configuration

XDEBUG

;Profiling settings (always on)xdebug.profiler_enable = 1xdebug.profiler_output_dir = /var/log/xdebug/

;Profiling settings (triggered by GET/POST/COOKIE)xdebug.profiler_enable = 0xdebug.profiler_output_dir = /var/log/xdebug/xdebug.profiler_enable_trigger = 1

Page 12: Managing and Monitoring Application Performance

Browser integration

XDEBUG

Page 13: Managing and Monitoring Application Performance

Profiling data

XDEBUG

fl=php:internalfn=php::spl_autoload_register881 3

fl=/Users/Sebastian/git/app/src/include/HTMLPurifier/HTMLPurifier.standalone.phpfn=HTMLPurifier_Bootstrap::registerAutoload878 21cfl=php:internalcfn=php::spl_autoload_functionscalls=1 0 0880 1cfl=php:internalcfn=php::spl_autoload_registercalls=1 0 0881 3

Page 14: Managing and Monitoring Application Performance

Profiling tools

XDEBUG

KCacheGrind for *nix systems

qcachegrind for MacOsX (and apparently Windows)

MacCallGrind for MacOsX

WebGrind via browser

Page 15: Managing and Monitoring Application Performance

qCacheGrind

XDEBUG

Page 16: Managing and Monitoring Application Performance

WebGrind

XDEBUG

Page 17: Managing and Monitoring Application Performance

profiling

web interface

xhProf

Page 18: Managing and Monitoring Application Performance

Installation

XHPROF

# pecl install xhprof

extension=”/usr/lib/php/extensions/xhprof.so”

configure in xhprof.ini

web server restart (optional)

Page 19: Managing and Monitoring Application Performance

Configuration

XHPROF

; XHProfextension = xhprof.soxhprof.output_dir = /var/log/xhprof/

Page 20: Managing and Monitoring Application Performance

Profiling tools

XHPROF

default web interface

xhGui (old, also known as XH UI)

xhGui (new, with MongoDB backend)

Page 21: Managing and Monitoring Application Performance

Default web interface - Installation

XHPROF

git clone [email protected]:facebook/xhprof.git

Page 22: Managing and Monitoring Application Performance

Default web interface - Installation

XHPROF

;Webserver (VirtualHost)<VirtualHost *:80> DocumentRoot “/Users/Sebastian/git/xhprof/xhprof_html” ServerName xhprof.localdomain

<Directory /Users/Sebastian/git/xhprof/xhprof_html> Order allow,deny Allow from all </Directory>

ErrorLog “/private/var/log/apache2/xhprof-error_log” CustomLog “/private/var/log/apache2/xhprof-access_log” common</VirtualHost>

Page 23: Managing and Monitoring Application Performance

Default web interface - Installation

XHPROF

;auto_prepend file - enable xhprof$xhProfHome = __DIR__ . ‘/..’;$profiler_namespace = ‘myapp’; // namespace for your application

if (extension_loaded(‘xhprof’)) { include_once “$xhProfHome/xhprof_lib/utils/xhprof_lib.php”; include_once “$xhProfHome/xhprof_lib/utils/xhprof_runs.php”; xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);}

Page 24: Managing and Monitoring Application Performance

Default web interface - Installation

XHPROF

;auto_prepend file - collect datafunction xhprofShutdownFunction(){ global $profiler_namespace; $xhProfUrl = “http://xhprof.localdomain/”;

if (extension_loaded(‘xhprof’)) { $xhprof_data = xhprof_disable(); $xhprof_runs = new XHProfRuns_Default(); $run_id = $xhprof_runs->save_run($xhprof_data, $profiler_namespace); $profiler_url = sprintf(“$xhProfUrl/index.php?run=%s&source=%s”, $run_id, $profiler_namespace); echo “<a href=’$profiler_url’ target=‘_blank’>Profiler output</a>”; }}register_shutdown_function(‘xhprofShutdownFunction’);

Page 25: Managing and Monitoring Application Performance

Default web interface - Installation

XHPROF

;enable profiling in your application (VirtualHost)<VirtualHost *:80> DocumentRoot “/Users/Sebastian/git/my_app/src” ServerName my_app.localdomain

<Directory /Users/Sebastian/git/my_app/src > Order allow,deny Allow from all </Directory>

php_admin_value auto_prepend_file /Users/Sebastian/git/xhprof/xhprof_html/header.php</VirtualHost>

Page 26: Managing and Monitoring Application Performance

Default web interface - Home page

XHPROF

Page 27: Managing and Monitoring Application Performance

Default web interface - Drilldown

XHPROF

Page 28: Managing and Monitoring Application Performance

Default web interface - Call graph

XHPROF

Page 29: Managing and Monitoring Application Performance

Default web interface - Full Call graph

XHPROF

Page 30: Managing and Monitoring Application Performance

XH UI - Installation

XHPROF

git clone [email protected]:preinheimer/xhprof.git

Page 31: Managing and Monitoring Application Performance

XH UI - Installation

XHPROF

;Webserver (VirtualHost)<VirtualHost *:80> DocumentRoot “/Users/Sebastian/git/xhui/xhprof_html” ServerName xhui.localdomain

<Directory /Users/Sebastian/git/xhui/xhprof_html> Order allow,deny Allow from all </Directory>

ErrorLog “/private/var/log/apache2/xhui-error_log” CustomLog “/private/var/log/apache2/xhui-access_log” common</VirtualHost>

Page 32: Managing and Monitoring Application Performance

XH UI - Configuration

XHPROF

# vim xhui/xhprof_lib/config.php

and reuse already provided xhui/external/header.php

Page 33: Managing and Monitoring Application Performance

XH UI - Installation

XHPROF

;enable profiling in your application (VirtualHost)<VirtualHost *:80> DocumentRoot “/Users/Sebastian/git/my_app/src” ServerName my_app.localdomain

<Directory /Users/Sebastian/git/my_app/src > Order allow,deny Allow from all </Directory>

php_admin_value auto_prepend_file /Users/Sebastian/git/xhui/external/header.php</VirtualHost>

Page 34: Managing and Monitoring Application Performance

XH UI - Home page

XHPROF

Page 35: Managing and Monitoring Application Performance

XH UI - Transaction detail

XHPROF

Page 36: Managing and Monitoring Application Performance

XH UI - Transaction detail

XHPROF

Page 37: Managing and Monitoring Application Performance

XHG - Installation

XHPROF

git clone [email protected]:preinheimer/xhgui.git

Page 38: Managing and Monitoring Application Performance

XHG - Installation

XHPROF

;Webserver (VirtualHost)<VirtualHost *:80> DocumentRoot “/Users/Sebastian/git/xhgui/webroot” ServerName xhgui.localdomain

<Directory /Users/Sebastian/git/xhgui/webroot> Order allow,deny Allow from all AllowOverride All </Directory>

ErrorLog “/private/var/log/apache2/xhgui-error_log” CustomLog “/private/var/log/apache2/xhgui-access_log” common</VirtualHost>

Page 39: Managing and Monitoring Application Performance

XHG - Requirements

XHPROF

MongoDB server

PHP MongoDB extension

PHP mcrypt extension

Page 40: Managing and Monitoring Application Performance

XHG - Installation

XHPROF

# cd xhgui

# php install.php

Page 41: Managing and Monitoring Application Performance

XHG - Installation

XHPROF

;enable profiling in your application (VirtualHost)<VirtualHost *:80> DocumentRoot “/Users/Sebastian/git/my_app/src” ServerName my_app.localdomain

<Directory /Users/Sebastian/git/my_app/src > Order allow,deny Allow from all </Directory>

php_admin_value auto_prepend_file /Users/Sebastian/git/xhgui/external/header.php</VirtualHost>

Page 42: Managing and Monitoring Application Performance

XHG - Home page

XHPROF

Page 43: Managing and Monitoring Application Performance

XHG - Transaction trace

XHPROF

Page 44: Managing and Monitoring Application Performance

XHG - Transaction trace

XHPROF

Page 45: Managing and Monitoring Application Performance

XHG - Transaction trace

XHPROF

Page 46: Managing and Monitoring Application Performance

XHG - Transaction history

XHPROF

Page 47: Managing and Monitoring Application Performance

XHG - Transaction call graph

XHPROF

Page 48: Managing and Monitoring Application Performance

Glossary

PROFILING

call count - number of times a function/request was called

wt (Wall Time/Wall Clock Time) - time it took to execute a function/request

cpu - CPU time spent executing a function/request

mu - Amount of memory used during function/request execution

pmu - The peak amount of memory used during function/request execution

exclusive - total time spent excluding time to execute other functions

inclusive - total time spent including time to execute other functions

Page 49: Managing and Monitoring Application Performance

Process

PROFILING

Profile and record the results

Identify functions/requests using the most CPU time/memory (exclusive)

Find out what’s causing the issue

Refactor and optimize the code - look for external resources - database, web services, filesystem

Profile and compare the results

start all over again

Page 50: Managing and Monitoring Application Performance

server monitoring

application monitoring

real user monitoring

NewRelic

Page 51: Managing and Monitoring Application Performance

Supported web applications

NEW RELIC

Page 52: Managing and Monitoring Application Performance

Supported PHP framework

NEW RELIC

Page 53: Managing and Monitoring Application Performance

Installation

NEW RELIC

# RHEL

$ rpm -Uvh http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm

$ yum install newrelic-php5

$ /usr/bin/newrelic-install

# Ubuntu / Debian

$ wget -O - https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -

deb http://apt.newrelic.com/debian/ newrelic non-free

$ apt-get install newrelic-php5

$ /usr/bin/newrelic-install

Page 54: Managing and Monitoring Application Performance

Server Monitoring

NEW RELIC

Page 55: Managing and Monitoring Application Performance

Server Monitoring - Main Dashboard

NEW RELIC

Portal01

App01

App02

Portal02

SugarCRM

SugarCRM

Support Centre

Page 56: Managing and Monitoring Application Performance

Server Monitoring - Overview

NEW RELIC

App02

App02

SugarCRM (App02)

Page 57: Managing and Monitoring Application Performance

Application Monitoring

NEW RELIC

Page 58: Managing and Monitoring Application Performance

Server Trace - Summary

NEW RELIC

App01(5.3.19+a2h(2.2.3):SugarCRM)

Page 59: Managing and Monitoring Application Performance

Server Trace - Details

NEW RELIC

Page 60: Managing and Monitoring Application Performance

Server Trace - SQL queries

NEW RELIC

Page 61: Managing and Monitoring Application Performance

Application Monitoring - Error Tracking

NEW RELIC

Page 62: Managing and Monitoring Application Performance

Real User Monitoring - App Dashboard

NEW RELIC

Page 63: Managing and Monitoring Application Performance

Understanding RUM

NEW RELIC

Web application - The time spent in the application code

Network - The time it takes for a request to make a round-trip over the internet.

DOM processing - Time spent in the browser parsing and interpreting the HTML.

Page rendering - Time spent in the browser displaying the HTML, running in-line JavaScript and loading images.

Page 64: Managing and Monitoring Application Performance

Understanding RUM

NEW RELIC

Source: http://blog.newrelic.com

Page 65: Managing and Monitoring Application Performance

Real User Monitoring - Browser Page Load

NEW RELIC

Page 66: Managing and Monitoring Application Performance

Real User Monitoring - Browser Page Load

NEW RELIC

Page 67: Managing and Monitoring Application Performance

Apdex

NEW RELIC

Page 68: Managing and Monitoring Application Performance

Apdex

NEW RELIC

0 T F

Satisfied zone: < T

Tolerating zone: T - F (4T)

Frustrated zone: > F

Page 69: Managing and Monitoring Application Performance

Apdex score

NEW RELIC

Satisfied customers + (Tolerating customers/2)

Total number of customers

Page 70: Managing and Monitoring Application Performance

Apdex by regions

NEW RELIC

Page 71: Managing and Monitoring Application Performance

Apdex - baseline

NEW RELIC

check the average response time

set your Apdex to average response time

find areas that require performance fixes

when performance improves lower your Apdex

Page 72: Managing and Monitoring Application Performance

New Relic - Map

NEW RELIC

memcached.local

crm.local

Page 73: Managing and Monitoring Application Performance

Keeping on top of the changes

NEW RELIC

Page 74: Managing and Monitoring Application Performance

Server Monitoring - plugins

NEW RELIC

Page 75: Managing and Monitoring Application Performance

Server Monitoring - APC

NEW RELIC

Page 76: Managing and Monitoring Application Performance

Server Monitoring - MySQL

NEW RELIC

Page 77: Managing and Monitoring Application Performance

Server Monitoring - Apache

NEW RELIC

Page 78: Managing and Monitoring Application Performance

PERFORMANCE MONITORINGSummary

Xdebug - application profiling during development stage

xhProf - application profiling during development stage and on live production platform

New Relic - end-to-end application monitoring on live production platfrom

Page 79: Managing and Monitoring Application Performance

PERFORMANCE MONITORINGAlternatives

DataDog - http://www.datadoghq.com/product/

GraphDat - http://www.graphdat.com

Scout - https://scoutapp.com/

Nagios - http://www.nagios.org/

Graphite - http://graphite.wikidot.com

Page 80: Managing and Monitoring Application Performance

ResourcesXdebug - http://www.xdebug.org/docs/profilerkCacheGrind - http://kcachegrind.sourceforge.netWebGrind - https://github.com/jokkedk/webgrindMacCallGrind for MacOsX - http://www.maccallgrind.com

xhProf - https://github.com/facebook/xhprofxhUI - https://github.com/preinheimer/xhprofxhGui - https://github.com/preinheimer/xhgui

New Relic - http://newrelic.comNew Relic Documentation - https://newrelic.com/docsApdex - http://apdex.org

http://techportal.inviqa.com/2009/12/01/profiling-with-xhprof/http://techportal.inviqa.com/2013/10/01/profiling-php-applications-with-xhgui/

Page 81: Managing and Monitoring Application Performance

Q & A

h"ps://joind.in/9301


Top Related