Slide 1

Slide 1 text

Akamai Connector for Varnish akamaidev.io/varnish-connector

Slide 2

Slide 2 text

Colin Bendell Director, CTO Office Akamai Dag Finstad Software Developer Varnish Software Davey Shafik Developer Evangelist Akamai

Slide 3

Slide 3 text

Simplified Dev; Simplified Ops; Engineered for Performance Akamai Connector for Varnish Performance & Caching The Connector Advanced Uses

Slide 4

Slide 4 text

Configuration APIs Monitoring Integrations Client Libraries Edge Logic Akamai CLI Testing developer.akamai.com/devops Akamai for DevOps

Slide 5

Slide 5 text

Purge Synchronization Define Cache Rules Ensure Best Practices Defer ESI Processing Device Characteristics Control Refresh Traffic Akamai Connector for Varnish

Slide 6

Slide 6 text

Performance & Caching

Slide 7

Slide 7 text

The Mobile User Experience

Slide 8

Slide 8 text

Page Load Time: Seconds We Have Different Experiences on the Web

Slide 9

Slide 9 text

Page Load Time: Seconds Users Expect Web Pages in 2s (even on cellular) But Users Expect Fast

Slide 10

Slide 10 text

Performance Impacts Business Metrics

Slide 11

Slide 11 text

▼ Wait ├ Caching ├ Protocol opt ├ Route opt. └ Sharding ├ webpack ├ sprites & inlining ├ lazyload └ PWA ▼ Reqs ├ Critical CSS ├ Service Workers ├ AMP └ 4:2:0 Chroma ▲ Render ▼ Bits ├ RWD ├ gzip / br ├ jp2 / webp └ HTTP/2 #WebPerf 101 Web Performance Strategies

Slide 12

Slide 12 text

Fixing Performance: Where do you start?

Slide 13

Slide 13 text

Performance & Caching

Slide 14

Slide 14 text

L1: 0.0005μs L2: 0.007μs L2: 0.030μs RAM: 0.1 μs SSD: 0.15 ms Seek: 10 ms Wifi: 25ms LTE: 75ms 3G: 150ms 1 bit of data accessed from CPU, Memory, Disk, Network Caching is Everywhere (200x L1) (20,000,000x L1) (300,000,000x L1) (1,000,000,000x L1) (10,000,000,000x L1)

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

First Deployment: No Caching 50ms 0ms 500ms TCP + HTTP + Server Think 400ms + 200ms + 500ms = 1,100ms

Slide 17

Slide 17 text

Real World 50ms 150ms 500ms TCP + HTTP + Server Think 800ms + 400ms + 500ms = 1,700ms 800ms + 800ms + 800ms = 2,400ms

Slide 18

Slide 18 text

Cache at Origin 50ms 150ms 500ms 800ms + 400ms + 1ms = 1,201ms

Slide 19

Slide 19 text

Cache at Origin = 800ms + 75 * (400ms + 1ms) TCP + HTTP + Server Think x 75 requests (httparchive.org) ( ) = 30.9 seconds!

Slide 20

Slide 20 text

Layers of Cache: Akamai + Origin 50ms 400ms + 100ms + 1ms = 101ms

Slide 21

Slide 21 text

Akamai's View of the Internet

Slide 22

Slide 22 text

Performance & Caching

Slide 23

Slide 23 text

CBC akamai.com/us/en/our-customers/customer-stories-cbc.jsp

Slide 24

Slide 24 text

Varnish at Origin with Long Tail content Problem: low offload 80% Offload 30s TTL 90% Offload

Slide 25

Slide 25 text

750 500 250 0 mbps 2 June 9 June 16 June 23 June 30 Jun Solution: Coordinated Caches 95+% Offload; Origin Traffic below 100mbps at peak

Slide 26

Slide 26 text

3s Page Load Time After: faster page load time 1/3rd total page load time 2s 1s 5s 6s

Slide 27

Slide 27 text

The Connector

Slide 28

Slide 28 text

Purge Synchronization Define Cache Rules Ensure Best Practices Defer ESI Processing Device Characteristics Control Refresh Traffic Akamai Connector for Varnish

