Slide 1

Slide 1 text

DISCOVERING & SOLVING PERFORMANCE ISSUES

Slide 2

Slide 2 text

I will give you… a quick tour of some tools I use an opinionated guide of practices an overview of typical problems/solutions

Slide 3

Slide 3 text

DENIS BRUMANN [email protected] @dbrumann

Slide 4

Slide 4 text

BEFORE YOU START… FIGURE OUT YOUR PROBLEM

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. https://jmeter.apache.org/

Slide 7

Slide 7 text

LOAD TEST
 Verify application behavior under normal and peak load conditions. STRESS TEST 
 Determine or validate an application’s behavior when pushed
 beyond normal or peak load conditions. CAPACITY TEST
 Determine how many users and/or transactions a given system
 will support and still meet performance goals.

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

WEB SERVER 
 access & error logs DATABASE 
 size, throughput, connections, slow queries CACHE
 hits, misses, size SYSTEM
 CPU & memory usage, disk I/O, network

Slide 13

Slide 13 text

WHAT TO DO? slowly increase sample size monitor changes & spot anomalies make one change at a time
 based on a verifiable assumption repeat

Slide 14

Slide 14 text

Search for causes not symptoms Do not make changes without cause Change as few things as possible Know when to stop

Slide 15

Slide 15 text

You have rock solid & kickass monitoring
 for your production system! Tests & monitoring can be reused & adapted
 for other scenarios

Slide 16

Slide 16 text

Performance Testing Guidance for Web Applications https://msdn.microsoft.com/en-us/library/bb924356.aspx

Slide 17

Slide 17 text

WHAT ABOUT THE CLIENT?

Slide 18

Slide 18 text

PERFORMANCE TAB

Slide 19

Slide 19 text

NETWORK TAB

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

MEANWHILE ON THE SERVER…

Slide 22

Slide 22 text

SYMFONY WEB PROFILER

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

PROFILING AS A SERVICE

Slide 25

Slide 25 text

BLACKFIRE

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

BLACKFIRE PLUGIN

Slide 29

Slide 29 text

BLACKFIRE PLUGIN

Slide 30

Slide 30 text

$config = new \Blackfire\ClientConfiguration(
 $clientId, $clientToken
 ); $client = new \Blackfire\Client($config); $probe = $client->createProbe(); // code to be profiled $client->endProbe($probe); BLACKFIRE SDK

Slide 31

Slide 31 text

TYPICAL PROBLEM GROUPS I/O WAIT CPU USAGE MEMORY NETWORK LATENCY SQL QUERIES

Slide 32

Slide 32 text

HOW TO DEVELOP FOR PERFORMANCE? DON’T!

Slide 33

Slide 33 text

DEVELOP FOR READABILITY MAINTAINABILITY SAFETY

Slide 34

Slide 34 text

WHAT DOES THAT MEAN? SOLID YAGNI DRY

Slide 35

Slide 35 text

AVOID ABSTRACTIONS & MAGIC
 You are solving concrete business problems MICRO-OPTIMIZATIONS
 Saving a few µs in cpu cycles never matters GUESSING
 Only real data from your performance counts

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

PHP 7

Slide 38

Slide 38 text

http://www.zend.com/en/resources/php7_infographic

Slide 39

Slide 39 text

PHP INSPECTIONS (EA EXTENDED)

Slide 40

Slide 40 text

BYTE CODE CACHE APC OpCache WinCache

Slide 41

Slide 41 text

FOR SYMFONY
 opcache.max_accelerated_files = 20000 realpath_cache_size=4096K realpath_cache_ttl=600 https://symfony.com/doc/current/performance.html

Slide 42

Slide 42 text

AUTOLOADING Use composer classmap composer dump-autoload --optimize \ --classmap-authoritative --no-dev composer install -noa

Slide 43

Slide 43 text

VARNISH https://varnish-cache.org

Slide 44

Slide 44 text

Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. Varnish Cache is really, really fast. It typically speeds up delivery with a factor of 300 - 1000x, depending on your architecture. https://varnish-cache.org/intro/index.html#the-basics

Slide 45

Slide 45 text

PHP NGINX VARNISH NGINX NGINX

Slide 46

Slide 46 text

Slide 47

Slide 47 text

CACHEABLE HTTP RESPONSES Cache-Control Expires ETag Last-Modified

Slide 48

Slide 48 text

UTILITIES SYMFONY Helper methods in Response-object
 Controller-Annotations @Cache PSR-7
 https://github.com/micheh/psr7-cache

Slide 49

Slide 49 text

CODE SAMPLE PSR-7 Response $response->withHeader( ‘Cache-Control’, ‘public, s-maxage=600, must-revalidate’ );

Slide 50

Slide 50 text

https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching

Slide 51

Slide 51 text

APPLICATION CACHING

Slide 52

Slide 52 text

DON’T BE FOOLED REDIS IS NOT EASY TO SETUP

Slide 53

Slide 53 text

APCu FILESYSTEM DATABASE

Slide 54

Slide 54 text

⚠ USE WITH CPU-HEAVY TASKS NOT MEMORY-HEAVY TASKS

Slide 55

Slide 55 text

DOCTRINE

Slide 56

Slide 56 text

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/ improving-performance.html METADATA & QUERY CACHES
 it is strongly discouraged to use Doctrine without a Metadata and Query cache (preferably with APC or Memcache as the cache driver). ALTERNATIVE RESULT FORMATS
 Make effective use of the available alternative query result formats like nested array graphs or pure scalar results, especially in scenarios where data is loaded for read-only purposes.

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

https://github.com/igorw/retry/issues/3

Slide 59

Slide 59 text

BACK IT UP WITH DATA! MEASURE ANALYZE OPTIMIZE MEASURE AGAIN

Slide 60

Slide 60 text

THANK YOU!