Distributed KV Store

Build a clustered key-value store with automatic discovery and remote messaging.

Architecture

A multi-node key-value store where any node can accept requests and route them to the node hosting the KVStore actor:

Any node can route requests to the KVStore via the distributed registry

Cross-Node Request Flow

Requests are automatically routed to the correct node

Cluster Formation

Nodes discover each other through gossip protocol

Protocol Buffer Messages

Remote messages use Protocol Buffers for efficient serialization:

proto/kv.proto
protobuf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

KVStore Actor

kv_store.rs
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

Node Setup

main.rs
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

Interactive CLI

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

Running the Cluster

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

The full example is available in the cineyma repository under examples/distributed-kv/.

Key Concepts

Distributed Registry

Actors register themselves by name. Any node can look up where an actor lives.

Location Transparency

ClusterClient.remote_addr() returns an address that works regardless of which node hosts the actor.

Gossip Protocol

Nodes exchange membership and registry information periodically, achieving eventual consistency.

Protocol Buffers

Remote messages use protobuf for efficient, language-agnostic serialization.

Next Steps