Live data from Hacker News

MQTT vs. Kafka: An IoT Advocate's Perspective

influxdata.com

71–80 of 122 posts

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#71

Earlier quoted context omitted.

And go for mqtt instead? Not a smart choice. Look, it’s going to work for a few hundred, few thousand topics. But as soon as you need resilience, replication, or you outgrow that one broker… good luck. Mqtt is awful to scale horizontally.

This comment seems backwards to me. If you're funnelling incoming messages in to hundreds of topics (or less) Kafka is a great "fat pipe" if you need millions (or tens of millions) of topics for IoT devices, MQTT is much more designed for that usecase Disclosure: I'm biased - I've worked on the MQTT spec and I'm the lead for Eclipse Amlen

You are absolutely right. That's what I said in my sibling comment so I'm not sure what's backwards. However, if your millions of little topics don't fit on a single machine - what do you do? You need a fat pipe. Hence you put your little topics into the fat pipe, send over the fat pipe to other mqtt brokers that need to disseminate egress.

Example - you have 1 topic with 1 producer and 20M consumers. Each consumer is a tcp connection. Say that you can do C1M happily, you still need 20 brokers to serve egress for all your connected clients. Now imagine that you have 100 brokers, 100M connected clients and your connections are randomly distributed over your brokers. You don't want to route every message to every broker because. So you need a fat pipe and some middle man that knows which brokers a message must be routed to because there are currently consumers connected to those brokers waiting subscribed to topics and waiting for messages. As someone who works on MQTT, you for sure understand the problem.

I have never heard of Eclipse Amlen. However, I am working with MQTT and Kafka since 2012 and have seen a nation-wide successful MQTT rollouts where MQTT and Kafka worked in tandem to solve exactly the problem you are talking about - millions of little concurrent connections distributed over a large fleet of devices for sub-100ms round trip.

It's not a competition, it's a coopoeration.

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#73
post #2

This article appears to be comparing MQTT and Kafka + Schema Registry. Using Schema Registry is not required to use Kafka, so OP overcomplicated their own set up for this comparison. There's no argument that Schema Registry is valuable, but it's not something that MQTT seems to provide out of the box, so the comparison seems flawed. I'd be interested in a comparison that is actually apples-to-apples instead of introd…

Comparing mqtt to kafka is already apples vs oranges. Adding the schema registry to this is like throwing a pitaya into the mix. Edit: after reading the article a couple of times it’s clear this isn’t a comparison. “Vs” in the title is the problem. The first impression would have been better if the title was something like ”Kafka and MQTT“. To be honest, as kafka and mqtt often reside next to each other, they complem…

[deleted]

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#74

Earlier quoted context omitted.

Those are two different technologies. Amqp is all about routing and queues. Kafka is a distributed log, it is not a queue. There’s a significant difference between those two. Kafka: every consumer for a partition within a consumer group will see a message at least once. A queue: it’s possible that a partition has multiple consumers and only one consumer sees a particular message. Kafka is relatively small to medium n…

Interesting. What are you thoughts on NSQ? https://github.com/nsqio/nsq Was looking at it earlier today, but haven't ever tried it out.

I haven’t used it so I’m not qualified to answer, sorry. I can only tell why I never used it: as far as I understand it’s possible to have data loss with nsq and there’s no replication.

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#75

An important question not mentioned in this article - and may not have been known by the author - is how much (Dev)Ops burden do each of these add? In the places I've worked that use Kafka, it's 100% always a source of issues and operational headaches. That's in fairly high throughput environments though, no idea if it "just works" flawlessly in easy going ones.

I wonder... how many issues was Kafka "soaking up" by dealing with concerns that applications and services didn't have to even consider? As in, I wonder how much application developer burden would be present if using MQTT instead.

The vast majority of "Kafka problems" (or rather "Kafka Streams problems") we have with a managed solution at work are due to not fully understanding how it works and how to set it up. There's so much stuff you can configure and so much potential to misuse it. Typical problems are wrong configuration for acks, not understanding durability guarantees, not understanding exactly-once semantics, not naming hidden topics in Kafka Streams, not using schema registry serializers for hidden topics, choosing the wrong partitioning scheme (and wanting to change it later), using Kafka clients with different hash functions, using wrong schema compatibility mode, etc. etc.

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#76

Earlier quoted context omitted.

Those are two different technologies. Amqp is all about routing and queues. Kafka is a distributed log, it is not a queue. There’s a significant difference between those two. Kafka: every consumer for a partition within a consumer group will see a message at least once. A queue: it’s possible that a partition has multiple consumers and only one consumer sees a particular message. Kafka is relatively small to medium n…

You are absolutely right, but not every project needs reliable messaging. Many projects can be just fine with ephemeral messaging, they might already have some kind of managed scalable database and failures can often be handled on the client side. Often we insert messaging into an HTTP system, or replace an HTTP system. In those cases, the client is waiting for an acknowledgement from the system that sits on the othe…

Yes, I agree wholeheartedly. If you don’t need reliable replication and can tolerate data loss, whatever rocks your boat :)

Personally, I do not find Kafka difficult to operate. ZooKeeper is basically a boring black box and there’s also kraft (the famous KIP-500).

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#77

Earlier quoted context omitted.

