kv

command
v0.0.0-...-ba27772 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2023 License: MIT Imports: 11 Imported by: 0

README

Example: Key-Value Store

This is a simple distributed in-memory key-value store using Ranger. You should not use it for anything under any circumstances; there's no persistence, and it totally ignores various important edge-cases. It's intended to demonstrate the following specific use case:

  • One or zero active replicas.
  • Direct (node-to-node) state transfer.
  • External proxy layer.

It has two components in addition to the controller:

  • node:
    This stateful service stores the actual data. It exposes a simple get/put interface over gRPC. It includes a Rangelet, which will coordinate workload assignment with the controller.
  • proxy:
    This stateless service connects to every node and watches the range assignments. It exposes the same get/put interface, but can transparently forward requests to the appropriate storage node.

Deps

Install dependencies with Brew.
Ths only works on macOS. (Sorry.)

$ brew bundle --file Brewfile
Homebrew Bundle complete! 2 Brewfile dependencies now installed.

Usage

Start consul in the background (for service discovery), and run a simple three node cluster:
(This uses Foreman to keep things simple, but you can also start up the services in separate tabs or whatever, if you prefer.)

$ brew services run consul
==> Successfully ran `consul` (label: homebrew.mxcl.consul)
$ cd ~/code/src/github.com/adammck/ranger/examples/kv
$ bin/dev.sh
23:15:00 controller.1 | started with pid 18951
23:15:00 proxy.1      | started with pid 18952
23:15:01 node.1       | started with pid 18953
23:15:01 node.2       | started with pid 18954
23:15:01 node.3       | started with pid 18955

Run a load test:
(This hammer tool is specific to the kv example, and is kind of janky. It's intended to demonstrate availability during range moves/splits/joins.)

$ cd tools/hammer
$ go build
$ ./hammer -addr localhost:5100 -duration 60s

Move range 1 (the only range, for now) to node 2:

$ rangerctl move 1 5201

Split range 1 onto nodes 1 and 3:

$ rangerctl split 1 m 5200 5202

Join ranges 1 and 3 back onto node 2:

$ rangerctl join 2 3 5021

Tests

These aren't exactly working right now.

$ bats test

License

MIT.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
proto
gen
tools

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL