Building Distributed Systems and Microservices in Go with NATS Streaming

Shiju Varghese
Oct 14, 2017 · 13 min read

Introducing NATS Streaming


File store for persistent logs

Message Log

Setup NATS Streaming

go get
go get
nats-streaming-server \--store file \--dir ./data \--max_msgs 0 \--max_bytes 0
--store <string>           Store type: MEMORY|FILE (default: MEMORY)
--dir <string> For FILE store type, this is the root directory
--max_msgs <int> Max number of messages per channel (0 for unlimited)
--max_bytes <size> Max messages total size per channel (0 for unlimited)
NATS Streaming Server runs using an embedded NATS Server

Building Distributed Systems with NATS Streaming

Using NATS Streaming in Microservices Architecture

Example with NATS Streaming

msg.Ack() // Manual ACK

Source Code

Clustering NATS Streaming Server

Fault Tolerance

Shiju Varghese

Written by

Distributed Systems Architect, Go Hacker and Author of two books on Go. Provides consulting and training on Go, Cloud-Native Microservices in India.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade