Definition
What it is
Traditional databases read/write from disk (even SSD, ~100 µs–1 ms). An IMDB keeps data in RAM (~100 ns), gaining 1000x latency improvement. The trade-off: RAM is volatile and expensive. Persistence is added via write-ahead logs, snapshots, or replication — but you're always working with a cached copy of disk or a copy that could be lost.
Examples: Redis, Memcached, Hazelcast, VoltDB, SAP HANA, Aerospike, Dragonfly. Each optimizes for a different access pattern.
Why it matters
For a storefront recommendation call, 100 ms from disk is a lost sale; 1 ms from RAM is invisible. IMDBs make real-time personalization economically viable. Redis caching is the most common architecture: DB is source of truth, Redis is the fast layer.
In-memory vs disk-based vs hybrid
Aspect | In-memory | Disk | Hybrid |
|---|---|---|---|
Latency | ~100 µs | ~10 ms | Varies |
Capacity | RAM-limited | Disk-limited | Both |
Durability | Snapshots + WAL | Full | Full |
Cost/GB | High | Low | Medium |
Example | Redis, Memcached | PostgreSQL, MySQL | SAP HANA |
Where IMDBs sit in a stack
graph LR R[Request] --> I[IMDB fast] I -->|hit| Resp[Response] I -->|miss| D[Disk DB] D --> I D --> Resp style I fill:#E8F5E9
How to use an IMDB well
IMDB that scales
Set eviction policy
maxmemory-policyon Redis:allkeys-lrufor caches,noevictionfor critical.Persist what matters
RDB/AOF for snapshots; replication for failover. Never treat IMDB as sole source of truth for critical data.
Cluster for scale
Single node = ~100 GB RAM. Shard above that.
TTL on everything ephemeral
Sessions, rate limits, temp tokens. Without TTL, RAM fills.
Common failures
Origin
The idea of keeping data in memory is as old as computing. Commercial IMDBs emerged in the 1990s for telecommunications (TimesTen, 1995). Memcached (2003) and Redis (2009) brought the pattern to web-scale caching. SAP HANA (2010) took it to enterprise analytics.
An in-memory database is a database management system that primarily relies on main memory for computer data storage.
— Wikipedia, *In-memory database*, 2024
Evidence
FAQ
- Are IMDBs durable?
Only with explicit persistence (snapshots, WAL, replication). RAM alone loses data on power loss.
- When to use?
Hot data with tight latency needs: sessions, caches, real-time ranking, rate limiters.
- Redis vs Memcached?
Redis has data types, persistence, pub/sub; Memcached is pure strings, simpler.
- Can I use IMDB as primary DB?
Only with replication + persistence. Most teams use disk DB as source of truth and IMDB as cache.
Connections
Zhang, H. et al. (2015). In-Memory Databases: A Survey. https://doi.org/10.1109/TKDE.2014.2349913
Redis (2024). Redis docs. https://redis.io/docs/
Etymology
Origin: compound
in-memory(adjective): data stored in RAMdatabase(noun): from Latin basis, "foundation"
Semantic network
● broader ● narrower ● related
Sources
Zhang, H. et al. (2015). https://doi.org/10.1109/TKDE.2014.2349913
Redis (2024). https://redis.io/docs/