OneCache: 一個兼容memcached分布式KV存儲

jopen 8年前發布 | 15K 次閱讀 緩存服務器 memcached

OneCache

OneCache是一個分布式key/value存儲,可以通過memcached協議訪問。OneCache nodes原生支持集群并且盡可能的復制。 添加節點進入集群有效地增加了高速緩存的存儲器內存儲能力。Replication of keys minimizes the impact of a single node failure as requests will transparently be forwarded to the new key leader.

OneCache's architecture is built around the concept of a one-hop distributed hash table. Many DHT algorithms are designed for a very large number of members, such as bitorrent DHTs, and trade lookup efficiency for per-node storage and communication. However, OneCache is built for a much smaller cluster size (<100) and as such, every node holds the full state of the underlying consistent hash ring. This is advantageous because every node is capable of forwarding requests to the correct node, which is why it receives the term one-hop.

OneCache's name then becomes a play on its one-hop DHT architecture and memcached protocol support.

Download pre-compiled binaries by browsing thereleases.

Usage

Single Node

To start a single OneCache node listening on memcached's default port, simply run:

$> ./onecache

Clustered

To start a cluster of OneCache nodes on a single machine (for ease of getting started) we must bind the nodes to non-default ports to avoid collision. If clustering on different machines, the default ports can be used.

Start the first node in one terminal:

$> ./onecache -gossip_port=7946 -port=11211

In another, start the second and have it join. The output will show it added a peer node.

$> ./onecache -gossip_port=7947 -port=11212 -join="127.0.0.1:7946"
2016/01/18 12:04:30 [INFO] onecache: added peer node &{c3f48bd0-4106-43d4-9044-15cf552037f0 192.168.1.10 11211}

Usage

Standard memcached libraries can be used, which make OneCache an easy drop in replacement for memcached as code doesn't have to be changed. OneCache is also accessible via the terminal:

$> telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set foo 0 0 12
hello, world
STORED

來自: https://github.com/dadgar/onecache

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!