Choosing the right database is a critical choice when building any software application. All databases have different strengths and weaknesses when it comes to performance, so deciding which database has the most benefits and the most minor downsides for your specific use case and data model is an important decision. Below you will find an overview of the key concepts, architecture, features, use cases, and pricing models of Apache Druid and MongoDB so you can quickly see how they compare against each other.

The primary purpose of this article is to compare how Apache Druid and MongoDB perform for workloads involving time series data, not for all possible use cases. Time series data typically presents a unique challenge in terms of database performance. This is due to the high volume of data being written and the query patterns to access that data. This article doesn’t intend to make the case for which database is better; it simply provides an overview of each database so you can make an informed decision.

Apache Druid vs MongoDB Breakdown


 
Database Model

Columnar database

Document database

Architecture

Druid can be deployed on-premises, in the cloud, or using a managed service

MongoDB uses a flexible, JSON-like document model for storing data, which allows for dynamic schema changes without downtime. It supports ad hoc queries, indexing, and real-time aggregation. MongoDB can be deployed as a standalone server, in a replica set configuration for high availability, or as a sharded cluster for horizontal scaling. It is also available as a managed cloud service called MongoDB Atlas, which provides additional features like automated backups, monitoring, and global distribution.

License

Apache 2.0

SSPL for community edition, commercial licenses for other versions

Use Cases

Real-time analytics, OLAP, time series data, event-driven data, log analytics, ad tech, user behavior analytics

Content management systems, mobile applications, real-time analytics, IoT data management, e-commerce platforms

Scalability

Horizontally scalable, supports distributed architectures for high availability and performance

Horizontally scalable with support for data sharding, replication, and automatic load balancing

Apache Druid Overview

Apache Druid is an open-source, real-time analytics database designed for high-performance querying and data ingestion. Originally developed by Metamarkets in 2011 and later donated to the Apache Software Foundation in 2018, Druid has gained popularity for its ability to handle large volumes of data with low latency. With a unique architecture that combines elements of time series databases, search systems, and columnar storage, Druid is particularly well-suited for use cases involving event-driven data and interactive analytics.

MongoDB Overview

MongoDB is a popular, open-source NoSQL database launched in 2009. Designed to handle large volumes of unstructured and semi-structured data, MongoDB offers a flexible, schema-less data model, horizontal scalability, and high performance. Its ease of use, JSON-based document storage, and support for a wide range of programming languages have contributed to its widespread adoption across various industries and applications.


Apache Druid for Time Series Data

Apache Druid is designed for real time analytics and can be a good fit for working with time series data that needs to be analyzed quickly after being written. Druid also offers integrations for storing historical data in cheaper object storage so historical time series data can also be analyzed using Druid.

MongoDB for Time Series Data

Although MongoDB is a general-purpose NoSQL database, it can be used for storing and processing time series data. The flexible data model of MongoDB allows for easy adaptation to the evolving structure of time series data, such as the addition of new metrics or the modification of existing ones. MongoDB provides built-in support for time-to-live (TTL) indexes, which automatically expire old data after a specified time period, making it suitable for managing large volumes of time series data with a limited storage capacity. MongoDB has also recently added a custom columnar storage engine and time series collection for time series use cases, meant to improve performance over the default MongoDB storage engine in terms of data compression and query performance.


Apache Druid Key Concepts

  • Data Ingestion: The process of importing data into Druid from various sources, such as streaming or batch data sources.
  • Segments: The smallest unit of data storage in Druid, segments are immutable, partitioned, and compressed.
  • Data Rollup: The process of aggregating raw data during ingestion to reduce storage requirements and improve query performance.
  • Nodes: Druid’s architecture consists of different types of nodes, including Historical, Broker, Coordinator, and MiddleManager/Overlord, each with specific responsibilities.
  • Indexing Service: Druid’s indexing service manages the process of ingesting data, creating segments, and publishing them to deep storage.

MongoDB Key Concepts

Some key terminology and concepts specific to MongoDB include:

  • Database: A MongoDB database is a container for collections, which are groups of related documents.
  • Collection: A collection in MongoDB is analogous to a table in relational databases, holding a set of documents.
  • Document: A document in MongoDB is a single record, stored in a JSON-like format called BSON (Binary JSON). Documents within a collection can have different structures.
  • Field: A field is a key-value pair within a document, similar to an attribute or column in a relational database.
  • Index: An index in MongoDB is a data structure that improves the query performance on specific fields within a collection.


Apache Druid Architecture

Apache Druid is a powerful distributed data store designed for real-time analytics on large datasets. Within its architecture, several core components play pivotal roles in ensuring its efficiency and scalability. Here is an overview of the core components that power Apache Druid.

  • Historical Nodes are fundamental to Druid’s data-serving capabilities. Their primary responsibility is to serve stored data to queries. To achieve this, they load segments from deep storage, retain them in memory, and then cater to the queries on these segments. When considering deployment and management, these nodes are typically stationed on machines endowed with significant memory and CPU resources. Their scalability is evident as they can be expanded horizontally simply by incorporating more nodes.
  • Broker Nodes act as the gatekeepers for incoming queries. Their main function is to channel these queries to the appropriate historical nodes or real-time nodes. Intriguingly, they are stateless, which means they can be scaled out to accommodate an increase in query concurrency.
  • Coordinator Nodes have a managerial role, overseeing the data distribution across historical nodes. Their decisions on which segments to load or drop are based on specific configurable rules. In terms of deployment, a Druid setup usually requires just one active coordinator node, with a backup node on standby for failover scenarios.
  • Overlord Nodes dictate the assignment of ingestion tasks, directing them to either middle manager or indexer nodes. Their deployment mirrors that of the coordinator nodes, with typically one active overlord and a backup for redundancy.
  • MiddleManager and Indexer Nodes are the workhorses of data ingestion in Druid. While MiddleManagers initiate short-lived tasks for data ingestion, indexers are designed for long-lived tasks. Given their intensive operations, these nodes demand high CPU and memory resources. Their scalability is flexible, allowing horizontal expansion based on the volume of data ingestion.
  • Deep Storage is a component that serves as Druid’s persistent storage unit. Druid integrates with various blob storage solutions like HDFS, S3, and Google Cloud Storage.
  • Metadata Storage is the repository for crucial metadata about segments, tasks, and configurations. Druid is compatible with popular databases for this purpose, including MySQL, PostgreSQL, and Derby.

