aws dynamodb_DynamoDB备忘单–您需要了解的有关2020 AWS认证开发人员助理认证的Amazon Dynamo DB的所有信息

aws dynamodb

The emergence of cloud services has changed the way we build web-applications. This in turn has changed the responsibilities of a Web Developer.

云服务的出现改变了我们构建Web应用程序的方式。 反过来,这改变了Web开发人员的职责。

We used to build everything into a single web-application on a single server. This encompassed multiple responsibilities such as storage, databases, authentication, background jobs, caching, and more.

我们曾经将所有内容构建到单个服务器上的单个Web应用程序中。 这包括多种职责,例如存储,数据库,身份验证,后台作业,缓存等。

Cloud services allows us to reduce the complexity of our web-app and web-servers by pushing the responsibilities to these highly available, scalable, and durable cloud services.

云服务使我们能够将责任推到这些高可用性,可扩展且持久的云服务上,从而降低了我们的Web应用程序和Web服务器的复杂性。

A Web Developer who knows how to deploy and integrate cloud services with a web-application is what we call a Cloud Engineer.

一位知道如何将云服务与Web应用程序部署和集成的Web开发人员就是我们所谓的云工程师。

If you want to fast-track your career as a Web Developer in 2020 then the AWS Developer Associate Certification can help you achieve that end goal.

如果您想在2020年快速发展成为Web开发人员的职业,那么AWS开发人员助理认证可以帮助您实现最终目标。

The most important AWS service you need to study to pass that AWS Developer Associate exam is DynamoDB.  So I have released what I call The Ultimate DynamoDB Cheatsheet for free. You can print this out on the day of your exam to increase your chances of passing.

要通过该AWS Developer Associate考试,您需要学习的最重要的AWS服务是DynamoDB。 因此,我免费发布了所谓的The Ultimate DynamoDB Cheatsheet 。 您可以在考试当天将其打印出来,以增加通过的机会。

It was Nader the AWS Developer Advocate for AWS Amplify who suggested I release my entire cheatsheet for free. You would not have this resource if it wasn't for him.

Nader是AWS Amplify的AWS开发倡导者,他建议我免费发布整个备忘单。 如果不是他的话,您将没有此资源。

It was Kirk the AWS Senior Technologist specializing in DynamoDB who volunteered his time to ensure the accuracy of this cheatsheet. This turned it from 5 pages to 8 pages long!  📄📄📄📄📄📄📄📄

专门研究DynamoDB的是AWS高级技术专家Kirk ,他自愿花费时间来确保此备忘单的准确性。 这使它从5页变成了8页! 📄📄📄📄📄📄📄📄

If you have Twitter, please do me the favor of thanking them by tweeting at  @dabit3 and @NoSQLKnowHow with the #AWSCertified hashtag.

如果您有Twitter,请通过使用#AWSCertified主题标签在@ dabit3@NoSQLKnowHow发推文,对我表示感谢。

So lets move on to the cheatsheet:

因此,让我们进入备忘单:

DynamoDB的基础 (The Basics of DynamoDB)

DynamoDB is a fully managed NoSQL key/value and document database.

DynamoDB是一个完全托管的NoSQL键/值和文档数据库。

DynamoDB is suited for workloads with any amount of data that require predictable read and write performance and automatic scaling from large to small and everywhere in between.

DynamoDB适合需要任何数据量且需要可预测的读取和写入性能以及自动从大到小的缩放以及介于两者之间的任何地方的工作负载。

DynamoDB scales up and down to support whatever read and write capacity you specify per second in provisioned capacity mode. Or you can set it to On-Demand mode and there is little to no capacity planning.

