zlacker

High-Performance server for NATS.io, the cloud and edge native messaging system

submitted by Kinran+(OP) on 2023-07-21 22:04:57 | 146 points 72 comments
[view article] [source] [go to bottom]

NOTE: showing posts with links only show all posts
◧◩
4. paulgb+gQ4[view] [source] [discussion] 2023-07-23 19:57:46
>>jitl+dM4
MQTT is a protocol rather than an alternative to NATS; NATS supports MQTT (https://docs.nats.io/running-a-nats-service/configuration/mq...)

As far as ideal use cases, we use NATS for https://plane.dev in two ways:

- As a message bus, it is a layer of abstraction on top of the network. Instead of each node needing to establish a connection to every node it needs to connect to, it just connects to a NATS cluster and messages are routed by subject. This is great for debugging because we can "wiretap" messages on a given subject pattern and verify what's being sent. We even have a service that listens on NATS subjects and conditionally turns events into Slack messages.

- It has a built-in RAFT implementation (via JetStream), which we piggyback on when we need to create consensus among nodes.

◧◩
7. vosper+f25[view] [source] [discussion] 2023-07-23 21:15:03
>>pnpnp+PO4
Any thoughts on NATS' JetStream? Looks quite compelling, to me.

https://docs.nats.io/using-nats/developer/develop_jetstream

15. gjvc+Vk5[view] [source] 2023-07-23 23:23:50
>>Kinran+(OP)
not to be confused with https://www.nats.aero/
◧◩◪◨⬒
28. protoc+XM5[view] [source] [discussion] 2023-07-24 03:29:15
>>vosper+RD5
You could do something in that vein, but it might be easier to have those streams all actually deliver to a set of consumers and write a bit of code to join them back together. https://natsbyexample.com/examples/jetstream/multi-stream-co... has an example (also a great resource for learning about NATS use cases!)
29. protoc+ON5[view] [source] 2023-07-24 03:37:29
>>Kinran+(OP)
I work quite a bit with CNCF wasmCloud (https://wasmcloud.com/) and that project wouldn't exist without NATS. You can think of wasmCloud as a distributed compute lattice using WebAssembly on the server for providing the compute and NATS to provide the interconnectivity between your various WebAssembly modules.

NATS certainly has its quirks, but I can't recommend it highly enough if you need any sort of pub/sub or stream processing. It even has built-in key-value and object storage for when you need to store larger messages or content. I definitely prefer Jetstream to Kafka in pretty much every use case I can think of. At my current employer (https://cosmonic.com) we use NATS not only for wasmCloud, but we also stream log data and metrics and it keeps up with everything we throw at it with a very low footprint. Auth is kind of counterintuitive until you've spent some time with it, but NATS provides you with a ton of flexibility (docs here: https://docs.nats.io/running-a-nats-service/configuration/se...).

https://natsbyexample.com/ is a great resource, and can do a better job than I can in illustrating the various ways NATS can be used along with different deployment topologies.

32. no_cir+xS5[view] [source] 2023-07-24 04:35:12
>>Kinran+(OP)
TIBCO Rednezvous, https://www.tibco.com/products/tibco-rendezvous, is the first thing that came to my mind from previous experience in the financial industry working with real-time market data. Although I'm not sure if it has built-in KV support for dealing with large payloads like NATS does, TIBCO RV and their related software packages are worth checking out to see what an long time established commercial product offers. Which leads me to...

... the protocol is text-based like HTTP with CR LF for field both for the client, https://docs.nats.io/reference/reference-protocols/nats-prot..., and cluster protocols, https://docs.nats.io/reference/reference-protocols/nats-serv... -- which means encoding overhead if your payloads are binary. So depending on your definition of performance, ymmv.

I really do not see how implementing an API across multiple languages is easier by making a new linefeed-based protocol, https://github.com/nats-io/nats-server/blob/0421c65c888bf381..., than just using code-generated JSON or gRPC (Protobuf or Flatbuffers). One could then write subscriptions/clustering algorithms in a protocol-neutral library.

35. jensne+rW5[view] [source] 2023-07-24 05:20:46
>>Kinran+(OP)
We've recently built an adapter for NATS KV so you can easily expose it through an HTTP-based GraphQL API. (https://docs.wundergraph.com/docs/databases/kv) We're also looking at supporting streams in the future.

What's great is that NATS is written in go and we can easily embed it for testing and dev purposes. Furthermore, Synadia makes it super easy to run NATS across multiple regions.

◧◩◪◨
36. klabb3+MW5[view] [source] [discussion] 2023-07-24 05:24:40
>>zerbin+if5
Jetstream has real time replay[1], and you can easily pick a starting time, and continue to stream new events as well.

But yes, to be able to replay without side effects you’ll want to make sure you’re setting up the consumers correctly. That may need some custom logic, but isn’t that necessary with any message queue?

[1]: https://docs.nats.io/using-nats/developer/develop_jetstream

◧◩
38. throw1+g36[view] [source] [discussion] 2023-07-24 06:34:45
>>throw1+X26
Ahh, they may work on QUIC this year: https://github.com/nats-io/nats-server/issues/457
◧◩◪◨⬒⬓
45. vosper+fa6[view] [source] [discussion] 2023-07-24 07:35:41
>>yes299+rG5
Yes you may well be right, that's kind of what I'm wondering (not using either Kafka or NATS today). Correct me if I'm wrong, but Kafka itself doesn't do joins either, right? I would need something like Flink's Window Join?

https://nightlies.apache.org/flink/flink-docs-master/docs/de...

◧◩
49. Sebast+Yr6[view] [source] [discussion] 2023-07-24 10:01:35
>>lakome+np5
Nats provides a nice CLI that can help with debugging: https://github.com/nats-io/natscli

Besides that I'm also working on a UI solution, that will help to get better overview of your cluster: https://qaze.app/

◧◩◪◨
59. no_cir+ZM7[view] [source] [discussion] 2023-07-24 16:25:31
>>klabb3+4W5
The only developers that would likely need to debug binary protocols are the framework developer themselves. It would be an extremely rare occurrence for someone to need to use a binary/hex viewer to figure out what is going wrong with their "app". Perhaps you are thinking of telemetry/introspection of one's own messages? In that case there usually is a library call to convert them to a human readable format like JSON, e.g., https://protobuf.dev/programming-guides/proto3/#json.

IMO it is a real waste of developer time to code up a new transport protocol without determining that the existing ones don't work or don't perform as well as needed. Multiply that by all the programming languages that need to be supported... when instead the client APIs could have been mostly code generated.

Although may only apply to the "client-side" API, what is going in the message payload? JSON probably, or some other serialization format. I don't think a lot of developers are hand writing parsers for their own payloads. The overhead of the JSON or Protobuf parser is already in there.

◧◩
61. coder5+hZ7[view] [source] [discussion] 2023-07-24 17:15:00
>>no_cir+xS5
I'm not sure how much it will reduce your skepticism, but I believe NATS was actually created by the same person who created TIBCO RV: https://twitter.com/derekcollison/status/1163299967089254402

Derek seems like the kind of person who might know a thing or two about messaging systems.

I really like what NATS has become, and I do appreciate the simplicity of the protocol.

◧◩
62. rcomba+339[view] [source] [discussion] 2023-07-24 22:48:39
>>evnix+se6
(note that NATS Streaming is a now deprecated predecessor to NATS JetStream)

Pull does have advantages over push (e.g. one-to-one flow control since the transfer of the messages is initiated by the client (pull requests)), and they are basically functionally equivalent (only thing push can do that pull can not is send a copy of all the message to all the subscribers, should you ever need it). They both exists because historically push came first and then pull later).

As a developper using NATS JetStream you should really not have to worry about push or pull, you should just care whether you want to consume the messages via call back or via an iterator or via fetching batches, after that whether pull or push is being used underneath the covers is irrelevant to you.

And this is exactly how it is in the new JetStream API (https://github.com/nats-io/nats.go/tree/main/jetstream#readm...) you don't have to worry about push/pull anymore and you can consume in any of the 3 ways described above (callback, iterator, fetch batch) it's all a lot simpler and easier to use.

◧◩◪◨⬒⬓
63. rcomba+j39[view] [source] [discussion] 2023-07-24 22:50:20
>>Kinran+xY6
See https://github.com/nats-io/nats.go/tree/main/jetstream#readm...
◧◩
65. rcomba+n59[view] [source] [discussion] 2023-07-24 23:05:16
>>jonath+ah6
It supports clients connecting over TCP (which can be encrypted) and Websockets (can also be encrypted), you can configure it to pick on any port you want and it works through Network Address Translation (see https://docs.nats.io/running-a-nats-service/configuration#co...). Even supports MQTT clients directly (https://docs.nats.io/running-a-nats-service/configuration/mq...)
◧◩◪◨
66. rcomba+k69[view] [source] [discussion] 2023-07-24 23:14:36
>>lakome+MX6
The 'auth callout' feature introduced in NATS 2.10 is there exactly for that (integrating NATS auth with whatever existing IdP system you already have): the client app passes whatever you use as it's credentials at connection time the server then passes them to the security callout service (something you write, following a template that receives whatever the client app passed as credentials and then works with whatever system you have to check those credentials and whatnot and then generates on the fly and returns to the servers equivalent NATS credentials which in turns uses them for that client connection. (https://github.com/nats-io/nats-architecture-and-design/blob...)
[go to top]