groupcache README

The project's README from github.com/golang/groupcache. As one markdown file: README.md.

groupcache

Summary

groupcache is a distributed caching and cache-filling library, intended as a replacement for a pool of memcached nodes in many cases.

For API docs and examples, see http://godoc.org/github.com/golang/groupcache

Comparison to memcached

Like memcached, groupcache:

Unlike memcached, groupcache:

Loading process

In a nutshell, a groupcache lookup of Get("foo") looks like:

(On machine #5 of a set of N machines running the same code)

  1. Is the value of "foo" in local memory because it's super hot? If so, use it.

  2. Is the value of "foo" in local memory because peer #5 (the current peer) is the owner of it? If so, use it.

  3. Amongst all the peers in my set of N, am I the owner of the key "foo"? (e.g. does it consistent hash to 5?) If so, load it. If other callers come in, via the same process or via RPC requests from peers, they block waiting for the load to finish and get the same answer. If not, RPC to the peer that's the owner and get the answer. If the RPC fails, just load it locally (still with local dup suppression).

Users

groupcache is in production use by dl.google.com (its original user), parts of Blogger, parts of Google Code, parts of Google Fiber, parts of Google production monitoring systems, etc.

Presentations

See http://talks.golang.org/2013/oscon-dl.slide

Help

Use the golang-nuts mailing list for any discussion or questions.

groupcache (golang/groupcache)

Searching Database…

这是什么?groupcache 是一个用于 Go 的分布式缓存及缓存填充库,在很多场景下可以替代一组 memcached 节点。
这是像 memcached 那样的独立服务器,还是需要嵌入到我代码里的东西?它是一个 Go 库,而不是单独的服务器。它既是客户端库,也是能与其他对等节点相互连接的服务器,直接在你的应用进程内部组成一个分布式缓存。
怎样把它添加到项目中?将它作为 Go 包导入,并配置一组对等节点;具体如何接入你的应用,请查看 API 文档和示例。
我需要用 Go 吗?能否在其他语言中使用?只能用于 Go——该库目前仅支持 Go,作者表示它被移植到其他语言的可能性非常小。
缓存值设置之后,我能更新它或让它过期吗?不能。groupcache 不支持带版本的值、缓存过期或显式删除,因此也没有 CAS 或 Increment/Decrement——键 'foo' 一旦为 'bar',就必须永远是 'bar'。
谁在生产环境中真正依赖它?Google 内部在使用:dl.google.com(最初的使用者)、Blogger 的部分功能、Google Code、Google Fiber,以及 Google 的生产环境监控系统。
groupcache 如何避免 memcached 在缓存未命中时出现的惊群效应(thundering herd)?它会协调缓存填充,使得在整个副本集群中,对某个键的加载只由一个进程执行,从而填充缓存;加载到的值随后会分发给所有等待该结果的其他调用方。
如果负责某个键的对等节点无法访问,会发生什么?如果对该负责节点的 RPC 调用失败,请求方节点会改为在本地加载该值,同时仍会合并本地并发的加载请求。
groupcache 如何决定由哪个节点负责某个键?它使用一致性哈希在对等节点集合中按键进行分片,与 memcached 的分片方式类似,因此每个键都会确定地映射到唯一一个负责节点。
groupcache 能应对被大量流量集中访问的“热点”键吗?可以——它会自动将超热门的条目镜像到多个进程中,从而避免热点问题,即某个热门键使一台 memcached 机器的 CPU 或网卡过载。
Creator
golang
Size
0.1 MB
Stars
13.3K
Updated
CommitNov 29
Age
13y
Commits · 90 Days