AWS DynamoDB最大项目大小

发布于 2025-02-06 06:32:43 字数 621 浏览 0 评论 0原文

我正在尝试使用DynamoDB创建一个简单的记录系统。使用此简单的表结构:

{
 "userName": "Billy Wotsit",
 "messageLog": [
   {
    "date": "2022-06-08 13:17:03",
    "messageId": "j2659afl32btc0feqtbqrf802th296srbka8tto0",
    "status": 200
   },
   {
    "date": "2022-06-08 16:28:37.464",
    "id": "eb4oqktac8i19got1t70eec4i8rdcman6tve81o0",
    "status": 200
   },
   {
    "date": "2022-06-09 11:54:37.457",
    "id": "m5is9ah4th4kl13d1aetjhjre7go0nun2lecdsg0",
    "status": 200
   }
  ]
}

很容易将消息日志中的项目数输入成千上万。

根据文档,“项目”的最大大小为400kb,这严重限制了可以存储的日志元素的最大数量。

在不诉诸于更传统的SQL诉讼的情况下,将存储此数量数据的正确方法是什么(实际上并不需要)

I am trying to create a simple logging system using DynamoDB. Using this simple table structure:

{
 "userName": "Billy Wotsit",
 "messageLog": [
   {
    "date": "2022-06-08 13:17:03",
    "messageId": "j2659afl32btc0feqtbqrf802th296srbka8tto0",
    "status": 200
   },
   {
    "date": "2022-06-08 16:28:37.464",
    "id": "eb4oqktac8i19got1t70eec4i8rdcman6tve81o0",
    "status": 200
   },
   {
    "date": "2022-06-09 11:54:37.457",
    "id": "m5is9ah4th4kl13d1aetjhjre7go0nun2lecdsg0",
    "status": 200
   }
  ]
}

It is easily possible that the number of items in the message log will run into the thousands.

According to the documentation an "item" can have a maximum size of 400kB which severly limits the maximum number of log elements that can be stored.

What would be the correct way to store this amount of data without resorting to a more traditional SQL-approach (which is not really needed)

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

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

发布评论

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

评论(1

坏尐絯℡ 2025-02-13 06:32:43

有关您的数据用例的一些信息将有所帮助。我的主要问题是

  1. 您需要多久一次更新/附加日志到条目?
  2. 您需要如何检索日志?您需要所有这些吗?您需要每个用户吗?您会按时间过滤吗?

在不知道您的数据读/写入模式的更多信息的情况下,更好的布局是让每个日志条目成为DB中的一个项目:

  1. 用户名可以是分区密钥
  2. 日志日期可以是sort键。
  3. (可选)如果您需要通过消息ID检索,则可以创建辅助索引。 (或对日志日期的副主席)

使用上述结构,您可以在日志条目中微不足道地附加&假设您已将其设置为适当的用例,则可以有效地检索它们。专注于了解排序键和辅助索引如何优化DB中的条目。您想避免在整个数据库中扫描寻找您的项目。请参阅有关更多信息。

Some information on use cases for your data would help. My primary questions would be

  1. How often do you need to update/ append logs to an entry?
  2. How do you need to retrieve the logs? Do you need all of them? Do you need them per user? Will you filter by time?

Without knowing any more info on your data read/write patterns, a better layout would be to have each log entry be an item in the DB:

  1. The username can be the partition key
  2. The log date can be the sort key.
  3. (optional) If you need to ever retrieve by message id, you can create a secondary index. (Or vice versa with the log date)

With the above structure, you can trivially append log entries & retrieve them efficiently assuming you've set your sort key / indexes appropriately to your use case. Focus on understanding how the sort key and secondary indexes optimize finding your entries in the DB. You want to avoid scanning through the entire database looking for your items. See Core Components of Amazon DynamoDB for more info.

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