• Articles

AWS DynamoDB - Explained

AWS DynamoDB - Explained

Overview

One of the most appealing parts of cloud computing services is the ability for developers to adopt a hands-off approach for time and budget-consuming areas such as assuring that capacity is never constrained or underutilized. DynamoDB automatically expands up to rising demands without restricting or delaying performance and then shrinks down to avoid wastage of resources.

The following topics are going to be discussed in this blog:

Table of Content

Take a look at our video on Amazon DynamoDB for a better understanding.

Video Thumbnail

Let us begin with a quick introduction to DynamoDB.

What is Amazon DynamoDB?

Amazon DynamoDB is a fully-managed NoSQL database service developed by Amazon between 2004 and 2007 for its own functional requirements.

DynamoDB is a database that requires very little setup and maintenance on the side of the user while providing excellent speed and flexibility. It is a key-value and document database with response speeds in the single digit milliseconds at any size. It is a fully managed, long-lasting database with security, backup, and restoration installed.

DynamoDB is usually referred to as a NoSQL database, which essentially indicates that it does not employ the typical SQL query language found in relational databases. Rather it uses a basic key-value format to store JSON objects.

Next, let us find out the pricing of DynamoDB.

Amazon DynamoDB Pricing

As part of the AWS Free Tier, you get the following Amazon DynamoDB features. Every payment is determined on a per-region, per-payer account on a monthly basis.

  • The provisioned capacity of 25 Write Capacity Units and 25 Read Capacity Units
  • Data storage capacity of 25 GB
  • In two AWS regions, there are 25 replicated write capacity units (rWCUs) for global tables
  • DynamoDB Streams received 2.5 million stream read requests
  • 1 GB of data transfer out (15 GB for the first 12 months) across all AWS services

Apart from the free tier, DynamoDB tables have two pricing options on demand and are provisioned.

DynamoDB charges for accessing, writing, and saving data in your DynamoDB tables as well as for adding any other functionality. DynamoDB provides two capacity modes, each with its own set of billing options for handling reads and writes on your tables.

On-demand

This mode eliminates the need to define the read and write throughput because it will scale up and down as needed. If your tables or traffic numbers include an element of volatility, this is a smart alternative.

Provisioned

This mode allows you to indicate the number of reads and writes per second that you anticipate being required. Here, autoscaling is provided to modify based on the given usage rate, ensuring great performance and budget control.

Prices vary depending on the region you use for both choices, so it is worth using the calculator to get an approximation.

Why is Amazon DynamoDB Essential?

DynamoDB aligns with the ideals of serverless applications—automated scalability based on your application load, pay-per-use pricing, ease of use, and no need to manage servers. As a result, it is a popular choice for AWS Serverless applications. Many firms also choose DynamoDB to power their serverless apps due to its low maintenance requirements and strong interaction with AWS’s serverless solution and AWS Lambda.

Since AWS DynamoDB is a key-value store, it is particularly advantageous to use when a single product in a single DynamoDB database includes all the data that is required for a specific single operation in your program. For instance, if your application dashboard shows a person and the articles they’ve read, then it will perform better and charge the cheapest per query if the articles are stored in the user entity.

However, putting users in one database and articles in another, when updating the page, necessitates retrieving one user and ten separate book entries. This may make DynamoDB less suitable—additional queries cost more and slow down your overall application experience when contrasted with a traditional data store.

Cloud Computing EPGC IITR iHUB

Terminology

Before getting started to know exactly how DynamoDB works, you need to know about a few terminologies.

  • Tables are collections that can hold an almost unlimited number of things including secondary indexes.
  • Secondary indexes use a distinct primary key and sort key to duplicate table elements.
  • Primary key is a type of attribute that is used to refer to things in the same way that an item ID is used.
  • Sort key is used to group objects in distinct sorting order.
  • Item stores data characteristics in a JSON format and is the most fundamental unit in DynamoDB.
  • Attribute is a key-value combination that provides informational data points about an item in a database table.
  • Streams are continuous streams of actions that change the state of a table.
  • Query is a method of retrieving a certain object or set of items.
  • Scan is a procedure for scanning a whole table or a piece of it.
  • Filter is a set of parameters to apply after a query or scan is completed but before the requester receives the results.

How does Amazon DynamoDB Work?

How does Amazon DynamoDB work?

DynamoDB architecture, like other databases, stores data in tables. Each table has a number of objects, each of which has a number of fields or characteristics. Each table must have a primary key, which must be present in all elements of the table. The primary key can be a single attribute or a combination of two attributes—a partition key and a sort key. You may use the main key to refer to individual objects in a table, or you can create your own indexes and use the keys from them.

Your DynamoDB table is not hosted on a single server, the data is instead spread over several servers ensuring scalability and great speed, but also preventing you from directly querying your data through a database host. You must use the Amazon DynamoDB HTTP API to write and read entries to and from a DynamoDB table, either directly or using the AWS SDK or AWS CLI. You can also batch read and write to AWS DynamoDB tables, even across several tables at the same time. Transactions, automatic backups, and cross-region replication are all supported by DynamoDB.

How to Get Started with Amazon DynamoDB?

AWS DynamoDB is really easy to set up. We will utilize the settings and features available in the AWS Free Tier here, so you are able to recreate a comparable version if you’re just getting started.

Step 1: Create a NoSQL Table

