MongoDB Atlas

MongoDB Atlas Review and Features

Written by Melvin Kosisochukwu

Last update: 9/17/2024

FeatureMongoDB Atlas

Infrastructure, Underlying technology

Cloud Infrastructure, database system and underlying egine

MongoDB multi-tenant infrastructure, AWS, GCP, Azure

Serverless Support

Serverless and Edge computing support

API

HTTPS Rest API support to run queries in Edge runtimes

Edge Functions

Serverless functions that run closer to the user, reducing latency and improving performance.

Supported by any Edge Environment with fetch API

Developer Experience

Database type

OLTP

Data model

Databases store data in models, such as Relational, Columnar or Document based

Document based, NoSQL

CLI

Command Line Interface tools that allow developers to perform tasks and manage the tool via the command line.

atlas

Languages, APIs

The languages supporting the database and API interface for inter-process communication

All languages supporting MongoDB driver

Query language

Supported query language such as SQL, MQL, PartiQL,

Mongo-Query-Language (MQL)

ACID compliant

ACID is a set of properties of database transactions intended to guarantee data validity despite errors, power failures, and other mishaps
ACID compliant, document level atomicity.

Self-hosting

Support for self-hosted Database instance
Atlas managed service has advantages over self-hosted MongoDB

Backups

Atlas ensures continuous cloud backup of replica sets and consistent, cluster-wide snapshots of sharded clusters

Security & Compliance Offerings

SOC2

Service Organization Control 2 compliance for managing customer data.

Multi-factor authentication

Support of the cloud-histed database for multi-factor authentication

Encryption

Cryptographic security at rest and on transportation level

Atlas encrypts all cluster storage and snapshot volumes at rest by default

SSO

Monitoring and analytics

Log retention

Query log retention usually keeps lofs of operations for debugging and replication purposes

Atlas retains the last 30 days of log messages and system event audit messages for each tier in a cluster"

Statistics

Tools and APIs for analysing and monitoring of Database performance

Web based monitoring tools

Scalability

Replication and Partitioning

By default run on replicaset, can automatically scale based on load

Introduction

MongoDB is an open-source NoSQL database. It is a document-based database system that stores data in a JSON-like document system called BSON(Binary JSON) and provides flexibility with data querying and indexing. MongoDB allows you to store data of varying structures without the constriction of a predefined schema.

In addition to all the features that the database system comes with, it also provides a cloud database option called Atlas.

MongoDB Atlas

MongoDB Atlas is a cloud-based, serverless database service built on the MongoDB Database Management System. It improves how MongoDB is deployed, scaled, and operated on the cloud and includes features to simplify database management, such as text search, data triggers, auto-scaling, and aggregation pipeline.

MongoDB Atlas Integrations platforms

Atlas allows you to integrate with various platforms to improve functionality and interoperability with other tools. It also gives you the option to deploy your database instance on different cloud providers:

  • Microsoft Azure
  • Amazon Web Services (AWS)
  • Google Cloud Platform (GCP)

There is also support for integration with serverless functions and containerization platforms like Docker and Kubernetes.

Atlas also supports connections to Business Intelligence tools like:

  • SystemDNS
  • Excel
  • Tableau
  • Qlik Sense
  • MySQL Workbench
  • Power Bi

The Bi-Connector feature allows you to connect to the business Intelligence tools available in the MongoDB atlas; this feature is only available on M10 Clusters larger. For more information on how to connect to these Business intelligence tools, you can peruse the official documentation here.

Getting Started With Atlas

To get started, you must register for a MongoDB Atlas account using the Atlas UI. Once you have completed the registration, you can create and deploy a free cluster.

A cluster is a collection of interconnected servers(nodes) that work together to store and manage data in a MongoDB database. Clusters facilitate horizontal scaling and performant databases.

On your dashboard, after you log in to Atlas, click on the “+ Create” button.

Select the M0, the free tier option. Enter the cluster name and select the provider you would like to host the cluster on from the options; next up is the region where the cluster should be deployed.

Click on Create Deployment. On the next page, you will be prompted to set up a database user for your new cluster. Enter a username and Password, click on Create Database User, and progress to the next step on the form, where you will select a connection method.

In the next step, select “Driver” as a connection method and proceed to the last step, where you will receive instructions on how to connect to your MongoDB Atlas database with the connection string.

Language Support For Driver

The Driver connection option has client support for the most popular programming languages, which includes:

[@portabletext/react] Unknown block type "table", specify a component for it in the `components.types` prop

