Corvus Redis Cluster Proxy

repository·master·Indexed 21 days ago

https://github.com/eleme/corvus

A fast, lightweight Redis cluster proxy designed for Redis 3.0 with cluster mode enabled. Corvus allows clients that do not natively support Redis Cluster to interact with a cluster by handling key routing and command splitting at the proxy level. It supports all single-key commands and automatically splits batch commands like MGET, MSET, DEL, and EXISTS into multiple single-key commands.

Tokens
3.5K
Snippets
22
Records
27
Agent score
70%

What's inside Corvus

  1. Build Corvus from source

    master

    To build Corvus from the latest source, you must first clone the repository and initialize submodules. You will need autoconf installed to handle dependencies.

    1. Clone the repository.
    2. Initialize submodules.
    3. Install dependencies using make deps.
    4. Build the binary using make.

    The resulting binary is located at ./src/corvus.

    git clone https://github.com/eleme/corvus.git
    cd corvus
    git submodule update --init
    make deps # need autoconf
    make
  2. Review Corvus load testing results

    master

    Corvus performance is evaluated using redis-benchmark to measure capacity under extreme load. These tests focus on maximum operational load rather than service quality (latency/return time). Detailed benchmark results for specific operations are available in the following reports:

  3. Run Redis MSET benchmarks with redis-benchmark

    master

    You can benchmark the MSET command in Redis using the redis-benchmark utility. This allows you to test the performance of multi-set operations by specifying the host, port, number of requests, rate, command type, payload size, and concurrency level.

    redis-benchmark -h 10.0.16.72 -p 8802 -n 90000000 -r 90000000 -t mset -P 1000 -c 100
  4. Benchmark Redis SET command

    master

    You can benchmark the performance of the Redis SET command using the redis-benchmark utility. The following example demonstrates a high-load test configuration targeting a specific host and port with a large number of requests and parallel clients.

    redis-benchmark -h 10.0.16.72 -p 8802 -n 90000000 -r 90000000 -t set -P 1000 -c 100
  5. Benchmark Redis GET performance with redis-benchmark

    master

    To benchmark the GET command performance in Redis, use the redis-benchmark utility. The following example demonstrates a high-load test configuration:

    • -h: Target host IP
    • -p: Target port
    • -n: Total number of requests
    • -r: Total number of requests (often used for range/repeat)
    • -t: The specific command to benchmark (get)
    • -P: Pipeline mode (number of requests to pipeline)
    • -c: Number of parallel clients

    Example command:

    redis-benchmark -h 10.0.16.72 -p 8802 -n 90000000 -r 90000000 -t get -P 1000 -c 100
  6. Run Corvus with a configuration file

    master

    To start the Corvus proxy, execute the binary and provide the path to your configuration file as the first argument. An example configuration file is provided in the repository as corvus.conf.

    ./src/corvus path/to/corvus.conf
  7. Supported and modified Redis commands in Corvus

    master

    Corvus acts as a proxy for Redis 3.0 clusters. It supports all single-key commands (e.g., SET, GET, INCR). Batch commands are automatically split into multiple single-key commands.

    Modified Command Behavior

    Some commands are intercepted or modified by the proxy:

    • MGET: Split into multiple GET commands.
    • MSET: Split into multiple SET commands.
    • DEL: Split into multiple single-key DEL commands.
    • EXISTS: Split into multiple single-key EXISTS commands.
    • PING: Ignored and not forwarded.
    • INFO, TIME: Information is collected by the proxy and returned instead of being forwarded to the backend.
    • SLOWLOG: Returns slowlogs saved by Corvus. Entries include a remote latency field before the total latency field. For multi-key commands (MGET, MSET, DEL, EXISTS), it logs the slowest sub-command.
    • AUTH: Authentication is performed within the proxy.
    • CONFIG: Supports get, set, and rewrite sub-commands to manage Corvus configuration.
    • SELECT: Ignored if the index is 0.
  8. Command restrictions and requirements in Corvus

    master

    Because Corvus proxies to a cluster, certain commands have restrictions based on key distribution across nodes.

    Key-Node Locality Requirements

    The following commands require all argument keys to belong to the same Redis node:

    • SORT
    • RPOP, LPUSH
    • SDIFF, SDIFFSTORE, SINTER, SINTERSTORE, SMOVE, SUNION, SUNIONSTORE
    • ZINTERSTORE, ZUNIONSTORE
    • PFCOUNTE, PFMERGE

    EVAL Restriction

    • EVAL: At least one key must be provided. If multiple keys are used, they must all belong to the same node.

    Unsupported Commands

    The following commands are not supported by Corvus:

    • Key Discovery/Management: KEYS, MIGRATE, MOVE, RANDOMKEY, RENAME, RENAMENX, SCAN.
    • Batch/Bitwise: BITOP, MSETNX.
    • Blocking Operations: BLPOP, BRPOP, BRPOPLPUSH.
    • Pub/Sub: PSUBSCRIBE, PUBLISH, PUBSUB, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE.
    • Scripting: EVALSHA, SCRIPT.
    • Transactions/Client: DISCARD, EXEC, MULTI, UNWATCH, WATCH, CLIENT, COMMAND, CLUSTER, ECHO, QUIT.
    • Admin/Persistence: BGREWRITEAOF, BGSAVE, CONFIG, DBSIZE, DEBUG, FLUSHALL, FLUSHDB, LASTSAVE, MONITOR, ROLE, SAVE, SHUTDOWN, SLAVEOF, SYNC, WAIT.
    • Other: OBJECT.
  9. Configure redis-benchmark for SET testing

    master

    When running redis-benchmark for the set command, the following flags are used in the provided benchmark profile:

    • -h <host>: The Redis server hostname or IP (e.g., 10.0.16.72).
    • -p <port>: The Redis server port (e.g., 8802).
    • -n <number>: Total number of requests to perform (e.g., 90000000).
    • -r <repetitions>: Number of repetitions per key (e.g., 90000000).
    • -t <type>: The command type to benchmark (e.g., set).
    • -P <pipeline>: Number of requests to pipeline (e.g., 1000).
    • -c <clients>: Number of parallel clients to use (e.g., 100).
  10. Redis MSET benchmark results (10 keys)

    master
    This section provides benchmark data for the Redis MSET command using 10 keys per operation. The values represent performance metrics (likely operations per second) recorded during testing. The results show high stability, with most values clustering around 148,200 to 148,300.
  11. Initialize a server connection with server_create()

    master

    To create a new server connection, use server_create(). This function requires a pointer to a context structure and an existing file descriptor (fd). It returns a pointer to a connection structure representing the new connection, or NULL if creation fails.

    struct connection *conn = server_create(ctx, fd);