Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Akamai Connector for Varnish

Akamai Connector for Varnish

Performance Matters. That's why you need multiple layers of caching. More importantly you need to synchronize and manage your caching layers. How do you accomplish this without adding more operational overhead?

Colin Bendell

June 26, 2017
Tweet

More Decks by Colin Bendell

Other Decks in Technology

Transcript

  1. Colin Bendell Director, CTO Office Akamai Dag Finstad Software Developer

    Varnish Software Davey Shafik Developer Evangelist Akamai
  2. Simplified Dev; Simplified Ops; Engineered for Performance Akamai Connector for

    Varnish Performance & Caching The Connector Advanced Uses
  3. Configuration APIs Monitoring Integrations Client Libraries Edge Logic Akamai CLI

    Testing developer.akamai.com/devops Akamai for DevOps
  4. Purge Synchronization Define Cache Rules Ensure Best Practices Defer ESI

    Processing Device Characteristics Control Refresh Traffic Akamai Connector for Varnish
  5. Page Load Time: Seconds Users Expect Web Pages in 2s

    (even on cellular) But Users Expect Fast
  6. ▼ 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
  7. 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)
  8. First Deployment: No Caching 50ms 0ms 500ms TCP + HTTP

    + Server Think 400ms + 200ms + 500ms = 1,100ms
  9. Real World 50ms 150ms 500ms TCP + HTTP + Server

    Think 800ms + 400ms + 500ms = 1,700ms 800ms + 800ms + 800ms = 2,400ms
  10. Cache at Origin = 800ms + 75 * (400ms +

    1ms) TCP + HTTP + Server Think x 75 requests (httparchive.org) ( ) = 30.9 seconds!
  11. 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
  12. 3s Page Load Time After: faster page load time 1/3rd

    total page load time 2s 1s 5s 6s
  13. Purge Synchronization Define Cache Rules Ensure Best Practices Defer ESI

    Processing Device Characteristics Control Refresh Traffic Akamai Connector for Varnish
  14. $ 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
  15. $ 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
  16. $ 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
  17. $ $ 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";
  18. $ 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 $
  19. $ $ 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); }
  20. 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
  21. /etc/akamai-connector.conf $ $ vim /etc/akamai-connector.conf # Akamai Connector configuration settings

    # The purge host to connect to purge_host=<purge host> # The client token credential for purging purge_client_token=<client token> # The client secret credential for purging purge_client_secret=<client secret> # The access token credential for purging purge_access_token=<access token>
  22. $ 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" }
  23. 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?
  24. 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?
  25. /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";
  26. $ 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 }
  27. $ 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 } $
  28. Short TTL, but refresh asynchronously Async Refresh & Grace TTL

    Cache Hit Cache Miss Cache Hit 5min TTL 5min TTL Cache Miss
  29. /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;
  30. Purge Synchronization Define Cache Rules Ensure Best Practices Defer ESI

    Processing Device Characteristics Control Refresh Traffic Akamai Connector for Varnish
  31. Optimize your website’s performance for web and mobile automatically Akamai

    Connector for Varnish Performance & Caching Installation Advanced Uses
  32. 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