Slide 1

Slide 1 text

Build Distributed Systems with NATS

Slide 2

Slide 2 text

What is Distributed Systems ? A distributed system is a group of computers working together as to appear as a single computer to the end-user.

Slide 3

Slide 3 text

Benefits of Distributed Systems ● Performance ● Fault Tolerance

Slide 4

Slide 4 text

Challenges ● Partial Failure ● Hard to debug / trace

Slide 5

Slide 5 text

Distributed System Communication ● Synchronous ○ REST, RPC ● Asynchronous ○ Kafka, RabbitMQ, Amazon SNS

Slide 6

Slide 6 text

Synchronous Communication

Slide 7

Slide 7 text

Implementation of Synchronous Communication

Slide 8

Slide 8 text

Asynchronous Communication

Slide 9

Slide 9 text

What is NATS ? https://nats.io NATS.io is a simple, secure and high performance open source messaging system for cloud native applications, IoT messaging, and microservices architectures.

Slide 10

Slide 10 text

NATS Creator Created By Derek Collison (https://twitter.com/derekcollison) ● Founder & CEO Synadia ● Former Founder & CEO Apcera ● Creator of CloudFoundry ● Google Developer APIs and JS CDN ● TIBCO Messaging

Slide 11

Slide 11 text

NATS Users

Slide 12

Slide 12 text

NATS Features ● Easy to use for developers and operators ● High-Performance ● Always on and available ● Extremely lightweight ● At Most Once and At Least Once Delivery ● Support for Observable and Scalable Services and Event/Data Streams ● Client support for over 30 different programming languages ● Cloud Native, a CNCF project with Kubernetes and Prometheus integrations

Slide 13

Slide 13 text

NATS Benchmark

Slide 14

Slide 14 text

NATS Use cases ● Cloud Messaging ○ Services (microservices, service mesh) ○ Event/Data Streaming (observability, analytics, ML/AI) ● Command and Control ○ IoT and Edge ○ Telemetry / Sensor Data / Command and Control ● Augmenting or Replacing Legacy Messaging Systems

Slide 15

Slide 15 text

Messaging Pattern ● Publish-Subscribe ● Queueing ● Request-Reply

Slide 16

Slide 16 text

Components of Messaging Architecture ● Message: Messages are the unit of data exchange. A payload, which is used for exchanging the data between applications. ● Subject: Subject specifies the destination of messages. ● Producer: Producers send messages to the NATS server. ● Consumer: Consumers receive messages from the NATS server. ● Messaging Server: NATS Server distributes the messages from producers to consumers.

Slide 17

Slide 17 text

Implementation of Asynchronous Communication

Slide 18

Slide 18 text

NATS Problem NATS offers an at most once quality of service. If a subscriber is not listening on the subject (no subject match), or is not active when the message is sent, the message is not received. This is the same level of guarantee that TCP/IP provides. By default, NATS is a fire-and-forget messaging system

Slide 19

Slide 19 text

Two Generals’ problem

Slide 20

Slide 20 text

Solution NATS Streaming ● Message/event persistence ● At-Least-Once Delivery model, giving reliable message delivery ● Rate limiting ● Replay/Restart ● Last Value Semantics

Slide 21

Slide 21 text

Subscription Types ● Regular ● Durable ● Queue Group ● Redelivery

Slide 22

Slide 22 text

Implementation

Slide 23

Slide 23 text

NATS Conclusion ● Simple ● No dependency ● Optional persistence ● Lightweight; 16MB docker image ● Lack of official GUI

Slide 24

Slide 24 text

Reference https://nats.io/ https://bravenewgeek.com/dissecting-message-queues/ https://hub.docker.com/_/nats https://hub.docker.com/_/nats-streaming https://en.wikipedia.org/wiki/Two_Generals%27_Problem