-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from hit9/README
Update README
- Loading branch information
Showing
1 changed file
with
80 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,118 @@ | ||
# Corvus | ||
Corvus | ||
====== | ||
|
||
[![Build Status](https://travis-ci.org/eleme/corvus.svg)](https://travis-ci.org/eleme/corvus) | ||
|
||
A fast and lightweight Redis Cluster Proxy for Redis 3.0 with cluster mode enabled | ||
focused on Linux >= 3.9. Clients designed for normal mode Redis can still be used | ||
through the proxy. Redirection errors are handled and slot map is cached in proxy. | ||
Corvus is a fast and lightweight redis cluster proxy for redis 3.0 with cluster mode enabled. | ||
|
||
Why | ||
--- | ||
|
||
## Build | ||
Most redis client implementations don't support redis cluster. We have a lot of services relying | ||
on redis, which are written in Python, Java, Go, Nodejs etc. It's hard to provide redis client | ||
libraries for multiple languages without breaking compatibilities. We use [twemproxy](https://github.com/twitter/twemproxy) | ||
before, but it requires restarting to add or remove backend redis instances, which causes service | ||
interruption. And twemproxy is single threaded, we have to deploy multiple twemproxy instances | ||
for large number of clients, which causes the sa headache. | ||
|
||
Build from source: | ||
Therefore, we made corvus. | ||
|
||
```bash | ||
$ make | ||
``` | ||
Features | ||
-------- | ||
|
||
Build in debug mode: | ||
* Fast. | ||
* Lightweight. | ||
* Zero dependencies. | ||
* Multiple threading. | ||
* Reuseport support. | ||
* Pipeline support. | ||
* Statsd integration. | ||
* Syslog integration. | ||
|
||
```bash | ||
$ make debug | ||
``` | ||
Requirements | ||
------------ | ||
|
||
## Run Proxy | ||
* Linux >= 3.9 | ||
|
||
Configuration file: | ||
Build | ||
----- | ||
|
||
```conf | ||
# corvus.conf | ||
Just make: | ||
|
||
# binding port | ||
bind 12345 | ||
``` | ||
$ make | ||
``` | ||
|
||
With debug mode enabled: | ||
|
||
# redis cluster nodes, comma separated list, can supply only one node | ||
node localhost:8000,localhost:8001,localhost:8002 | ||
``` | ||
make debug | ||
``` | ||
|
||
# threads share the same binding port using SO_REUSEPORT | ||
thread 4 | ||
Binary can be found at `./src/corvus`. | ||
|
||
# log level, available values: debug, info, warn, error | ||
# if not supplied or wrong value `info` is used | ||
loglevel info | ||
Configuration | ||
------------- | ||
|
||
# whether log to syslog | ||
syslog 0 | ||
``` | ||
Example configuration file is at [corvus.conf](corvus.conf). | ||
|
||
Run proxy: | ||
Usage | ||
----- | ||
|
||
```bash | ||
./src/corvus corvus.conf | ||
$ ./src/corvus path/to/corvus.conf | ||
``` | ||
|
||
## Commands | ||
Commands | ||
-------- | ||
|
||
All single key commands are supported. Commands performing complex multi-key | ||
operations like unions or intersections are available as well as long as | ||
the keys all belong to the same node. | ||
* All single-key commands (like `SET`, `GET`, `INCR`..) are supported. | ||
* Batch commands are split into multiple single-key commands. | ||
* Commands performing complex multi-key operations like unions or intersections | ||
are available as well as long as the keys all belong to the same node. | ||
|
||
#### Modified commands | ||
|
||
- `MGET`: split to multiple `GET` | ||
- `MSET`: split to multiple `SET` | ||
- `DEL`: split to multiple single key `DEL` | ||
- `EXISTS`: split to multiple single key `EXISTS` | ||
- `PING`: not forward to redis server | ||
- `INFO`: not forward to redis server, return information collected in proxy | ||
|
||
* `MGET`: split to multiple `GET`. | ||
* `MSET`: split to multiple `SET`. | ||
* `DEL`: split to multiple single key `DEL`. | ||
* `EXISTS`: split to multiple single key `EXISTS`. | ||
* `PING`: ignored and won't be forwarded. | ||
* `INFO`: won't be forwarded to backend redis, information collected in proxy | ||
will be returned. | ||
|
||
#### Restricted commands | ||
|
||
- `EVAL`: at least one key, if mutiple keys given, all keys should belong to same node | ||
* `EVAL`: at least one key should be given. If there are multiple keys, all of | ||
them should belong to the same one node. | ||
|
||
The following commands require all argument keys to belong to the same one redis node: | ||
|
||
#### All keys should belong to the same node | ||
|
||
``` | ||
# key | ||
SORT(with STORE) | ||
# list | ||
RPOPLPUSH | ||
# set | ||
SDIFF SDIFFSTORE SINTER SINTERSTORE SMOVE SUNION SUNIONSTORE | ||
# sorted set | ||
ZINTERSTORE ZUNIONSTORE | ||
# hyperloglog | ||
PFCOUNT PFMERGE | ||
``` | ||
* `SORT`. | ||
* `RPOP`, `LPUSH`. | ||
* `SDIFF`, `SDIFFSTORE`, `SINTER`, `SINTERSTORE`, `SMOVE`, `SUNION`, `SUNIONSTORE`. | ||
* `ZINTERSTORE`, `ZUNIONSTORE`. | ||
* `PFCOUNTE`, `PFMERGE`. | ||
|
||
#### Unsupported commands | ||
|
||
``` | ||
KEYS MIGRATE MOVE OBJECT RANDOMKEY RENAME RENAMENX SCAN WAIT | ||
# string | ||
BITOP MSETNX | ||
# list | ||
BLPOP BRPOP BRPOPLPUSH | ||
The following commands are not available, such as `KEYS`, we can't search keys across | ||
all backend redis instances. | ||
|
||
# pub/sub | ||
PSUBSCRIBE PUBLISH PUBSUB PUNSUBSCRIBE SUBSCRIBE UNSUBSCRIBE | ||
* `KEYS`, `MIGRATE`, `MOVE`, `OBJECT`, `RANDOMKEY`, `RENAME`, `RENAMENX`, `SCAN`, `WAIT`. | ||
* `BITOP`, `MSETNX` | ||
* `BLPOP`, `BRPOP`, `BRPOPLPUSH`. | ||
* `PSUBSCRIBE`, `PUBLISH`, `PUBSUB`, `PUNSUBSCRIBE`, `SUBSCRIBE`, `UNSUBSCRIBE`. | ||
* `EVALSHA`, `SCRIPT`. | ||
* `DISCARD`, `EXEC`, `MULTI`, `UNWATCH`, `WATCH`. | ||
* `CLUSTER`. | ||
* `AUTH`, `ECHO`, `QUIT`, `SELECT`. | ||
* `BGREWRITEAOF`, `BGSAVE`, `CLIENT`, `COMMAND`, `CONFIG`, `DBSIZE`, `DEBUG`, `FLUSHALL`, | ||
`FLUSHDB`, `LASTSAVE`, `MONITOR`, `ROLE`, `SAVE`, `SHUTDOWN`, `SLAVEOF`, `SLOWLOG`, `SYNC`, `TIME`. | ||
|
||
# script | ||
EVALSHA SCRIPT | ||
License | ||
------- | ||
|
||
# transaction | ||
DISCARD EXEC MULTI UNWATCH WATCH | ||
MIT. Copyright (c) 2016 Eleme Inc. | ||
|
||
# cluster | ||
CLUSTER | ||
AUTH ECHO QUIT SELECT | ||
BGREWRITEAOF BGSAVE CLIENT COMMAND CONFIG DBSIZE DEBUG FLUSHALL FLUSHDB LASTSAVE | ||
MONITOR ROLE SAVE SHUTDOWN SLAVEOF SLOWLOG SYNC TIME | ||
``` | ||
See [LICENSE](LICENSE) for details. |