DynamoDB为论坛建模

DynamoDB为论坛建模

本文介绍了如何使用不带热分区的Amazon DynamoDB为论坛建模?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS DynamoDB文档包含示例



您可以使用上述架构。现在为您查询


  1. 论坛主题(按发布日期或最新回复排序)

     从GSI2中选择,其中GSI2 pk = Forum123并排序为GSI2 SK 

    您可以根据经常问到的用例来选择保留在GSI2 Sk最新回复/发布日期中的人员。


  2. 回复按主题(按分页发布的日期排序)

     选择pk = topic和sk以回复开头并按sk 
    排序


  3. 用户答复(按发布日期排序)

     从GSI2中选择,其中pk = User123,sk以回复和排序方式开始sk 


  4. 按用户划分的主题(按发布日期排序)

     从GSI2中选择,其中pk = User123和sk开头为主题和排序方式sk 


  5. 投票最多的主题



 如果您要在多个论坛上执行此操作。但是此GSI肯定会遇到热键问题。因为只有一把钥匙。代替这样做,您可以在表中保留一个固定的键值,以保留这些计数。并且这些值由异步过程更新。 


The AWS DynamoDB documentation includes an example schema for a forum. However, the number of questions this schema is able to answer seems very small. In addition, the table seems to suffer from a hot-key problem (a burst of replies backs up on the same partition).

In a talk title "Advanced Design Patterns for Amazon DynamoDB" the presenter around 43 minutes breaks down a complex use-case from Audible using only a single table with 3 GSI (indexes).

I'm trying to learn proper DynamoDB modeling coming from a standard RDBMS 3NF background. How would a forum be designed to prevent hot-partitions while still meeting these common use-cases?

Queries:

  • Topics by Forum (sorted by date posted, or most recent reply)
  • Replies by Topic (sorted by date posted with pagination)
  • Replies by User (sorted by date posted)
  • Topics by User (sorted by date posted)
  • Topics with most votes

Basic Schema(?):

I'm assuming there are multiple solutions (including using a single table). I'm looking for any answer that can solve this while providing guidance on when, and how, to

You can use the above schema. Now for you queries

  1. Topics by Forum (sorted by date posted, or most recent reply)

    Select from GSI2 where GSI2 pk=Forum123 and sortby GSI2 SK
    

    you can choose whom to keep in GSI2 Sk recent reply/date posted based on which use case is frequently asked.

  2. Replies by Topic (sorted by date posted with pagination)

    Select where pk=topic and sk startswith reply and sortby sk
    

  3. Replies by User (sorted by date posted)

    Select from GSI2 where pk=User123 and sk startswith reply and sortby sk
    

  4. Topics by User (sorted by date posted)

    Select from GSI2 where pk=User123 and sk startswith topic and sortby sk
    

  5. Topics with most votes
This will require another GSI if you want to do this operation across multiple forums. but This GSI will certainly suffer from hot key issue. since there will be only one key. Instead of doing that, you can keep one fixed key value in your table who keeps these counts. and these values are updated by an async process.

这篇关于如何使用不带热分区的Amazon DynamoDB为论坛建模?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 05:39