In-memory databases: use cases and pros-cons

Arun Singh
4 min readSep 12, 2022

In-memory databases are a valuable and attractive alternative to traditional databases that rely on the physical storage of data. Here are a few use cases where the incredibly high speeds offered by an in-memory database may outweigh the downside of less stable data.

Ecommerce

Storing a small component on an ecommerce application (such as a customer’s shopping cart) in an in-memory database can help provide a better customer experience by speeding up application response times. It greatly improves shopping cart conversion probability.

Selling online ads

Selling online ad impressions relies on dynamic bidding. In the time it takes a user to load a web page, multiple advertisers must bid simultaneously for the ad space that’s about to be created. This process must be completed in far less than a second, a job well suited to an in-memory database.

IoT sensor data

Networks of IoT sensors collect and transmit constant streams of data. Some organizations use an in-memory database to quickly compute and store IoT data prior to transfer to a traditional database for long-term storage.

Session stores and caching

Caching temporarily stores data to provide a faster experience for website users. Session management works similarly by temporarily storing information on a user’s identity and actions for tracking purposes. In-memory databases are ideal for storing temporary data and making it available for quick retrieval.

Real-time analytics

Being able to query data as it’s created offers some big benefits, especially when it comes to industries such as online retail and banking. Online retailers suggest related or similar products based on real-time actions of customers, providing additional opportunities to boost sales. In banking, in-memory databases can help analyze a consumer’s typical purchasing patterns quickly, allowing financial institutions to block potentially fraudulent transactions that deviate from the norm.

In-memory databases ?

Most databases, including cloud and on-premises systems, store data on physical hard drives. In contrast, in-memory databases store data within the RAM of one or more computers. The data isn’t committed to a hard disk―it exists only in the RAM.

When an in-memory database is created, the whole data set is uploaded directly into the working memory of the computer. The data within the database is reviewed and adjusted quickly as new data is committed to the database. Transaction logs are used to record changes. If needed, in-memory databases can be rolled back to an earlier state in the event an error occurs.

All data in an in-memory database must be processed according to ACID principles to ensure all transactions are processed reliably. To be ACID-compliant, data from an in-memory database must be easily retrievable in the event of a crash. There are two primary options to maintain ACID compliance: copy the data continuously from the database to a more stable form of storage, such as a cloud storage server, or store the data in nonvolatile RAM that can store files in a retrievable format.

DATABASE

With data stored directly in RAM, in-memory databases can perform in ways that aren’t possible when using traditional databases. Although this unique database configuration presents some significant benefits, it also comes with some significant drawbacks.

Advantages

Much higher access speeds

The biggest selling point of an in-memory database is its speed. With no need to retrieve data from physical storage, these systems are much faster than traditional databases, making it easier and quicker to complete data analytics tasks. Without any disk operations to contend with, latency is also more consistent.

Increased performance for read operations

In-memory databases remove the need to limit how many read operations are occurring simultaneously on a disk. With this constraint removed, different algorithms can be used to query the data, resulting in a general performance boost.

Evaluate all types of data with a distributed data infrastructure

Setting up a distributed data infrastructure can result in significant improvements in the storage capacity, processing, and transfer of unstructured data such as video, images, and text.

Disadvantages

Cost

The expense of in-memory data is substantially higher than cloud storage or on-premises options. Storing data in the working memory of a computer or network of computers is orders of magnitudes higher, so RAM storage is much more costly to purchase and maintain than disk storage.

High potential for data loss

RAM was originally intended to be used for temporary storage. If the computer or network crashes, the stored data could be lost. For this reason, it’s vital to use either nonvolatile RAM or replicate the in-memory database contents into a conventional database.

Increased performance for read operations

In-memory databases remove the need to limit how many read operations are occurring simultaneously on a disk. With this constraint removed, different algorithms can be used to query the data, resulting in a general performance boost.

Data storage constraints

RAM memory has far less storage capacity than the near-limitless storage capabilities of modern cloud warehouses. Networking computers together can help ease storage constraints to a point, but when RAM storage runs out, any new write operations would fail, resulting in unplanned data loss.

--

--

Arun Singh

Work as Enterprise Data Architect, Cloud Data Architect and focuses on building data architectures on cloud platforms. www.linkedin.com/in/arun-k-singh-3221372