4

I have a stream enabled dynamodb table. A lambda function consumes this stream. Each record in the dynamodb stream has a SequenceNumber assigned to it. What is its significance?

Lets say that record1 entered the stream before record2. Does it mean that SequenceNumber(record1) < SequenceNumber(record2) ?

Jarede
  • 3,310
  • 4
  • 44
  • 68
mightyMouse
  • 658
  • 15
  • 23

1 Answers1

5

The meaning of Sequence Number is explained in docs:

Each data record has a sequence number that is unique per partition-key within its shard. Kinesis Data Streams assigns the sequence number after you write to the stream with client.putRecords or client.putRecord. Sequence numbers for the same partition key generally increase over time. The longer the time period between write requests, the larger the sequence numbers become.

For your question, it depends on the partition. If its same partition, it will increase. But if you put records in different partitions, they may not preserve the order.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • What is the meaning of the sequence numbers "generally increase". I mean can they be equal / decrease within the same shard – mightyMouse Apr 08 '21 at 12:06
  • 1
    @mightyMouse I think it means that its not guaranteed by AWS that it always increases. Thus, there could be some edge cases where they are same, if maybe lots of records are uploaded at the same time. Sadly, docs are not specific to indicate this. – Marcin Apr 08 '21 at 12:17
  • okay. but what about a particular hash key. if updates are made to a specific item only then will they be increasing. – mightyMouse Apr 08 '21 at 12:30
  • You linking stream docs. Yet DynamoDB Stream says `A DynamoDB stream is an ordered flow of information about changes to items in a DynamoDB table.` So i wonder if you push 5M queries/s to DynamoDB, sequence number will still be in order or not, like in Kinesis Data Streams? From DynamoDB docs sound like it would be in order. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html – Lukas Liesis Jun 25 '22 at 07:38