Slide 1

Slide 1 text

Andrew Betts Principal developer advocate | Fastly The changing face of loading resources

Slide 2

Slide 2 text

• Developer relations at Fastly • W3C Technical Architecture Group • Previously Financial Times, Nikkei Who is this guy?

Slide 3

Slide 3 text

• Why is loading important to your strategy • Overview of modern networking patterns (more detail at Code) • Fastly customer experiences • Trends and future needs Agenda today

Slide 4

Slide 4 text

Complexity of resource loading is increasing Better browser support gives developers more control, better tools (like webpagetest) offer better monitoring.

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

• Fewer origins • Terminate close to user • Smart caching Key network performance factors • Fast rendering • Bandwidth optimisation • Governance and control

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

HTTP evolution changes our priorities 1.0 1.1 2 QUIC Fewer connections per origin Multiplexing / async More encryption More origin-scoped features Cheaper requests Pricy connections Origin centricity Use fewer origins Terminate closer to user

Slide 9

Slide 9 text

51 trackers

Slide 10

Slide 10 text

Use fewer origins Connections remain expensive to set up. Use a routing layer to expose only one origin. example.com In-house app Video provider Analytics provider

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Denver (DEN) Stockholm (BMA) 7,800km Theoretical best RTT: 90ms Practical RTT: 146ms

Slide 13

Slide 13 text

TCP + TLS handshake = up to 4 round-trips

Slide 14

Slide 14 text

Dynamic site acceleration with shielding Always on, optimised, low latency Slow-start, congested, high-latency

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Types of object for caching Static: Stuff that never changes JavaScript CSS Images Templates /resources/style-v3.css Dynamic: unique to a single user Inbox message list Shopping cart Preference values /my/cart Years private* * Still benefits from DSA Event driven: changes when things happen Articles Product lists Search results Stock prices /api/getCurrentPrice Years* * If you can purge

Slide 17

Slide 17 text

Purging when things happen User Event: Comment posted Edge Server Uncached, fetch from origin Hit! return “304 Not Modified” from Edge cache After purge, uncached again PURGE MISS...

Slide 18

Slide 18 text

Asynchronous serve stale (while revalidate) Users max-age expires Edge Server Requests flooding in Just one request goes to origin. The rest are held at the edge. All requests fulfilled After expiry, requests still get fast cached response Asynchronous fetch to refresh the cache Cache repopulated

Slide 19

Slide 19 text

Synchronous serve stale (on error from origin) Users max-age expires Edge Server Requests flooding in Just one request goes to origin, populates cache at the edge Request after expiry causes fetch to origin Origin server is offline, refuses connection stale-while-reval expires SERVER DOWN! Server super-stale object from cache

Slide 20

Slide 20 text

Purging the browser too? User Event: Comment posted Fastly Server Uncached, fetch from origin PURGE PURGE?

Slide 21

Slide 21 text

Options for purging the browser cache • Clear-Site-Data – Dedicated spec; simple, already supported in Chrome – Clears cache by adding a Clear-Site-Data header to any response • Silent push – Can be more granular (purge just one thing) – Could work in background – Depends on the Budget API spec

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Conventional model

Slide 24

Slide 24 text

“Single page app” => App shell => PRPL Initial download is static bundle Then it’s all API calls

Slide 25

Slide 25 text

Serviceworker & streams /frags/header /home.frag /frags/footer / Cache/purge all these individually! Serviceworker splits request into parts

Slide 26

Slide 26 text

Event streaming Initial download is static bundle Continuous stream of small events

Slide 27

Slide 27 text

Real time flight departures (powered by SSE)

Slide 28

Slide 28 text

Google AMP (Accelerated Mobile Pages)

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Origin policy - for shared metadata Content-Security-Policy: HTTP-Strict-Transport-Security: X-Frame-Options: Referrer-Policy: Cache-Control: X-XSS-Protection: ... Content-Security-Policy: HTTP-Strict-Transport-Security: X-Frame-Options: Referrer-Policy: Cache-Control: X-XSS-Protection: ... Content-Security-Policy: HTTP-Strict-Transport-Security: X-Frame-Options: Referrer-Policy: Cache-Control: X-XSS-Protection: ... /home /about /shop /.well-known/origin-policy

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Access-Control-Allow-Origin Access-Control-Allow-Headers Access-Control-Allow-Methods Access-Control-Allow-Credentials Content-Security-Policy HTTP-Strict-Transport-Security X-Frame-Options X-Content-Type-Options X-XSS-Protection Security headers Test your site’s security headers with securityheaders.io

Slide 33

Slide 33 text

Modern TLS Test your site’s TLS with ssllabs.com/ssltest

Slide 34

Slide 34 text

Feature-Policy: { "geolocation": [ "self", "https://example.com" ], “vibrate”: [] } Feature policy HTTP header This page is not allowed to use vibration!

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

“stale-while-revalidate is one of the most exciting features I’ve worked with so far. It allowed us to successfully serve the live blog while constantly updating its content, ensuring our readers had access to the freshest content without seeing errors.” - Zack Tollman Wired

Slide 37

Slide 37 text

“With Fastly’s shielding service, we were able to eliminate ELB, HAProxy, and Varnish in our origin application. It simplifies our architecture, reduces latency and makes monitoring and managing the environment a lot easier and less painful.” - Dale Neufeld Shopify 18,000% spike in traffic during Superbowl ad

Slide 38

Slide 38 text

“Streaming miss was a giant win for us. When we were unable to cache our large audio files, the TTFB was between 1 and 2 seconds. But with Fastly, 90% of our requests are cached on the edge, and the remaining 10% have a TTFB of 400 or 500 milliseconds, resulting in a significantly better experience for our users.” - Darrell Mozingo 7digital

Slide 39

Slide 39 text

• Package manager for JavaScript community • Downloads tarballs using a custom CLI client • Recently released npm5 • 50% reduction in request count by doing better analysis of already-installed packages. npm

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

• Web innovations are accelerating, don’t get left behind • Massive wins in security and performance • If you can, use a CDN that gives you a lot of this stuff out of the box • Some decisions are easy to retrofit, others are once-in-a-generation, so long term planning needed Conclusions

Slide 42

Slide 42 text

Thanks for listening I am Get the slides: Andrew Betts @triblondon [email protected] fastly.us/leaders Take our survey: fastly.us/2skOnXM