DynamoDB可以扩展和缩减以支持在预置容量模式下每秒指定的任何读写容量 。 或者,您可以将其设置为按需模式,几乎没有容量规划。

  • DynamoDB stores 3 copies of data on SSD drives across 3 AZs in a region.

    DynamoDB将3个数据副本存储在一个区域中3个AZ上的SSD驱动器

  • DynamoDB's most common datatypes are B (Binary), N (Number), and S (String)

    DynamoDB最常见的数据类型是B (二进制), N (数字)和S (字符串)

  • Tables consist of Items (rows) and Items consist of Attributes (columns)

    表由项目 (行)组成,项目由属性 (列)组成

读写一致性 (Reads and Writes Consistency)

DynamoDB can be set to support Eventually Consistent Reads (default) and Strongly Consistent Reads on a per-call basis.

可以将DynamoDB设置为在每次调用的基础上支持最终一致读取 (默认)和强烈一致读取

Eventually consistent reads data is returned immediately but data can be inconsistent. Copies of data will be generally consistent in 1 second.

最终一致的读取数据会立即返回,但数据可能会不一致。 数据副本通常会在1秒内保持一致。

Strongly Consistent Reads will always read from the leader partition since it always has an up-to-date copy. Data will never be inconsistent but latency may be higher. Copies of data will be consistent with a guarantee of 1 second.

高度一致的读取将始终从引导者分区读取,因为它始终具有最新副本。 数据永远不会不一致,但是延迟可能会更高。 数据副本将与1秒的保证一致。

分区 (Partitions)

A Partition is when DynamoDB slices your table up into smaller chunks of data. This speeds up reads for very large tables.

分区是指DynamoDB将表切成更小的数据块。 这会加快超大型表的读取速度。

DynamoDB automatically creates Partitions for:

DynamoDB自动为以下对象创建分区:

  • Every 10 GB of Data or

    每10 GB数据或
  • When you exceed RCUs (3000) or WCUs (1000) limits for a single partition

    当您超出单个分区的RCU(3000)或WCU(1000)限制时
  • When DynamoDB sees a pattern of a hot partition, it will split that partition in an attempt to fix the issue.

    当DynamoDB看到热分区的模式时,它将拆分该分区,以尝试解决此问题。

DynamoDB will try to evenly split the RCUs and WCUs across Partitions

DynamoDB将尝试在分区之间平均分配 RCU和WCU

主键设计 (Primary Key Design)

Primary keys define where and how your data will be stored in partitions

主键定义数据在何处以及如何存储在分区中

The Key schema can be made up of two keys:

密钥架构可以由两个密钥组成:

  • Partition Key (PK) is also known as HASH

    分区密钥(PK)也称为HASH

  • The Sort Key (SK) is also known as RANGE

    排序键(SK)也称为RANGE

When using the AWS DynamoDB API eg. CLI, SDK they refer to the PK and SK by their alternative names due to legacy reasons.
使用AWS DynamoDB API时 由于传统原因,CLI,SDK通过备用名称引用了PK和SK。

Primary key comes in two types:

主键有两种类型:

  • Simple Primary Key (Using only a Partition Key)

    简单主键(仅使用分区键)

  • Composite Primary Key (Using both a Partition and Sort Key)

    复合主键(同时使用分区键和排序键)

Key Uniqueness is as follows:

密钥唯一性如下:

  • When creating a Simple Primary Key the PK value may be unique

    创建简单主键时,PK 值可能是唯一的

  • When creating a Composite Primary Key the combined PK and  SK must be unique

    创建复合主键时,组合的PK和SK必须唯一

When using a Sort key, records on the partition are logically grouped together in Ascending order.

使用排序键时,分区上的记录在逻辑上按升序分组在一起。

次要指标 (Secondary Indexes)

DynamoDB has two types of Indexes:

DynamoDB有两种类型的索引:

  • LSI - Local Secondary index

    LSI-本地二级索引

  • GSI -  Global Secondary Index

    GSI-全球二级指数

