On This Page
Fast and flexible NoSQL database service for performance with millisecond latency at any scale
When you use the DynamoDB service, you are charged for reading, writing, and storing data in DynamoDB tables, as well as any additional features you enable. DynamoDB supports two resource provisioning modes that correspond to specific billing schemes for processing read and write operations on your tables: on-demand and with preparation. Click the following links to learn more about the billing options for each provisioning mode
Ecommerce Websites, gaming websites etc.
- Global tables are useful for having multiple copies of tables in different region.
- All DynamoDB tables are encrypted at rest using an AWS owned CMK by default.
- Items - in DynamoDB is similar in many ways to rows, records, or tuples in other database systems. Each DynamoDB table contains zero or more items. An item is a collection of attributes that is uniquely identifiable for each record in that table.
- Attributes - Each item is composed of one or more attributes. Attributes in DynamoDB are similar in many ways to fields or columns in other database systems.
- Each item in the table has a unique identifier, a primary key, or a partition key that distinguishes the item from all of the others in the table. The primary key consists of one attribute.
- Primary key
- Partition key
- Partition key and sort key (range attribute)
- A primary key can either be a sinale-attribute partition key or a composite partition-sort key.
- Both partition and sort keys attributes must be defined as type string, number, or binary.
- Global secondary index - a partition key and a sort key that can be different from those on the base table; query at table level across all partitions; eventual consistency:
- Different partition key and sort key from base table
- Only eventually consistent
- Can be created after table is created
- Using a random prefix for the GSI partition key enables to have high cardinality for the partition key
- Local secondary index - same partition key as the base table, but a different sort key: query on a single partition; eventual or strong consistency:
- Same partition key, different sort key from base table
- Eventual and strongly consistent
- Should be created when creating a table
- Calculate RCU (read capacity unit) & WCU (write capacity unit):
- 1 RCU = 2 eventual consistent read of 4 KB, 1 strongly consistent read of 4 KB
- 1 WCU = 1 write per second for data for an item as large as 1 KB.
- DynamoDB Streams is an optional feature that captures data modification events in DynamoDB tables. The data about these events appears in the stream in near real time and in the order that the events occurred.
- Queries or scan on GSI consume RCU on index not on table
- Auto scaling
- Storing session state could be on elastic cache or dynamodb
- Provisioned throughput - ProvisionedThroughputExceededException
- Reserved capacity, On-demand, Burst. Adaptive
- On-demand backups, point-in-time recovery
- Best practices when using Scan in dynamodb - Use parallel scan
- to control the amount of data returned per request use the Limit parameter. This can help prevent situations where one worker consumes all the provisioned throuahput at the expense of all other workers
- DynamoDB does not support item locking, and conditional writes are perfect for implementing optimistic concurrency.
DynamoDB vs Aurora
|Amazon DynamoDB||Amazon Aurora|
|Was developed by Amazon in 2012||Was developed by Amazon in 2015.|
|It is hosted, scalable database service by Amazon with data stored in Amazon cloud||It is MySQL and PostgreSQL compatible cloud service by Amazon|
|It does not provide concept of Referential Integrity. Hence, no Foreign Keys||It provides concept of Referential Integrity. Hence, no Foreign Keys|
|Eventual Consistency and Immediate Consistency are used to ensure consistency in distributed system||Immediate Consistency is used to ensure consistency in distributed system|
|Its Primary database models are Document store and Key-value store||Its Primary database model is Relational DBMS|
|It does not support Server-side scripting||It supports Server-side scripting|
|It supports sharding as partitioning method||Partitioning can be done with horizontal partitioning|
|It does not support SQL query language||It supports SQL query language|
|It supports replication methods||It supports only one replication method – Master-slave replication|
|It does not offer API for user-defined Map/Reduce methods. But maybe implemented via Amazon Elastic MapReduce||It does not offer API for user-defined Map/Reduce methods|
DynamoDB supports different consistency models when performing reads:
- Eventually, consistent reads may not always reflect the latest data if there was recently write activity on the table. Since the data in this scenario rarely changes, eventually consistent reads, which are cheaper than strongly consistent reads, can be tolerated.
A developer is designing a web application that allows the users to post comments and receive in a real-time feedback.
Which architectures meet these requirements? (Select TWO.)
- Create an AWS AppSync schema and corresponding APIs. Use an Amazon DynamoDB table as the data store.
- Create a WebSocket API in Amazon API Gateway. Use an AWS Lambda function as the backend and an Amazon DynamoDB table as the data store
- Create an AWS Elastic Beanstalk application backed by an Amazon RDS database. Configure the application to allow long-lived TCP/IP sockets.
- Create a GraphQL endpoint in Amazon API Gateway. Use an Amazon DynamoDB table as the data store.
- Enable WebSocket on Amazon CloudFront. Use an AWS Lambda function as the origin and an Amazon Aurora DB cluster as the data store
AWS AppSync simplifies application development by letting users create a flexible API to securely access, manipulate, and combine data from one or more data sources. AWS AppSync is a managed service that uses GraphQL to make it easy for applications to get the exact data they need.
AWS AppSync allows users to build scalable applications, including those requiring real-time updates, on a range of data sources, including Amazon DynamoDB. In Amazon API Gateway, users can create a WebSocket API as a stateful frontend for an AWS service (such as AWS Lambda or DynamoDB) or for an HTTP endpoint.
The WebSocket API invokes the backend based on the content of the messages it receives from client applications. Unlike a REST API, which receives and responds to requests, a WebSocket API supports two-way communication between client applications and the backend.