MongoDB vs Redis: How do these two powerful NoSQL databases, both with different focuses, compare? While MongoDB is primarily designed for large volumes of data, Redis impresses with its speed. The two systems can also be combined.

MongoDB: Scalable and flexible

MongoDB, derived from the English term ‘humongous’, is one of the best-known and most popular NoSQL systems in the world. The database was developed in 2009 by the company 10gen (now MongoDB Inc.) to store and securely manage large and diverse amounts of data. The system is char­ac­ter­ised in par­tic­u­lar by its high ho­ri­zont­al scalab­il­ity and the as­so­ci­ated flex­ib­il­ity that comes with it. MongoDB is written in C++ and is dis­trib­uted under the Server Side Public License as an open-source database man­age­ment system, which is con­tinu­ally being further developed and which offers ad­di­tion­al pro­pri­et­ary versions.

Tip

You can get the most out of MongoDB with Managed MongoDB from IONOS. You’ll benefit from extensive security features and from our expert ex­per­i­ence. Arrange a non-binding con­sulta­tion any time!

Redis: The NoSQL solution with speed

The two solutions in this MongoDB vs Redis com­par­is­on were released in the same year despite their many dif­fer­ences. Redis, whose name is derived from ‘REmote DIc­tion­ary Server’, was released in 2009. The in-memory database was pro­grammed in ANSI C by Salvatore San­fil­ippo. Like MongoDB, it is open source (under the 3-clause BSD license) and does not work re­la­tion­ally, largely dis­pens­ing with classic table patterns. The system’s simple design is par­tic­u­larly im­press­ive due to its high user-friend­li­ness and speed. The system itself is very sleek but can be expanded in a variety of ways, which is why it is one of the most fre­quently used key-value stores in the world.

Intended use

MongoDB is, above all, an expert in the field of big data. If you need to manage large amounts of data and different data types, the NoSQL solution offers all the right pre­requis­ites. The system is also designed for in­creas­ing re­quire­ments and therefore grows along with them. MongoDB has es­tab­lished itself in primarily for content man­age­ment, for e-commerce solutions and ap­plic­a­tions that should remain freely con­fig­ur­able and require constant, real-time analysis.

In com­par­is­on, Redis relies pre­dom­in­antly on the speed factor. Like MongoDB, it also stores data in key-value pairs and supports numerous data types. The standard response times of less than one mil­li­second is a special feature, which enables the pro­cessing of countless sim­ul­tan­eous requests in real-time. This makes Redis an ideal choice for caching or session storage, where fre­quently used data of different types needs to be made available as quickly as possible. Other areas in which mainly Redis is used are mes­sen­gers and chat rooms, (online) games, real-time analyses, streaming, financial services and the Internet of Things. Redis can be scaled both ho­ri­zont­ally and ver­tic­ally.

Func­tion­al­ity

Our com­par­is­on of MongoDB vs Redis shows that their ap­proaches and functions differ. Although both systems choose a non-re­la­tion­al approach, they interpret it dif­fer­ently. MongoDB stores data as documents in BSON format and bundles these documents into col­lec­tions. This data can be struc­tured, semi-struc­tured or un­struc­tured. The documents consist of key-value pairs, whereby the key is always a character string and the value can consist of other documents, arrays, Boolean values or other file types. In order to ensure high avail­ab­il­ity, MongoDB relies on sharding, in which data is dis­trib­uted across several nodes. Queries are made using the MongoDB Query Language.

Redis achieves its extremely high speeds because all data is stored directly in RAM and can therefore be made available im­me­di­ately. This means that the latency is quite low compared to most other solutions (despite this the storage space is limited). Like its opponent in the MongoDB vs Redis com­par­is­on, Redis also relies on key-value pairs. The in-memory database supports different values and data struc­tures, such as hashes, lists, sets, streams and strings. The re­spect­ive keys are stored in a dic­tion­ary and a parser is used to process multiple values. There are modules for ad­di­tion­al query functions.

Per­form­ance

MongoDB is a fast database that enables high-speed read and write queries. Thanks to the schema-free structure of the NoSQL solution, there are no delays even with large volumes of data. This speed is also achieved through a com­bin­a­tion of the different memories. However, when comparing MongoDB vs Redis, the in-memory database is usually sig­ni­fic­antly faster. As the data is stored directly in the main memory, it is available im­me­di­ately, which is why Redis is the optimal solution if content needs to be retrieved as quickly as possible. However, this also costs RAM. At 4 GB per 100,000 assets, con­sump­tion is around four times as high as with MongoDB.