LSI-本地二级索引 (LSI - Local Secondary index)

  • Supports strongly or eventual consistency reads

    支持强烈或最终的一致性读取

  • Can only be created with initial table (cannot be modified or and cannot deleted unless also deleting the table)

    只能使用初始表创建(无法修改或不能删除,除非也删除表)
  • Only Composite

    仅复合
  • 10GB or less per partition

    每个分区10GB或更少
  • Share capacity units with base table

    与基本表共享容量单位
  • Must share Partition Key (PK) with base table.

    必须与基本表共享分区密钥(PK)。

GSI-全球二级指数 (GSI -  Global Secondary Index)

  • Only eventual consistency reads  (cannot provide strong consistency)

    读取最终一致性 (无法提供强一致性)

  • Can create, modify, or delete at anytime

    可以随时创建,修改或删除
  • Simple and Composite

    简单和复合
  • Can have whatever attributes as Primary Key (PK) or Secondary Key (SK)

    可以具有任何属性,例如主键(PK)或辅助键(SK)
  • No size restriction per partition

    每个分区没有大小限制
  • Has its own capacity settings (does not share with base table)

    有自己的容量设置(不与基表共享)

扫瞄 (Scan)

Your table(s) should be designed in such a way that your workload primary access patterns do not use Scans. Overall, scans should be needed sparingly, for example for an infrequent report.

表的设计方式应使您的工作负载主要访问模式不使用扫描。 总体而言,应该少量地进行扫描,例如对于不频繁的报告。

  • Scans through all items in a table and then returns one or more items through filters

    扫描表中的所有项目,然后通过过滤器返回一个或多个项目
  • By default returns all attributes for every item (use ProjectExpression to limit)

    默认情况下,返回每个项目的所有属性(使用ProjectExpression进行限制)

  • Scans are sequential, and you can speed up a scan through parallel scans using Segments and Total Segments

    扫描是顺序扫描,您可以使用“ 细分”和“ 总细分”通过并行扫描来加快扫描速度

  • Scans can be slow, especially with very large tables and can easily consume your provisioned throughput.

    扫描速度可能很慢,尤其是对于非常大的表,扫描很容易消耗您预配置的吞吐量。
  • Scans are one of the most expensive ways to access data in DynamoDB.

    扫描是访问DynamoDB中数据的最昂贵的方法之一。

询问 (Query)

  • Find items based on primary key values

    根据主键值查找项目
  • Table must have a composite key in order to be able to query

    表必须具有复合键才能查询
  • By default queries are Eventually Consistent (use ConsistentRead True to change Strongly Consistent)

    默认情况下,查询最终是一致的(使用ConsistentRead True更改为“高度一致”)

  • By default returns all attributes for each item found by a query (use ProjectExpression to limit)

    默认情况下返回查询找到的每个项目的所有属性(使用ProjectExpression进行限制)

  • By default is sorted ascending (use ScanIndexForward to False to reverse order to descending)

    默认情况下按升序排序(使用ScanIndexForward为False可以将顺序反转为降序)

容量模式 (Capacity Modes)

DynamoDB has two capacity modes, Provisioned and On-Demand. You can switch between these modes once every 24 hours.

DynamoDB具有两种容量模式,即ProvisionedOn-Demand 。 您可以每24小时在这些模式之间切换一次

已配置 (Provisioned)

Provisioned Throughput Capacity is the maximum amount of capacity your application is allowed to read or write per second from a table or index

预配置吞吐量是您的应用程序每秒从表或索引中读取或写入的最大容量

  • Provisioned is suited for predictable or steady state workloads

    预配置适用于可预测或稳定的工作负载

  • RCUs is Read Capacity Unit

    RCU是读取容量单位

  • WCUs is Write Capacity Unit

    WCU是写入容量单位

You should enable Auto Scaling with Provisioned capacity mode. In this mode, you set a floor and ceiling for the capacity you wish the table to support. DynamoDB will automatically add and remove capacity to between these values on your behalf and throttle calls that go above the ceiling for too long.

