Feedback using NATS at

@rophilogene

Romaric Philogene | CEO @ Qovery

Who am I?

struct Profile<'a> {
    name: &'a str,
    age: u8,
    job_position: &'a str,
    company: &'a str,
    skills: Vec<&'a str>,
}

fn main() {
    let profile = Profile {
        name: "Romaric Philogene",
        age: 32,
        job_position: "CEO & Co-founder",
        company: "Qovery",
        skills: vec![
            "Kotlin",
            "Rust",
            "Python",
            "Infrastructure",
        ],
    };

    print!("{} greets you 👋", profile.name);
}

@rophilogene

@rophilogene

Qovery is a multi-cloud deployment platform

Developer

Github, Gitlab, Bitbucket

Qovery

@rophilogene

Compose your deployment flow with Qovery

@rophilogene

Multi-regions apps deployment

@rophilogene

NATS @ Qovery

Cloud-native messaging system

(incubated CNCF project 👏)

@rophilogene

NATS is easy to install (and maintain)

# Single server NATS on Kubernetes
$ kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-server/single-server-nats.yml
# Run NATS locally with Docker
$ docker run -p 4222:4222 nats
[1] 2021/02/18 14:57:09.669439 [INF] Starting nats-server version 2.1.9
[1] 2021/02/18 14:57:09.669553 [INF] Git commit [7c76626]
[1] 2021/02/18 14:57:09.669828 [INF] Starting http monitor on 0.0.0.0:8222
[1] 2021/02/18 14:57:09.669900 [INF] Listening for client connections on 0.0.0.0:4222
[1] 2021/02/18 14:57:09.669917 [INF] Server id is NDGLXRBY5JMEQ6EUY2N7ORCNXBOPFUYQDARFVZTMU2CUO7K4ZZYNVLVQ
[1] 2021/02/18 14:57:09.669926 [INF] Server is ready
[1] 2021/02/18 14:57:09.670293 [INF] Listening for route connections on 0.0.0.0:6222

Run NATS on Kubernetes

Run NATS on Docker

@rophilogene

NATS is low memory footprint

$ nats-top

nats-server version 0.6.4 (uptime: 31m42s)
Server:
  Load: CPU: 0.8%   Memory: 5.9M  Slow Consumers: 0
  In:   Msgs: 34.2K  Bytes: 3.0M  Msgs/Sec: 37.9  Bytes/Sec: 3389.7
  Out:  Msgs: 68.3K  Bytes: 6.0M  Msgs/Sec: 75.8  Bytes/Sec: 6779.4

@rophilogene

NATS is easy to use

nc, err := nats.Connect("demo.nats.io")
if err != nil {
    log.Fatal(err)
}
defer nc.Close()

// Subscribe
sub, err := nc.SubscribeSync("updates")
if err != nil {
    log.Fatal(err)
}

// Wait for a message
msg, err := sub.NextMsg(10 * time.Second)
if err != nil {
    log.Fatal(err)
}

// Use the response
log.Printf("Reply: %s", msg.Data)
nc, err := nats.Connect("demo.nats.io")
if err != nil {
    log.Fatal(err)
}
defer nc.Close()

// Use a WaitGroup to wait for a message to arrive
wg := sync.WaitGroup{}
wg.Add(1)

// Subscribe
if _, err := nc.Subscribe("updates", func(m *nats.Msg) {
    wg.Done()
}); err != nil {
    log.Fatal(err)
}

// Wait for a message to come in
wg.Wait()

Synchronous

Asynchronous

@rophilogene

Multiple subscribers

Paris

New York

Sydney

requests

requests

 requests

requests

@rophilogene

Dynamic message routing with NATS subject

engine.cust1.a

engine.cust1.b

engine.cust1.c

engine.cust2.a

engine.cust2.b

engine.cust3.a

environment deployment

command

engine.{customer_id}.{engine_id}

@rophilogene

NATS queuing with NATS subject

environment deployment

command x100

x10

with queue group

@rophilogene

To consider

1. Slow consumers = low performance

2. STAN is not as mature as Kafka - But the NATS team is working hard on it :)

3. Queue group: random load balancing. No fair load balance :(

4. No letter box - if you lose your connection, you lose all pending messages.

TO CONCLUDE 👨‍🏫

@rophilogene

To conclude 👨‍🏫

As an ops NATS is:

  • Easy to install
  • Easy to maintain (Low maintenance cost)
  • Lightweight
  • Scalable
  • Reliable
  • And built for the Cloud

As a dev NATS is:

  • Available in the most popular prog languages.
  • Easy to use

THANKS 👏

QUESTIONS?

CNCF Meetup: feedback using NATS at Qovery

By Romaric Philogène

CNCF Meetup: feedback using NATS at Qovery

  • 118