Contrasting NATS with Apache Kafka

Emil Koutanov
ITNEXT
Published in
6 min readSep 2, 2020

--

TL;DR Kafka is an Event Streaming Platform, while NATS is a closer to a conventional Message Queue. Kafka is optimised around the unique needs of emerging Event-Driven Architectures, which enrich the traditional pub-sub model with strong ordering and persistence semantics. Conversely, NATS is highly optimised around pub-sub topologies, and is an excellent platform for decoupling systems where message order and reliable delivery is a non-issue.

I’ll preface this post by pointing out that there is another product — NATS Streaming — which is a different beast and is closer to Kafka. You may want to take a detour to NATS Streaming if you after an alternative event streaming platform; otherwise, read on.

Subscriptions

At its core, NATS is about publishing and listening for messages. These depend heavily on subjects which scope messages into streams or topics. Consumers subscribe to topics either verbatim (matching the topic name precisely), or using wildcards. Below is an illustration of publisher-subject-consumer relationship in NATS.

On the face of it, this isn’t diametrically opposed from Kafka, which also decouples producers and consumes by way of topics. However, their semantics differ. Kafka organises its topics into partitions — unbounded, totally ordered streams of records (Kafka’s substitute…

--

--

Software architect, an engineer, and a dad. Also an avid storyteller, maintainer of Kafdrop, and author of Effective Kafka.