Slide 29

Slide 29 text

High Level Architecture Akamai Edge Varnish App Server CCU API

Slide 30

Slide 30 text

Installation

Slide 31

Slide 31 text

Getting Started (v4 or later) or

Slide 32

Slide 32 text

$ cp akamai_connector.repo /etc/yum.repos.d/ $ yum clean all $ yum install varnish-plus-akamai-connector [..] Installed: Varnish-plus-akamai-connector.x86_64 0:0.20170505-1.el7 Complete! $ Installation

Slide 33

Slide 33 text

$ akamai-connector-setup.sh

Slide 34

Slide 34 text

$ akamai-connector-setup.sh Akamai Connector for Varnish setup Usage: akamai-connector-setup.sh {install|force-*|remove-*|help} install Install the base Akamai VCLs and conf Does not overwrite if destination exists force-vcl Backup and force install the base Akamai VCLs force-conf Backup and force install the Akamai conf force-all Backup and force install the base Akamai VCLs and conf remove-vcl Remove the base Akamai VCLs remove-conf Remove the Akamai conf remove-all Remove the base Akamai VCLs and conf help This message Source: /usr/share/doc/akamai-connector VCL Destination: /etc/varnish Conf Destination: /etc/akamai-connector.conf

Slide 35

Slide 35 text

$ akamai-connector-setup.sh install $ Akamai Connector for Varnish setup Installing Source: /usr/share/doc/akamai-connector/akamai_auto.vcl Destination: /etc/varnish Arguments: --no-clobber Success Source: /usr/share/doc/akamai-connector/akamai.vcl Destination: /etc/varnish Arguments: --no-clobber Success Source: /usr/share/doc/akamai-connector/akamai-connector.conf.example Destination: /etc/akamai-connector.conf Arguments: --no-clobber Success

Slide 36

Slide 36 text

$ $ vim /etc/varnish/default.vcl /etc/varnish/default.vcl vcl 4.0; import std; backend default { .host = "127.0.0.1"; .port = "8080"; } sub vcl_backend_response { // usual stuff here set beresp.ttl = 5m; } import akamai; include "akamai_auto.vcl";

Slide 37

Slide 37 text

$ systemctl reload varnish $ Validating the configuration $

Slide 38

Slide 38 text

$ http \ http://localhost/akamai/testobject.html \ Via:"akamai.net(ghost) (AkamaiGHost)" HTTP/1.1 200 OK Content-Length: 20480 Date: Fri, 16 Jun 2017 12:49:54 GMT X-Varnish: 32770 3 Edge-Control: max-age=310, post-check=300 Via: 1.1 varnish-v4, Akamai Connector/1.0.2 Accept-Ranges: bytes Connection: keep-alive Validating the configuration $

Slide 39

Slide 39 text

$ $ vim /etc/varnish/default.vcl /etc/varnish/default.vcl vcl 4.0; import std; import akamai; include "akamai_auto.vcl"; backend default { .host = "127.0.0.1"; .port = "8080"; } sub vcl_recv { // usual stuff here } if (req.method == "PURGE") { return (purge); }

Slide 40

Slide 40 text

Setting up Purge akamaidev.io/api-credentials Ensure you have the API credentials for the CCU application host = akab-j4ut6lhxxxxk4zg-pfoqijsuxhntuabu.luna.akamaiapis.net client_secret = 6bbwkmp7xXXXX3srdgnwuhmmwgt6raln8uwd2njezo+8= access_token = akab-dzwylxxxxsx2s2fw-7ah4yypbk7bcii65 client_token = akab-cphsxxxxdyrym4-4drvje7rfbyvumfc

Slide 41

Slide 41 text

/etc/akamai-connector.conf $ $ vim /etc/akamai-connector.conf # Akamai Connector configuration settings # The purge host to connect to purge_host= # The client token credential for purging purge_client_token= # The client secret credential for purging purge_client_secret= # The access token credential for purging purge_access_token=

Slide 42

Slide 42 text

$ systemctl reload varnish $ Validating the configuration $

Slide 43

Slide 43 text

$ http PURGE http://localhost/article \ Host:example.com Validating purge configuration { "estimatedSeconds": 5, "purgeId": "01d62080-5295-11e7-af78", "supportId": "17PY1497618559250268-202654912", "httpStatus": 201, "detail": "Request accepted" }

Slide 44

Slide 44 text

Hold ‘Til Told

Slide 45

Slide 45 text

Example: Sports News Hold 'Til Told WPO Sports WPO Sports wposports.com

Slide 46

Slide 46 text

{ "CHC": 0, "CLE": 0 } Cache forever; until it changes Hold 'Til Told

Slide 47

Slide 47 text

8:02 8:04 (1-0) 8:48 (1-1) 9:12 (2-1) 9:56 (5-1) 10:08 (5-3) 10:09 (6-3) 10:30 (6-6) 12:24 (8-6) 12:42 (8-7) 12:56 Scores change infrequently, but must be up-to-date What is the Right TTL?

Slide 48

Slide 48 text

8:02 8:04 (1-0) 8:48 (1-1) 9:12 (2-1) 9:56 (5-1) 10:08 (5-3) 10:09 (6-3) 10:30 (6-6) 12:24 (8-6) 12:42 (8-7) 12:56 Scores change infrequently, but must be up-to-date How do you keep scores fresh?

Slide 49

Slide 49 text

/etc/varnish/default.vcl vcl 4.0; import std; import akamai; include "akamai_auto.vcl"; sub vcl_backend_response { } // Edge TTL set beresp.ttl = 365d; // Downstream TTL set beresp.http.Cache-Control = "max-age=5";

Slide 50

Slide 50 text

$ http GET origin.example.com/score/CHC-CLE \ Via:"akamai.net(ghost) (AkamaiGHost)" Testing Hold 'Til Told (Origin) HTTP/1.1 200 OK Edge-Control: max-age=24h,downstream-ttl=5s { "CHC": 0, "CLE": 0 }

Slide 51

Slide 51 text

$ http GET example.com/score/CHC-CLE Testing Hold 'Til Told (Edge) HTTP/1.1 200 OK Cache-Control: max-age=5 { "CHC": 0, "CLE": 0 } $

Slide 52

Slide 52 text

Grace TTL / Prefresh

Slide 53

Slide 53 text

Cache Miss = Poor User Experience Edge Varnish Origin

Slide 54

Slide 54 text

Short TTL, but refresh asynchronously Async Refresh & Grace TTL Cache Hit Cache Miss Cache Hit 5min TTL 5min TTL Cache Miss

Slide 55

Slide 55 text

Short TTL, but refresh asynchronously Async Refresh & Grace TTL Cache Hit Cache Hit Cache Hit

Slide 56

Slide 56 text

/etc/varnish/default.vcl vcl 4.0; import std; import akamai; include "akamai_auto.vcl"; sub vcl_backend_response { set beresp.ttl = 5m; } // Grace TTL set beresp.grace = 30s;

Slide 57

Slide 57 text

Varnish Grace TTL to Akamai Prefresh Automatic Translation Cache Hit Grace TTL TTL Prefresh TTL

Slide 58

Slide 58 text

Purge Synchronization Define Cache Rules Ensure Best Practices Defer ESI Processing Device Characteristics Control Refresh Traffic Akamai Connector for Varnish

Slide 59

Slide 59 text

Optimize your website’s performance for web and mobile automatically Akamai Connector for Varnish Performance & Caching Installation Advanced Uses

Slide 60

Slide 60 text

Akamai Connector for Varnish v1 The Beginning of the Journey

Slide 61

Slide 61 text

Call To Action • Register and download the Connector today; its free! • Download: https://www.varnish-software.com/products/akamai-connector-for-varnish/ • Documentation: https://akamai-connector.varnish-software.com/akamai-connector-guide.pdf • Support: email to [email protected] • Akamai Developer site: http://akamaidev.io/varnish-connector Reformat: Austin

Slide 62

Slide 62 text

Akamai Connector for Varnish Take Action! akamaidev.io/varnish-connector

Slide 63

Slide 63 text

Akamai Connector for Varnish akamaidev.io/varnish-connector @ColinBendell @DShafik Dag Finstad