Redis : Things You Should Know Before Using

Ganga Siva Krishna Palla
3 min readAug 6, 2019
redis

What is Redis?

Redis (/ˈrɛdɪs/; Remote Dictionary Server) is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.

What is In-memory database?

An In-memory database is a database management system that primarily relies on main memory for computer data storage.

Why Redis is faster than RDBMS?

cache-aside

An RDBMS uses RAM for caches, write-back buffers and other optimizations, and also persists data on an SSD or HDD.

Redis uses RAM for storing data, and as such all Redis data is stored primarily in the server’s main memory. This makes it so that both read and write operations are very fast.

Is Redis data volatile?

All data in Redis is stored in RAM.

RAM is a volatile memory. It only maintains its data while the device is powered.

So, to overcome this setback Redis stores a copy of data in RAM and persists this data on an SSD or HDD.

https://redis.io/topics/persistence

When to Redis?

  • Applications where response time is critical.
  • Not a typical standalone database
  • When you have a well-planned design
  • The size of your data is stable

Common Use Cases

  • Caching:With Redis’s capability to easily persist the data to disk, it is a superior alternative to the traditional memcached solution for caching.
  • Publish and Subscribe: Redis provides the capability to distribute data utilizing the Publish/Subscribe messaging paradigm.Some organizations have moved to Redis and away from other message queuing systems (i.e., RabbitMQ, zeromq) due to Redis’s simplicity and performance.
  • Queues : Projects such as Resque use Redis as the back-end for queueing background jobs.
  • Counters: Atomic commands such as HINCRBY, allow for a simple and thread-save implementation of counters. Since these are atomic operations, the counters will maintain consistency when accessed from multiple application servers.

Key Features

  • High-Level Data Structures
  • High Performance
  • Lightweight With No Dependencies
  • High Availability

Disadvantages of Redis:

  • Redis is an in-memory store: all your data must fit in memory.
  • Redis is a data structure server. There is no query language (only commands) and no support for a relational algebra. A lot of flexibility is lost.
  • Redis is NOT good if you need to minimize the chance of data loss in case Redis stops working (for example after a power outage).
  • Redis only offers basic security (in term of access rights) at the instance level.
  • A unique Redis instance is not scalable. It only runs on one CPU core in single-threaded mode. To get scalability, several Redis instances must be deployed and started.

Here, I have only described the main drawbacks, but there are also plenty of benefits in using Redis.

Who’s using Redis?

A list of well known companies using Redis:

And many others!, techstacks.io maintains a list of popular sites using Redis, the information may not be always updated since many companies change their tech stack during their lifetime, but is an interesting resource.

https://redis.io/topics/whos-using-redis

If you enjoyed this article please recommend and share.

--

--