SlideShare a Scribd company logo
1 of 48
Download to read offline
γ€€γ€€γ€€γ€€
Simple, Secure and Scalable Messaging
For The Cloud Native Era
Waldemar Quevedo /
All Things Open / October 2017
@wallyqs
1 . 1
Agenda
Intro to the NATS project
NATS & NATS Streaming Overview
Demos
2 . 1
NATS is a simple, high performance open source
messaging system for cloud native applications.
3 . 1
Facts about NATS
Written by Derek Collison in 2010, originally for CloudFoundry
Initial implementation in Ruby, was then rewritten in Go in 2012
Project used in production environments for ~7 years
NATS Server v1.0.0 milestone reached in July 2017
Github Organization: https://github.com/nats-io
4 . 1
NATS is fast
5 . 1
Stats about NATS
NATS Server can process above +11M messages per second (w/ nats-bench)
6 . 1
Stats about NATS
Reliable Low Latency Pub Sub!
Source: http://bravenewgeek.com/benchmarking-message-queue-latency/
7 . 1
NATS is
predictable
8 . 1
γ€€γ€€γ€€γ€€
https://twitter.com/ripienaar/status/905299955077787648
9 . 1
γ€€γ€€γ€€γ€€
https://twitter.com/ngduynd/status/907922573521936384
10 . 1
NATS is simple
11 . 1
Simplicity in NATS
Plain text protocol with few commands β†’ Simple network clients & API
7MB binary with no dependencies β†’ Small Docker image
Fire & Forget Pub Sub on top of TCP/IP
| PUB | SUB | UNSUB | CONNECT | INFO | MSG | -ERR | +OK | PING | PONG |
telnet demo.nats.io 4222
Connected to demo.nats.io.
INFO {"server_id":"Fzwx2ndlHFg3lvVwwdBRSe","tls_required":false,...,"max_payload":1048576}
SUB hello 1
+OK
PUB hello 5
world
+OK
MSG hello 1 5
world
12 . 1
Basic API: Go Client
package main
import (
"log"
"github.com/nats-io/go-nats"
)
func main(){
nc, err := nats.Connect("nats://127.0.0.1:4222")
if err != nil {
log.Fatalf("Error: %s", err)
}
done := make(chan struct{})
nc.Subscribe("hello", func(m *nats.Msg){
log.Printf("[Received] %s", string(m.Data))
done <- struct{}{}
})
nc.Publish("hello", []byte("world"))
<-done
}
13 . 1
Basic API: Ruby Client
require 'nats/client'
NATS.start do |nc|
nc.subscribe("hello") do |msg|
puts "[Received] #{msg}"
end
nc.publish("hello", "world")
end
14 . 1
Basic API: Python Client
await nc.connect()
async def handler(msg):
print("[Received] {data}".format(
data=msg.data.decode()))
# Coroutine based subscriber
await nc.subscribe("foo", cb=handler)
await nc.publish("foo", "bar")
15 . 1
Basic API: Node.js Client
var nats = require('nats').connect();
// Simple Publisher
nats.publish('foo', 'Hello World!');
// Simple Subscriber
nats.subscribe('foo', function(msg) {
console.log('[Received] ' + msg);
});
16 . 1
Basic API: C Client
natsConnection_Publish(nc,"foo",data,5);
natsConnection_Subscribe(&sub,nc,"foo",onMsg, NULL);
void
onMsg(natsConnection *nc, natsSubscription *sub,
natsMsg *msg, void *closure)
{
printf("[Received] %.*sn",
natsMsg_GetData(msg));
// ...
}
17 . 1
Basic API: C# Client
using NATS.Client;
ConnectionFactory cf = new ConnectionFactory();
IConnection c = cf.CreateConnection();
ISyncSubscription sSync = c.SubscribeSync("hello");
// Wait up to 1000 ms for next message
Msg m = sSync.NextMessage(1000);
c.Publish("hello", Encoding.UTF8.GetBytes("world"));
18 . 1
Basic API: Java Client
Connection nc = Nats.connect();
nc.subscribe("foo", m -> {
System.out.printf("Received a message: %sn", new String(m.getData()));
});
nc.publish("foo", "Hello World".getBytes());
19 . 1
Clients of cially supported by the NATS team
20 . 1
NATS is resilient
21 . 1
Protection against Slow Consumers
package main
import (
"log"
"github.com/nats-io/go-nats"
)
func main(){
nc, err := nats.Connect("nats://127.0.0.1:4222")
if err != nil {
log.Fatalf("Error: %s", err)
}
n := 0
total := 1000000000
done := make(chan struct{})
nc.Subscribe("hello", func(m *nats.Msg){
n++
if n == total {
close(done)
}
})
for i := 0; i < total; i++ {
nc.Publish("hello", []byte("world"))
}
select {
case <-done:
}
}
22 . 1
Protection against Slow Consumers
Server disconnects client with Slow Consumer error
Client was too slow at processing the received messages.
[33682] 2017/10/19 07:52:51.647917 [INF] Starting nats-server version 0.9.6
[33682] 2017/10/19 07:52:51.648085 [INF] Starting http monitor on 0.0.0.0:8222
[33682] 2017/10/19 07:52:51.648631 [INF] Listening for client connections on 0.0.0.0:4222
[33682] 2017/10/19 07:52:51.648691 [INF] Server is ready
[33682] 2017/10/19 07:52:55.376292 [INF] 127.0.0.1:63184 - cid:1 - Slow Consumer Detected
[33682] 2017/10/19 07:52:57.424381 [INF] 127.0.0.1:63185 - cid:2 - Slow Consumer Detected
[33682] 2017/10/19 07:52:59.478090 [INF] 127.0.0.1:63186 - cid:3 - Slow Consumer Detected
[33682] 2017/10/19 07:53:01.541496 [INF] 127.0.0.1:63188 - cid:4 - Slow Consumer Detected
23 . 1
NATS Server Cluster
High Availability via full-mesh cluster topology
24 . 1
NATS Server Cluster
High Availability via full-mesh cluster topology
25 . 1
NATS & Delivery Guarantees
The NATS Server is re & forget, providing at-most once delivery.
This means that if the consumer is not connected it will not receive the message!
26 . 1
Is NATS a Message Broker/Queue?
From the book (Kleppmann, O'Reilly)
"a message broker (also known as a message queue), is essentially a kind of database
that is optimized for handling message streams."
βŒγ€€
Designing Data-Intensive Applications
27 . 1
Is NATS a Message Broker/Queue?
From the book (Kleppmann, O'Reilly)
"By centralizing the data in the broker, these systems can more easily tolerate clients
that come and go (connect, disconnect, and crash)
"the question of durability is moved to the broker instead
βŒγ€€
Designing Data-Intensive Applications
28 . 1
Is NATS a Message Broker/Queue?
From the book (Kleppmann, O'Reilly)
"Faced with slow consumers, they generally allow unbounded queueing (as opposed to
dropping messages or backpressure)
βŒγ€€
Designing Data-Intensive Applications
29 . 1
The NATS Server does none of that!
It's the total opposite.
30 . 1
γ€€
31 . 1
NATS Streaming
codename: STAN
32 . 1
NATS Streaming
Supports at-least-once delivery model and durability of messages
Rate limiting & message redelivery features
First release in 2016
33 . 1
NATS Streaming: How it works
Designed as a request/response protocol which uses NATS as its transport.
34 . 1
NATS Streaming: How it works
Designed as a request/response protocol which uses NATS as its transport.
35 . 1
NATS Streaming: How it works
Designed as a request/response protocol which uses NATS as its transport.
36 . 1
NATS Streaming: How it works
Designed as a request/response protocol which uses NATS as its transport.
37 . 1
NATS Streaming Clustering
Clustering support in the works!
To be fair, you have to have a very high IQ to understand Rick & Morty clustering
https://github.com/nats-io/nats-streaming-server/issues/316
38 . 1
NATS Streaming: Go Client
Publish and persist a message
Start with last received message
Receive all messages
sc, _ := stan.Connect(clusterID, clientID)
sc.Publish("foo", []byte("Hello World"))
sub, err := sc.Subscribe("foo", func(m *stan.Msg) {
fmt.Printf("Received a message: %sn", string(m.Data))
})
sub, err := sc.Subscribe("foo", func(m *stan.Msg) {
fmt.Printf("Received a message: %sn", string(m.Data))
}, stan.DeliverAllAvailable())
39 . 1
NATS Streaming: Ruby Client
require 'stan/client'
sc = STAN::Client.new
# Customize connection to NATS
opts = { servers: ["nats://127.0.0.1:4222"] }
sc.connect("test-cluster", "client-123", nats: opts)
# Simple async subscriber
sub = sc.subscribe("foo", start_at: :first) do |msg|
puts "Received a message (seq=#{msg.seq}): #{msg.data}"
end
# Synchronous Publisher, does not return until an ack
# has been received from NATS Streaming.
sc.publish("foo", "hello world")
40 . 1
NATS Streaming: Python Client
nc = NATS()
await nc.connect(io_loop=loop)
sc = STAN()
await sc.connect("test-cluster", "client-123", nats=nc)
await sc.publish("hi", b'hello')
async def cb(msg):
print("Received a message (seq={}): {}".format(msg.seq, msg.data))
# Subscribe to get all messages since beginning.
sub = await sc.subscribe("hi", start_at='first', cb=cb)
await sub.unsubscribe()
41 . 1
NATS Streaming: Node.js Client
var stan = require('node-nats-streaming').connect('test-cluster', 'test');
stan.on('connect', function () {
stan.publish('hello', 'world', function(err, guid){ /*...*/ });
var opts = stan.subscriptionOptions().setStartWithLastReceived();
var subscription = stan.subscribe('hello', opts);
subscription.on('message', function (msg) {
console.log('Received [' + msg.getSequence() + '] ' + msg.getData());
});
});
42 . 1
NATS Streaming: Java Client
StreamingConnectionFactory cf = new StreamingConnectionFactory("test-cluster", "bar");
StreamingConnection sc = cf.createConnection();
sc.publish("foo", "Hello World".getBytes());
Subscription sub = sc.subscribe("foo", new MessageHandler() {
public void onMessage(Message m) {
System.out.printf("Received a message: %sn", new String(m.getData()));
doneSignal.countDown();
}
}, new SubscriptionOptions.Builder().deliverAllAvailable().build());
43 . 1
NATS Streaming: C# Client
var cf = new StanConnectionFactory();
using (var c = cf.CreateConnection("test-cluster", "appname"))
{
using (c.Subscribe("foo", (obj, args) =>
{
Console.WriteLine(
System.Text.Encoding.UTF8.GetString(args.Message.Data));
}))
{
c.Publish("foo", System.Text.Encoding.UTF8.GetBytes("hello"));
}
}
44 . 1
Also of cially supported by the NATS team
45 . 1
Remember: There are 2 servers
NATS Server / gnatsd
NATS Streaming Server / nats-streaming-server
NATS Streaming itself uses the NATS Server: Two birds, one stone
https://github.com/nats-io/gnatsd
https://github.com/nats-io/nats-streaming-server
46 . 1
Demos
47 . 1
Congrats!
Now you're ready to start using
/github.com/nats-io @nats_io
https://nats.io/
48 . 1

More Related Content

What's hot

A New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & ConnectivityA New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & ConnectivityNATS
Β 
NATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
NATS: Simple, Secure and Scalable Messaging For the Cloud Native EraNATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
NATS: Simple, Secure and Scalable Messaging For the Cloud Native Erawallyqs
Β 
Simple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder MeetupSimple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder MeetupApcera
Β 
The Zen of High Performance Messaging with NATS (Strange Loop 2016)
The Zen of High Performance Messaging with NATS (Strange Loop 2016)The Zen of High Performance Messaging with NATS (Strange Loop 2016)
The Zen of High Performance Messaging with NATS (Strange Loop 2016)wallyqs
Β 
NATS for Modern Messaging and Microservices
NATS for Modern Messaging and MicroservicesNATS for Modern Messaging and Microservices
NATS for Modern Messaging and MicroservicesApcera
Β 
NATS + Docker meetup talk Oct - 2016
NATS + Docker meetup talk Oct - 2016NATS + Docker meetup talk Oct - 2016
NATS + Docker meetup talk Oct - 2016wallyqs
Β 
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATSDeep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATSNATS
Β 
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATSDeploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATSNATS
Β 
How Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine LearningHow Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine LearningApcera
Β 
Easy, Secure, and Fast: Using NATS.io for Streams and Services
Easy, Secure, and Fast: Using NATS.io for Streams and ServicesEasy, Secure, and Fast: Using NATS.io for Streams and Services
Easy, Secure, and Fast: Using NATS.io for Streams and ServicesNATS
Β 
NATS Connect Live | NATS as a Service Mesh
NATS Connect Live | NATS as a Service MeshNATS Connect Live | NATS as a Service Mesh
NATS Connect Live | NATS as a Service MeshNATS
Β 
KubeConEU - NATS Deep Dive
KubeConEU - NATS Deep DiveKubeConEU - NATS Deep Dive
KubeConEU - NATS Deep Divewallyqs
Β 
KubeCon NA 2019 Keynote | NATS - Past, Present, and the Future
KubeCon NA 2019 Keynote | NATS - Past, Present, and the FutureKubeCon NA 2019 Keynote | NATS - Past, Present, and the Future
KubeCon NA 2019 Keynote | NATS - Past, Present, and the FutureNATS
Β 

What's hot (13)

A New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & ConnectivityA New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & Connectivity
Β 
NATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
NATS: Simple, Secure and Scalable Messaging For the Cloud Native EraNATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
NATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
Β 
Simple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder MeetupSimple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder Meetup
Β 
The Zen of High Performance Messaging with NATS (Strange Loop 2016)
The Zen of High Performance Messaging with NATS (Strange Loop 2016)The Zen of High Performance Messaging with NATS (Strange Loop 2016)
The Zen of High Performance Messaging with NATS (Strange Loop 2016)
Β 
NATS for Modern Messaging and Microservices
NATS for Modern Messaging and MicroservicesNATS for Modern Messaging and Microservices
NATS for Modern Messaging and Microservices
Β 
NATS + Docker meetup talk Oct - 2016
NATS + Docker meetup talk Oct - 2016NATS + Docker meetup talk Oct - 2016
NATS + Docker meetup talk Oct - 2016
Β 
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATSDeep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Β 
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATSDeploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Β 
How Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine LearningHow Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine Learning
Β 
Easy, Secure, and Fast: Using NATS.io for Streams and Services
Easy, Secure, and Fast: Using NATS.io for Streams and ServicesEasy, Secure, and Fast: Using NATS.io for Streams and Services
Easy, Secure, and Fast: Using NATS.io for Streams and Services
Β 
NATS Connect Live | NATS as a Service Mesh
NATS Connect Live | NATS as a Service MeshNATS Connect Live | NATS as a Service Mesh
NATS Connect Live | NATS as a Service Mesh
Β 
KubeConEU - NATS Deep Dive
KubeConEU - NATS Deep DiveKubeConEU - NATS Deep Dive
KubeConEU - NATS Deep Dive
Β 
KubeCon NA 2019 Keynote | NATS - Past, Present, and the Future
KubeCon NA 2019 Keynote | NATS - Past, Present, and the FutureKubeCon NA 2019 Keynote | NATS - Past, Present, and the Future
KubeCon NA 2019 Keynote | NATS - Past, Present, and the Future
Β 

Similar to Simple, Secure, Scalable Messaging for the Cloud Native Era - AllThingsOpen 2017 Talk

Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm NATS
Β 
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and SwarmSimple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and SwarmApcera
Β 
The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATSThe Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATSApcera
Β 
The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATS The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATS NATS
Β 
NATS for Rubyists - Tokyo Rubyist Meetup
NATS for Rubyists - Tokyo Rubyist MeetupNATS for Rubyists - Tokyo Rubyist Meetup
NATS for Rubyists - Tokyo Rubyist Meetupwallyqs
Β 
Writing Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talkWriting Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talkNATS
Β 
GopherFest 2017 talk - Adding Context to NATS
GopherFest 2017 talk - Adding Context to NATSGopherFest 2017 talk - Adding Context to NATS
GopherFest 2017 talk - Adding Context to NATSNATS
Β 
Gopher fest 2017: Adding Context To NATS
Gopher fest 2017: Adding Context To NATSGopher fest 2017: Adding Context To NATS
Gopher fest 2017: Adding Context To NATSApcera
Β 
OSCON: Building Cloud Native Apps with NATS
OSCON:  Building Cloud Native Apps with NATSOSCON:  Building Cloud Native Apps with NATS
OSCON: Building Cloud Native Apps with NATSwallyqs
Β 
Mysql Latency
Mysql LatencyMysql Latency
Mysql Latencysrubinstein
Β 
Implementing Domain Events with Kafka
Implementing Domain Events with KafkaImplementing Domain Events with Kafka
Implementing Domain Events with KafkaAndrei Rugina
Β 
Splunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the messageSplunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the messageDamien Dallimore
Β 
Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1KlaraOrban
Β 
Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101Timothy Spann
Β 
Fully fault tolerant real time data pipeline with docker and mesos
Fully fault tolerant real time data pipeline with docker and mesos Fully fault tolerant real time data pipeline with docker and mesos
Fully fault tolerant real time data pipeline with docker and mesos Rahul Kumar
Β 
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)Jakub Botwicz
Β 
Distribute Key Value Store
Distribute Key Value StoreDistribute Key Value Store
Distribute Key Value StoreSantal Li
Β 
Distribute key value_store
Distribute key value_storeDistribute key value_store
Distribute key value_storedrewz lin
Β 
Princeton Dec 2022 Meetup_ StreamNative and Cloudera Streaming
Princeton Dec 2022 Meetup_ StreamNative and Cloudera StreamingPrinceton Dec 2022 Meetup_ StreamNative and Cloudera Streaming
Princeton Dec 2022 Meetup_ StreamNative and Cloudera StreamingTimothy Spann
Β 

Similar to Simple, Secure, Scalable Messaging for the Cloud Native Era - AllThingsOpen 2017 Talk (20)

Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Β 
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and SwarmSimple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Β 
The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATSThe Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATS
Β 
The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATS The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATS
Β 
NATS for Rubyists - Tokyo Rubyist Meetup
NATS for Rubyists - Tokyo Rubyist MeetupNATS for Rubyists - Tokyo Rubyist Meetup
NATS for Rubyists - Tokyo Rubyist Meetup
Β 
Writing Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talkWriting Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talk
Β 
GopherFest 2017 talk - Adding Context to NATS
GopherFest 2017 talk - Adding Context to NATSGopherFest 2017 talk - Adding Context to NATS
GopherFest 2017 talk - Adding Context to NATS
Β 
Gopher fest 2017: Adding Context To NATS
Gopher fest 2017: Adding Context To NATSGopher fest 2017: Adding Context To NATS
Gopher fest 2017: Adding Context To NATS
Β 
OSCON: Building Cloud Native Apps with NATS
OSCON:  Building Cloud Native Apps with NATSOSCON:  Building Cloud Native Apps with NATS
OSCON: Building Cloud Native Apps with NATS
Β 
Mysql Latency
Mysql LatencyMysql Latency
Mysql Latency
Β 
Implementing Domain Events with Kafka
Implementing Domain Events with KafkaImplementing Domain Events with Kafka
Implementing Domain Events with Kafka
Β 
Splunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the messageSplunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the message
Β 
Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1
Β 
MQTT with .NET Core
MQTT with .NET CoreMQTT with .NET Core
MQTT with .NET Core
Β 
Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101
Β 
Fully fault tolerant real time data pipeline with docker and mesos
Fully fault tolerant real time data pipeline with docker and mesos Fully fault tolerant real time data pipeline with docker and mesos
Fully fault tolerant real time data pipeline with docker and mesos
Β 
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
Β 
Distribute Key Value Store
Distribute Key Value StoreDistribute Key Value Store
Distribute Key Value Store
Β 
Distribute key value_store
Distribute key value_storeDistribute key value_store
Distribute key value_store
Β 
Princeton Dec 2022 Meetup_ StreamNative and Cloudera Streaming
Princeton Dec 2022 Meetup_ StreamNative and Cloudera StreamingPrinceton Dec 2022 Meetup_ StreamNative and Cloudera Streaming
Princeton Dec 2022 Meetup_ StreamNative and Cloudera Streaming
Β 

More from NATS

RethinkConn 2022!
RethinkConn 2022!RethinkConn 2022!
RethinkConn 2022!NATS
Β 
NATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATS
NATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATSNATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATS
NATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATSNATS
Β 
NATS Connect Live!
NATS Connect Live!NATS Connect Live!
NATS Connect Live!NATS
Β 
NATS Connect Live | SwimOS & NATS
NATS Connect Live | SwimOS & NATSNATS Connect Live | SwimOS & NATS
NATS Connect Live | SwimOS & NATSNATS
Β 
NATS Connect Live | Pub/Sub on the Power Grid
NATS Connect Live | Pub/Sub on the Power GridNATS Connect Live | Pub/Sub on the Power Grid
NATS Connect Live | Pub/Sub on the Power GridNATS
Β 
NATS Connect Live | Distributed Identity & Authorization
NATS Connect Live | Distributed Identity & AuthorizationNATS Connect Live | Distributed Identity & Authorization
NATS Connect Live | Distributed Identity & AuthorizationNATS
Β 
NATS Connect Live | Resgate
NATS Connect Live | ResgateNATS Connect Live | Resgate
NATS Connect Live | ResgateNATS
Β 
NATS Connect Live | NATS & Augmented Reality
NATS Connect Live | NATS & Augmented RealityNATS Connect Live | NATS & Augmented Reality
NATS Connect Live | NATS & Augmented RealityNATS
Β 
OSCON 2019 | Time to Think Different
OSCON 2019 | Time to Think DifferentOSCON 2019 | Time to Think Different
OSCON 2019 | Time to Think DifferentNATS
Β 
NATS vs HTTP for Interservice Communication
NATS vs HTTP for Interservice CommunicationNATS vs HTTP for Interservice Communication
NATS vs HTTP for Interservice CommunicationNATS
Β 
Using NATS for Control Flow in Distributed Systems
Using NATS for Control Flow in Distributed SystemsUsing NATS for Control Flow in Distributed Systems
Using NATS for Control Flow in Distributed SystemsNATS
Β 
Integration Patterns for Microservices Architectures
Integration Patterns for Microservices ArchitecturesIntegration Patterns for Microservices Architectures
Integration Patterns for Microservices ArchitecturesNATS
Β 
Simple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder Meetup Simple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder Meetup NATS
Β 
Actor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupActor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupNATS
Β 
NATS for Modern Messaging and Microservices
NATS for Modern Messaging and Microservices NATS for Modern Messaging and Microservices
NATS for Modern Messaging and Microservices NATS
Β 
Implementing Microservices with NATS
Implementing Microservices with NATSImplementing Microservices with NATS
Implementing Microservices with NATSNATS
Β 
How Greta uses NATS to revolutionize data distribution on the Internet
How Greta uses NATS to revolutionize data distribution on the Internet How Greta uses NATS to revolutionize data distribution on the Internet
How Greta uses NATS to revolutionize data distribution on the Internet NATS
Β 
How Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine Learning How Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine Learning NATS
Β 

More from NATS (18)

RethinkConn 2022!
RethinkConn 2022!RethinkConn 2022!
RethinkConn 2022!
Β 
NATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATS
NATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATSNATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATS
NATS Connect Live | Serverless on Kubernetes with OpenFaaS & NATS
Β 
NATS Connect Live!
NATS Connect Live!NATS Connect Live!
NATS Connect Live!
Β 
NATS Connect Live | SwimOS & NATS
NATS Connect Live | SwimOS & NATSNATS Connect Live | SwimOS & NATS
NATS Connect Live | SwimOS & NATS
Β 
NATS Connect Live | Pub/Sub on the Power Grid
NATS Connect Live | Pub/Sub on the Power GridNATS Connect Live | Pub/Sub on the Power Grid
NATS Connect Live | Pub/Sub on the Power Grid
Β 
NATS Connect Live | Distributed Identity & Authorization
NATS Connect Live | Distributed Identity & AuthorizationNATS Connect Live | Distributed Identity & Authorization
NATS Connect Live | Distributed Identity & Authorization
Β 
NATS Connect Live | Resgate
NATS Connect Live | ResgateNATS Connect Live | Resgate
NATS Connect Live | Resgate
Β 
NATS Connect Live | NATS & Augmented Reality
NATS Connect Live | NATS & Augmented RealityNATS Connect Live | NATS & Augmented Reality
NATS Connect Live | NATS & Augmented Reality
Β 
OSCON 2019 | Time to Think Different
OSCON 2019 | Time to Think DifferentOSCON 2019 | Time to Think Different
OSCON 2019 | Time to Think Different
Β 
NATS vs HTTP for Interservice Communication
NATS vs HTTP for Interservice CommunicationNATS vs HTTP for Interservice Communication
NATS vs HTTP for Interservice Communication
Β 
Using NATS for Control Flow in Distributed Systems
Using NATS for Control Flow in Distributed SystemsUsing NATS for Control Flow in Distributed Systems
Using NATS for Control Flow in Distributed Systems
Β 
Integration Patterns for Microservices Architectures
Integration Patterns for Microservices ArchitecturesIntegration Patterns for Microservices Architectures
Integration Patterns for Microservices Architectures
Β 
Simple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder Meetup Simple Solutions for Complex Problems - Boulder Meetup
Simple Solutions for Complex Problems - Boulder Meetup
Β 
Actor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupActor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder Meetup
Β 
NATS for Modern Messaging and Microservices
NATS for Modern Messaging and Microservices NATS for Modern Messaging and Microservices
NATS for Modern Messaging and Microservices
Β 
Implementing Microservices with NATS
Implementing Microservices with NATSImplementing Microservices with NATS
Implementing Microservices with NATS
Β 
How Greta uses NATS to revolutionize data distribution on the Internet
How Greta uses NATS to revolutionize data distribution on the Internet How Greta uses NATS to revolutionize data distribution on the Internet
How Greta uses NATS to revolutionize data distribution on the Internet
Β 
How Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine Learning How Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine Learning
Β 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
Β 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
Β 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
Β 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
Β 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
Β 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto GonzΓ‘lez Trastoy
Β 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
Β 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
Β 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
Β 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
Β 
(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...
(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...
(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...gurkirankumar98700
Β 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
Β 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
Β 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
Β 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
Β 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
Β 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
Β 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
Β 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
Β 

Recently uploaded (20)

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
Β 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
Β 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Β 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
Β 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Β 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Β 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Β 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
Β 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Β 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Β 
(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...
(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...
(Genuine) Escort Service Lucknow | Starting β‚Ή,5K To @25k with A/C πŸ§‘πŸ½β€β€οΈβ€πŸ§‘πŸ» 89...
Β 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
Β 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Β 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Β 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
Β 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
Β 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
Β 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
Β 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
Β 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
Β 

Simple, Secure, Scalable Messaging for the Cloud Native Era - AllThingsOpen 2017 Talk

  • 1. γ€€γ€€γ€€γ€€ Simple, Secure and Scalable Messaging For The Cloud Native Era Waldemar Quevedo / All Things Open / October 2017 @wallyqs 1 . 1
  • 2. Agenda Intro to the NATS project NATS & NATS Streaming Overview Demos 2 . 1
  • 3. NATS is a simple, high performance open source messaging system for cloud native applications. 3 . 1
  • 4. Facts about NATS Written by Derek Collison in 2010, originally for CloudFoundry Initial implementation in Ruby, was then rewritten in Go in 2012 Project used in production environments for ~7 years NATS Server v1.0.0 milestone reached in July 2017 Github Organization: https://github.com/nats-io 4 . 1
  • 6. Stats about NATS NATS Server can process above +11M messages per second (w/ nats-bench) 6 . 1
  • 7. Stats about NATS Reliable Low Latency Pub Sub! Source: http://bravenewgeek.com/benchmarking-message-queue-latency/ 7 . 1
  • 12. Simplicity in NATS Plain text protocol with few commands β†’ Simple network clients & API 7MB binary with no dependencies β†’ Small Docker image Fire & Forget Pub Sub on top of TCP/IP | PUB | SUB | UNSUB | CONNECT | INFO | MSG | -ERR | +OK | PING | PONG | telnet demo.nats.io 4222 Connected to demo.nats.io. INFO {"server_id":"Fzwx2ndlHFg3lvVwwdBRSe","tls_required":false,...,"max_payload":1048576} SUB hello 1 +OK PUB hello 5 world +OK MSG hello 1 5 world 12 . 1
  • 13. Basic API: Go Client package main import ( "log" "github.com/nats-io/go-nats" ) func main(){ nc, err := nats.Connect("nats://127.0.0.1:4222") if err != nil { log.Fatalf("Error: %s", err) } done := make(chan struct{}) nc.Subscribe("hello", func(m *nats.Msg){ log.Printf("[Received] %s", string(m.Data)) done <- struct{}{} }) nc.Publish("hello", []byte("world")) <-done } 13 . 1
  • 14. Basic API: Ruby Client require 'nats/client' NATS.start do |nc| nc.subscribe("hello") do |msg| puts "[Received] #{msg}" end nc.publish("hello", "world") end 14 . 1
  • 15. Basic API: Python Client await nc.connect() async def handler(msg): print("[Received] {data}".format( data=msg.data.decode())) # Coroutine based subscriber await nc.subscribe("foo", cb=handler) await nc.publish("foo", "bar") 15 . 1
  • 16. Basic API: Node.js Client var nats = require('nats').connect(); // Simple Publisher nats.publish('foo', 'Hello World!'); // Simple Subscriber nats.subscribe('foo', function(msg) { console.log('[Received] ' + msg); }); 16 . 1
  • 17. Basic API: C Client natsConnection_Publish(nc,"foo",data,5); natsConnection_Subscribe(&sub,nc,"foo",onMsg, NULL); void onMsg(natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure) { printf("[Received] %.*sn", natsMsg_GetData(msg)); // ... } 17 . 1
  • 18. Basic API: C# Client using NATS.Client; ConnectionFactory cf = new ConnectionFactory(); IConnection c = cf.CreateConnection(); ISyncSubscription sSync = c.SubscribeSync("hello"); // Wait up to 1000 ms for next message Msg m = sSync.NextMessage(1000); c.Publish("hello", Encoding.UTF8.GetBytes("world")); 18 . 1
  • 19. Basic API: Java Client Connection nc = Nats.connect(); nc.subscribe("foo", m -> { System.out.printf("Received a message: %sn", new String(m.getData())); }); nc.publish("foo", "Hello World".getBytes()); 19 . 1
  • 20. Clients of cially supported by the NATS team 20 . 1
  • 22. Protection against Slow Consumers package main import ( "log" "github.com/nats-io/go-nats" ) func main(){ nc, err := nats.Connect("nats://127.0.0.1:4222") if err != nil { log.Fatalf("Error: %s", err) } n := 0 total := 1000000000 done := make(chan struct{}) nc.Subscribe("hello", func(m *nats.Msg){ n++ if n == total { close(done) } }) for i := 0; i < total; i++ { nc.Publish("hello", []byte("world")) } select { case <-done: } } 22 . 1
  • 23. Protection against Slow Consumers Server disconnects client with Slow Consumer error Client was too slow at processing the received messages. [33682] 2017/10/19 07:52:51.647917 [INF] Starting nats-server version 0.9.6 [33682] 2017/10/19 07:52:51.648085 [INF] Starting http monitor on 0.0.0.0:8222 [33682] 2017/10/19 07:52:51.648631 [INF] Listening for client connections on 0.0.0.0:4222 [33682] 2017/10/19 07:52:51.648691 [INF] Server is ready [33682] 2017/10/19 07:52:55.376292 [INF] 127.0.0.1:63184 - cid:1 - Slow Consumer Detected [33682] 2017/10/19 07:52:57.424381 [INF] 127.0.0.1:63185 - cid:2 - Slow Consumer Detected [33682] 2017/10/19 07:52:59.478090 [INF] 127.0.0.1:63186 - cid:3 - Slow Consumer Detected [33682] 2017/10/19 07:53:01.541496 [INF] 127.0.0.1:63188 - cid:4 - Slow Consumer Detected 23 . 1
  • 24. NATS Server Cluster High Availability via full-mesh cluster topology 24 . 1
  • 25. NATS Server Cluster High Availability via full-mesh cluster topology 25 . 1
  • 26. NATS & Delivery Guarantees The NATS Server is re & forget, providing at-most once delivery. This means that if the consumer is not connected it will not receive the message! 26 . 1
  • 27. Is NATS a Message Broker/Queue? From the book (Kleppmann, O'Reilly) "a message broker (also known as a message queue), is essentially a kind of database that is optimized for handling message streams." βŒγ€€ Designing Data-Intensive Applications 27 . 1
  • 28. Is NATS a Message Broker/Queue? From the book (Kleppmann, O'Reilly) "By centralizing the data in the broker, these systems can more easily tolerate clients that come and go (connect, disconnect, and crash) "the question of durability is moved to the broker instead βŒγ€€ Designing Data-Intensive Applications 28 . 1
  • 29. Is NATS a Message Broker/Queue? From the book (Kleppmann, O'Reilly) "Faced with slow consumers, they generally allow unbounded queueing (as opposed to dropping messages or backpressure) βŒγ€€ Designing Data-Intensive Applications 29 . 1
  • 30. The NATS Server does none of that! It's the total opposite. 30 . 1
  • 33. NATS Streaming Supports at-least-once delivery model and durability of messages Rate limiting & message redelivery features First release in 2016 33 . 1
  • 34. NATS Streaming: How it works Designed as a request/response protocol which uses NATS as its transport. 34 . 1
  • 35. NATS Streaming: How it works Designed as a request/response protocol which uses NATS as its transport. 35 . 1
  • 36. NATS Streaming: How it works Designed as a request/response protocol which uses NATS as its transport. 36 . 1
  • 37. NATS Streaming: How it works Designed as a request/response protocol which uses NATS as its transport. 37 . 1
  • 38. NATS Streaming Clustering Clustering support in the works! To be fair, you have to have a very high IQ to understand Rick & Morty clustering https://github.com/nats-io/nats-streaming-server/issues/316 38 . 1
  • 39. NATS Streaming: Go Client Publish and persist a message Start with last received message Receive all messages sc, _ := stan.Connect(clusterID, clientID) sc.Publish("foo", []byte("Hello World")) sub, err := sc.Subscribe("foo", func(m *stan.Msg) { fmt.Printf("Received a message: %sn", string(m.Data)) }) sub, err := sc.Subscribe("foo", func(m *stan.Msg) { fmt.Printf("Received a message: %sn", string(m.Data)) }, stan.DeliverAllAvailable()) 39 . 1
  • 40. NATS Streaming: Ruby Client require 'stan/client' sc = STAN::Client.new # Customize connection to NATS opts = { servers: ["nats://127.0.0.1:4222"] } sc.connect("test-cluster", "client-123", nats: opts) # Simple async subscriber sub = sc.subscribe("foo", start_at: :first) do |msg| puts "Received a message (seq=#{msg.seq}): #{msg.data}" end # Synchronous Publisher, does not return until an ack # has been received from NATS Streaming. sc.publish("foo", "hello world") 40 . 1
  • 41. NATS Streaming: Python Client nc = NATS() await nc.connect(io_loop=loop) sc = STAN() await sc.connect("test-cluster", "client-123", nats=nc) await sc.publish("hi", b'hello') async def cb(msg): print("Received a message (seq={}): {}".format(msg.seq, msg.data)) # Subscribe to get all messages since beginning. sub = await sc.subscribe("hi", start_at='first', cb=cb) await sub.unsubscribe() 41 . 1
  • 42. NATS Streaming: Node.js Client var stan = require('node-nats-streaming').connect('test-cluster', 'test'); stan.on('connect', function () { stan.publish('hello', 'world', function(err, guid){ /*...*/ }); var opts = stan.subscriptionOptions().setStartWithLastReceived(); var subscription = stan.subscribe('hello', opts); subscription.on('message', function (msg) { console.log('Received [' + msg.getSequence() + '] ' + msg.getData()); }); }); 42 . 1
  • 43. NATS Streaming: Java Client StreamingConnectionFactory cf = new StreamingConnectionFactory("test-cluster", "bar"); StreamingConnection sc = cf.createConnection(); sc.publish("foo", "Hello World".getBytes()); Subscription sub = sc.subscribe("foo", new MessageHandler() { public void onMessage(Message m) { System.out.printf("Received a message: %sn", new String(m.getData())); doneSignal.countDown(); } }, new SubscriptionOptions.Builder().deliverAllAvailable().build()); 43 . 1
  • 44. NATS Streaming: C# Client var cf = new StanConnectionFactory(); using (var c = cf.CreateConnection("test-cluster", "appname")) { using (c.Subscribe("foo", (obj, args) => { Console.WriteLine( System.Text.Encoding.UTF8.GetString(args.Message.Data)); })) { c.Publish("foo", System.Text.Encoding.UTF8.GetBytes("hello")); } } 44 . 1
  • 45. Also of cially supported by the NATS team 45 . 1
  • 46. Remember: There are 2 servers NATS Server / gnatsd NATS Streaming Server / nats-streaming-server NATS Streaming itself uses the NATS Server: Two birds, one stone https://github.com/nats-io/gnatsd https://github.com/nats-io/nats-streaming-server 46 . 1
  • 48. Congrats! Now you're ready to start using /github.com/nats-io @nats_io https://nats.io/ 48 . 1