为什么我们需要 Apache Kafka 和 NoSQL 数据库? [英] Why we require Apache Kafka with NoSQL databases?

查看:25
本文介绍了为什么我们需要 Apache Kafka 和 NoSQL 数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Kafka 是一种实时消息传递服务.它以分布式和容错方式安全地存储数据流.我们可以在来到生产者时过滤流数据.我不明白为什么我们需要像 MongoDB 这样的 NoSQL 数据库来在 Apache Kafka 中存储相同的数据.真正的问题是,为什么我们在 NoSQL 数据库和 Apache Kafka 中存储相同的数据?

Apache Kafka is an real-time messaging service. It stores streams of data safely in distributed and fault-tolerant. We can filter streaming data when comming producer. I don't understant that why we need NoSQL databases like as MongoDB to store same data in Apache Kafka. The true question is that why we store same data in a NoSQL database and Apache Kafka?

我认为如果我们需要一个 NoSQL 数据库,我们可以先从 MongoDB 中的客户端收集数据流,而无需使用 Apache Kafka.但是,大多数大数据架构偏好在数据源和 NoSQL 数据库之间使用 Apache Kafka.(

I think if we need a NoSQL database, we can collect streams of data from clients in MongoDB at first without the use of Apache Kafka. But, most of big data architecture preference using Apache Kafka between data source and NoSQL database.(see)

这对真实系统有什么好处?

What is the advantages of that for real systems?

推荐答案

这种架构有几个优点:

  1. Kafka 作为数据集成总线

它有助于轻松地在多个生产者和许多消费者之间分发数据.Apache Kafka 在这里充当数据".集成消息总线.

It helps distribute data between several producers and many consumers easily. Here Apache Kafka serves as an "data" integration message bus.

Kafka 作为数据缓冲区

将 Kafka 放在你的终点"之前像 MongoDB 或 MySQL 这样的数据存储就像一个自然的数据缓冲区.因此,您可以独立部署/维护/重新部署您的消费者服务.在您的服务停止维护时,Kafka 仍在存储所有传入的数据,这非常有用.

Putting Kafka in front of your "end" data storages like MongoDB or MySQL acts like a natural data buffer. So you are able to deploy/maintain/redeploy your consumer services independently. At the time your service is down for maintanance Kafka is still storing all incoming data, that is quite useful.

Kafka 作为短时数据存储

您不必将所有内容都存储在 Kafka 中:您经常使用具有保留功能的 Kafka 主题.这意味着所有早于某个值的数据将被 Kafka 自动删除.因此,例如,您可能有 1 周保留期的 Kafka 主题(因此您仅存储 1 周的数据),但同时您的数据存在于经典 SQL-DB 或 Cassandra 等长期存储服务中.

You don't have to store everything in Kafka: very often you use Kafka topics with retention. It means all data older than some value will be deleted by Kafka automatically. So, for example you may have Kafka topic with 1 week retention (so you store 1 week of data only) but at the same time your data lives in long time storage services like classic SQL-DBs or Cassandra etc.

Kafka 作为长期数据存储

另一方面,您可以使用 Apache Kafka 作为长期存储系统.使用压缩主题使您可以仅存储每个键的最后一个值.因此,您的主题将成为您应用的最后状态存储.

On the other hand you can use Apache Kafka as a long term storage system. Using compacted topics enables you to store only the last value for each key. So your topic becomes a last state storage of your app.

这篇关于为什么我们需要 Apache Kafka 和 NoSQL 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