Managing Database Access

To manage your database access, you can create users and supported IP addresses that could access your database. To make a database, you need owner access to the Atlas organization or project. To create a new user, go to your Atlas dashboard and click on database access on the sidebar. On the screen, click on the “+ADD NEW DATABASE USER” button at the top left.

The modal has four Authentication options: Password, X.509 certificates, AWS IAM, and Federated Auth. We will walk through how to add a user with password authentication. In the authentication options, select Password. Enter the username and Password, and choose a role for the user. Atlas gives you the option to create a temporary user with access that expires in six hours, one day, or one week.

You can also control the IP access list in your database. On the sidebar, click on the network access; on the page, click on “+ADD IP ADDRESS.” this triggers a modal; you can fill in the details with your IP address or 0.0.0.0/0, which is a wildcard IP that allows access from everywhere.

Database

Databases in Atlas are logical containers for collections. Atlas UI provides a way for you to manage/interact with your database; this would allow you to create a new database or drop a database. To drop a database, you would need a user with owner and admin access. To create a database, navigate to the Database on your dashboard and click on browse the collection. On the next page, you will find the “+ CREATE DATABASE” button, which will trigger a modal/dialog. You will need to enter your database name, collection name, and additional preferences for your collection.

To drop a database, you can hover over the database, click the delete icon, trigger a Dialog where you will enter the database name, and then click “Drop.”

Collection

A collection is a group of related documents. The documents in a collection can have different typed fields, and a collection exists within a single database. Collections in MongoDB do not enforce a schema, meaning that documents within a collection can have different fields and data types. You can perform CRUD operations on a collection to insert, create, update, and delete documents.

Create A Collection

To create a collection, navigate to the collections tab, select a database, and click on the "CREATE COLLECTION" button. This will trigger the dialog with a form to enter the collection name and an optional dropdown of additional preferences for the collection. Click the "Create" button. You can view the collections associated with a database directly on your Atlas UI.

Drop A Collection

To drop a collection, you need to hover or select the collection and click on the trash icon. On the dialog, confirm the drop action by typing the name of the collection and Drop.

Documents

Documents are data structures that contain key-value pairs in Binary JSON (BSON) format. They are MongoDB's basic unit of data and are used to store and manipulate data.

Documents in mongoDB are not restricted by a schema. Documents in MongoDB are similar to JSON, meaning you can have nested documents and arrays. Atla provides an interface for performing query operations on documents. You can find an extensive guide on the different queries on the official documentation for documents.

The MongoDB drivers allow you to programmatically perform operations on the database, collections, and documents.

Indexes

Indexes are MongoDB data structures that store a small portion of a collection's data in an ordered form to improve query performance by reducing the number of documents that need to be scanned. When querying with indexes in MongoDB, the database uses the index to return only documents that match the query rather than scanning the entire collection.

Aggregation in MongoDB Atlas

Aggregation involves running all documents in a collection through stages called aggregation pipelines. This allows you to filter, refine, and transform data, collect summaries, and perform complex data operations. Aggregation in Atlas allows you to perform analytics operations directly on your database without having to move to another system, resulting in faster queries.

MongoDB lets you perform aggregation on the Atlas UI. Select the database and the collection you would like to perform aggregation operations. Click on the aggregation tab.

You can add stages to your pipeline by clicking the add stages button and selecting the operation you would like to perform on each stage. Each stage can have a different operation. Some of the operations that can be performed in an aggregation pipeline include:

  • $match: This operation performs a filter query on the collection based on specified criteria.
  • $group: This is used to group documents together based on a key. It helps calculate the total for the grouped documents, using $sum or $avg to calculate the average.
  • $sort: this can be used to sort documents in a specified order based on particular criteria.
  • $limit: This is used to control the maximum number of documents returned as a result.
  • $project: This is used to reshape the document by including or excluding fields, and it is useful for renaming existing fields.

The aggregation pipeline has many more operations and features that cannot be covered in this article. You can find out more information on aggregation here.

Sharding Collection

Sharding is a method for distributing system datasets over multiple servers/systems, adding additional servers to increase capacity as needed. It is used to support the deployment of large datasets. Sharding a collection allows you to distribute the data across multiple shards, improving performance and scalability for large data sets and high throughput operations.

Advantages of sharding

  • Read/Write workloads are distributed across the shard in the sharded clusters; each shard processes a subset of the cluster operation. This horizontal scaling helps improve the database's performance.
  • High availability due to the sharded cluster's ability to perform partial read/write operations when one or more shard replica sets are unavailable.
  • Sharding allows data to be spread across multiple systems, improving cluster storage.

