如果它大于10m并将其分为多个流,则在Nodejs中流json对象的最佳实践是什么?

发布于 2025-01-28 07:31:04 字数 134 浏览 4 评论 0原文

我有一个JSON对象,它是一个大对象。我需要将(写)作为卡夫卡消息发送(写),这需要大量时间。

我需要一种机制来流式json对象,如果它大于10m,请将其分为多个流消息,然后发送。

请帮助我找到最佳练习。

谢谢。

I have a JSON object, it is a big object. I need to send (write) it as a Kafka message and it takes a lot of time.

I need a mechanism to stream the JSON object and if it is bigger than 10M, split it into multiple stream messages and then send it.

Please help me to find a best practice.

Thank you.

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

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

发布评论

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

评论(1

橘和柠 2025-02-04 07:31:04

如果可以在客户端中进行解压缩。我会这样做:

  • 压缩10MB JSON文件。它将减少到约115kb
  • 编码基本64文件。它将将大小添加到160KB

160KB的大小比10MB小得多,应该易于流式传输。
这与Netflix所做的(压缩)相似,这就是为什么他们的电影流在我们电视上如此快的原因

If it is possible to do decompress in the client. I would do :

  • compress 10MB json file. It will reduce to about 115KB
  • encode base64 the file. It will add the size to 160KB

160KB is a lot smaller than 10MB and should be easy to streamed.
It's similar with what netflix does ( compression ) that's why their movie stream so fast in our TV

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