...

Text file src/github.com/golang/groupcache/README.md

Documentation: github.com/golang/groupcache

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

View as plain text