Cache bonanza
-
Upload
harald-schult-ulriksen -
Category
Data & Analytics
-
view
205 -
download
1
Transcript of Cache bonanza
![Page 1: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/1.jpg)
Cache bonanzaHarald Schult Ulriksen
@hsulriksenhttp://aurum.no
![Page 2: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/2.jpg)
![Page 3: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/3.jpg)
HTTP Cache Output cache
Application cache
![Page 4: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/4.jpg)
RFC 7234 - HTTP/1.1 Caching
![Page 5: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/5.jpg)
RFC 7234 - HTTP/1.1 Caching
A stored response can be considered fresh if the response can be reused without validation
![Page 6: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/6.jpg)
RFC 7234 - HTTP/1.1 CachingAlthough 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.
![Page 7: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/7.jpg)
RFC 7234 - HTTP/1.1 CachingFreshness
• s-max-age• max age• expires• heuristics
![Page 8: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/8.jpg)
RFC 7234 - HTTP/1.1 CachingFreshness
• s-max-age• max age• expires• heuristics
Last modified Last requested Now
Tid
![Page 9: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/9.jpg)
RFC 7234 - HTTP/1.1 CachingFreshness
• s-max-age• max age• expires• heuristics
Validation - RFC 7232
• Etag• Last-Modified
• If-none-match• If-modified-since
![Page 10: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/10.jpg)
RFC 7234 - HTTP/1.1 CachingLinker
• RFC 7234 - https://tools.ietf.org/html/rfc7234• RFC 7232 - https://tools.ietf.org/html/rfc7234• Mark Nottinham - 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
![Page 11: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/11.jpg)
Application cache• Local cache• Redis • Redis with msgpack•Distributed layered cache•With synchronization• Fun with Redis
![Page 12: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/12.jpg)
Local cache
![Page 13: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/13.jpg)
Demo
![Page 14: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/14.jpg)
Remote cache
![Page 15: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/15.jpg)
Remote cache
![Page 16: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/16.jpg)
Remote cache
![Page 17: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/17.jpg)
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.
![Page 18: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/18.jpg)
Demo
![Page 19: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/19.jpg)
In production
![Page 20: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/20.jpg)
Layered distributed cacheApplication Local cache Remote cache Slow thing
![Page 21: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/21.jpg)
Demo
![Page 22: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/22.jpg)
Pub-sub12
3
4
1.Store data 2.Send publish notification3.Publish notification4.Get data
![Page 23: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/23.jpg)
Demo
![Page 24: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/24.jpg)
In production
![Page 25: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/25.jpg)
In production
![Page 26: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/26.jpg)
Other datastructures in RedisSearch for «An introduction to data types and abstractions»
• Key/Value• Lists• Hashsets• Set• Sorted set• Hyperloglog• Geospatial
![Page 27: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/27.jpg)
Lua scriptAtomisk operasjon. Ingen rollback. Kan lastes opp til server og kalles basert på hash.
![Page 28: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/28.jpg)
Add now-playing
![Page 29: Cache bonanza](https://reader036.fdocuments.in/reader036/viewer/2022062311/58ecb81c1a28ab35298b45b1/html5/thumbnails/29.jpg)
Read