clusterduck-redis
v0.1.34
Published
clusterduck-redis [![total downloads of clusterduck-redis](https://img.shields.io/npm/dt/clusterduck-redis.svg)](https://www.npmjs.com/package/clusterduck-redis) ======= [![clusterduck-redis's License](https://img.shields.io/npm/l/clusterduck-redis.svg)](
Downloads
10
Maintainers
Readme
clusterduck-redis
A Redis extension for Clusterduck which includes:
- Health checks
- Balancer: Envoy integration with seamless hot restarting.
- Native Redis balancer (EXPERIMENTAL)
- Redis server wrapper
Table Of Contents
Installation
Clusterduck is required.
npm i -g clusterduck-redis
Configuration
Let's define a Redis cluster named my_redis_cluster
:
# clusters:
my_redis_cluster:
type: clusterduck-redis
Nodes
Then let's define some nodes:
# List of nodes
nodes:
- addr: 127.0.0.1:6379
- addr: 127.0.0.1:6380
Note that you can omit this altogether if you want to only add nodes dynamically.
Health checks
Now let's set up a simple health check.
health_checks:
- type: basic
timeout: 1s
every: 1s
commands:
- [ 'SET', 'x', 'y' ]
Now every second each node in the cluster will get checked on.
Envoy balancer
Envoy is required to be installed.
Let's write up a config:
balancers:
my_balancer:
type: envoy
listen: 0.0.0.0:9999
# This section is optional
admin:
access_log_path: "/tmp/admin_access.log"
address:
socket_address:
address: "127.0.0.1"
port_value: 9901
Note:
clusterduck
will runenvoy
with an according configuration. Hot restarting works out-of-box so thatenvoy
is always kept in sync withclusterduck
. It requires no middleware or additional configuration.
Redis server wrapper
If you want to run multiple Redis instances you can use redis-server-wrapper
to make life easier.
Let's start a Redis instance:
CLUSTER=redis_cache redis-server-wrapper start -d
It will pick an unused port from the range, spawn a Redis instance, and add the address to your Clusterduck cluster.
If you want to stop a Redis instance, just run clusterduck stop [port]
and it will remove it from the cluster first,
then wait a bit, so the traffic is off the instance and then gracefully shutdown Redis.
Debug
For debugging purposes use DEBUG
environmental variable:
DEBUG=ioredis*,envoy clusterduck
Cluster events
Event | Description
--------------------|------------------------------------------------------
nodes
| Set of nodes has changed
active
| Set of active nodes has changed
Node events
Event | Description
--------------------|------------------------------------------------------
state
| Node state has changed
Dependencies
Envoy balancer
License
LGPL 3.0 or later.