Slide 1

Slide 1 text

By Thijs Feryn Web performance as an essential part of the user experience

Slide 2

Slide 2 text

Slow websites suck

Slide 3

Slide 3 text

Web performance is an essential part of the user experience

Slide 4

Slide 4 text

Slow ~ Down

Slide 5

Slide 5 text

Saturated market

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Hi, I’m Thijs

Slide 10

Slide 10 text

I’m @ThijsFeryn on Twitter

Slide 11

Slide 11 text

I’m an Evangelist At

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Infrastructure

Slide 14

Slide 14 text

Code

Slide 15

Slide 15 text

Slow database

Slide 16

Slide 16 text

Slow API call

Slide 17

Slide 17 text

Browser rendering

Slide 18

Slide 18 text

User location

Slide 19

Slide 19 text

Time To First Byte

Slide 20

Slide 20 text

DNS TCP TLS Request Response TTFB Render

Slide 21

Slide 21 text

CODE + INFRA

Slide 22

Slide 22 text

Identify slowest parts

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Reduce the impact of the code on the server

Slide 26

Slide 26 text

Response times at increased concurrency Response times 0 35 70 105 140 Concurrency 10 50 100 150 200 250 300 350 400 450 500 Page 1 Page 2 Hypothetical example

Slide 27

Slide 27 text

Not just raw speed

Slide 28

Slide 28 text

Stable speed under increasing load Response times 0 10 20 30 40 Concurrency 10 50 100 150 200 250 300 350 400 450 500

Slide 29

Slide 29 text

Refactor slow code Write fast code

Slide 30

Slide 30 text

Optimize database

Slide 31

Slide 31 text

Improve the API call

Slide 32

Slide 32 text

Optimize runtime

Slide 33

Slide 33 text

After a while you hit the limits

Slide 34

Slide 34 text

E-commerce context

Slide 35

Slide 35 text

Platforms Frameworks

Slide 36

Slide 36 text

Mo money Mo servers

Slide 37

Slide 37 text

High A vailability

Slide 38

Slide 38 text

Recurring cost

Slide 39

Slide 39 text

CAPEX

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Cache

Slide 42

Slide 42 text

Optimize database Optimize runtime A void A void

Slide 43

Slide 43 text

Don’t recompute if the data hasn’t changed

Slide 44

Slide 44 text

3 x 2 = ?

Slide 45

Slide 45 text

What can you cache? Byte code Database output External services Files from disk Pages

Slide 46

Slide 46 text

Caching is not a compensation for poor code

Slide 47

Slide 47 text

Caching is an essential architectural strategy

Slide 48

Slide 48 text

Varnish

Slide 49

Slide 49 text

Normally User Server

Slide 50

Slide 50 text

With Varnish User Varnish Server

Slide 51

Slide 51 text

Leverage HTTP for caching

Slide 52

Slide 52 text

Cache-Control: public, max-age=500, s-maxage=3600 Vary: Accept-Encoding, Accept-Language ETag: 7ECE8823114E4155A2A72657BB2682D0 Surrogate-Control: key=ESI/1.0 Content-Encoding: deflate Transfer-Encoding: chunked

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

E-commerce context

Slide 55

Slide 55 text

Platform integration for Varnish, Memcached, Redis

Slide 56

Slide 56 text

Combine Varnish & Redis

Slide 57

Slide 57 text

Browser rendering

Slide 58

Slide 58 text

Time To First Paint

Slide 59

Slide 59 text

Time To First Meaningful Paint

Slide 60

Slide 60 text

DNS TCP TLS Request Response TTF(M)P Render

Slide 61

Slide 61 text

JPG PNG CSS ICO JS Sum of individual loading/rendering times WOFF JPG JPG PNG CSS CSS JS

Slide 62

Slide 62 text

#Round Trips x Round Trip Time

Slide 63

Slide 63 text

Reduce Round Trips

Slide 64

Slide 64 text

Reduce Response Sizes

Slide 65

Slide 65 text

✓ Compress images ✓ Illustrations in SVG format ✓ Inline images, CSS, JS ✓ CSS sprites ✓ Use “srcset” to get the right image size ✓ Uglify CSS/JS ✓ Combine CSS/JS files Reduce Response Sizes & Round Trips

Slide 66

Slide 66 text

✓ Avoid blocking Javascript ✓ Chunked Transfer-Encoding ✓ Gzip compression for non-binary data ✓ Domain sharding for static assets ✓ HTTP/2 Reduce Response Sizes & Round Trips

Slide 67

Slide 67 text

JPG PNG CSS JS HTML JPG JPG PNG CSS CSS JS domain.ext img.domain.ext static.domain.ext HTTP/1.1 domain sharding

Slide 68

Slide 68 text

JPG PNG CSS JS HTML JPG JPG PNG CSS CSS JS domain.ext HTTP/2

Slide 69

Slide 69 text

✓ Multiplexing requests over single connection ✓ Header compression ✓ Server push HTTP/2

Slide 70

Slide 70 text

User location

Slide 71

Slide 71 text

Network latency

Slide 72

Slide 72 text

✓ Trans Atlantic: 75 ms ✓ Europe: 11 ms ✓ North America: 39 ms ✓ Trans Pacific: 102 ms ✓ Latin America: 133 ms ✓ EMEA to Asia Pacific: 131 ms Network latency

Slide 73

Slide 73 text

3G & EDGE

Slide 74

Slide 74 text

Content Delivery Network

Slide 75

Slide 75 text

http://www.metacdn.com/

Slide 76

Slide 76 text

Reverse caching proxies all over the world

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

✓ Less latency ✓ Caching ✓ Serve stale data if origin site is down ✓ Output optimization ✓ Anti-DDoS measures CDN benefits

Slide 79

Slide 79 text

Web performance is a discipline in its own

Slide 80

Slide 80 text

https://feryn.eu https://twitter.com/ThijsFeryn https://instagram.com/ThijsFeryn

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content