• Stars
    star
    451
  • Rank 96,968 (Top 2 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 6 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Distributed object storage server from Douban Inc.

GoBeansDB Release

Yet anonther distributed key-value storage system from Douban Inc.

Any memcached client cache interactive with GobeansDB without any modification.

Related

Prepare

GoBeansDB use go mod manage dependencies, please make sure your Go version >= 1.11.0 first.

Install

$ git clone http://github.com/douban/gobeansdb.git
$ cd gobeansdb
$ go mod vendor
$ make

test

$ make test  # unit test
$ make pytest  # Integrated test

run

$ ${GOPATH}/bin/gobeansdb -h

Python Example

import libmc


mc = libmc.Client(['localhost:7900'])
mc.set("foo", "bar")
mc.get("foo")

Features

  • 协议: memcached。推荐 libmc 客户端(c++ 实现,目前支持 go 和 python,基于 poll 的并发 get_multi/set_multi)
  • sharding: 静态 hash 路由,分桶数 16 整数倍
  • 索引: 内存索引全部 key,开销约为每个 key 20 字节,主要内存用 c 分配。 get hit 直接定位到文件 record,get miss 不落盘。
  • 最终一致性:同步脚本不断比较一个桶三副本 htree(每个桶一个 16 叉的内存 merkle tree)做同步,比较时间戳。
  • 文件格式:data 文件可以看成 log(顺序写入); 每个 record 256 bytes 对齐,有 crc 校验。

在 douban 使用方法

mc_client --- cache
          |
          --- any beansdb proxy -- beansdb servers 
  • 用于单个 key 并发写很少的数据
  • gobeansproxy 负责路由, 固定 3 副本
  • 两个集群: 分别存储 图片类 (cache 为 CDN) 和 长文本 (cache 为 mc 集群)。
  • 支持离线 dpark 读写,读支持本地化。
  • 可以视情况保留一段时间完整的写记录。
  • 借助 python 脚本 管理,近期整理后会部分开源,包 admin UI(readonly),同步脚本等

磁盘上的样子(256分区):

  • /var/lib/beansdb
    • 0/
      • 0/ -> /data1/beansdb/0/0
        • 000.data
        • 000.000.idx.s
        • 000.001.idx.s
        • ...
        • 008.000.idx.hash
        • ...
        • 009.data
        • 009.000.idx.s

入坑指南

优点

  1. 数据文件即 log, 结构简单,数据安全
  2. htree 设计 方便数据同步;
  3. 全内存索引,访问磁盘次数少,尤其可以准确过滤掉不存在的 key。

缺点/注意

  1. 一致性支持较弱,时间戳目前是秒级(受限于数据文件格式)。
  2. 全内存索引,有一定内存开销,在启动时载入索引略慢(约十几秒到半分钟, 决定于key 数量)。
  3. 数据文件格式的 padding 对小 value 有一定浪费。

配置重点(详见 wiki)

  • 分桶数
  • htree 高度(决定 merkle tree 部分内存大小和 溢出链表的平均长度)

beansdb 关系

  • 兼容
    • 数据文件格式不变
    • 仍使用 mc 协议("@" "?" 开头的特殊 key 用法略不同)
    • htree 的核心设计不变
  • 改进
    • go 实现,更稳定,方便配置和维护(http api等)
    • 内存开销变小
    • hint 文件格式和后缀变了
    • 同一个节点不同数据文件不在混部署,以避免坏一个损失整个点数据

一些设计/实现要点见 wiki

More Repositories

1

DOUAudioStreamer

A Core Audio based streaming audio player for iOS and macOS
Objective-C
2,768
star
2

dpark

Python clone of Spark, a MapReduce alike framework in Python
Python
2,691
star
3

code

[DEPRECATED]Douban CODE
CSS
1,811
star
4

beansdb

Archived, see GoBeansDB instead.
C
870
star
5

douban-client

Python client library for Douban APIs (OAuth 2.0)
Python
744
star
6

rexxar-android

Mobile Hybrid Framework Rexxar Android Container
Java
667
star
7

rexxar-ios

Mobile Hybrid Framework Rexxar iOS Container
Objective-C
578
star
8

FRDIntent

A framework for handle the call between view controllers in iOS
Swift
492
star
9

libmc

Fast and light-weight memcached client for C++ / #python / #golang #libmc
C++
442
star
10

greenify

Make blocking C library work with gevent
C
427
star
11

ynm3k

UI Automation + YUItest driven acceptance tests that can be hooked into Jenkins
JavaScript
410
star
12

paracel

Distributed training framework with parameter server
C++
337
star
13

douban-objc-client

Objective-C client library for Douban APIs (OAuth 2.0)
Objective-C
254
star
14

beanseye

Proxy and monitor for beansdb in Go
Go
233
star
15

rexxar-web

Mobile Hybrid Framework Rexxar Web SDK
JavaScript
206
star
16

Kenshin

Kenshin: A time-series database alternative to Graphite Whisper with 40x improvement in IOPS
Python
206
star
17

tfmesos

Tensorflow in Docker on Mesos #tfmesos #tensorflow #mesos
Python
191
star
18

pymesos

A pure python implementation of Mesos scheduler and executor
Python
163
star
19

brownant

Brownant is a web data extracting framework.
Python
159
star
20

linguist

Language Savant, Python clone of github/linguist.
Python
153
star
21

graph-index

index of Graphite & Diamond
Python
129
star
22

CaoE

Kill all children processes when the parent dies
Python
101
star
23

douban-quixote

Douban's Quixote
Python
82
star
24

douban-utils

Douban's Utils
Python
59
star
25

python-libmemcached

DEPRECATED, use https://github.com/douban/libmc instead. python-libmemcached is a python extention for libmemcached
Python
57
star
26

PyCharlockHolmes

Character encoding detecting library for Python using ICU and libmagic.
Common Lisp
50
star
27

DOUSNSSharing

SNS OAuth 2 binding and sharing
Objective-C
47
star
28

ellen

Ellen is a wrapper of pygit2 and git command.
Python
41
star
29

Polymorph

Transform value of dictionary to property of Objective-C class, by using a `dynamic` like directive.
Objective-C
40
star
30

douban-sqlstore

Douban's MySQL lib.
Python
31
star
31

gpack

GIT Smart HTTP Server Rack Implementation, Python clone of https://github.com/schacon/grack
Python
30
star
32

douban-orz

The Missing Data Manager In Douban
Python
29
star
33

douban-mc

Douban's Memcached lib for python.
Python
27
star
34

charts

Helm charts from douban
Smarty
24
star
35

helpdesk

Yet another helpdesk based on multiple providers
Python
22
star
36

sina

A GIT Smart HTTP Server WSGI Implementation.
Python
21
star
37

sa-tools-core

Handy tools for sysadmin.
Python
18
star
38

graphite-kenshin

A plugin for using graphite-web with the kenshin-based storage backend.
Python
16
star
39

gobeansproxy

A proxy for GoBeansDB
Go
13
star
40

beansdbadmin

GoBeansDB Admin UI
Python
9
star
41

redarrow-rs

A command dispatcher to run executables remotely and safely.
Rust
6
star
42

MTURLProtocol

Multiple NSURLProtocol subclasses alternative solution.
Objective-C
4
star
43

python-libmagic

A wrapper for libmagic with static build.
Python
3
star
44

qiniu-exporter

Go
2
star
45

aliyun-exporter

Go
2
star
46

pyquicklz

C
1
star
47

upyun-exporter

Go
1
star
48

sa-tools-go

go version for sa-tools
Go
1
star