View on GitHub

adr

Journal of Architectural Decision Records made for the project

Use JetStream for Distributed Lattice Cache

Context and Problem Statement

During the course of normal operation, wasmCloud hosts need to share certain information; metadata about the contents and operation of the lattice. This includes information such as a lookup table of JWT claims, a lookup table that maps OCI URLs to public keys, and a list of link definitions.

This information needs to be shared with all hosts in a lattice at all times, and it needs to withstand things like partition events and temporary connectivity loss, as well as expected events like the termination and starting of individual host processes.

The current solution to this problem is not reliable, doesn’t scale beyond simple installations and, worse, can quite easily result in “split-brain” problems where different hosts have different views of the same set of information, potentially causing runtime failures in production.

Decision Drivers

Considered Options

Decision Outcome

Chosen option: Use NATS JetStream, because this is the only option that actually satisfies all of our runtime production requirements while still enabling a simple developer experience and not burdening the developer by requiring the installation of additional software.

Positive Consequences

Negative Consequences

Pros and Cons of the Options

Leave As-Is

Continue using naive state replication by simply emitting at most once messages in fire-and-forget fashion into the lattice.

Use Redis

Communicate with a Redis server (or cluster) and store lattice cache metadata in Redis keys

Use memcached/etcd/consul/etc

Use one of these other servers that are often optimized for high-efficiency, in-memory operation.

Use NATS JetStream

Rely on the features of streams in NATS JetStream to manage the lattice shared metadata