What is Redis?

Connect with

what is RedisWhat is Redis, Redis is an open-source NoSQL advanced Key-value database for In-memory cache. Learn features of Redis, why we use Redis, use case of Redis.

1. Overview of what is Redis In-memory cache

This is more than the distributed key-value, in-memory, replication of key, for caching server.
Redis is an open-source NoSQL advanced Key-value database, which is written in C. ReDiS is the short form of Remote Dictionary Server, so you can write it RediS too based on the short form of Redis. It also referred to as a data structure server. This is more than the distributed key-value, in-memory, replication of key, for caching server.

Redis is not only used for cache solutions and Session Management, this is more than in-memory caching. Redis is most widely used in caching solution. Here, I’m going to share with you high level stuff about Redis one by one. I know, explaining all the things in one post is not feasible, so I try to cover high level only in this post.

2. Features of Redis

You should understand features of Redis before understanding what is Redis. There are so many features of Redis distributed caching system.

  • Data is being persistent in-memory as well as stored on disk that’s make Redis fast.
  • Redis supports simple master-slave replication.
  • Redis can execute 1,00,000 queries per second.
  • Redis can be used for PUB/SUB or QUEUE .

3. Advantages of using Redis

  • High speed
  • Support pub/sub , queue, durability
  • Server-side locking
  • Rich Client Side Library
  • Support Atomic Operation

4. Limitations of Redis

Every system has some limitation so the Redis has too, following are the limitation of Redis.

  • Single threaded
  • It has got limited client support for consistent hashing
  • It has significant overhead for persistence

5. Which one you choose Speed OR Durability?

If you ask yourself , Redis gives you which one , Speed or Durability or both? Answer is NO, Redis purposely compromise the durability to enhance the speed. In Redis, in the event of system failure or crash, Redis writes to disk but may fall behind and lose the data which is not stored.

In order to improve durability in Redis, or you can say, to improve the durability of Redis, uses “append only file” strategu, which can be configured by using fsync data on disk. But be careful when you configure fsync()

  • Fsync() every time : a new command is added to the append log file: It is safe but very slow.
  • Fysnc() one time every second: It is fast, but you may lose 1 second of data if system fails.
  • Never fsync(): It is an unsafe method, and your data is in hand of Operating System.

6. List of operation keys of Redis

What is Redis operations. Key operations of Redis includes:

  • TYPE key
  • TTL key
  • KEYS pattern
  • EXPIRE key seconds
  • EXPIREAT key timestamp
  • EXISTS key
  • DEL key

7. Use case of Redis

There is so many use case of Redis but here I cover only a few main use case of Redis.

  • For Distributed Caching
  • for storing of app session
  • for pub/sub
  • for Que

8. Why we use Redis?

You can ask yourself why we use Redis? we can find a few answers, here, I try to cover why we use Redis. Following is the list of reasons to use Redis in your distributed Application but this is not final.

  • Data Replication: by supporting multilevel master-slave cluster set up Replication supports multiple & multilevel slaves.
    – Automatically restores & partially (re)synchronizes the master-slave connections on outrage.
  • Publish-Subscribe Interface: designed over the paradigm of high decoupling, it facilitates user by providing a ready to use publication & subscription interface
  • Expiry with TTL: Redis keys could be configured/set to automatically expire on specified time interval for each key.
  • LRU (Least Recently Used) Capabilities: the ‘maxmemory’ directive is used in order to limit the memory usage to a fixed amount. On reaching at max memory usage, it evicts the keys as per specified LRU policies among 6 available options.
  • Ease of Use: easy to use commands. It supports high-level, atomic & server-side operations (no need to write code) like intersection, union between sets or Sorting of lists, sets etc.
  • Automatic Failover & Highly Available (HA): it supports clustering via Redis Sentinel, a system designed to monitor cluster-instances, notify user if something goes wrong, handle failover by electing new master and act as configuration provider.
  • Partially Transactional: it supports partially ACID (atomic, consistent, isolated, durable) transactions. A transaction would start by executing MULTI command and flush then exit by executing DISCARD. The transaction supports CAS (check-and-set) behavior but can’t roll-back.
  • Great Performance: when get/set keys during heavy load time. Though it works in single-threaded model, it offers faster read/writes than any RDBMS due to its in-memory nature. it serves One lac of key in a sec if you required more than this then you have to configure cluster.
  • Database as a Service: it is deployed & available as a managed service on all leading cloud providers like Amazon, Rackspace …
  • Partially Secure: it is designed to be accessed by trusted clients inside trusted environments only. While it does not try to implement Access Control, it provides authentication layer that could be turned on by editing the ‘redis.conf’ file. In secure mode, it is required by client to authenticate itself by sending the ‘AUTH’ command followed by the password before executing any data request.
  • Persistence by Snapshotting: perform point-in-time snapshots of your dataset at specified intervals (configurable) in a binary file called ‘dump.rdb’. It is configurable to take snapshot at specified intervals or can be done manually by executing ‘SAVE’ or ‘BGSAVE’ commands.
  • Persistence by Append Only File (AOF) & Log Rewriting: every time ReDiS receives a command that changes the dataset/value, it will append it to the AOF. When you restart Redis it will re-play the AOF to rebuild the state.
  • Supported programming languages: JAVA, C, C#, PHP, Python, JS, Perl, Ruby etc.
  • Scripting Support: it supports LUA Scripting. LUA is a cross platform & light weight language

8. References

I hope you enjoyed this post about What is Redis. you can visit tutorials indexing page for more articles.
Happy learning for what is redis cache? features of Redis, limitation of redis and use case of Redis.

Connect with

1 thought on “What is Redis?”

  1. Pingback: Raju

Leave a Comment

Your email address will not be published. Required fields are marked *