Amazon DynamoDB is a fully managed NoSQL database service developed by Amazon. A recent meetup at Bi4 Group demonstrated how to connect to the service and how it compares to MongoDB.
DynamoDB is a non-relational database that was developed and open sourced by Amazon. It was developed to store shopping cart items from Amazon customers. DynamoDB lets users offload the administrative burdens of operating and scaling a distributed database, doing away with possible issues concerning hardware provisioning, setup and configuration, replication, software patching, or cluster scaling. Also, DynamoDB offers encryption at rest, eliminating the operational burden and complexity involved in protecting sensitive data.
This meetup focused on Python as the language from where to connect to DynamoDB. There are two ways to directly connect to DynamoDB. The first way is to use Boto, an official package from AWS and a wrapper around DynamoDB’s API. The second way is Pynamo DB, a Python wrapper that offers a more ORM-like approach to DynamoDB.
Boto offers all the available features from DynamoDB, but its reference guide is not that easy to understand. However, Boto is a very active project and is a little easier to use than the DynamoDB API itself. The second option to connect to DynamoDB is to use PynamoDB, a Python wrapper for DynamoDB that uses a more pythonic syntax. PynamoDB supports both the use of the DynamoDB API and a local version.
It’s easy to develop and test DynamoDB on a local environment. You can do this by launching DynamoDB at a local port, either by running a standalone .jar file or by launching a Docker container with a preconfigured DynamoDB image.
There are various resources available that compare DynamoDB and MongoDB. Compared to MongoDB, DynamoDB offers a highly scalable solution with higher throughput. DynamoDB supports less data types than MongoDB. Although DynamoDB’s queries have improved over time, they’re still quite verbose and complex. Multi-attribute indexes don’t exist in DynamoDB and there’s no support for datetime objects, which requires you to use either an integer timestamp or a date string. There’s a size limit for separate items: for DynamoDB this is 400KB, compared to 16MB for MongoDB. By far, the biggest advantage of DynamoDB is that management, maintenance and troubleshooting is all taken care of, in addition to offering encryption at rest.
DynamoDB offers high performance, but at a high price. It has a free tier “forever” option, so you can try it for something basic without having to pay. After that, the pricing model is based on Write Capacity Units (WCU), Read Capacity Units (RCU) and storage used by the DB itself.
DynamoDB is a non-relational database that is hosted and managed by Amazon. Although it has its strong points, it probably will not be a replacement for MongoDB anytime soon for Bi4 Group. Limits on the document size, the query engine, indexing and some other questions we discussed in the Meetup make the shift unviable for many of our current use cases. However, it might be an interesting alternative to MongoDB, for example when working with data that has a predictable schema, or when a guaranteed and stable read and write performance is required, or an infrastructure with high availability and strong replication needs.