To make a NoSQL table, follow these steps.

  • Select Create Table from the DynamoDB console.
  • The table must then be given a name.
  • Use a feature with a range of values and uniformly dispersed access patterns for the Primary Key or Partition Key, which is used to redistribute data across partitions for scalability.
  • The Sort Key does exactly what it says—it allows you to sort the data. Another value that works across all of your data and can help you delve further into the table is required here.
  • The Default Settings box must be unticked to enable DynamoDB Auto Scaling. This will automatically create the DynamoDBAutoScaleRole AWS IAM role, which will control the auto-scaling process.
  • Finally, click Create after scrolling all the way down.

Step 2: Write Data to a Table using the Console or AWS CLI

  • Insert additional elements into the table you made in Step 1.

Step 3: Read Data from a Table

  • Here, you need to read back an item prepared in Step 2. By specifying an element, DynamoDB Scan helps you read an item from the table using the AWS DynamoDB terminal or AWS CLI.

Step 4: Update Data in a Table

  • Now, you need to update an item that you generated in Step 2. By supplying an element and the revised name, you may update the name of an item in the table using the DynamoDB console or AWS CLI.

Step 5: Query Data in a Table

  • By specifying elements in this step, you query the data that you wrote in the table in Step 2. This will show you all of the tracks that are linked to the primary key. This is a DynamoDB query.

Step 6: Create a Global Secondary Index

  • Now, you have to construct a global secondary index for the Music table that you generated in Step 1.

Step 7: Query the Global Secondary Index

  • Using the AWS DynamoDB interface or AWS CLI, you may query the table’s global secondary index.

With these simple steps, you can get started with DynamoDB.

Get 100% Hike!

Master Most in Demand Skills Now!

DynamoDB vs MongoDB

Now, let us differentiate between DynamoDB and MongoDB.

ParametersDynamoDBMongoDB
Ability to Run AnywhereIt is only available in AWSIt deploys anywhere
Released in the Year20122009
Data ModelJSON support for a limited key-value storageDocument repository based on JSON
Popularity and AvailabilityIt is 16th most popularIt is fifth most popular
QueryingOnly key-value queries are allowedIt is rich in query language
Data TypesDynamoDB data types are lesser compared to MongoDBIt offers additional built-in data types
IndexingThe settings for DynamoDB are pre-configured and handled by AWSIt provides more granular indexing settings
Data IntegrityEventually consistentStrongly consistent
IntegrationOther AWS services are strongly integrated with itOther AWS services are not natively integrated with it
Monitoring & Performance TuningBlack boxTransparent
BackupOn-demand or continuous backupOn-demand, continuous, or snapshot backup
PriceHighly variableConsistent

Advantages of Amazon DynamoDB

In this section, we will talk about the various advantages of AWS DynamoDB.

  • Fully Managed

Everything has been taken care of. It is a completely managed solution, which means that you don’t have to do anything to keep the database functioning.

  • Performance and Scalability

Developers may satisfy consumer demand by combining incremental scalability and high performance with the convenience of cloud management, dependability, and tabular data architecture provided by DynamoDB.

  • Automatic Replication

With DynamoDB Global Tables, you can create a multi-master, multi-region database with little setup and upkeep. When you have consumers in different parts of the world using locally-deployed instances of your application, this can assist in speeding up its performance.

  • Greater Efficiency

Using a fully managed solution decreases the amount of time your team spends on operations, enabling you to invest more time in product development.

  • Secure

DynamoDB is secure because it employs tried-and-true mechanisms to authenticate users and prevent illegal data access.

  • Support for Streaming

You may build streams of changes to your data tables with DynamoDB. This makes adding automation based on your DynamoDB data changes a breeze.

  • Time to Live (TTL)

TTL is a procedure that allows you to provide a timestamp for deleting expired data from your tables. TTL can help you save space and money by reducing the amount of data you save.

  • Fine-grained Access Control

It offers the owner of a DynamoDB table a lot of power over the data in the table.

Disadvantages of Amazon DynamoDB

Moving on, let us now discuss some of the disadvantages of DynamoDB:

  • It is a private database with no open-source version.
  • It demands that your data be accessed in a consistent manner.
  • It prevents you from joining data from various tables.
  • It can only be deployed on AWS and not on individual computers or servers.
  • The querying data is quite constrained.
  • There are no Triggers in this field.
  • There is no idea of foreign keys to refer to other table entries.
  • It has quite a few limits—the partition throughput limitations, the item size limit, and the page size limit for Query and Scan operations.

Amazon DynamoDB Use Cases

DynamoDB has a plethora of applications since it is a service that is required in a wide range of circumstances. Disney, Dropbox, Snapchat, Zoom, and many more established corporations use DynamoDB as part of their infrastructure.

The following are a few use cases for DynamoDB:

  • To create smartphone apps
  • To make a database of media metadata
  • To deliver a consistent shopping experience
  • To develop platforms for large-scale gaming

Conclusion

Amazon DynamoDB is a perfect alternative for today’s real-time, web-based applications since it allows you to outsource the operations and scalability of a highly-available distributed database cluster.

Hope you have acquired familiarity with the topic.

Course Schedule

Name Date Details
AWS Certification 14 Dec 2024(Sat-Sun) Weekend Batch View Details
21 Dec 2024(Sat-Sun) Weekend Batch
28 Dec 2024(Sat-Sun) Weekend Batch