在 AWS DynamoDB 上存储聊天日志? [英] Storing Chat Log on AWS DynamoDB?

查看:20
本文介绍了在 AWS DynamoDB 上存储聊天日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用 AWS DynamoDB 构建一个聊天应用程序.该应用程序将支持 1:1 和群聊.

I am thinking of building a chat app with AWS DynamoDB. The app will support 1:1 and group chats.

我想为每个聊天创建一个表,其中每个发送的聊天文本行都有一条记录.DynamoDB 适合这种工作吗?

I want to create one table for each one of the chats, where there is a record for each sent chat text line. Is DynamoDB suitable for this kind of job?

我也在考虑合并两个表.但是,如果有——让我们假设——10 万或 100 万用户,这是一个好主意吗?

I am also thinking of merging both tables. But is this a good idea, if there are – let's assume – 100k or 1000k users?

推荐答案

我认为您可能会遇到表的读取容量问题.写入容量应该没问题,因为每秒传入的消息不多(例如 10 条左右),但是您需要不断地为所有用户读取它,所以这会很昂贵.

I think you may run into problems with the read capacity on your table. The write capacity should be ok, as there are not so many messages coming in per second (e.g. 10 or so), but you'll need to constantly read from it for all users, so that'll be expensive.

如果您想将 DynamoDB 用作存储并像通过网络进行任何正常聊天一样分发聊天消息,那么根据您的使用案例,这可能是有意义的.假设您有一个哈希键 UserId 和 Timestamp,您可以查询特定时间段内来自特定用户的所有消息作为结果.但是,如果您想在聊天文本中搜索(可能是一个更有用的功能),那么 DynamoDB 本身将无法工作.它不像 SQL,您可以在其中执行 LIKE '%abc%' 查询(这在 SQL 中也不是一个好主意).

If you want to use DynamoDB just as storage and distribute the chat messages like in any normal chat over the network, then it may make sense, depending on your use cases. You could, assuming you have a hash key UserId and Timestamp, query all messages from a specific user during a specific period as a result. If you want, however, search within the chat text (a much more useful feature, probably), then DynamoDB won't work per se. It's not like SQL, where you could do a LIKE '%abc%' query (which isn't a good idea in SQL either).

您最好使用 S3 作为数据存储和 ElasticSearch 作为搜索工具.如果您需要上述用例在时间跨度 S 内从用户 X 获取所有消息"(作为一个简单示例),您还可以使用 DynamoDB 来存储元数据,例如 UserId、Timestamp、PositionInFile 或类似的东西.

Probably you're better off using S3 as data storage and ElasticSearch as search instrument. If you require the aforementioned use case "get all messages from user X in timespan S" (as a simple example) you could additionally use DynamoDB to store metadata, such as UserId, Timestamp, PositionInFile or something like that.

这篇关于在 AWS DynamoDB 上存储聊天日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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