Apresentando a Rediscover Magazine
MongoDB is a document-oriented, disk-based database. Redis is an in-memory, persistent, data structure store. Both databases fall into the NoSQL category – in that they are used to solve computing and data storage problems for which use of traditional RDBMS solutions would be like using a hammer to kill an ant.
But Redis and MongoDB are quite different and optimized for different uses. Disk based MongoDB is optimized for operational simplicity, schema-free design and very large data volumes.
Redis, on the other hand, is an in-memory, NoSQL data structures store, frequently used as a database, cache, or a message broker. Unlike other in-memory stores, it persists data and is remarkably versatile due to its data structures (Sets, Sorted Sets, Hashes, Lists, Strings, Bit Arrays). Redis enables developers to perform common operations on these structures at the lowest possible complexity and highest possible performance. In other words, Redis is purposebuilt for performance and simplicity.
MongoDB and Redis
A very common use case relevant to MongoDB users is Redis’ usage as a data ingestion buffer. MongoDB is awesome at handling any volume or variety of data being generated – however, extreme velocity poses a challenge to any disk – based database. When you have millions of data points coming at your application, using a disk-based database directly simply means that you run the risk of losing data or creating excessively long queues to store data yet to be processed.
Mobile, IoT, APIs and massively online applications usually have this problem – there is just too much data being generated for it to be digested easily by any disk-based database, even if it is for storing and batch analytics. Real-time, instantaneous processing is something that can’t be achieved with disk based databases, without throwing a lot of expensive hardware at the problem. This is where Redis comes in. With Redis running very efficiently in memory, it becomes radically simple to enable real-time analysis of fast moving data by shifting some of the processing to Redis.
Another scenario is when several documents in MongoDB are being updated simultaneously or in very close succession. Every update triggers a write to the database, requiring you to maintain multiple shards and throw a ton of hardware at the problem. By using Redis, which handles extremely high throughput at sub-millisecond latencies, instead, you can manage the updates in-memory and consolidate writes to the disk-based database. This approach reduces hardware needs and creates savings on operational costs.
However, don’t stop there: keep learning more and download now the complete and free ebook “5 Use Cases that Showcase Why You Need Active-Active Redis Enterprise” and good reading!