Atlas Search

Atlas Search is a full-text search feature embedded in MongoDB Atlas. With It, you can easily create search indexes, construct search queries using the $search aggregation pipeline stage, and implement best practices for scaling and monitoring search workloads. Atlas Search is a relevance-based search that lets you create a search experience for your app's users without having to implement your search algorithm.

Relevance-based search, often referred to as relevance search, is an approach to information retrieval that prioritizes search results on their relevance to the user's query. It involves algorithms and techniques designed to analyze the content of documents or data and determine their relevance to a given search query, considering factors such as keyword frequency, proximity, context, and user behavior.

An Atlas search index is crucial in the Atlas Search component; it is a data structure that facilitates the categorization of data in an easily searchable format. Atlas Search indexes can be created by specifying the fields to index using dynamic mappings or static mappings. Dynamic mappings automatically index all fields of supported types in each document, while static mappings allow you to identify the fields to index selectively.

Atlas search indexes help improve your application's search functionality and quickly retrieve relevant documents based on the searched term. For more information, refer to the official documentation on Atlas Search.

Normalization vs Denormalization: A shift from traditional SQL thinking.

Normalization and Denormalization are different techniques for organizing data in a database. In traditional SQL databases, which are table-based, normalization is the preferred technique for data organization. Normalization involves splitting data into different tables to avoid data redundancy and improve data integrity. In MongoDB, the preferred technique is Denormalization, which involves combining data into a single document to make data retrieval faster.

Normalization involves splitting the data into multiple tables and establishing a relationship between each table using a foreign key. This helps reduce data duplication and improves consistency.

In Denormalization, related data that is frequently accessed/fetched together is stored together to improve data retrieval speed and reduce complex joins or frequent lookups. By duplicating frequently fetched data in documents, MongoDB can retrieve required data with fewer queries, resulting in improved performance. Denormalization does require a lot of maintenance to ensure data consistency, and while it improves performance, it might lead to additional complexity when updating data.

MongoDB Atlas pricing

The pricing for MongoDB atlas depends on various factors, such as type of instance, storage usage and cloud provider. Atlas offers diverse pricing options including a free option.

  • The shared pricing option involves shared RAM and vCPUs. Cost starts from $0/Month for the M0 cluster offering 512 MB storage, $9/Month for 2GB on M2 and $25/Month for 5GB on the M5 cluster.
  • The dedicated pricing option starts from $57/Month, offering 10GB to 4TB of storage, 2GB to 768GB RAM, Network isolation and fine-grained access controls, and Multi-region and multi-cloud options available.
  • The Serverless pricing option starts at $0.10/million reads. This offers up to 1TB storage.

For detailed information on each pricing you can visit the MogoDB pricing page.

Pros and Cons of using MongoDB Atlas

MongoDB and MongoDB Atlas offer many advantages to businesses and developers, but there are also some drawbacks to using these technologies. We will look at how these drawbacks and advantages compare.

Pros of using MongoDB Atlas

  • MongoDB allows for flexible document schema, making it easier for developers to work with.
  • MongoDB provides drivers for different programming languages, improving developers' accessibility.
  • MongoDB has a large community of users who can provide help and support.
  • Atlas provides a fully managed database as a service, removing the complexity of managing scaling and performance optimization for businesses and developers.
  • Scalability: MongoDB's horizontal scaling architecture allows the application to handle spikes in traffic and massive numbers of read/write requests.
  • Atlas provides powerful capabilities that improve the developer experience, such as full-text search and a fully managed backend service for building mobile and web applications.
  • Community-developed libraries that support MongoDB/Atlas; these libraries improve how MongoDB is used.

Cons of using MongoDB Atlas

  • Understanding the MongoDB Binary JSON(BSON) document model and query language might involve a learning curve.
  • Cost: While Atlas offers a free cluster, it is also a paid service, and the fee depends on usage.
  • There might be some efforts involved in migrating data from another database to MongoDB.
  • Although flexible schemas provide some advantages in data modeling and adaptability, they could also lead to data corruption. Without proper validation, incorrect or invalid data could be stored in the database.

MongoDB has a large community and technology, offering many advantages to developers and businesses interested in a NoSQL database. You can check out the Code Examples featuring different programming languages and provide practical usage examples for MongoDB. You should refer to the official documentation for additional information on MongoDB usage and the features it offers.