Scalab­il­ity

A com­pletely different picture emerges when comparing the scaling options in the MongoDB vs Redis com­par­is­on. Although both systems offer generally good options, in this area it’s MongoDB that shines. The database is designed in such a way that it can grow ho­ri­zont­ally without re­stric­tions and manages a wide variety of data types. Sharding dis­trib­utes data in a way that makes it both available and able to be processed par­tic­u­larly ef­fect­ively. Although Redis offers ho­ri­zont­al and vertical scaling, it only ever uses one shard by default. Only hashed sharding is possible and man­age­ment must be carried out manually.

Avail­ab­il­ity

Sharding also has a positive effect on the avail­ab­il­ity of data in a MongoDB database. The system uses replica sets and allows users to create up to 50 replicas of a file. These can then be stored on different nodes. Automatic failover functions not only determine a primary point, but also auto­mat­ic­ally replace it im­me­di­ately in the event of a failure.

Redis also offers high avail­ab­il­ity and uses different nodes if required. However, there is no automatic failover unless this is set up manually by the ad­min­is­trat­or. If this is not the case, the failover must also be initiated in­de­pend­ently.

Com­pat­ib­il­ity

When you compare MongoDB vs Redis, the biggest sim­il­ar­ity is probably their excellent com­pat­ib­il­ity with operating systems and pro­gram­ming languages. As cross-platform systems, both com­pet­it­ors work under Linux, macOS and Windows. MongoDB also offers Solaris and Redis has BSD in its program. The selection of possible pro­gram­ming languages is also huge in both cases.

Pro­gram­ming language Supported by Mongo DB Supported by Redis
Ac­tion­script
C
C#
C++
Clojure
Cold­Fu­sion
Crystal
D
Dart
Delphi
Elixir
Erlang
Fancy
Go
Groovy
Haskell
knuckle
Java
JavaS­cript
Kotlin
Lisp
Lua
MatLab
Objective-C
OCaml
Pascal
Perl
PHP
Power­Shell
Prolog
Pure Data
Python
R
Rebol
Ruby
Rust
Scala
Scheme
Smalltalk
Swift
Tcl
Visual Basic

Query language

The query is performed dif­fer­ently for MongoDB and Redis. MongoDB relies on its own MongoDB Query Language (MQL), which supports a syntax similar to JSON. This also enables data analyses and queries across multiple areas and keys. Redis, on the other hand, does not have its own query language and instead uses simple commands to simplify and speed up data searches. Only key-value queries are possible by default. For further options, you need to integrate ad­di­tion­al modules.

Two open-source databases

Common to both MongoDB and Redis is the open-source approach that both systems pursue. Both rely on open standards that are used and further developed by a dedicated community. MongoDB provides ad­di­tion­al com­mer­cial versions such as En­ter­prise or Atlas (for use in the Cloud). These offer ad­di­tion­al security features and receive pro­fes­sion­al support.

Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flex­ib­il­ity with no minimum contract
  • 24/7 expert support included

Which companies use MongoDB and Redis?

There are numerous large companies that rely on one of the two con­tenders in our com­par­is­on of MongoDB vs Redis. Some of the best-known users of MongoDB are:

  • Adobe
  • Amadeus
  • AppScale
  • Craftbase
  • Disney
  • Etsy
  • Foursquare
  • Lyft
  • MTV
  • The New York Times
  • Via Varejo

Among other companies and platforms using Redis are:

  • Airbnb
  • Craigslist
  • GitHub
  • Hel­lo­Fresh
  • InstaCart
  • Instagram
  • Pinterest
  • Slack
  • Snapchat
  • Stack­Over­flow
  • Trello
  • Uber
  • X (formerly Twitter)

Is MongoDB or Redis right for you?

So who wins in the MongoDB vs Redis com­par­is­on? The answer depends hugely on your re­quire­ments. If you need a database that is char­ac­ter­ised by high speed and immediate data avail­ab­il­ity, Redis is your optimal choice. If your main focus is on big data and the greatest possible flex­ib­il­ity, you can’t go wrong with MongoDB. But if in doubt, you don’t have to choose at all! MongoDB and Redis also work extremely well together and can combine their re­spect­ive strengths. This allows you to benefit from the speed that Redis offers while retaining all the scaling options of MongoDB.

Tip

Would you like to find out more? In our Digital Guide you’ll find all kinds of in­form­at­ive articles on the databases. You’ll find an in­tro­duc­tion to Redis, a list of the best open-source databases and help with your first steps with MongoDB and many, many more!

Go to Main Menu