DynamoDB flow

DynamoDB flow is an optional feature for capturing data DynamoDB table modification event. These data will be the order of events related to events that occurred near real-time appears in the stream.

Each event consists of a flow records  indicate. If you enable the flow of the table, then whenever one of the following events occurs, DynamoDB will write a stream flow records:

  • We added a new item to the list: stream will capture an image of the entire project, including all its properties.

  • Updated Project: Stream project will capture any attributes that have been modified in the "before" and "after" images.

  • An item was deleted from the table: stream capture its image before the whole project is deleted.

Each flow record also contains the name of the table, the event timestamp, and other metadata. Flow records with 24 hours of the life cycle; after this time, they are automatically removed from the stream.

You can DynamoDB stream with AWS Lambda combination to create a trigger  - there is code that is automatically executed when you are interested in events in the stream. For example, suppose you have a company that contains customer information  Customers  table. Suppose you want to send to each new customer a "Welcome" email. You can enable a flow of the table, then the stream associated with the Lambda function. Lambda function will be executed when a new flow records appear, but will only deal Add to  Customers  new project table. For a  EmailAddress  any item of property, Lambda function will be called Amazon Simple Email Service (Amazon SES) to send e-mail to that address.

note

In this example, the last customer Craig Roe will not receive an email, because he did not  EmailAddress .

In addition to the trigger, but also provides a powerful flow DynamoDB solutions, e.g., the AWS AWS region and the data region across the copy, the data table DynamoDB particular view, the use of data analysis Kinesis concrete views.

DynamoDB support indicates the type of numeric, string or binary set of values. All elements must be the same type of focus. For example, a digital set type attribute can contain numbers, strings set only contains the string, and so on.

As long as the size of the project value contained in the item DynamoDB size limit (400 KB), the number of values ​​set no limit.

When your application writes data to DynamoDB table and receive a 200 response HTTP ( OKtime), the write has occurred and lasting. The final data will be consistent in all the stored position, usually only one second or less.

DynamoDB support eventual consistency  and strong consistency  read.

Eventually consistent read

When you read the data from DynamoDB table, the result of the write operation response may reflect not just completed. Response may contain stale data. If you repeat a read request after a short time, the response will return the latest data.

Reads with strong consistency

When you request a strongly consistent read, DynamoDB will return a response with the latest data, updated to reflect all write operations from previously successful. If the network delays or interruptions may not perform reads with strong consistency. Global secondary index (GSI) does not support consistent read.

note

Unless you specify a different read mode, otherwise DynamoDB will use eventually consistent read. Read operations (e.g.  GetItem, Query and a  Scan) providing a  ConsistentRead parameter. If you set this parameter to true, DynamoDB will use strong consistency read during operation.

Partitioning and data distribution

DynamoDB stores data in partitions. Partition  is assigned to a table memory, supported by SSD (the SSD), and can be automatically replicated in a plurality of regions within the available area AWS. Partition Manager solely responsible for the DynamoDB - You do not need to personally manage partitions from.

When you create a table, the table is the initial state  CREATING. In the meantime, DynamoDB allocates enough to partition table, in order to meet the preset throughput requirements. Changes to the state table  ACTIVE , then you can begin to read and write data tables.

In the following cases, DynamoDB will allocate additional partitions to the table:

  • You increase the throughput of presets set the table beyond the support capacity of existing partitions.

  • Filling an existing partition size limit has been reached, and requires more storage space.

Partition management automatically in the background, the program is transparent. Your table will remain available throughput and fully supports the pre-throughput requirements.

For more details, please refer to the partitioning key design .

DynamoDB the Global secondary index also contain a partition. GSI data in its data base tables stored separately, but almost the same behavior index partitions and the partition table.

Data distribution: partitioning key

If the table has a simple primary key (only the key partition), DynamoDB partition key value according to its storage and retrieval of various items.

Partitioning key values ​​used as input values ​​DynamoDB inner hash function, thereby item written to the table. The output value of the hash function determines which items will be stored in the partition.

Read from a table an item, you must specify the partition key for the project. DynamoDB uses this value as an input value of a hash function to generate a partition can be found from the item.

The following figure shows called  Pets  of a table across a plurality of partitions. Table's primary key is  AnimalType (display only this key property). In this case, DynamoDB string based  Dog  hash value using a hash function to determine which memory location of the new item. Please note that the program is not stored in sorted order. Location of each item is determined by its hash value of the partitioning key.

note

DynamoDB is optimized, no matter how many partition table, can be unified allocation of items on these partitions. We recommend that you choose a more distinct values ​​(relative to the number of entries in the table) partition key.

Data distribution: sort section key and key

If the table has a composite primary key (and key partition sort keys), DynamoDB will use the data distribution: partitioning key the same manner as in the hash value is calculated partition key - but orderly sorted key having physical location of items stored in the same partition key immediately adjacent each other.

An item is written to the table, DynamoDB calculates hash partition key value to determine the storage partitions project. In this partition, there may be several items with the same partition key value, and therefore will DynamoDB the ascending sort key items stored in other projects.

To read an item in the table, you must specify the partition key and sort key for the project. DynamoDB will compute the hash partitioning key, which can generate a partition of the project to find.

If you want to project with the same partition key, you can by a single operation ( Query) to read multiple items in the table. DynamoDB will return all items have the partition key values. Alternatively, you can also apply certain conditions on the sort key so that it returns only the items within a specific range of values.

假设 Pets 表具有由 AnimalType(分区键)和 Name(排序键)构成的复合主键。下图显示了 DynamoDB 写入项目的过程,分区键值为 Dog、排序键值为 Fido

为读取 Pets 表中的同一项目,DynamoDB 会计算 Dog 的哈希值,从而生成这些项目的存储分区。然后,DynamoDB 会扫描这些排序键属性值,直至找到 Fido

要读取 AnimalType 为 Dog 的所有项目,您可以执行 Query 操作,无需指定排序键条件。默认情况下,这些项目会按存储顺序 (即按排序键的升序) 返回。或者,您也可以请求以降序返回。

要仅查询某些 Dog 项目,您可以对排序键应用条件(例如,仅限 Name 以 A 至 K 范围内的字母开头的 Dog 项目)。

注意

在 DynamoDB 表中,每个分区键值的非重复排序键值无数量上限。如果您需要在 Pets 表中存储数十亿个 Dog 项目,DynamoDB 会自动分配足够的存储来满足这一需求。

Guess you like

Origin www.cnblogs.com/cloudrivers/p/11227398.html