您应该启用“具有预置容量模式的自动扩展” 。 在这种模式下,您可以设置您希望桌子支撑的容量的上限和下限。 DynamoDB将代表您自动添加和删除这些值之间的容量,并限制超出上限的时间太长的限制调用。

If you go beyond your provisioned capacity, you’ll get an Exception:  ProvisionedThroughputExceededException (throttling)

如果您超出了配置的容量,则会收到异常: ProvisionedThroughputExceededException (限制)

Throttling is when requests are blocked due to read or write frequency higher than set thresholds. E.g. exceeding set provisioned capacity, partitions splitting, table/index capacity mismatch.

节流是指由于读取或写入频率高于设置的阈值而阻止请求的情况 。 例如,超出设置的预定容量,分区拆分,表/索引容量不匹配。

一经请求 (On-Demand)

On-Demand Capacity is pay per request. So you pay only for what you use.

按需容量是按请求付费。 因此,您只需为使用的商品付费。

  • On-Demand is suited for new or unpredictable workloads

    按需适用于新的不可预测的工作负载

  • The throughput is only limited by the default upper limits for a table (40K RCUs and 40K WCUs)

    吞吐量仅受表的默认上限限制(40K RCU和40K WCU)
  • Throttling can occur if you exceed double your previous peak capacity (high water mark) within 30 minutes. For example, if you previously peaked to a maximum of 30,000 ops/sec, you could not peak immediately to 90,000 ops/sec, but you could to 60,000 ops/sec.

    如果您在30分钟内超过先前峰值容量(高水位线)的两倍, 就会发生节流 。 例如,如果您之前的最高峰值为30,000 ops / sec,则无法立即达到90,000 ops / sec,但最高峰值为60,000 ops / sec。

  • Since there is no hard limit, On-Demand could become very expensive based on emerging scenarios

    由于没有硬性限制, 因此根据新兴情况, 按需可能会变得非常昂贵

计算读写 (Calculating Reads and Writes)

计算读数(RCU) (Calculating Reads (RCU))

A read capacity unit represents:

读取容量单位表示:

  • one strongly consistent read per second,

    每秒强烈一致的读取,
  • or two eventually consistent reads per second,

    或每秒两次最终一致的读取,
  • for an item up to 4 KB in size.

    大小最大为4 KB的项目。

How to calculate RCUs for strong

如何计算强大的 RCU

  1. Round data up to nearest 4.

    将数据四舍五入至最接近的值4。
  2. Divide data by 4

    将数据除以4
  3. Times by number of reads

    读取次数的倍数

Here's an example:

这是一个例子:

  • 50 reads at 40KB per item. (40/4) x 50 = 500 RCUs

    每个项目以40KB读取50次。 (40/4)x 50 = 500个RCU
  • 10 reads at 6KB per item. (8/4) x 10 = 20 RCUs

    每个项目10读,大小为6KB。 (8/4)x 10 = 20个RCU
  • 33 reads at 17KB per item. (20/4) x 33 = 132 RCUs

    每个项目以33KB读取,大小为17KB。 (20/4)x 33 = 132个RCU

How to calculate RCUs for eventual

如何计算最终的 RCU

  1. Round data up to nearest 4.

    将数据四舍五入到最接近的4。
  2. Divide data by 4

    将数据除以4
  3. Times by number of reads

    读取次数的倍数
  4. Divide final number by 2

    将最终数字除以2
  5. Round up to the nearest whole number

    四舍五入到最接近的整数

Here's an example:

这是一个例子:

  • 50 reads at 40KB per item. (40/4) x 50 / 2 = 250 RCUs

    每个项目以40KB读取50次。 (40/4)x 50/2 = 250个RCU
  • 11 reads at 9KB per item. (12/4) x 11 / 2 = 17 RCUs

    每个项目11次读取,大小为9KB。 (12/4)x 11/2 = 17个RCU
  • 14 reads at 24KB per item. (24/4) x 14 / 2 = 35 RCUs

    14个条目,每个条目24KB。 (24/4)x 14/2 = 35个RCU

