frequently asked Redis interview questions and answers

1) Tell Me About Redis?
Redis is an open-source, advance key value data store and cache. It is also referred as a data structure server which keys not only contains strings, but also hashes, sets, lists, and sorted sets.

2) Tell Me About the meaning of Redis?
Redis stands for REmote DIctionary Server.

3) How is Redis different from other databases?
Redis is a NoSQL, Opensource, in-memory data-structure store. It follows the principle of key-value store.
It is extremely fast, persistent, portable and supports many languages such as C, C++, C#, Clojure, Common Lisp, D, Dart, Erlang, Go, Haskell, Haxe, Io, Java, JavaScript (Node.js), Julia, Lua, Objective-C, Perl, PHP, Pure Data, Python, R, Racket, Ruby, Rust, Scala, Smalltalk and Tcl.

4) In which language Redis is written?
Redis is written in ANSI C and mostly used for cache solution and session management. It creates unique keys for store values.

5) Tell Me About the usage of Redis?
Redis is a special key-value store database that can function as a NoSQL database or as a memory-cache store to improve performance when serving data that is stored in system memory.

6) How to interect with Redis?
After the installation of the server you can run the Redis Client provided by redis installation or you can open the command prompt and use the following command:
  1. redis-cli  
By using any of them, you can interect with Redis.

7) Which are the most popular companies using Redis?
Twitter, Github, Stackoverflow etc. are the most popular companies using Redis.

8) Tell Me About the main features of Redis?
Following are the main features of Redis:
  • Redis is very simple to install setup and manage.
  • Redis is very fast. It can execute 100000 queries per second.
  • Redis is fast because data is being persistent in memory as well as stored on the disk.
  • Redis is very fast because it loads the whole dataset in primary memory.
  • Redis operations working on different data types are atomic so these operations can be accomplished safely i.e. to set or increase a key, add or remove elements from a set or increase a counter.
  • It supports various types of data structure such as strings, hashes, sets, lists, sorted sets etc.
  • Redis supports a variety of languages i.e. C, C++, C#, Ruby, Python, Twisted Python, PHP, Erlang, Tcl, Perl, Lua, Java, Scala etc.
  • If your favorite language is not supported yet, you can write your own client library, as the Protocol is pretty simple.
  • Redis supports simple master to slave replication.
  • Redis is portable.

9) Explain the Replication feature of Redis?
Redis performs simple Master to Slave Replication. When a relationship is established, data from the master is transferred to the slave. Once it is done, all changes to the master replicate to the slave.

10) Tell Me About the advantages of using Redis?
Following is a list of some important advantages of Redis:
  • Redis is very fast.
  • It supports a server-side locking.
  • It has a rich client side library.
  • It is a good counter.
  • It supports Atomic Operation.

11) Tell Me About the disadvantages/limitations of using Redis?
Following are the disadvantages/ limitations of Redis:
  • It is single threaded.
  • It has got limited client support for consistent hashing.
  • It has significant overhead for persistence.
  • It is not deployed widely.

12) Tell Me About the difference between Redis and RDBMS?
There are a lot of differences between Redis and RDBMS:
  • Redis is a NoSQL database while RDBMS is an SQL database.
  • Redis follows the key-value structure while RDBMS follows the table structure.
  • Redis extremely fast while RDBMS is comparatively slow.
  • Redis stores all the dataset in primary memory while RDBMS stores its dataset in secondary memory.
  • Redis is generally used to store small and frequently used files while RDBMS is used to store big files.
  • Redis provides only official support for Linux, BSD, Mac OS X, Solaris. It doesn?t provide official support for Windows currently while RDBMS provides support for both.

13) Tell Me About the difference between Memcached and Redis?
Memcached only does caching information.
Redis also does caching information as well as it has some additional features like persistence and replication.
Memcached supports the functionality of LRU (Least Recently Used) eviction of values.
Redis does not support the functionality of LRU (Least Recently Used) eviction of values
In Memcached when they overflow memory, the one you have not used recently (LRU- Least Recently Used) will get deleted.
In Redis you can set a time out on everything, when memory is full, it will look at three random keys and deletes the one which is closest to expiry.
Memcached supports CAS(Check And Set)
Redis does not support CAS ( Check And Set). It is useful for maintaining cache consistency.
In Memcached, you have to serialize the objects or arrays in order to save them and to read them back you have to un-serialize them.
Redis has got stronger data structures; it can handle strings, binary safe strings, list of binary safe strings, sorted lists, etc.
Memcached has a maximum of 250 bytes length.
Redis has a maximum of 2GB key length.
Memcached is multi-threaded
Redis is single threaded

14) Tell Me About the operation keys of Redis?
A list of operation keys of Redis are given below:
  • TYPE key
  • TTL key
  • KEYS pattern
  • EXPIRE key seconds
  • EXPIREAT key timestamp
  • EXISTS key
  • DEL key

15) Which are the different data types used in Redis?
There are mainly 5 types of data types supported by Redis:
  • Strings
  • Hashes
  • Lists
  • Sets
  • Sorted Sets

16) Which are the most popular commands of the Redis database?
For more information:Click Here

17) We all know that Reds is fast, but is it also durable?
No. Redis compromises with durability to enhance the speed. In Redis, in the case of system failure or crash, it writes to disk but may fall behind and lose the data which is not stored.

18) Tell Me About the way to improve the durability of Redis?
To improve the durability of Redis “append only file” can be configured by using fsync data on disk.
  • 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.

19) Tell Me About the things you must have to take care while using Redis?
While using Redis, you must have to take care of following instructions:
  • Select a consistent method to name and prefix your keys. Manage your namespace.
  • Create a “Registry” of key prefixes that maps each of your internal documents for those applications which “own” them.
  • For every class you put through into your Redis infrastructure: design, implement and test the mechanisms for garbage collection or data migration to archival storage.
  • Design, implement and test a sharding library before you have invested much into your application deployment and make sure that you keep a registry of “shards” replicated on each server.
  • Separate all your K/V store and related operations into your own library/API or service.

20) How can you use Redis with .Net application?
To use Redis in .Net applications, follow these steps:
  • First, Download Redis Server.
  • Install Redis Server.
  • Download Redis Client.
  • Set Configuration into Web.config File.
  • Use Redis Client Class.

Leave a Reply

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