Working of MongoDB (original) (raw)

Last Updated : 5 May, 2026

MongoDB is a document-oriented NoSQL database that stores data in BSON format with a flexible schema.

Components of MongoDB

MongoDB consists of core components that work together to store, manage, and retrieve data efficiently in a distributed environment.

1. Drivers

MongoDB drivers are client libraries that enable applications to connect to and interact with MongoDB databases using language-specific APIs.

2. MongoDB Shell

MongoDB Shell is an interactive JavaScript-based command-line interface used to interact with MongoDB databases.

3. Storage Engine

The storage engine manages how data is stored and retrieved from memory and disk.

MongoDB primarily uses the WiredTiger storage engine, with limited support for specialized engines.

Storage Engine Description Use Case
WiredTiger Default and primary storage engine, it supports document-level concurrency and compression. Ideal for most applications, including high-performance and write-intensive workloads.
In-Memory Engine Stores data in RAM for ultra-fast access; data is not persisted after restart. Suitable for caching and real-time, low-latency applications.

Working of MongoDB

MongoDB works on Application Layer and the Data Layer. The following image shows the working of MongoDB.

applicationLayer

1. Application Layer

The Application Layer, also known as the abstraction layer, connects users to MongoDB by handling user interaction and server-side processing.

2. Data Layer

The Data Layer is responsible for storing and processing data in MongoDB, handling queries and managing data storage through core components.

**Note: Reading and writing data from memory is much faster than from disk. MongoDB optimizes performance by using memory for frequently accessed data while relying on disk for long-term storage.

MongoDB Data Flow

This describes the internal flow of data across MongoDB components during operations:

  1. **User Interaction: The user interacts with the application (frontend) and sends a request.
  2. **Backend Processing: The backend server receives the request, processes it, and communicates with MongoDB using drivers or the MongoDB shell.
  3. **MongoDB Server: The MongoDB server receives the request, processes the query, and determines the required data operations.
  4. **Storage Engine: The storage engine performs data read/write operations in memory or on disk as instructed by the MongoDB server.
  5. **Response Return: The result is sent back from MongoDB to the backend, and then to the frontend for the user.