计算写(写) (Calculating Writes (Writes))

A write capacity unit represents:

写容量单位表示:

  • one write per second,

    每秒写一次
  • for an item up to 1 KB

    用于最大1 KB的项目

How to calculate Writes

如何计算

  1. Round data up to nearest 1.

    将数据四舍五入到最接近的1。
  2. Times by number of writes

    写入次数

Here's an example:

这是一个例子:

  • 50 writes at 40KB per item. 40 x 50 = 2000 WCUs

    每个项目40个KB,可写入50次。 40 x 50 = 2000个WCU
  • 11 writes at 1KB per item. 1 x 11 = 11 WCUs

    每个项目以1KB写入11次。 1 x 11 = 11个WCU
  • 18 writes at 500 BYTES per item. 1 x 18 = 18 WCUs

    每项500次写入18次写入。 1 x 18 = 18个WCU

DynamoDB加速器
(DynamoDB Accelerator)

DynamoDB Accelerator (DAX) is a fully managed in-memory write through cache for DynamoDB that runs in a cluster

DynamoDB Accelerator (DAX)是针对群集中运行的DynamoDB的完全托管的内存中直写式缓存

  • Reads are eventually consistent

    读取最终是一致的
  • Incoming requests are evenly distributed across all of the nodes in the cluster.

    传入请求均匀分布在集群中的所有节点上。
  • DAX can reduce read response times to microseconds

    DAX可以将读取响应时间减少到微秒

DAX非常适合: (DAX is ideal for:)

  • fastest response times possible

    最快的响应时间
  • apps that read a small number of items more frequently

    读取少量项目的应用程序
  • apps that are read intensive

    密集阅读的应用

DAX不适用于: (DAX is not ideal for:)

  • Apps that require strongly consistent reads

    需要高度一致读取的应用
  • Apps that do not require microsecond read response times

    不需要微秒读取响应时间的应用
  • Apps that are write intensive, or that do not perform much read activity

    写入密集型或读取活动不多的应用

  • If you don’t need DAX consider using ElastiCache

    如果您不需要DAX,请考虑使用ElastiCache

DynamoDB事务 (DynamoDB Transactions)

DynamoDB supports transactions via the TransactWriteItems and TransactGetItems API calls.

DynamoDB通过TransactWriteItemsTransactGetItems API调用支持事务。

Transactions let you query multiple tables at once and are an all-or-nothing approach (all API calls must succeed).

事务使您可以一次查询多个表,这是一种全有或全无的方法(所有API调用必须成功)。

全局表 (Global tables)

DynamoDB Global tables provide a fully managed solution for deploying multi-region, multi-master databases.

DynamoDB Global表提供了用于部署多区域,多主数据库的完全托管的解决方案。

(Streams)

DynamoDB Streams allows you to set up a Lambda function triggered every time data is modified in a table to react to changes. Streams do not consume RCUs.

通过DynamoDB Streams ,您可以设置每次修改表中的数据以响应更改时触发的Lambda函数。 流不占用RCU。

DynamoDB API (DynamoDB API)

DynamoDB API's most notable commands via CLI:  aws dynamodb <command>

通过CLI的DynamoDB API最著名的命令: aws dynamodb <命令>

aws dynamodb get-item returns a set of attributes for the item with the given primary key. If no matching item, then it does not return any data and there will be no Item element in the response.

aws dynamodb get-item返回具有给定主键的项的一组属性。 如果没有匹配的项目,则它不返回任何数据,并且响应中将没有Item元素。

aws dynamodb put-item Creates a new item, or replaces an old item with a new item. If an item that has the same primary key as the new item already exists in the specified table, the new item completely replaces the existing item.

aws dynamodb put-item创建新项目,或将旧项目替换为新项目。 如果指定表中已经存在与新项目具有相同主键的项目,则新项目将完全替换现有项目。

