Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
DocumentDB
3.
Working 
4.
How to access my Amazon DocumentDB cluster
5.
Performance
6.
Amazon DocumentDB Storage
7.
Amazon DocumentDB Reliability
8.
High Availability
9.
Backing Up and Restoring in Amazon DocumentDB
10.
Security in Amazon DocumentDB
11.
Existing MongoDB authentication with Amazon DocumentDB
12.
Frequently Asked Questions
12.1.
What does "MongoDB-compatible" mean?
12.2.
Do I need to change client drivers to use Amazon DocumentDB?
12.3.
Does Amazon DocumentDB support ACID transactions?
12.4.
Which port does a DocumentDB cluster listen on?
12.5.
How fast is AWS DocumentDB?
12.6.
Is Amazon DocumentDB serverless?
13.
Conclusion
Last Updated: Mar 27, 2024
Easy

Amazon DocumentDB

Author Apoorv
1 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

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

DocumentDB

Some programmers fail to consider their data model in terms of normalized rows and columns. Data is typically represented as a JSON document in the application tier because it is more intuitive for developers to think of their data model as a document.

Document databases have increased in popularity because they allow you to persist data in a database using the same document model format as your application code. For flexible and agile development, document databases provide strong and intuitive APIs.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Working 

Amazon DocumentDB (with MongoDB compatibility) is a fully-managed database service that works with MongoDB. You can run the same application code and utilize the same drivers and tools with Amazon DocumentDB as you can with MongoDB. Amazon DocumentDB supports MongoDB 3.6 and 4.0.

To use Amazon DocumentDB, you must first create a cluster. A cluster comprises one or more database instances and a cluster volume that manages their data. A virtual database storage volume that spans multiple Availability Zones is known as an Amazon DocumentDB cluster volume. The cluster data is duplicated in each Availability Zone.
 

Source: https://docs.aws.amazon.com/

 

When your application sends data to the primary instance, it performs a long-term write to the cluster volume. The status of that writing (not the data) is then replicated to each active replica. Because Amazon DocumentDB replicas do not participate in write processing, they are better for reading scaling. After the primary instance writes the data, reads from Amazon DocumentDB replicas are finally consistent with little replica lag—usually less than 100 milliseconds. Reads from the replicas will always be read in the same sequence as they were written to the main. The rate of data change affects replica latency, and periods of intense write activity can increase replica lag.

How to access my Amazon DocumentDB cluster

Amazon DocumentDB clusters are hosted in a customer's Amazon Virtual Private Cloud (VPC) and can be accessed directly by Amazon Elastic Compute Cloud (EC2) instances or other AWS services hosted in the same VPC.Amazon DocumentDB can also be accessed via VPC peering by Amazon EC2 instances or other AWS services in separate VPCs in the same region or in other regions. The mongo shell or MongoDB drivers are required to access Amazon DocumentDB clusters. When connecting to an Amazon DocumentDB cluster, you must first authenticate. See Connecting to an Amazon DocumentDB Cluster from Outside an Amazon VPC for further information.

Must read, Amazon Hirepro

Performance

Amazon DocumentDB just writes write-ahead logs to storage and does not need to write full buffer page syncs. Amazon DocumentDB writes are often faster than traditional databases as a result of this optimization, which does not affect durability. With up to 15 read replicas, Amazon DocumentDB clusters may expand to millions of reads per second.

Amazon DocumentDB Storage

The data in Amazon DocumentDB is kept in a cluster volume, which is a single virtual volume with solid-state disks (SSDs). A cluster volume is made up of six copies of your data that are duplicated automatically across several AWS Regions and Availability Zones. This replication ensures that the data is highly durable and minimizes data loss. Because copies of your data already exist in different Availability Zones, it also helps ensure that your cluster is more available during a failover. These copies can keep serving data requests to your Amazon DocumentDB cluster's instances.

Amazon DocumentDB Reliability

Amazon DocumentDB is built to be dependable, long-lasting, and fault-tolerant. (You should set up your Amazon DocumentDB cluster so that it has many replica instances in different Availability Zones to improve availability.) Amazon DocumentDB has a number of built-in features that make it a dependable database.

High Availability

By using replicas as failover targets for the primary instance, Amazon DocumentDB provides highly available cluster configurations. If, in any case, the primary instance fails, an Amazon DocumentDB replica becomes the new primary; however, there is a temporary interruption during which read and write requests to the primary instance fail with an exception.

