clusterduck-redis

0.1.34 • Public • Published

clusterduck-redis total downloads of clusterduck-redis

clusterduck-redis's License latest version of clusterduck-redis

A Redis extension for Clusterduck which includes:

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 run envoy with an according configuration. Hot restarting works out-of-box so that envoy is always kept in sync with clusterduck. 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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.34
    0
    • latest

Version History

Package Sidebar

Install

npm i clusterduck-redis

Weekly Downloads

0

Version

0.1.34

License

GPL-3.0-only

Unpacked Size

78.3 kB

Total Files

11

Last publish

Collaborators

  • kakserpom