aws dynamodb update-item Edits an existing item's attributes, or adds a new item to the table if it does not already exist.

aws dynamodb update-item编辑现有项目的属性,或将新项目添加到表(如果尚不存在)。

aws dynamodb batch-get-item returns the attributes of one or more items from one or more tables. You identify requested items by primary key. A single operation can retrieve up to 16 MB of data, which can contain as many as 100 items.

aws dynamodb batch-get-item返回一个或多个表中一个或多个项目的属性。 您可以通过主键标识请求的项目。 一个操作最多可以检索16 MB的数据 ,其中可以包含多达100个项目

aws dynamodb batch-write-item puts or deletes multiple items in one or more tables. Can write up to 16 MB of data, which can comprise as many as 25 put or delete requests. Individual items to be written can be as large as 400 KB.

aws dynamodb batch-write-item在一个或多个表中放置或删除多个项目。 最多可以写入16 MB的数据 ,其中可以包含多达25个放置或删除请求 。 要写入的单个项目最大可以为400 KB

aws dynamodb create-table adds a new table to your account. Table names must be unique within each Region.

aws dynamodb create-table将新表添加到您的帐户。 表名称在每个区域内必须唯一。

aws dynamodb update-table Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.

aws dynamodb update-table修改给定表的预配置吞吐量设置,全局二级索引或DynamoDB流设置。

aws dynamodb delete-table operation deletes a table and all of its items.

aws dynamodb delete-table操作将删除表及其所有项目。

aws dynamodb transact-get-items is a synchronous operation that atomically retrieves multiple items from one or more tables (but not from indexes) in a single account and Region. Call can contain up to 25 objects. The aggregate size of the items in the transaction cannot exceed 4 MB.

aws dynamodb transact-get-items是一种同步操作,该操作以原子方式从单个帐户和区域中的一个或多个表(但不是从索引)中检索多个项目。 呼叫最多可以包含25个对象 。 交易中项目的总大小不能超过4 MB

aws dynamodb transact-write-items a synchronous write operation that groups up to 25 action requests. These actions can target items in different tables, but not in different AWS accounts or Regions, and no two actions can target the same item.

aws dynamodb transact-write-items同步写操作,最多可分组25个操作请求 。 这些操作可以针对不同表中的项目,但不能针对不同的AWS账户或区域中的项目,并且没有两个操作可以针对同一项目。

aws dynamodb query finds items based on primary key values. You can query table or secondary index that has a composite primary key.

AWS dynamodb 查询根据主键值查找项目。 您可以查询具有复合主键的表或二级索引。

aws dynamodb scan returns one or more items and item attributes by accessing every item in a table or a secondary index.

AWS dynamodb 扫描通过访问表或二级索引中的每个项目来返回一个或多个项目和项目属性。

To火箭到火星 (🚀 rocketsToMars)

I want to help you enter the web and cloud industry. That is why I am releasing my free AWS Developer Associate Certification 2020 course on the freeCodeCamp YouTube channel with 10+ hours of additional content I have never released previously.

我想帮助您进入Web和云行业。 这就是为什么我要在freeCodeCamp YouTube频道上发布我的免费 AWS开发人员协会2020认证课程,其中包含10个小时以上从未有过的额外内容。

This free course will be released in a few days as I apply the final touches.

当我应用最后的修饰时,此免费课程将在几天后发布。

I believe in making tech education accessible to the world because in-turn the more we upskill, the sooner we can lift people out of poverty, the sooner we can engineer sustainable solutions to keep our planet green and healthy, and the sooner we can launch rockets to Mars.

我相信让全世界都能接受技术教育是因为反过来,我们的技能提高得越多,我们就能越早使人们摆脱贫困,我们就可以越早设计出可持续的解决方案来保持地球的绿色和健康,就可以越早推出火箭前往火星。

翻译自: https://www.freecodecamp.org/news/ultimate-dynamodb-2020-cheatsheet/

aws dynamodb

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值