github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/golang/groupcache/README.md (about) 1 # groupcache 2 3 ## Summary 4 5 groupcache is a caching and cache-filling library, intended as a 6 replacement for memcached in many cases. 7 8 For API docs and examples, see http://godoc.org/github.com/golang/groupcache 9 10 ## Comparison to memcached 11 12 ### **Like memcached**, groupcache: 13 14 * shards by key to select which peer is responsible for that key 15 16 ### **Unlike memcached**, groupcache: 17 18 * does not require running a separate set of servers, thus massively 19 reducing deployment/configuration pain. groupcache is a client 20 library as well as a server. It connects to its own peers. 21 22 * comes with a cache filling mechanism. Whereas memcached just says 23 "Sorry, cache miss", often resulting in a thundering herd of 24 database (or whatever) loads from an unbounded number of clients 25 (which has resulted in several fun outages), groupcache coordinates 26 cache fills such that only one load in one process of an entire 27 replicated set of processes populates the cache, then multiplexes 28 the loaded value to all callers. 29 30 * does not support versioned values. If key "foo" is value "bar", 31 key "foo" must always be "bar". There are neither cache expiration 32 times, nor explicit cache evictions. Thus there is also no CAS, 33 nor Increment/Decrement. This also means that groupcache.... 34 35 * ... supports automatic mirroring of super-hot items to multiple 36 processes. This prevents memcached hot spotting where a machine's 37 CPU and/or NIC are overloaded by very popular keys/values. 38 39 * is currently only available for Go. It's very unlikely that I 40 (bradfitz@) will port the code to any other language. 41 42 ## Loading process 43 44 In a nutshell, a groupcache lookup of **Get("foo")** looks like: 45 46 (On machine #5 of a set of N machines running the same code) 47 48 1. Is the value of "foo" in local memory because it's super hot? If so, use it. 49 50 2. Is the value of "foo" in local memory because peer #5 (the current 51 peer) is the owner of it? If so, use it. 52 53 3. Amongst all the peers in my set of N, am I the owner of the key 54 "foo"? (e.g. does it consistent hash to 5?) If so, load it. If 55 other callers come in, via the same process or via RPC requests 56 from peers, they block waiting for the load to finish and get the 57 same answer. If not, RPC to the peer that's the owner and get 58 the answer. If the RPC fails, just load it locally (still with 59 local dup suppression). 60 61 ## Users 62 63 groupcache is in production use by dl.google.com (its original user), 64 parts of Blogger, parts of Google Code, parts of Google Fiber, parts 65 of Google production monitoring systems, etc. 66 67 ## Presentations 68 69 See http://talks.golang.org/2013/oscon-dl.slide 70 71 ## Help 72 73 Use the golang-nuts mailing list for any discussion or questions.