DynamoDB: Why Do We Need One More Database?

    • stunntech blog author image
    • Muhammed Shah

  • |
  • March 20, 2019

Right now, we have more than plenty of Databases, like the MySQL, DB2, PostgreSQL for RDBMS and for Non-RDBMS we have MongoDB, Cassandra, Redis, CouchDB etc. So Why exactly do we want DynamoDB?

Here are my main 8 points where DynamoDB is much better than all other existing databases.


      1. Scalability

 One of the major advantages of Dynamodb is scalability. In SQL databases, we need to specify the structure of the table, ie Table Schema. What type of data we can insert and what type of datatypes can be used inside that etc. What if the developer needs to add an extra field to the database? First, you need to shut the Application then make a backup, then update the table schema, the make the App live again. So what if we want to have this on production run? Will the end-user be happy? Same with the Non-RDBMS like MongoDB, We want to have a predefined ‘Model schema’ for the table. We cannot add any data other than those predefined. Here the DynamoDB comes into play. The only thing DynamoDB wants predefined is their ‘Primary Key and Sort Key’. Then you can add anything to the Database. For example, you are developing an App, In that, you need a User signup Page. If the client is asking to add an extra field, just update the field that we want to be inserted, that's all. No more DB management headaches.


      2. The entire setup is done by AWS

Other advantages of Dynamodb is the configuration and setting up of DB is done by the AWS itself. No need to worry about installing drivers managing clusters, database management etc. These all are handled by AWS itself. No need to worry much about those part of setting up the Database and managing those. They have a built-in console to analyse the Read/Write usage and all. Even they have set up a notification mechanism if there is an unusual spike in the Read/Write. Another advantage of not handling the setup is that we don't want to handle the multiple querying and the processor core for the DB. Everything is handled by the AWS itself.


      3. Auto Scaling

The best feature of the DynamoDB is its auto-scaling. For an enterprise application, if the number of users changed from thousands to millions and we need to handle it, just turn on the auto scaling feature on. The basic plan of dynamoDB needs to specify the Read/Write capacity unit. These can be the bottleneck when we don't know how many users will be using our application? So using this auto-scaling feature, Our database can handle any amount of data Read / Writes.


      4. Multi-Tenancy support by default

In the case of other databases, we need to specify how the data will be abstracted from the other tenant users. This is much more important for enterprise-level users. In the Dynamodb it can be achieved by using the IAM Role provided by the AWS. We can restrict the user from a row level, or column level or even from the entire database. This is much more efficient and easy to use than on the other databases.


      5. Global Tables

In almost all databases, if we are having a user from different regions, and the database is residing on a single region may end up getting slower ping response for the distant users from the database region. Think of this instant, if our database is set up on the Indian server and then if our client is from the USA, He will be getting the response much slower. So think about having a million of users and you are providing a database from a single region. In Dynamo, AWS is providing a global table feature where we can setup a database for that region. If we want to share common data across databases, the database duplication is also handled by them.


      6. Dynamodb Stream Triggers

Another best feature of DynamoDB is Streams. Basically, the stream is a function which gets triggered when there is a database insert, modify or remove operation in done. The major advantage of an application is that, for example, for user signup, we need to create some default kinds of stuff for the user. So without streams, we may create a function like First signup user, then create default kinds of stuff, then sends back the success response. In streams, we can move that create default stuff operation to the streams. So if there is a DB change for user data, we can call the create default stuff function. Sounds cool right? It is.


      7. Secondary Indexes

Every database support querying on every field of a table. But DynamoDB needs indexes in order to search. The only Key they are providing by default is a primary key. We can use a Sort key also. But these two is not sufficient for the real-world application. So here comes the secondary indexes. We can create any field indexes. The index can be of a different type for DynamoDB, Local secondary index and global secondary index. Local index can’t be queryable, but the GSI supports querying. Another major feature is that we can have reverse GSI. that is if we are searching a user by using the username as PK and date joined as SK. If we want to query just the reverse, That is, we want to know which users are joined on date x to y. This can be achieved by DynamoDB.


      8. The Scariest Part

Yes, you guessed it right, the pricing. The pricing of dynamic is not for using the storage or how much time does the Read/Write time. It's for the size of Read/Write. The basic plan for the DynamoDB is $1.25 for 1 million WCU (Write capacity unit). The one WCU is 1kb. So basically they charge for having a write up to 1gb and Read capacity Unit costs $0.25 for 1 million RCU. But the cost is not just this, if we are having a basic plan and throttled DB, it will still take up the RCU and WCU from 1miilion. And for all secondary index, it costs. For Global tables, it costs much more. And streams are also highly priced.