Crystal NATS client outperforming the Rust and Go clients

I’ve been working for a while on updating the Crystal NATS client for v0.32+. I compared it with the Rust and Go clients and Crystal is outperforming them both. It outperforms Go in terms of scaling only, really, since the Go client has the same throughput but uses 60% more CPU, so you’d be able to get more throughput per core with Crystal.

14 Likes

Congrats! Do you have plans for NATS Streaming Server support?

@andrenth I’ve just published initial support for NATS streaming:

NATS Streaming depends heavily on the NATS request/reply model and the repo linked in my original post needs some work to perform better on that. I was only able to get 140 requests per second with it and I couldn’t figure out why, so I reimplemented vanilla NATS. In doing so, I was able to get some really great throughput boosts on both publish (almost 18M publishes/sec, up from ~13M) and subscribe (4.8M received/sec, up from 3M), too.

For request/reply, I was able to sustain 218k/sec across 200 fibers. This might also be able to go higher, too, since this benchmark had both the request and reply running inside the same process.

For streaming, I need to understand the performance characteristics a bit better but my initial benchmarks are able to receive 64k messages/sec.

I’m also going to try to work with the folks at Synadia to see if we we can work my changes to the vanilla NATS client into their repo under the nats-io namespace.

4 Likes

Nice! :slight_smile: