+ All Categories
Home > Software > Caching go big or go home - ndc 2016

Caching go big or go home - ndc 2016

Date post: 22-Jan-2018
Category:
Upload: harald-schult-ulriksen
View: 156 times
Download: 6 times
Share this document with a friend
28
Caching Go big or go home Harald Schult Ulriksen @hsulriksen
Transcript

CachingGo big or go home

Harald Schult Ulriksen

@hsulriksen

HTTP CacheOutput

cache

Application

cache

RFC 7234 - HTTP/1.1 Caching

RFC 7234 - HTTP/1.1 Caching

A stored response can be considered fresh

if the response can be reused without validation

RFC 7234 - HTTP/1.1 Caching

Although caching is an entirely OPTIONAL feature of HTTP, it can be assumed that reusing a cached response is desirable and that such reuse is the default behavior when no requirement or local configuration prevents it. Therefore, HTTP cache requirements are focused on preventing a cache from either storing a non-reusable response or reusing a stored response inappropriately, rather than mandating that caches always store and reuse particular responses.

RFC 7234 - HTTP/1.1 Caching

Freshness

• s-max-age

• max age

• Expires

• heuristics

RFC 7234 - HTTP/1.1 Caching

Freshness

• s-max-age

• max age

• Expires

• heuristics

Last modified Last requested Now

Tid

RFC 7234 - HTTP/1.1 Caching

Freshness

• s-max-age

• max age

• Expires

• heuristics

Validation - RFC 7232

• Etag

• Last-Modified

• If-none-match

• If-modified-since

RFC 7234 - HTTP/1.1 Caching

Links

• RFC 7234 - https://tools.ietf.org/html/rfc7234

• RFC 7232 - https://tools.ietf.org/html/rfc7234

• Mark Nottingham - https://www.mnot.net/cache_docs

• Darrel Miller - http://bizcoder.com/caching-is-hard-draw-me-a-picture

• Jesse Wilson – https://publicobject.com/2015/03/26/how-do-http-caching-heuristics-work

Application cache

• ASP.NET Core (or Microsoft.extensions.caching)

• Local cache

• Redis

• Redis with msgpack

• Distributed layered cache

• With synchronization

Microsoft.Extensions.Caching

Microsoft.Extensions.Caching

IMemoryCache

• Powered by dictionary

• Supports callback oneviction.

• Has priority on items in cache

• Compacts on GC Gen2

Microsoft.Extensions.Caching

IMemoryCache

• Powered by dictionary

• Supports callback oneviction.

• Has priority on items in cache

• Compacts on GC Gen2

IDistributedCache

• MemoryCache

• Redis

• SQL Server

• You do the serialization

Local cache

Demo

Remote cache

Remote cache

Remote cache

Redis

• http://redis.io

• Key value store + data structures

• By Salvatore Sanfilippo / @antirez

• Ansi C

• Single threaded

• Lua in server

• Microsoft research port to windows – nuget redis-64

• On Azure, AWS og Google cloud.

Demo

In production

Layered distributed cache

Application Local cache Remote cache Slow thing

Demo

Pub-sub

1

2

3

4

1.Store data

2.Send publish notification

3.Publish notification

4.Get data

Demo

In production

In production


Recommended