If your Amazon DocumentDB cluster has no replicas, a failure causes the primary instance to be recreated. Promoting an Amazon DocumentDB replica, on the other hand, is far quicker than re-creating the primary instance. We recommend creating one or more Amazon DocumentDB replicas as a failover target.

Unlike other databases, Amazon DocumentDB does not need to replay the redo log from the most recent database checkpoint (usually five minutes) and certify that all changes have been implemented before making the database operational again. In most cases, this reduces database restart times to less than 60 seconds. When you restart Amazon DocumentDB, the cache is removed from the database process and made available instantly. You won't have to throttle access until the cache is repopulated to avoid brownouts.

Backing Up and Restoring in Amazon DocumentDB

Amazon DocumentDB (with MongoDB compatibility) backs up your data for 1–35 days to Amazon Simple Storage Service (Amazon S3), allowing you to restore to any point during that time rapidly. As part of this continuous backup procedure, Amazon DocumentDB takes automatic snapshots of your data. You can also create a manual snapshot of your cluster's data to save backup data longer than the backup retention time. The backup process has no effect on the performance of your cluster.

Security in Amazon DocumentDB

At AWS, cloud security is a top focus. You have access to a data center and network architecture intended to meet the needs of the most security-conscious enterprises as an AWS customer. AWS is in charge of safeguarding the entire infrastructure that powers AWS Cloud services. AWS also supplies you with services that are safe to utilize. As part of the AWS compliance initiatives, third-party auditors test and verify the effectiveness of our security. AWS is responsible for the infrastructure that supports AWS Cloud services.AWS also supplies you with services that are safe to utilize. As part of the AWS compliance initiatives, third-party auditors test and verify the effectiveness of our security. The AWS service that you utilize determines your obligation. Other considerations include the sensitivity of your data, the requirements of your company, and applicable laws and regulations.

Existing MongoDB authentication with Amazon DocumentDB

Amazon DocumentDB uses VPC's stringent network and authorization border. IAM users, roles, and policies offer authentication and authorization for Amazon DocumentDB administration APIs. Authentication to an Amazon DocumentDB database is done using normal MongoDB tools and drivers, and the default authentication technique for MongoDB is Salted Challenge Response Authentication Mechanism (SCRAM).

Frequently Asked Questions

What does "MongoDB-compatible" mean?

Amazon DocumentDB is "MongoDB compliant," which implies it works with the Apache 2.0 open source MongoDB 3.6 and 4.0 APIs. As a result, you can utilize Amazon DocumentDB with the same MongoDB drivers, apps, and tools. While Amazon DocumentDB supports the great majority of MongoDB APIs used by customers, it does not support all of them. Our primary goal has been to provide capabilities that customers actually utilize and require.

Do I need to change client drivers to use Amazon DocumentDB?

No, Amazon DocumentDB works with a vast majority of MongoDB drivers compatible with MongoDB 3.4+.

Does Amazon DocumentDB support ACID transactions?

Yes. Amazon DocumentDB now supports atomicity, consistency, isolation, and durability (ACID) transactions across multiple documents, statements, collections, and databases, thanks to the addition of MongoDB 4.0 compatibility.

Which port does a DocumentDB cluster listen on?

The name of the replica set cannot be changed. Connecting to the cluster endpoint in replica set mode is advised for general use. All instances in an Amazon DocumentDB cluster listen for connections on the same TCP port.

How fast is AWS DocumentDB?

Amazon DocumentDB writes are often faster than traditional databases as a result of this optimization, which does not affect durability. With up to 15 read replicas, Amazon DocumentDB clusters may expand to millions of reads per second.

Is Amazon DocumentDB serverless?

DocumentDB is not a serverless service. You need to manage the backend server to use it.

Conclusion

In this article, we have extensively discussed the theory of Amazon DocumentDB. We also explored concepts like its working, security, performance, etc.

After reading about the Amazon DocumentDB, are you not feeling excited to read/explore more articles on the topic of AWS? Don't worry; Coding Ninjas has you covered. To learn, see Introduction to AWSAWS FeaturesManaging Devices with AWS IoTAWS Amplify, and AWS Cost & Usage Report.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc., you must look at the problems, interview experiences, and interview bundle for placement preparations. 

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Live masterclass