MongoDB Architecture

MongoDB’s architecture is centered around its flexible, document-based data model. As a NoSQL database, MongoDB supports a schema-less structure, which allows for the storage and querying of diverse data types, such as nested arrays and documents. MongoDB can be deployed as a standalone server, a replica set, or a sharded cluster. Replica sets provide high availability through automatic failover and data redundancy, while sharded clusters enable horizontal scaling and load balancing by distributing data across multiple servers based on a shard key.

Free Time-Series Database Guide

Get a comprehensive review of alternatives and critical requirements for selecting yours.

Apache Druid Features

Data Ingestion

Apache Druid supports both real-time and batch data ingestion, allowing it to process data from various sources like Kafka, Hadoop, or local files. With built-in support for data partitioning, replication, and roll-up, Druid ensures high availability and efficient storage.

Scalability and Performance

Druid is designed to scale horizontally, providing support for large-scale deployments with minimal performance degradation. Its unique architecture allows for fast and efficient querying, making it suitable for use cases requiring low-latency analytics.

Columnar Storage

Druid stores data in a columnar format, enabling better compression and faster query performance compared to row-based storage systems. Columnar storage also allows Druid to optimize queries by only accessing relevant columns.

Time-optimized Indexing

Druid’s indexing service creates segments with time-based partitioning, optimizing data storage and retrieval for time-series data. This feature significantly improves query performance for time-based queries. Data Rollups

Druid’s data rollup feature aggregates raw data during ingestion, reducing storage requirements and improving query performance. This feature is particularly beneficial for use cases involving high-cardinality data or large volumes of similar data points.

MongoDB Features

Flexible Data Model

MongoDB’s schema-less data model allows for the storage and querying of diverse data types, making it well-suited for handling complex and evolving data structures.

High Availability

MongoDB’s replica set feature ensures high availability through automatic failover and data redundancy.

Horizontal Scalability

MongoDB’s sharded cluster architecture enables horizontal scaling and load balancing, allowing it to handle large-scale data processing and querying.


Apache Druid Use Cases

Geospatial Analysis

Apache Druid provides support for geospatial data and queries, making it suitable for use cases that involve location-based data, such as tracking the movement of assets, analyzing user locations, or monitoring the distribution of events. Its ability to efficiently process large volumes of geospatial data enables users to gain insights and make data-driven decisions based on location information.

Machine Learning and AI

Druid’s high-performance data processing capabilities can be leveraged for preprocessing and feature extraction in machine learning and AI workflows. Its support for real-time data ingestion and low-latency querying make it suitable for use cases that require real-time predictions or insights, such as recommendation systems or predictive maintenance.

Real-Time Analytics

Apache Druid’s low-latency querying and real-time data ingestion capabilities make it an ideal solution for real-time analytics use cases, such as monitoring application performance, user behavior, or business metrics.

MongoDB Use Cases

Content Management Systems

MongoDB’s flexible data model makes it an ideal choice for content management systems, which often require the ability to store and manage diverse content types, such as articles, images, and videos. The schema-less nature of MongoDB allows for easy adaptation to changing content structures and requirements.

IoT Data Storage and Analytics

MongoDB’s support for high data volumes and horizontal scalability makes it suitable for storing and processing data generated by IoT devices, such as sensor readings and device logs. Its ability to index and query data efficiently allows for real-time analytics and monitoring of IoT devices.

E-commerce Platforms

MongoDB’s flexibility and performance features make it an excellent choice for e-commerce platforms, where diverse product information, customer data, and transaction records need to be stored and queried efficiently. The flexible data model enables easy adaptation to changes in product attributes and customer preferences, while the high availability and scalability features ensure a smooth and responsive user experience.


Apache Druid Pricing Model

Apache Druid is an open source project, and as such, it can be self-hosted at no licensing cost. However, organizations that choose to self-host Druid will incur expenses related to infrastructure, management, and support when deploying and operating Druid in their environment. These costs will depend on the organization’s specific requirements and the chosen infrastructure, whether it’s on-premises or cloud-based.

For those who prefer a managed solution, there are cloud services available that offer Apache Druid as a managed service, such as Imply Cloud. With managed services, the provider handles infrastructure, management, and support, simplifying the deployment and operation of Druid. Pricing for these managed services will vary depending on the provider and the selected service tier, which may include factors such as data storage, query capacity, and data ingestion rates.

MongoDB Pricing Model

MongoDB offers various pricing options, including a free, open-source Community Edition and a commercial Enterprise Edition, which includes advanced features, management tools, and support. MongoDB Inc. also offers a fully managed cloud-based database-as-a-service, MongoDB Atlas, with a pay-as-you-go pricing model based on storage, data transfer, and compute resources. MongoDB Atlas offers a free tier with limited resources for users who want to try the service without incurring costs.

Get started with InfluxDB for free

InfluxDB Cloud is the fastest way to start storing and analyzing your time series data.