280 likes | 465 Views
Caching. Herng-Yow Chen. How caches improve performance and reduce cost How to measure their effectiveness Where to place caches to maximize impact Also explain how HTTP keeps cached copies fresh How caches interact with other caches and servers. Outline. Bandwidth Bottlenecks.
E N D
Caching Herng-Yow Chen
How caches improve performance and reduce cost How to measure their effectiveness Where to place caches to maximize impact Also explain how HTTP keeps cached copies fresh How caches interact with other caches and servers Outline
Bandwidth-imposed transfer time delays, idealized (time in seconds)
Hits, Misses, and Revalidations (a) Cache hit Cache object Cache server client (b) Cache miss Server object Server object Cache server client (c) Cache revalidate hit Freshness check Cache object “Still fresh” Cache server client
Revalidations (a) Revalidate hit (slow hit) Freshness check Cache object “Still fresh” Cache server client Server object same as cached copy (b) Revalidate miss Freshness check Server object Server object Cache server client Cached copy is out of date
Revalidations (cont.) • Revalidate hit Revalidate request with If-Modified-Since GET /announce.html HTTP/1.0 If-Modified-Since: Sat, 29 Jun 2002, 14:30:00 GMT server Cache (browser cache or proxy cache) HTTP/1.0 304 Not Modified Date: Wed, 03 Jul 2002, 19:18:23 GMT Content-type: text/plain Content-length: 67 Expires: Fri, 05 Jul 2002, 05:00:00 GMT “Still fresh” response
Revalidate hit 304 Not Modified response Revalidate miss 200 OK response, with the full content Object deleted 404 Not Found response Three cases in revalidation
Hit Rate (Hit Ratio) The fraction of requests that are served from cache. Sometimes it is called document hit ratio. The hit rate ranges from 0 to 1 but is often described as a percentage, e.g., 0%, 40% (decent) , 100% Goal: even a modest-sized cache may contain enough popular documents to significantly improve performance and reduce traffic. Cache Performance measurement
Represent the faction of all bytes transferred that were served from cache. This metric captures the degree of traffic savings. (e.g., 100% no traffic went out across the Internet). Is preferred by people who are billed for each byte of traffic. Document hit rate doesn’t tell the whole story, because documents are not all the same size. Some large objects might be accessed less often but contribute more to overall traffic. Document Hit ratio vs. Byte Hit ratio Optimize for overall latency reduction. (document hit) Optimize for bandwidth saving (byte hit) Another metric: Byte Hit Rate
Cache Topologies (a) Accessing private cache Internet client Private cache Web server (b) Accessing shared public cache Internet client Web server Public cache client
Public Proxy Caches (a) Redundant accesses from private caches Internet client client Server client (b) Shared caches can reduce traffic Internet client client Server Cache client
Cache Meshes, Content Routing, and Peering X Y Origin server B’s access point A’s access point Wide area network X Sibling Organization A Organization B
Cache Processing Flowchart Request arrives Cached? no yes Fresh enough? Revalidated? no Revalidate with server no Fetch from server yes yes Store into cache Update freshness Of cached document Server to client
Document Expiration HTTP/1.0 200 OK Date: Sat, 29 Jun 2002, 14:30:00 GMT Content-type: text/plain Content-length: 67 Expires: Fri, 05 Jul 2002, 05:00:00 GMT Independence Day sale at Joe’s Hardware Come shop with us today! HTTP/1.0 200 OK Date: Sat, 29 Jun 2002, 14:30:00 GMT Content-type: text/plain Content-length: 67 Cache-Control: max-age=484200 Independence Day sale at Joe’s Hardware Come shop with us today! (a) Expires header (b) Cache-Control:max-age header
If-Modified-Since : Date Revalidation Conditional request GET /announce.html HTTP/1.0 If-Modified-Since: Sat,29 Jun 2002, 14:30:00 GMT HTTP/1.0 304 Not Modified Date: Wed, 03 Jul 2002, 19:18:23 GMT Expires: Fri, 05 Jul 2002, 14:30:00 GMT client Server Response (a)If-Modifies-Since successful revalidation Conditional request GET /announce.html HTTP/1.0 If-Modified-Since: Sat,29 Jun 2002, 14:30:00 GMT HTTP/1.0 200 OK Date: Fri, 05 Jul 2002, 14:30:00 GMT Content-type: text/plain Content-length: 124 Expires: Mon, 09 Sep 2002, 05:00:00 GMT All exterior house paint on sale through Labor Day. Just another reason for you to shop this summer at Joe’s Hardware! client Server Response (b)If-Modifies-Since failed revalidation
If-None-Match:Entity Tag Revalidation Conditional request GET /announce.html HTTP/1.0 If-None-Match: “v2.6” ETag: “v2.6” ETag: “v2.6” HTTP/1.0 304 Not Modified Date: Wed, 03 Jul 2002, 19:18:23 GMT ETag: “v2.6” Expires: Fri, 05 Jul 2002, 05:00:00 GMT Server Cache Response
Heuristic Expiration 20% of time between fresh and last modification (LM-factor=0.2) Cached copy is fresh for time period New expiration time When cache talked to server Last modified
HTTP-EQUIV tags cause problems, because most software ignores them
Reference: Caching • http://www.w3.org/protocols/rfc2616/rfc2616.txt RFC 2616, “Hypertext Transfer Protocol,” by R. Fielding, J. Gettys, J.Mongul, H.Frystyk, L.Mastinter, P.Leach, and T.Berners-Lee. • Web Caching Duane Wessels, O’Reilly & Associates, Inc. • http://search.ietf.org/rfc/rfc3040.txt RFC 3040, “Internet Web Replication and Caching Taxonomy.” • Web Proxy Servers Ari Luotinen, Prentice Hall Computer Books. • http://search.ietf.org/rfc/rfc3143.txt RFC 3143, “Know HTTP Proxy/Caching Problems.” • http://www.squid-cache.org Squid Web Proxy Cache.