kafka和mqtt的區別和聯繫

參考:https://www.zhihu.com/question/30343125架構

二者雖然都是從傳統的Pub/Sub消息系統演化出來的,可是進化的方向不同,如下是幾個比較突出的點:分佈式

  1. Kafka是爲了數據集成的場景,與以往Pub/Sub消息總線不同,經過分佈式架構提供了海量消息處理、高容錯的方式存儲海量數據流、保證數據流的順序等特性。能夠參考雲上的卡夫卡 - 數據工會
  2. MQTT是爲了物聯網場景而優化,不但提供多個QoS選項(exact once、at least once、at most once),並且還有層級主題、遺囑等等特性。能夠參考MQTT入門篇 - 數據工會

說白了都是傳統消息系統(老爸)的子嗣,只是與不一樣的場景(老媽)結合的產物。不過,二者卻能夠結合起來使用。好比能夠用MQTT接受物聯網設備上傳的數據,而後接入Kafka,最後能夠同時分發到HDFS歸檔、數據倉庫作OLAP分析、Elasticsearch作全文檢索,這樣的架構很是適合大型物聯網項目,不但可以處理海量數據同時也具備很好的擴展性。優化

MQTT and Kafka, on paper, are publish/subscribe (pub/sub) messaging platforms. But a key distinction between the two relates to how they are put to use. Unlike Kafka, MQTT is a machine-to-machine (M2M) messaging protocol. This means that while Kafka is responsible for data management and ingestion into computation systems, MQTT specializes in data packet exchange between two physical devices. In our home automation example, if we want to adjust air conditioning according to ambient temperature, the temperature sensor must be able to communicate with the air conditioner. This communication is held through MQTT. As expected, MQTT is only intended for small-sized data sets, where responsiveness and power efficiency are prioritized. This doesn’t lend well to large data sets – the result being bad scaling. Kafka, on the other hand, is designed specifically with massive data feeds in mind. Sound IoT systems use Kafka and MQTT in conjunction, co-existing separately for maximum performance and scalability.ui

相關文章
相關標籤/搜索