Those are two different technologies. Amqp is all about routing and queues. Kafka is a distributed log, it is not a queue. There’s a significant difference between those two. Kafka: every consumer for a partition within a consumer group will see a message at least once. A queue: it’s possible that a partition has multiple consumers and only one consumer sees a particular message. Kafka is relatively small to medium n…

> Kafka is a distributed log When should you use Kafka instead of storing rows in SQL with a timestamp so you can replay them/fetch them if needed? Why do you need a sharded Kafka cluster? Most businesses are going to have Redis, SQL, and probably RabbitMQ. Where/why add Kafka to that stack?

> When should you use Kafka instead of storing rows in SQL with a timestamp so you can replay them/fetch them if needed?

When the use case warrants it and when downstream consumers need to be notified of a change in the data or its state. That is, in reactive architectures.

A data streaming platform (of which Kafka is one example) will push the data, whereas a database (relational or not) requires to be explicitly polled (queried)[1]. A poll for new data is inefficient, is computationally expensive (a waste of CPU cycles when the data has not changed) and is prone to create creating delays in the data processing (when the polling interval is too long). Data streaming platforms will deliver the changes in near realtime.

Also, Kafka, being a distributed append only log, keeps an entire temporal history of all data changes. That is, if an event or an object has undergone a series of state transitions, such as create -> update 1 -> update 2 -> update 3 -> delete, it will be fully available in a topic as five separate events. If a consumer is only interested in the latest state change, a series of events can be compacted into an equivalent of a database table (naturally, it is called a K-table in Kafka) and the consumer can use the K-table instead of having to process the entire event stream[2]. K-tables and event streams can be flipped over with no extra effort.

Kafka is, effectively, your databases's own transaction log sans the query engine.

> Why do you need a sharded Kafka cluster?

Kafka cluster are not sharded. At least not in the database sense, as it is a cluster. A consumer sees one living thing[3] – the cluster, and the cluster can be dynamically resized without the consumer(s) knowing or noticing it. The cluster will then rebalance itself.

> Where/why add Kafka to that stack?

Kafka is typically used to get the data out of data sources and deliver a temporal series of changes to interested consumers. If the data needs to queried ad-hoc or explicitly, Kafka is then fronted by one or many (usually, domain specific) event stores. An event store can be a database (a RDBMS or a document one), a document search engine (e.g. Elastic Search or a vector database) or anything else that has a query engine in it. It can be a cache as well when either the speed of retrieval or affinity to the data are important.

[1] It is possible to mimic the Kafka temporal history via the use of triggers that would inject a copy of the row being changed into an «audit» table before allowing a update to occur, but, with time and in high data volume environments, the table size will balloon and will drag the database down.

[2] Most databases now have change event streams that abstract the database transaction log away and deliver raw row changes as a temporal history of events, which is a functional equivalent of data/event streaming (using Kafka or similar) sans the scalability and the distributed processing – the onus to implement either or both is entirely on the consumer and that part is hard. Therefore, a database change event stream is oftentimes hooked directly into a Kafka cluster.

[3] Not entire true in most implementations, but it is rabbit hole for another time to go down into.

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#78

Earlier quoted context omitted.

> However his points still remains: Most of the usage of Kafka I have seen in production are the result of a random Architect/Techlead who tried follow the hype train on event sourcing and a recipe for disaster. While calling this out on a message board comment section is going to be well-received, asking "do we need this" while working at the company with said architect/tech lead is not well-received. How many of us…

And go for mqtt instead? Not a smart choice. Look, it’s going to work for a few hundred, few thousand topics. But as soon as you need resilience, replication, or you outgrow that one broker… good luck. Mqtt is awful to scale horizontally.

Soooo right around when you have actual business with actual customers and use cases and are in best moment to re-architecture your app properly instead of throwing infrastructure at wall and seeing what sticks

Then just shove MQTT topics into kafka and slowly migrate stuff over.

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#79

Earlier quoted context omitted.

And go for mqtt instead? Not a smart choice. Look, it’s going to work for a few hundred, few thousand topics. But as soon as you need resilience, replication, or you outgrow that one broker… good luck. Mqtt is awful to scale horizontally.

Maybe something AMQP related instead?

Architecturally AMQP is just bigger brother of MQTT, to the point some queue brokers (like RabbitMQ) can accept both.

MQTT 5 made difference smaller too.

Re: MQTT vs. Kafka: An IoT Advocate's Perspective

#80
post #78

Earlier quoted context omitted.

And go for mqtt instead? Not a smart choice. Look, it’s going to work for a few hundred, few thousand topics. But as soon as you need resilience, replication, or you outgrow that one broker… good luck. Mqtt is awful to scale horizontally.

Soooo right around when you have actual business with actual customers and use cases and are in best moment to re-architecture your app properly instead of throwing infrastructure at wall and seeing what sticks Then just shove MQTT topics into kafka and slowly migrate stuff over.

I worked on a smart home platform where we did exactly that. But we moved from RabbitMQ to Kafka. This was a Spring Boot microservice architecture. We moved all of it without changing the service consume/publish semantics. The added benefit was that to facilitate the move, we wrote full integration tests on real containers and we have replaced RabbitMQ with Kafka under those tests. The system handled much better under load and the company had full integration tests. The migration took 2 weeks with 8 weeks writing tests for a team of 3.
Post reply on HN