What is NATS Cluster?
NATS is messaging stripped to its fast, essential core: subject-based pub/sub, request/reply, and - via JetStream - persistent streams, work queues, and key-value/object stores. It is astonishingly light (tens of megabytes per node) and astonishingly quick, which is why it underpins so much cloud-native infrastructure.
This template runs a 3-node cluster on the stock image, configured entirely with command flags (the same no-custom-build approach as the mongodb replica set). All three nodes share one all-peers routes list - NATS ignores its own self-route - so the mesh forms by gossip with no seed asymmetry, and JetStream replicates across all three.
Internal-only by design: it speaks raw TCP on 4222, and apps in the project connect there directly.
What you get
- Pub/sub, request/reply, and queue groups
- JetStream: persistent streams, work queues, KV and object stores
- 3-node cluster via flags - stock image, no custom build
- Replication factor 3 across per-node volumes
- Monitoring endpoint + health checks on :8222
- Apache-2.0; ~30 MB per node
How it runs on Lyngbak
| Service | Role | Public |
|---|---|---|
nats-0..2 | cluster nodes (client :4222, cluster :6222, monitor :8222) | no |
Sizing and billing
Nodes idle in tens of megabytes; 256 MiB each is generous. JetStream volume size is the dial - raise it as streams retain more.
A resource is a flat monthly price, with RAM and disk add-ons when the stack needs a little more than a tier, and room for your own apps on a larger one. On Usage Billing each service takes the smallest size that fits it and is billed by the second it runs, so a stopped stack stops costing CPU and RAM. Its 14.65 GiB of volumes cost $0.15 per GiB a month ($2.20/mo) for as long as they exist. One workspace can use both. See pricing
Run it locally first
The same compose file runs with plain Docker Compose. Clone the template source, copy .env.example to .env, and run docker compose up -d.
Questions
NATS, Kafka, or RabbitMQ?
NATS for low-latency cloud-native messaging and lightweight persistent streams with the smallest footprint; Kafka/Redpanda for high-throughput, long-retention event logs; RabbitMQ for classic AMQP work queues with mature routing. All are in this catalogue - NATS is the one you reach for when simplicity and latency matter most.
Is JetStream production-ready in this setup?
Yes - three nodes give JetStream a quorum for replication-factor-3 streams, surviving any single node loss. Each node persists to its own volume; declare streams with R3 and writes are durable across the cluster.
How do apps connect?
From the same project: nats://nats-0:4222 (any node accepts connections; list all three for failover). The client port is raw TCP and never exposed publicly. Add --user/--pass flags if you need auth.