DynamoDB is one of the non-Structured Query Language (NoSQL) databases that are currently in use today. Scaling of this database is very easy, and it offers no overhead in terms of administration. However, it has a limitation when it comes to the design of the schema.
Once you have migrated your data from MongoDB to DynamoDB, you will notice that the task of administering the data will be reduced and that it will be possible for you to archive the old data. The archiving here can mean that the data which is not queried more often by the database can be moved and stored in slow storage.
Each of the components can have a single table. After setting up the tables, the read and write operations can be specified for each of the tables, and this will be determined by how often the table is being accessed.
The database reserves up to 300 seconds of unused read and writes capacity.
If you want to enrich your career and become a professional in MongoDB, then visit Mindmajix - a global online training platform: "MongoDB Training" This course will help you to achieve excellence in this domain.
However, the index is one of the limitations that DynamoDB has. You are allowed to use either a hash key or a combination of the hash key and the range key. This means that a multiple-key index is not supported. The following is an example of the search result entry in our system:
{
name : “john”,
sex : “male”,
country : “US”,
results : “…”,
added_on : 2015-07-03T11:00:00Z
}
The solution to the limitation is to combine fields, and then split out the tables. When the tables are split, then this means that we will be having more tables in our system, and this will help in improving our control over capacity planning for the different data which we are handling.
Related BLog: [Comparing DynamoDB and MongoDB]
After combining the fields and splitting the tables, we ended up having search results that look as follows:
{
name : “john”,
sex : “male”,
results : “…”,
created_on : 2015-07-03T11:00:00Z
}
…
{
name : “hellen”,
sex : “female”,
results : “…”,
created_on : 2015-08-04T12:00:00Z
}
However, you need to be careful when dealing with this, as it has to match your use case and even the product. This means that it might not be an obvious solution to all of the similar problems, but it has guided you on how you can think outside the box and get things done.
You also need to note that in DynamoDB, the native Date or Date-Time object is not supported. This means that you have to come up with ways on how to handle these. The solution to this is to convert this into the Linux timestamp and then store the number. An example of this is given below:
{
name : “john”,
sex : “male”,
results : “…”,
added_on : 1248764145
}
What happens is that the conversion of the date into timestamp is done at the application layer and before we can query the DynamoDB. The sorting can also be performed at this point.
Checkout MongoDB Interview Questions
Your application can need to query the database for data, include the field for the date. In this case, you will have to Query the database rather than using the “GetItem” command. An example of this is given below:
find({
“keyword” : “john”,
“added_date” : new Date(2015, 1, 2)
});
In DynamoDB, I might need to query the following command:
“name” : {
“AttributeValueList” : [ { “S” : “john” } ],
“ComparisonOperator” : “EQ”
},
“added_date” : {
“AttributeValueList” : [
{ “N” : 1520170510 },
{ “N” : 1620256897 }
],
“ComparisonOperator” : “BETWEEN”
}
The querying can be done, but there are some problems associated with it. First, the Query command is slower when compared to the “GetItem” command, which is straight forward. In the latter case, the user is given both the hash key and the range key for matching.
Frequently asked Devops Interview Questions
DynamoDB also provides us with the “BatchGetItem” which can be used to get the search results for multiple keywords that are frequently used in applications. Each of the API requests to the DynamoDB can lead to an overhead which can add up whenever we are handling the names the application is requesting.
One can choose to store their data which has been formatted as a string. Consider the example given below:
{
name : “john”,
sex : “male”,
country : “US”,
results : “…”,
created_on : “2015-02-04”
}
We can then use the “GetItem” object so as to get our data more quickly. This is shown in the example given below:
“name” : {
“S” : “john”,
},
“added_date” : {
“S” : “2015-02-04”),
}
With the above, we will be in a position to fetch the data in batches. When you use the DynamoDB web console, the data will also become human-readable, which means that the user will save some time.
Now that you using DynamoDB, you will notice how it offers effortless scaling and zero maintenance. Some creativity is needed when designing the tables and breaking out of the old paradigm.
Other than concentrating on configuring your MongoDB, your efforts will only be needed in the development of the product.
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
DevOps Training | Nov 19 to Dec 04 | View Details |
DevOps Training | Nov 23 to Dec 08 | View Details |
DevOps Training | Nov 26 to Dec 11 | View Details |
DevOps Training | Nov 30 to Dec 15 | View Details |
Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.