Migration of MongoDB to DynamoDB

(5.0)

| 2153 Ratings

DynamoDB is one of the non-Structured Query Language (NoSQL) databases which 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 a 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 write capacity.

Inclined to build a profession as Devops Developer? Then here is the blog post on Devops Training Online.

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:

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. After combining the fields and splitting the tables, we ended up having search results which looks as follows:

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, 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.

You 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:

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.

DynamoDB also provides us with the “BatchGetItem” which can be used to get the search results for multiple keywords which 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.

Storing Data as String

One can choose to store their data which has been formatted as a string. Consider the example given below:

Now that you using DynamoDB, you will notice how it offers an 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 development of the product.

Subscribe For Free Demo

Phone *

E-mail Address *

Free Demo for Corporate & Online Trainings.

About The Author

Ravindra Savaram is a Content 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.

Popular Courses in 2019

Related Articles

Mindmajix - Online global training platform connecting individuals with the best trainers around the globe. With the diverse range of courses, Training Materials, Resume formats and On Job Support, we have it all covered to get into IT Career. Instructor Led Training - Made easy.