Amazon DynamoDB
Overview
AWS DynamoDB is a serverless, fully managed key-value NoSQL database built to run high-performance applications of any size. DynamoDB has built-in security, automatic multi-region replication, an in-memory cache`, and data import and export features.
What is DynamoDB?
AWS DynamoDB is a managed NoSQL database service that enables the creation of database tables capable of storing and retrieving vast volumes of data.
It intelligently handles table data flow across numerous servers while maintaining performance. It also relieves consumers of the responsibility of running and scaling a decentralized network.
As a result, AWS DynamoDB manages hardware availability, installation, configuration, duplication, software upgrades, cluster scalability, and so on.
Key Concepts of DynamoDB
-
Tables It is a collection that can store practically unlimited objects and also has secondary indices.
-
Primary key It is a type of attribute that uniquely identify items in the table.
-
Sort Key Type of attribute is used to group objects in specific sorting order.
-
Secondary Index Uses a separate primary key and sort key to replicate table items.
-
Item A fundamental element in AWS DynamoDB which stores data characteristics in JSON format.
-
Attribute Contains informative data elements about a database table object in the form of a key-value pair.
-
Query The action of retrieving a particular object (or) set of items.
-
Streams A continuous stream of changing state actions against a table.
-
Filter Rules apply after a scan (or) query before the results are provided to the requester.
-
Scan The operation of scanning the complete table (or) a portion of it.
RDBMS Vs NoSQL
RELATIONAL DATABASE MANAGEMENT SYSTEM (RDBMS) | NoSQL |
---|---|
1. These databases have a static schema. | 1. They have a dynamic schema. |
2. These databases are unsuitable for storing hierarchical data. | 2. These databases are best for storing hierarchical data. |
3. These databases are used for complex queries. | 3. These databases are not a good option for complex queries. |
4. Vertically scalable and follows ACID property. | 4. Horizontally scalable and follows CAP(consistency, availability, partition tolerance). |
How does DynamoDB Store Data?
Despite considerable rigidity, DynamoDB provides two data models, allowing for different demands and flexibility.
The first is a key-value store, a scaled-up distributed hash table. The objects in the table are distinguished by a key-value pair of characteristics used to GET, SET, UPDATE, and DELETE.
There are two attributes: the Primary Key, which functions similarly to an item ID, and the Sort Key, which allows the objects to be ordered. Hash tables are dependable, consistent, and quick regardless of size; nevertheless, their disadvantage is that only a single record may be fetched at a time.
To address this, DynamoDB may be utilized as a wide-column store, meaning each row can contain an unlimited number of columns at any moment.
This B-tree data structure and secondary index allow you to find an item while supporting range searches. They used to refer to and sort objects using various Primary Keys and Sort Keys. It's also worth noting that DynamoDB is a schema-less database in which things can have multiple properties.
Use Cases of DynamoDB
-
Create software apps Create internet-scale apps that support user-content metadata and caches while handling millions of user queries per second.
-
Develop media metadata repository With multi-Region replication across AWS Regions, you can increase throughput and concurrency for media and entertainment applications like real-time video streaming and interactive content while lowering latency.
-
Provide consistent retail experiences Deploy shopping carts, workflow engines, inventory monitoring, and customer profiles using design patterns. DynamoDB can handle millions of queries per second, enabling high-traffic, extreme-scaled events.
-
Large-scale gaming platforms Concentrate on driving innovation while incurring minimal operating costs. Create a game platform for millions of concurrent users by including player data, session history, and leaderboards.
Setting Up AWS Dynamo DB.
(A) To create a NoSQL Table
-
In the DynamoDB console, click on Create Table.
-
Provide the name of the table.
- Choose a character with a range of values and consistently dispersed access patterns since the Primary Key or Partition Key is used to redistribute data across partitions for scalability.
- The Sort Key allows the user to sort the data shown below.
- User can select from the two available options of capacity mode, i.e., on-demand and provisioned, as shown below.
- Click on Create.
(B) Adding Data
-
As shown below, select "Create Item."
-
While creating an item, the user has to provide the item name, and value, and type and click on create the item.
DynamoDB Streams
It is a feature of AWS DynamoDB that records changes to a database when the change occurs, saving these updates in a log that is preserved for 24 hours.
Stream Record is produced using the primary key characteristics of the altered items, assuring that all changes are logged in the order in which they happened. It can be set up to collect extra information, such as the states before and after the modification.
DynamoDB Streams enables other services to access and operate stream data. Some examples are:
Resources are conserved by combining metrics from several actions, such as buffering social media "likes" for a predetermined `period and combining the whole value only once.
An email is delivered when a client adds data to a DynamoDB database to ensure the additional data entry is accurate.
Up to a thousand times every minute, a mobile app refreshes a table with data. Another software records these changes and provides real-time app statistics like engagement.
However, they must be in the same region because AWS utilizes separate endpoints for DynamoDB and DynamoDB Streams.
DynamoDB Scan
By reading every item in a table or secondary index, a DynamoDB Scan generates a collection of results. By pressing the Sort Key, you may modify the Scan's order. A filter expression can also specify which items are returned from the Scan.
If possible, avoid doing scans because they might be expensive, and instead, use queries unless you really must go over every item.
DynamoDB Pricing
DynamoDB charges for accessing, writing, and storing data in your DynamoDB tables and any other features you select. DynamoDB provides two capacity modes for processing reads and writes on your tables:
On-Demand: This mode eliminates the need to define read and write throughput because it will scale up and down as needed. It is a fantastic alternative if you have volatility in your tables or traffic numbers.
Provisioned: A provisioned capacity specifies the number of reads and writes per second you anticipate you will be required. Autoscaling can change based on the set usage rate to ensure good performance and budget management.
The AWS Free Tier includes the following DynamoDB options. Each benefit is determined on a per-region, per-account basis each month.
-
Provisioned capacity of 25 WCUs and 25 RCUs
-
Data storage capacity of 25 GB
-
25 rWCUs for global tables distributed across two AWS Regions
-
2.5 million DynamoDB Streams stream read requests
-
1 GB of data transmission out (15 GB for the first year) aggregated across AWS services
Benefits of DynamoDB
Scalability and performance: Amazon DynamoDB is built for scalability. No need to be concerned about predetermined data storage restrictions for each table. Data of any size may be saved and retrieved. As the table develops in size, DynamoDB will distribute itself automatically.
Control rule access: DynamoDB's fine-grained access control gives the table owner more significant control over the data in the table.
Consistent schema item storage: DynamoDB is a NoSQL data model that processes less structured data more effectively than a relational data model. It makes it simpler to manage query volumes and provides high-speed queries for item storage in inconsistent schemas.
Automated data management: DynamoDB generates a backup of your data for safety reasons, allowing owners to have data preserved in the cloud.
Service management: Developers do not have to worry about setting up and configuring a distributed database cluster and maintaining continuing cluster operations. It controls the complexity of scaling, partitioning, and` re-partitioning data over more machine resources to fulfill I/O performance needs.
Speed: Amazon DynamoDB offers high throughput with extremely low latency. Latencies remain consistent as datasets grow due to the distributed nature of DynamoDB's data placement and request routing algorithms.
Long-lasting and widely accessible: Amazon DynamoDB replicates data across at least three separate data centers. Even in the face of varied failure scenarios, the system continues to operate` and serve data.
Flexible: Amazon DynamoDB supports the construction of dynamic tables, which can contain any amount of characteristics, including multi-valued attributes.
Cost-effective: We pay for what we use, with no minimum payments. Its price structure is simple to compute.
Conclusion
-
DynamoDB (non-relational database) is a stable service that allows small, medium, and big businesses to grow their applications.
-
AWS DynamoDB includes backups, restores, and security options and is suitable for mobile and web apps.
-
AWS DynamoDB is used to redesign almost any application, except for specific services such as financial transactions and healthcare.
-
DynamoDB makes it very easy to create event-driven architecture and user-friendly applications.
-
Any problems in analytical workloads are easily solved using an analytic-focused SQL layer, making DynamoDB a valuable tool for users.