An Introduction To AWS DynamoDB
If you’ve been looking around for a NoSQL database to use, you’ve likely stumbled upon DynamoDB. For NoSQL databases, it’s one of the most effective and easy to use databases on the market today. Once you understand the basics, DynamoDB becomes a powerful tool that provides reliable, scalable storage for your data.
Important Features of AWS DynamoDB
AWS DynamoDB is Serverless
The average application utilizes 10% of its allocated server capacity. That means you’re wasting about 90% of the money spent on servers goes to waste. Plus, you’re potentially unable to handle spikes in traffic.
With a serverless environment, you’re only paying for compute when you need it. This optimizes your costs, but also enables you to scale. Because the underlying cloud platform is managing the scale of your application, you don’t have to worry about provisioning new servers, patching your operating systems, or hitting a wall with scalability. A serverless setup enables you to handle these key features automatically.
DynamoDB is a serverless product. Because of this, you communicate directly to DynamoDB via HTTP. It’s essentially an API for your data storage and retrieval. This simplifies workflows and allows you to leverage the same database across microservices.
Given that DynamoDB is an AWS product, it’s also able to take advantage of CloudFormation. This allows developers to create a database via code, and version control any changes to the keys, indexes, capacity, and other attributes of the database. The configuration itself also becomes easy to replicate across environments since the whole configuration is in code. We highly recommend taking advantage of CloudFormation and the Serverless Application Model when building out serverless environments with DynamoDB.
Since DynamoDb is a fully managed database, you don’t have to worry about updates or scaling. Getting your data structured appropriately will create high performance at any scale. Since DynamoDB replicates itself on various edge networks, you can actually get better performance with a higher workload. Try doing that with a relational database!
Wide Column Data Model
With relational databases, you have a table that represents an object and rows that represent attributes of that object. However, with DynamoDB, that isn’t the case. With DynamoDB, you aren’t creating as many tables as you would with a relational database. We typically only have one table and utilize a technique called index overloading to structure data.
Given each record in the database may be a different object, wide column stores allow us to create any attribute that we may need to represent the value of the data. Although this is less structured than relational data on the surface, it’s still important to maintain a proper database schema and making clear the object type as a value of the item.
Security with IAM
As an AWS resource, DynamoDB utilizes IAM for access control. IAM roles can be created and updated via the AWS console or a CloudFormation template. We highly recommend utilizing CloudFormation and tracking your infrastructure as code. It makes components easy to reuse. More importantly, you’ll always have backups of your infrastructure and can revert changes if necessary.
As a serverless product, DynamoDB is billed on how much you use it. If you don’t use DynamoDB, then you don’t have to pay for it. If your application reaches immense scale, you have to pay for it, but Dynamo will handle the scaling for you for the most part.
There’s two types of pricing models: provisioned capacity and on-demand capacity. Provisioned capacity is when you essentially guarantee that you’ll use a certain amount of resources when starting out. This requires a contract and minimum expense, although you’ll get cheaper compute at scale.
For most people starting out, you simply need on-demand capacity. You’ll pay for the service when you need it, and you aren’t locked into any minimum requirements. It’s a great option for starting out, and you can always move to a provisioned capacity if the numbers make sense.
To get a better understanding of what it will cost to run DynamoDB, check out the AWS cost calculator here.
Streams are a time series replication of changes to items in the database. Streams allow you to create an event driven architecture where certain actions occur when a given event takes place. Using Lambda, you can consume streams. For instance, you can send an email when an item is inserted into a database, update an attribute, or perform any combination of possible events in a Lambda function.
Streams are a very powerful feature of DynamoDB, and they help you maintain cleaner code and more reliable architecture.
When To Use AWS DynamoDB
Although there’s a ton of different use cases for DynamoDB, there’s two more common situations when it is certainly the right tool for the job.
If you’re doing work around IoT, messaging, or any other situation where you could have tremendous load on your database, there’s nothing better than DynamoDB in our opinion. It’s so reliable that Amazon mandates that it is used for all internal Tier-1 services. A Tier-1 service at Amazon is any piece of the application that captures revenue. Amazon knows that DynamoDB is scalable, and they literally put their money where their mouth is.
Second, any time you’re using a serverless architecture, it likely makes sense to use DynamoDB. Because it has an HTTP interface, it’s easy to communicate with from a multitude of services. DynamoDB is becoming the default database choice for serverless applications for good reason. It fits in seamlessly with a common AWS architecture.
If you’re going to use DynamoDB in an application, we recommend taking the following actions. First, take advantage of free credit programs offered by AWS. You may be eligible for up to $100,000 in credits that you can use towards DynamoDB expenses. Learn more about free credit options here.
Second, we highly recommend Dynobase as an intuitive client for DynamoDB. Dynobase enables you to properly structure queries, and generate code for your applications. It’s the cleanest, most intuitive client for DynamoDB that we have found. Click here to get Dynobase.