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(?):
- Forum: Partition key: Forum_GUID. Attributes: Name, Desc
- User: Partition key: User_GUID. Attributes: email, join_date
- Thread: Composite key: Forum_GUID, Topic_GUID. Attributes: posted_by, date, votes, body, subject
- Reply: Composite key: Topic_GUID, Reply_GUID. Attributes: posted_by, date, votes, body
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 properly use indexes to scale out an application's writes.