What is redis?
Redis which is short for Remote Dictionary Server is a data structure store that supports a variety of abstract data structures (including but not limited to bitmaps, strings, and lists). This software is also an open source one and is written in ANSI C. Redis can be used as a message broker, database, as well as a cache. It allows you to conveniently run atomic operations such as incrementing the value in a hash, union, computing set intersection, and difference. Redis performs best in an in-memory dataset. This particular project took off when its founder Salvator Sanfillipo was trying to scale his other Italian startup.
Redis is now capable of entertaining millions of requests in any given moment and delivers the response in a matter of milliseconds and caters to real time applications in the fields of Iot, Financial services, healthcare, and gaming. Furthermore, it also allows you to persist your data in two distinct ways: by dumping the dataset onto the disk or by appending each individual command to a log that is disk-based. Redis enables its users to have a data model that is very different from its counterparts, especially in comparison to a relational database management system that is also known as an RDBMS. When a user puts in a command, the user does not describe the query that requires execution but on the contrary describes the specific operations that must be undertaken on the abstract data types.
All the data redis has access to resides in-memory, as opposed to other database systems that store the data on either SSD(s) or disks. Since redis does not make use of disks or SSD(s) it has remarkable speed. It relies heavily on the fork system call to have two processes being executed simultaneously, the parent process serves the client whereas the child process is in charge of creating a copy of the data that is present on the stick. This in-memory feature of redis is one of the biggest advantages they have against their competition.
Another thing worth mentioning is a service that redis renders called redis sentinel, which gives you a scalable solution and enables you to use horizontal clustering which has a built in replication feature that spreads the data across the nodes in a cluster.
Some features of redis include:
- Automatic failover
- Keys that have a limited time-to-live
- Lua Scripting
- Lru eviction of keys
- Transactions
- Pub/Sub
- Can be used from most programming languages
- Asynchronous replication is supported
- In-memory datastore
- Simple and easy to use
- Machine learning
- Flexible data structures
- High availability
Redis is mostly used for:
Caching, chatting, messaging, queues, rich media streaming, geospatial, machine learning, and gaming leader boards.
Some of the languages supported by redis are as follows: C, C#, ActionScript, Clojure, Chicken, Crystal, Common Lisp, D, Dart, Erlang, Elixir, Go, Haskell, Haxe, Io, Java, Javascript, Julia, Lua, Objective C, O Camel, Perl, PHP, Pure Data, Python, R, Ruby, Rust, Scala, Smalltalk, Swift, and Tcl.
When you should avoid using redis
- When you are caching static assets Redis doesn’t work very well when it comes to caching static assets for websites such as images, CSS, or even video files. These particular assets can be better optimized by employing a web server configuration or even a content delivery network (CDN)
- When latency will not be an issue The biggest advantage of using redis is it’s high speed and zero latency, but if speed isn’t a priority and a little latency can be tolerated there are other options you can make use of, such as Apache Cassandra.
- In order to store extremely large data sets Redis definitely has the capability to hold but on the off chance that your data exceeds the memory capacity offered by your cluster, it might not give you optimum results. Although redis’ disk persistence can be configured to be available on every write, this will undoubtedly impact the performance. Backups, however, can add an additional sense of security.
Some well known companies and tech giants that use redis in order to save databse are: Github, Twitter, Weibo, Pinterest, Craigslist, Snapchat, Digg, Stackoverflow, and Flickr.
On a concluding note, redis is an extremely efficient, fast, and flexible database that offers a host of options when it comes to databases and is undeniably one of the most versatile databases that do not use SQL.