DynamoDB - Activity Table

DynamoDB - Activity Table

DynamoDB threads allow you to track and respond to changes to table elements. Use this feature to create an application that reacts to changes by updating information from different sources. Synchronize data for thousands of users of a large multi-user system. Use it to send notifications to users about updates. Its applications are varied and significant. DynamoDB threads serve as the primary tool used to achieve this functionality.

Streams capture time-ordered sequences containing modifications to elements in a table. They store this data for a maximum of 24 hours. Applications use them to view original and modified items in near real time.

The streams included in the table commit all modifications. On any CRUD operation, DynamoDB creates a stream entry with the primary key attributes of the changed items. You can customize streams for additional information such as before and after images.

Streams carry two guarantees −

  • Each entry appears once in the stream and

  • Each modification of an element results in stream entries of the same order as the modifications.

Each entry appears once in the stream and

Each modification of an element results in stream entries of the same order as the modifications.

All streams are processed in real time so that you can use them for related functions in applications.

Flow control

When creating a table, you can turn on the flow. Existing tables allow you to disable the flow or change settings. Streams offer the feature of running asynchronously, which means there is no performance impact on the table.

Use the AWS Management Console for easy flow management. First go to the console and select Tables . On the Overview tab, select Flow control . Inside the window, select the information to be added to the stream when the table data is modified. After entering all settings, select Enable .

If you want to disable any existing threads, select Flow Control , and then Disable .

You can also use the CreateTable and UpdateTable APIs to enable or modify a stream. Use the StreamSpecification parameter to customize the stream. StreamEnabled specifies a state meaning true for enabled and false for disabled.

StreamViewType specifies the information to add to the stream: KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, and NEW_AND_OLD_IMAGES.

Stream Reading

Reading and processing streams by connecting to an endpoint and making API requests. Each stream is made up of stream entries, and each entry exists as a separate revision to which the stream belongs. Stream entries include a serial number that reveals the order in which they were published. The entries are owned by groups, also known as shards. Shards function as containers for multiple entries, and also contain the information needed to access and view entries. Recordings are automatically deleted after 24 hours.

These shards are created and removed as needed and do not last long. They are also automatically divided into several new segments, usually in response to bursts of recording activity. When disconnecting a stream, open open shards. The hierarchical relationship between shards means that applications must prioritize parent shards for the correct processing order. You can use the Kinesis Adapter to do this automatically.

Note . Operations that do not result in changes do not write stream records.

Accessing and processing records requires performing the following tasks −

  • Determine the ARN of the target stream.
  • Determine the shards of the stream containing the target records.
  • Access the shard(s) to get the records you want.

Note. There should be no more than 2 processes reading the shard at the same time. If it exceeds 2 processes, then it can choke the source.

Available streaming API actions include

  • ListStreams
  • DescribeStream
  • GetShardIterator
  • GetRecords

You can view the following stream reading example −