Book Image

DynamoDB Applied Design Patterns

By : Uchit Hamendra Vyas
Book Image

DynamoDB Applied Design Patterns

By: Uchit Hamendra Vyas

Overview of this book

Table of Contents (17 chapters)
DynamoDB Applied Design Patterns
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

DynamoDB versus MongoDB


Both DynamoDB and MongoDB are NoSQL databases used to build for high scalability, high performance, and high availability. The main difference between the two is that DynamoDB is a service provided by Amazon AWS, so it can only run in AWS. MongoDB is a software application provided by the database company MongoDB Inc (formerly known as 10gen Inc), which can be installed and run anywhere. From the data model point of view, DynamoDB is a key-value database, which means that it's a columnar database, whereas MongoDB is a document-oriented Database. DynamoDB abstracts all the operations details of replication and sharding of the database from the end user, but in MongoDB we have full access to the source code and can dig into the file formats. This might be an advantage or a disadvantage. MongoDB uses internal memory to store the (windowed) working set, enabling faster access to data. So if our datasets are much larger than the accessible memory, then DynamoDB scales to much larger datasets.

DynamoDB is suitable for use cases where data access is by one or two dimensions of data, but if your data access patterns state more than two dimensions of data, then MongoDB is a better option, because it supports any number of indexes. MongoDB has major limitations when running MapReduce jobs, but DynamoDB integrates with Elastic MapReduce (EMR) and reduces the complexity of analyzing unstructured data.

If you have an AWS account, then DynamoDB is very simple to use, which means that we have to work only on applications, whereas other management of the database server would be handled by AWS. This means that if you have less manpower, then it's good to use DynamoDB. If we use DynamoDB, then other Amazon services, such as CloudSearch, Elastic MapReduce, and other services for database backup and restore can be easily integrated with it so that it can speed up development and reduce the cost of server management. In MongoDB, we must have the right servers, installation, and configurations. AWS provides excellent performance with DynamoDB by giving single-digit latency on very heavy data traffic. All data is replicated synchronously across all availability zones without any downtime, even while there are frequent throughput updates. The Amazon DynamoDB pricing policy is pay only for what you use, which means you can buy on operations-per-second capability instead of CPU hours or storage space. You have to specify the request throughput of your table you want to achieve (the capacity you request to reserve for reads and writes). The official AWS SDK supports Java, JavaScript, Ruby, PHP, Python, and .NET, while MongoDB mostly supports the likes of C, C++, Perl, Erlang, PowerShell, ProLog, MATLAB, and so on.

Let's look more closely into the comparison of DynamoDB and MongoDB:

Specification

DynamoDB

MongoDB

Data model

Key value

Document store

Operating system

Cross platform (hosted)

Linux

Windows

Solaris

OS X

License

Commercial

Open source

Data storage

Solid-state drive (SSD)

Any

Secondary indexes

Yes

Yes

Accessing method

REST API

JSON

Server-side script

No

JavaScript

Triggers

No

No

Partitioning

Sharding

Sharding

Integrity model supports

  • BASE

  • MVCC

  • ACID

  • Eventual consistency

  • Log replication

  • Read committed

BASE

Atomicity

Yes

Conditional

Transaction

No

Yes

Full text search

No

Yes

Geospatial indexes

No

Yes

Horizontal scalability

Yes

Yes

Replication method

Master-slave replica

Master-slave replica

Max. size value

64 KB

16 MB

Object-relational mapping

No

Yes

Function-based index

Yes

No

Log Support

No

Yes

Operation performed per second

1,000

10,000

User concepts

Access rights for users and roles can be defined via the AWS Identity and Access Management (IAM)

Users can be defined with full access or read-only access

In the previous table, the Integrity model supports row mentions a few values. They are as follows:

  • BASE: It stands for Basically Available, Soft state, Eventual consistency

  • MVCC: It stands for Multiversion Concurrency Control

  • ACID: It stands for Atomicity, Consistency, Isolation, Durability