Course contentsShow
← System Design
Lesson 673 of 1,91918. Message Queues and BrokersFree lesson

NATS and Lightweight Messaging

NATS architecture, at-most-once delivery, and use cases for fire-and-forget messaging.

NATS and Lightweight Messaging

What You'll Learn

You'll discover how NATS provides ultra-lightweight, fire-and-forget messaging with minimal guarantees but maximum performance.


Why NATS Is Different

While brokers like RabbitMQ and Kafka emphasize durability and strong guarantees, NATS takes the opposite approach: it's designed for speed, simplicity, and low latency. Think of it as the difference between certified mail (RabbitMQ) versus shouting across a crowded room (NATS)—one guarantees delivery, the other prioritizes immediacy.

NATS Architecture

NATS is a simple server that routes messages between publishers and subscribers in memory:

  • No message persistence by default—messages exist only while in flight
  • Minimal protocol overhead—lightweight TCP connections with simple text-based commands
  • No complex routing—pure subject-based pub-sub (like orders.created or sensor.temperature)
  • Stateless server—no queues to manage, no acknowledgments to track

If a subscriber isn't connected when you publish, the message is lost. Period.

At-Most-Once Delivery

NATS provides at-most-once delivery semantics: a message is delivered either zero or one time, never more. There's no retry mechanism or durability. If the subscriber crashes mid-processing, that message is gone.

This is "fire-and-forget" messaging—you send it and move on.

When to Use NATS

Perfect for scenarios where speed matters more than guarantees:

  • Real-time telemetry (sensor data, metrics)
  • Ephemeral notifications (user online status)
  • Cache invalidation signals
  • High-frequency updates where losing occasional messages is acceptable

NATS excels when you can tolerate message loss in exchange for microsecond latency and millions of messages per second.


Key Takeaway: NATS prioritizes lightweight, high-performance messaging with at-most-once delivery, making it ideal for fire-and-forget scenarios where speed trumps durability.