DEV Community

Cover image for The Document DB (Amazon DocumentDB)
Augusto Valdivia for AWS Community Builders

Posted on • Edited on

The Document DB (Amazon DocumentDB)

I hope you are having fun 😃 reading and building some cool stuff throughout this series of articles.

Until now we have learned:

On this article we will learn about our next database Amazon DocumentDB

What is an Amazon DocumentDB?

Amazon DocumentDB (with MongoDB compatibility) is a fast, reliable, and fully managed database service. Amazon DocumentDB makes it easy to set up, operate, and scale MongoDB-compatible databases in the cloud. With Amazon DocumentDB, you can run the same application code and use the same drivers and tools that you use with MongoDB.

rocket

How does one know when to choose an Amazon DocumentDB?

If you are searching for a database that allows you to store documents and provides you with fast access to query any attribute of your data, then Amazon DocumentDB is your DB of choice.

What are some industry Amazon DocumentDB use cases?

  • User Profiles
  • Real-Time Big Data
  • Personalization
  • Content Management
  • Mobile

Now that we have a general idea of Amazon DocumentDB let us continue drilling deeper and let us explore and build an Amazon DocumentDB resource:

If you are familiar with MongoDB Amazon DocumentDB gives you access to the following capabilities:

  • ACID transactions
  • Change streams
  • AWS Database Migration Service
  • Performance and indexing
  • Operators
  • Role based access control

Note: Although Amazon DocumentDB offers this list of capabilities it does not offer all of MongoDB capabilities known today. Please keep in mind that if you are planning to use this DB.

Let us see some important characteristics about Amazon DocumentDB

Amazon DocumentDB

Performance:

- Automatically storage grows in size as your data volume increase
- Storage volume increase in increments of 10 GB, up to a maximum of 64 TiB
- Can add replicas in minutes regardless of the storage volume size
-  Provides a reader endpoint, so the application can connect without having to track replicas as they are added and removed
- Collection size
 (sum of all collections can't exceed cluster limit) – does not include the index size    32 TB
- Collections per cluster   100,000
- Databases per cluster 100,000
- Document nesting depth    100 levels
- Document size 16 MB
- Index key size    2,048 bytes
- Indexes per collection    64
- Keys in a compound index  32
- Maximum number of writes in a single batch command    100,000
- Number of users per cluster   1000

Scalability:

- Amazon DocumentDB, can increase read throughput to support high-volume application requests by creating up to 15 replica instances
- Replicas share the same underlying storage, lowering costs and avoiding the need to perform writes at the replica nodes
- Scale compute and memory resources for each of your instances up or down. Compute scaling operations typically complete in a few minutes.

Availability:

- Often down to single digit milliseconds
- Continuously monitors the health of cluster
- On an instance failure automatically restarts the instance and associated processes
- Doesn't require a crash recovery replay of database redo logs, which greatly reduces restart times
- Automates failover to one of up to 15 replicas that one create in other Availability Zones
- Enables point-in-time recovery for each cluster. This feature allows you to restore your cluster to any second during your retention period, up to the last 5 minutes
- Backup retention period up to 35 days

Security:

- Runs in an Amazon Virtual Private Cloud (Amazon VPC)
- Can configure firewall settings to control network access to clusters
- Can encrypt your databases using keys that you create and control through AWS Key Management Service (AWS KMS)
- Encryption in transit for a cluster is managed via the TLS parameter
- Identity and Access Management (IAM)

Enter fullscreen mode Exit fullscreen mode

Please note that some of these limitations are adjustable and others are not.

Oh, right it is building 👷 time let us build this database using Terraform

Terraform code previous:

resource "aws_docdb_cluster" "doc_db" {
  cluster_identifier      = "docdb-cluster-name"
  engine                  = "docdb"
  master_username         = "user_name"
  master_password         = "Always_use_complex_password"
  backup_retention_period = 10
  preferred_backup_window = "00:00-01:00"
  skip_final_snapshot     = true
}
Enter fullscreen mode Exit fullscreen mode

Find the Terraform repo and directions for this project here

Diagram

DOCDB

References:

https://docs.aws.amazon.com/documentdb/latest/developerguide/limits.html

Enter fullscreen mode Exit fullscreen mode

Top comments (0)