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


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.

preguntada hace 3 meses119 visualizaciones
1 Respuesta

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).

respondido hace 3 meses
profile picture
revisado hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas