Choosing Partition and Sort Key for the DynamoDB for a job queue

0

DynamoDB newbie question

I am trying to build a job table which really acts as a priority queue(One Lambda fills once a day and other lambda executes by reading one at a time). Below is the high level flow:

  • First Lambda --> reads the job parameters from JSONs and inserts to DDB table --> Second Lambda --> reads each job and executes the job accordingly.

Trying to see what Partition Key and Sort Key would make sense? Couple of things I thought of

  1. UUID as JobID: But Second Lambda wouldn't know this random ID to read from the DDB Table
  2. IndexName#RunDate: For any reason, if the first lambda re-runs after few hours, records shall be overridden and the previous state is lost.
  3. IndexName#RunDate#Run1: This needs that first lambda to read the records to check if the records are already present and then increment the number

I am looking for some simpler approach.

已提問 3 個月前檢視次數 119 次
1 個回答
0

You mentioned priority but I'm not sure I understand the requirements around that. Are all the jobs for a particular day processed with the same priority? Or do you want to have them processed in a preferred order? Maybe you meant that the priority is just by day (so records from the earlier date get processed first)?

I think your first thought is likely to be the right start - each job has its own unique JobID in a table that has a simple key (partition key only - no sort key). And you will likely need a GSI (or two) from there. Just need a bit more of the priority processing detail I mentioned above to give recommendations on the GSI(s).

已回答 3 個月前
profile picture
專家
已審閱 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南