• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

KeyDB: KeyDB是Redis的高性能分支,专注于多线程、内存效率和高吞吐量 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

KeyDB

开源软件地址:

https://gitee.com/mirrors/KeyDB

开源软件介绍:

What is KeyDB?

KeyDB is a high performance fork of Redis focussing on multithreading, memory efficiency, and high throughput. In addition to multithreading KeyDB also has features only available in Redis Enterprise such as FLASH storage support, and some not available at all such as direct backup to AWS S3.

On the same hardware KeyDB can perform twice as many queries per second as Redis, with 60% lower latency.

Why fork Redis?

The Redis maintainers have continually reiterated that they do not plan to support multithreading. While we have great respect for the redis team, we feel the analysis justifying this decision is incorrect. In addition we wanted open source implementations of features currently only available in proprietary modules. We feel a fork is the best way to accelerate development in the areas of most interest to us.

We plan to track the Redis repo closely and hope our projects can learn from each other.

Benchmarking KeyDB

Please note keydb-benchmark and redis-benchmark are currently single threaded and too slow to properly benchmark KeyDB. We recommend using a redis cluster benchmark tool such as memtier. Please ensure your machine has enough cores for both KeyDB and memteir if testing locally. KeyDB expects exclusive use of any cores assigned to it.

For more details on how we benchmarked KeyDB along with performance numbers check out our blog post: Redis Should Be Multithreaded

New Configuration Options

With new features comes new options:

server-threads N

The number of threads used to serve requests. This should be related to the number of queues available in your network hardware, not the number of cores on your machine. Because KeyDB uses spinlocks to reduce latency; making this too high will reduce performance. We recommend using 4 here. By default this is set to one.

scratch-file-path /path

If you would like to use the FLASH backed storage this option configures the directory for KeyDB's temporary files. This feature relies on snapshotting to work so must be used on a BTRFS filesystem. ZFS may also work but is untested. With this feature KeyDB will use RAM as a cache and page to disk as necessary. NOTE: This requires special compilation options, see Building KeyDB below.

db-s3-object /path/to/bucket

If you would like KeyDB to dump directly to AWS S3 this option specifies the bucket. Using this option with the traditional RDB options will result in KeyDB backing up twice to both locations. This requires the AWS CLI tools to be installed and configured which are used under the hood to transfer the data.

All other configuration options behave as you'd expect. Your existing configuration files should continue to work unchanged.

Building KeyDB

KeyDB can be compiled and is tested for use on Linux. KeyDB currently relies on SO_REUSEADDR's load balancing behavior which is available only in Linux. When we support marshalling connections across threads we plan to support other operating systems such as FreeBSD.

Compiling is as simple as:

% make

You can enable flash support with (Note: autoconf and autotools must be installed):

% make MALLOC=memkind

Fixing build problems with dependencies or cached build options

KeyDB has some dependencies which are included into the deps directory.make does not automatically rebuild dependencies even if something inthe source code of dependencies changes.

When you update the source code with git pull or when code inside thedependencies tree is modified in any other way, make sure to use the followingcommand in order to really clean everything and rebuild from scratch:

make distclean

This will clean: jemalloc, lua, hiredis, linenoise.

Also if you force certain build options like 32bit target, no C compileroptimizations (for debugging purposes), and other similar build time options,those options are cached indefinitely until you issue a make distcleancommand.

Fixing problems building 32 bit binaries

If after building KeyDB with a 32 bit target you need to rebuild itwith a 64 bit target, or the other way around, you need to perform amake distclean in the root directory of the KeyDB distribution.

In case of build errors when trying to build a 32 bit binary of KeyDB, trythe following steps:

  • Install the packages libc6-dev-i386 (also try g++-multilib).
  • Try using the following command line instead of make 32bit:make CFLAGS="-m32 -march=native" LDFLAGS="-m32"

Allocator

Selecting a non-default memory allocator when building KeyDB is done by settingthe MALLOC environment variable. KeyDB is compiled and linked against libcmalloc by default, with the exception of jemalloc being the default on Linuxsystems. This default was picked because jemalloc has proven to have fewerfragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

Verbose build

KeyDB will build with a user friendly colorized output by default.If you want to see a more verbose output use the following:

% make V=1

Running KeyDB

To run KeyDB with the default configuration just type:

% cd src% ./keydb-server

If you want to provide your keydb.conf, you have to run it using an additionalparameter (the path of the configuration file):

% cd src% ./keydb-server /path/to/keydb.conf

It is possible to alter the KeyDB configuration by passing parameters directlyas options using the command line. Examples:

% ./keydb-server --port 9999 --replicaof 127.0.0.1 6379% ./keydb-server /etc/keydb/6379.conf --loglevel debug

All the options in keydb.conf are also supported as options using the commandline, with exactly the same name.

Playing with KeyDB

You can use keydb-cli to play with KeyDB. Start a keydb-server instance,then in another terminal try the following:

% cd src% ./keydb-clikeydb> pingPONGkeydb> set foo barOKkeydb> get foo"bar"keydb> incr mycounter(integer) 1keydb> incr mycounter(integer) 2keydb>

You can find the list of all the available commands at http://redis.io/commands.

Installing KeyDB

In order to install KeyDB binaries into /usr/local/bin just use:

% make install

You can use make PREFIX=/some/other/directory install if you wish to use adifferent destination.

Make install will just install binaries in your system, but will not configureinit scripts and configuration files in the appropriate place. This is notneeded if you want just to play a bit with KeyDB, but if you are installingit the proper way for a production system, we have a script doing thisfor Ubuntu and Debian systems:

% cd utils% ./install_server.sh

The script will ask you a few questions and will setup everything you needto run KeyDB properly as a background daemon that will start again onsystem reboots.

You'll be able to stop and start KeyDB using the script named/etc/init.d/keydb_<portnumber>, for instance /etc/init.d/keydb_6379.

Code contributions

Note: by contributing code to the KeyDB project in any form, including sendinga pull request via Github, a code fragment or patch via private email orpublic discussion groups, you agree to release your code under the termsof the BSD license that you can find in the COPYING file included in the KeyDBsource distribution.

Please see the CONTRIBUTING file in this source distribution for moreinformation.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap