消息巴士发送更新的最佳实践

发布于 2025-01-29 12:15:43 字数 229 浏览 3 评论 0原文

我想了解使用消息总线更新多个服务时的最佳实践。

基本的表演案例是通过总线发送完整的对象,每个人都可以立即获取数据并处理它。

另一个选项是通过总线,3/4字段发送最小的必要数据,然后每个听力服务都应请求主应用程序以获取所需的数据以对其进行处理。

主要应用程序不是等待任何人完成工作,我们正在谈论一个具有30至40个字段且不超过10KB的对象,通常小于5KB。

使用第二种方法是否有建筑优势?

I would like to understand what are the best practices when using a message bus to update several services.

The basic show case is to send the full object through the bus and everyone listening can immediately get the data and process it.

Other option is to send the minimal necessary data through the bus, 3/4 fields, and then each listening service should request the main application to fetch the required data to process it.

The main application is not waiting for anyone to complete their work, and we are talking about an object with 30 to 40 fields and no more than 10kb, most usually less than 5kb.

Is there any architectural advantage using the second approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2025-02-05 12:15:43

设计总是关于选项之间的权衡。

选项1:这是优选且易于实现,并真正从生产者那里脱颖而出。如果需要压缩,则可以减小尺寸,尽管压缩可以稍微降低总体吞吐量。
这种方法将需要更多的磁盘空间和应用程序内存。
例如:JSON有效载荷。
您的示例似乎更适合选项1。

选项2:如果Kafka消息的目的是通知最小信息,并且其他详细信息可以是文件或独立对象/多媒体URL,则可以使用。
一个参考实现是在AWS S3事件流中,其中S3发布消息到达信息(例如:某人上传文件)和S3 URL,然后消费者可以使用此信息来处理。这种方法需要对象存储或多媒体主机,以允许消费者连接和下载/处理特定事件。

Design is always about tradeoff between options.

Option-1: This is preferred and simple to implement and truly decouple from producer. If require compression can be enable to reduce the size, though compression can slightly reduce the overall throughput.
This approach will require more disk space and application memory.
Ex: Json payload.
Your example appears to be more suitable with option-1.

Option-2: This can be use if purpose of kafka message is to notify with minimal information and additional details could be file or independent object/multimedia urls.
One Reference implementation is in AWS S3 event streaming, where S3 publish the message arrival information(ex:someone uploaded file) and S3 url, then consumer can use this information to process. This approach require object storage or multimedia host to allow the consumer to connect and download/process particular event.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文