Redis#Clustering

{{Short description|Source available in-memory key–value database}}

{{Other uses}}

{{Infobox software

| name = Redis

| logo = Redis logo.svg

| logo size = 200px

| logo alt =

| logo caption =

| screenshot =

| screenshot size =

| screenshot alt =

| caption =

| author = Salvatore Sanfilippo{{cite web |url=http://www.eu-startups.com/2011/01/an-interview-with-salvatore-sanfilippo-creator-of-redis-working-out-of-sicily/ |title=An interview with Salvatore Sanfilippo, creator of Redis, working out of Sicily |date=January 4, 2011 |last=Bernardi |first=Stefano |website=EU-Startups |publisher=Menlo Media}}{{cite web |url=https://redis.com/blog/salvatore-sanfilippo-welcome-to-redis-labs |title=Salvatore Sanfilippo: Welcome to Redis Labs |date=July 15, 2015 |last=Haber |first=Itamar |website=Redis Labs}}

| developer = Redis

| released = {{Start date and age|2009|02|26}}{{Cite web |title=Page 7 of 7 - Redis - Google Code Archive - Long-term storage for Google Code Project Hosting. |author= |work=code.google.com |date= |access-date=22 March 2024 |url= https://code.google.com/archive/p/redis/downloads?page=7}}

| latest release version = {{wikidata|property|edit|reference|P348}}

| latest release date = {{start date and age|{{wikidata|qualifier|mdy|P348|P577}}}}

| latest preview version =

| latest preview date =

| programming language = C

| operating system = Unix-like{{cite web |title=Introduction to Redis |url=https://redis.io/topics/introduction |quote=Redis is written in ANSI C and works in most POSIX systems like Linux, *BSD, OS X without external dependencies.}}

| language = English

| genre = Data structure store, key–value database

| license = Redis Source Available License or SSPL{{cite web |url=https://github.com/redis/redis/blob/0b34396924eca4edc524469886dc5be6c77ec4ed/LICENSE.txt |title=LICENSE.txt |website=GitHub|date=20 March 2024 }}

}}

Redis ({{IPAc-en|ˈ|r|ɛ|d|ɪ|s}};{{cite web |title=FAQ: Redis |url=https://redis.io/topics/faq |access-date=12 February 2022 |website=Redis.io |language=en-US}}{{cite web |title=Google Groups |url=https://groups.google.com/d/msg/redis-db/MtwjZC5gCeE/f-5T-OIcCW8J |access-date=25 February 2022 |website=groups.google.com}} Remote Dictionary Server) is an in-memory key–value database, used as a distributed cache and message broker, with optional durability.{{Cite web |title=Redis |url=https://redis.io/ |access-date=2023-07-22 |website=Redis |language=en}} Because it holds all data in memory and because of its design, Redis offers low-latency reads and writes, making it particularly suitable for use cases that require a cache. Redis is the most popular NoSQL database,{{Cite web |last=Clark |first=Lindsay |title=Redis becomes the most popular database on AWS as complex cloud application deployments surge |url=https://www.theregister.com/2020/11/23/redis_the_most_popular_db_on_aws/ |access-date=2023-07-22 |website=www.theregister.com |language=en}}{{Cite web |title=Instablinks EP 07: Redis™—The Most Popular In-Memory Database Technology |url=https://www.instaclustr.com/resources/instablinks-ep-07-redis-the-most-popular-in-memory-database-technology/ |access-date=2023-07-22 |website=Instaclustr |language=en}} and one of the most popular databases overall.{{Cite web |title=DB-Engines Ranking |url=https://db-engines.com/en/ranking |access-date=2023-07-22 |website=DB-Engines |language=en}}

The project was developed and maintained by Salvatore Sanfilippo, starting in 2009.{{Cite web|date=2016-06-20|title=A conversation with Salvatore Sanfilippo, creator of the open-source database Redis|url=https://venturebeat.com/2016/06/19/redis-creator/|access-date=2021-06-29|website=VentureBeat|language=en-US}} From 2015 until 2020, he led a project core team sponsored by Redis Labs.{{cite web |url=https://www.networkworld.com/article/941072/redis-labs-hires-the-creator-of-redis-salvatore-sanfilippo.html |title=Redis Labs hires the creator of Redis, Salvatore Sanfilippo |last=Kepes |first=Ben |date=July 15, 2015 |website=Network World |access-date=August 30, 2015}} Salvatore Sanfilippo left Redis as the maintainer in 2020.{{Cite web|last=Francisco|first=Thomas Claburn in San|title=Database maestro Antirez says arrivederci to Redis: Seems he wants an unstructured life writing code, not a structured one managing software|url=https://www.theregister.com/2020/06/30/redis_creator_antirez_quits/|access-date=2021-06-29|website=www.theregister.com|language=en}} In 2021 Redis Labs dropped the Labs from its name and now is known simply as "Redis".{{Cite web |date=2021-08-11 |title=Database startup Redis Labs rebrands as ... just Redis |url=https://siliconangle.com/2021/08/11/redis-labs-rebrands-redis/ |access-date=2021-08-11 |website=SiliconANGLE |language=en-US}}

In 2018, some modules for Redis adopted a modified Apache 2.0 with a Commons Clause.{{cite web|first1=Thomas|last1=Claburn|access-date=2024-03-21|title=Redis has a license to kill: Open-source database maker takes some code proprietary|url=https://www.theregister.com/2018/08/23/redis_database_license_change/|website=www.theregister.com}} In 2024, the main Redis code switched from the open-source BSD-3 license to being dual-licensed under the Redis Source Available License v2 and the Server Side Public License v1.

History

File:Salvatore Sanfilippo.png

The name Redis means Remote Dictionary Server. The Redis project began when Salvatore Sanfilippo, nicknamed antirez, the original developer of Redis, was trying to improve the scalability of his Italian startup, developing a real-time web log analyzer. After encountering significant problems in scaling some types of workloads using traditional database systems, Sanfilippo began in 2009 to prototype a first proof of concept version of Redis in Tcl.{{cite web |title=Tcl prototype of Redis |date=April 28, 2017 |website=GitHub Gist |last=Sanfilippo |first=Salvatore |url=https://gist.github.com/antirez/6ca04dd191bdb82aad9fb241013e88a8 |access-date=October 8, 2018}} Later Sanfilippo translated that prototype to the C language and implemented the first data type, the list. After a few weeks of using the project internally with success, Sanfilippo decided to open source it, announcing the project on Hacker News. The project began to get traction, particularly among the Ruby community, with GitHub and Instagram being among the first companies adopting it.{{cite web |title=Introducing Resque |date=November 3, 2009 |website=Blog |last=Wanstrath |first=Chris |url=https://blog.github.com/2009-11-03-introducing-resque/ |access-date=October 8, 2018}}{{cite web |url=https://instagram-engineering.com/storing-hundreds-of-millions-of-simple-key-value-pairs-in-redis-1091ae80f74c |title=Storing hundreds of millions of simple key-value pairs in Redis |date=October 31, 2011 |last=Krieger |first=Mike |website=Instagram Engineering Blog |access-date=October 8, 2018}}

Sanfilippo was hired by VMware in March 2010.{{cite web |title=VMware Hires Redis Key Developer – But Why? |date=March 17, 2010 |website=Blog |last=Shapira |first=Gwen |url=https://prodlife.wordpress.com/2010/03/17/vmware-hires-redis-key-developer-but-why/ |access-date=September 25, 2016}}{{cite web |title=VMware: the new Redis home |website=Blog |date=March 15, 2010 |last=Sanfilippo |first=Salvatore |url=http://antirez.com/post/vmware-the-new-redis-home.html |access-date=September 25, 2016}}{{cite web |url=http://blogs.vmware.com/console/2010/03/vmware-hires-key-developer-for-redis.html |title=VMware: The Console: VMware hires key developer for Redis |website=VMware Blog |date=March 15, 2010 |last=Collison |first=Derek |archive-url=https://web.archive.org/web/20100322191425/http://blogs.vmware.com/console/2010/03/vmware-hires-key-developer-for-redis.html |archive-date=March 22, 2010 |access-date=September 25, 2016 |url-status=dead }}

In May 2013, Redis was sponsored by Pivotal Software (a VMware spin-off).{{cite web |url=https://redis.io/topics/sponsors |title=Redis Sponsors |last=Sanfilippo |first=Salvatore |website=Redis.io |publisher=Redis Labs |access-date=April 11, 2019}}

In June 2015, development became sponsored by Redis Labs.{{cite web |url=http://antirez.com/news/91 |title=Thanks Pivotal, Hello Redis Labs |date=July 15, 2015 |last=Sanfilippo |first=Salvatore |website= |access-date=2019-04-03}}

In August 2018, Redis Labs announced the switch to a source-available software license, modified Apache 2.0 with a Commons Clause for some of the optional modules available for Redis, while affirming that the core software will remain BSD-licensed.{{cite web|url=https://redis.io/blog/redis-license-bsd-will-remain-bsd/|title=Redis' License is BSD and will remain BSD|date=August 22, 2018|last=Shoolman|first=Yiftach|website=Redis.io|publisher=Redis Labs|access-date=September 30, 2024}}

In October 2018, Redis 5.0 was released, introducing Redis Stream – a new data structure that allows storage of multiple fields and string values with an automatic, time-based sequence at a single key.{{Cite web|url=https://redis.com/blog/redis-5-0-is-here/|title = Redis 5.0 is here!|date = 22 October 2018}}

In June 2020, Salvatore Sanfilippo stepped down as Redis' sole maintainer. Sanfilippo was succeeded by Yossi Gottlieb and Oran Agra.{{Cite web|url=https://www.theregister.com/2020/06/30/redis_creator_antirez_quits/|title=Database maestro Antirez says arrivederci to Redis: Seems he wants an unstructured life writing code, not a structured one managing software|website=theregister.com}}{{Cite web|title=The end of the Redis adventure -|url=http://antirez.com/news/133|access-date=2020-11-10|website=antirez.com}}

In March 2024, Redis switched to a different proprietary software license, styled as the Redis Source Available License v2, and the Server Side Public License v1, also for its core repository, breaking the 2018 pledge. As a consequence, the Linux Foundation created a fork under the name of Valkey,{{Cite web |title=Linux Foundation Launches Open Source Valkey Community |url=https://www.linuxfoundation.org/press/linux-foundation-launches-open-source-valkey-community}} allowing community maintainers, contributors, and users to continue working on an open source version of the Redis database.

Differences from other database systems

Redis popularized the idea of a system that can be considered a store and a cache at the same time. It was designed so that data is always modified and read from the main computer memory, but also stored on disk in a format that is unsuitable for random data access. The formatted data is only reconstructed into memory once the system restarts.

Redis also provides a data model that is very unusual compared to a relational database management system (RDBMS). User commands do not describe a query to be executed by the database engine but rather specific operations that are performed on given abstract data types. Therefore data must be stored in a way which is suitable later for fast retrieval. The retrieval is done without help from the database system in form of secondary indexes, aggregations or other common features of traditional RDBMS. The Redis implementation makes heavy use of the fork system call, to duplicate the process holding the data, so that the parent process continues to serve clients while the child process writes the in-memory data to disk.

Popularity

According to monthly DB-Engines rankings, Redis is often the most popular key–value database.{{cite web |url=http://db-engines.com/en/ranking/key-value+store |title=DB-Engines Ranking - popularity ranking of key-value stores |website=DB-Engines}} Redis has also been ranked the #4 NoSQL database in user satisfaction and market presence based on user reviews,{{cite web |url=http://about.g2crowd.com/press-release/best-nosql-databases-fall-2015/ |title=Best NoSQL Databases: Fall 2015 Report from G2 Crowd |publisher=G2 Crowd |access-date=2015-08-25 |archive-date=2015-08-24 |archive-url=https://web.archive.org/web/20150824012237/http://about.g2crowd.com/press-release/best-nosql-databases-fall-2015/ |url-status=dead }} the most popular NoSQL database in containers,{{cite web |url=https://www.datadoghq.com/docker-adoption/ |title=8 Surprising Facts about Real Docker Adoption |website=Datadog|date=13 June 2018 }} and the #4 Data store of 2019 by ranking website stackshare.io.{{Cite web|title=🏆 The Top 50 Developer Tools of 2019|url=https://stackshare.io/posts/top-developer-tools-2019|access-date=2020-07-28|website=StackShare|language=en}} It was voted most loved database in the Stack Overflow [https://insights.stackoverflow.com/survey/ Developer Survey] each year from 2017 to 2021,{{cite web|url=https://insights.stackoverflow.com/survey/2021#section-most-loved-dreaded-and-wanted-databases|title=Developer Survey Results 2021: Most Loved, Dreaded, and Wanted Databases|website=Stack Overflow|publisher=Stack Exchange|access-date=2021-08-23}} however, it has since fallen to sixth place.{{cite web|url=https://survey.stackoverflow.co/2024/technology#most-popular-technologies-database|title=2024 Stack Overflow Developer Survey|website=Stack Overflow|publisher=Stack Exchange|access-date=2025-04-24}}

Supported languages

Since version 2.6, Redis features server-side scripting in the language Lua.{{cite web |url=https://redis.io/commands/eval |title=EVAL – Redis |website=redis.io}}

Many programming languages have Redis language bindings on the client side, including:{{cite web |url=https://redis.io/clients |title=Redis |website=redis.io}} ActionScript, C, C++, C#, Chicken, Clojure, Common Lisp, Crystal, D, Dart, Delphi,{{cite web | url=https://github.com/danieleteti/delphiredisclient | title=Danieleteti/Delphiredisclient | website=GitHub | date=17 September 2022 }} Elixir, Erlang, Go, Haskell, Haxe, Io, Java, Nim, JavaScript (Node.js), Julia, Lua, Objective-C, OCaml, Perl, PHP, Pure Data, Python, R,{{cite web |url=https://cran.r-project.org/web/packages/rredis/ |title=rredis: "Redis" Key/Value Database Client |last=Lewis |first=B. W. |date=5 July 2015 |website=The Comprehensive R Archive Network |access-date=2019-04-03}} Racket, Ruby, Rust, Scala, Smalltalk, Swift, and Tcl. Several client software programs exist in these languages.

Data types

Redis maps keys to types of values. An important difference between Redis and other structured storage systems is that Redis supports not only strings, but also abstract data types:

  • Lists of strings
  • Sets of strings (collections of non-repeating unsorted elements)
  • Sorted sets of strings (collections of non-repeating elements ordered by a floating-point number called score)
  • Hash tables where keys and values are strings
  • Bitmaps
  • HyperLogLogs used for approximated set cardinality size estimation, available since Redis 2.8.9 in April 2014.
  • Stream of entries with consumer groups, allows you to store multiple fields and string values with an automatic, time-based sequence at a single key, available since Redis 5.0 in October 2018
  • Geospatial data through the implementation of the geohash technique, available since Redis 3.2.{{cite web |url=https://github.com/antirez/redis/blob/3.2/00-RELEASENOTES |title=Redis 3.2 Release Notes |website=GitHub |access-date=2017-03-10}}

The type of a value determines what operations (called commands) are available for the value. Redis supports high-level, atomic, server-side operations like intersection, union, and difference between sets and sorting of lists, sets and sorted sets.

More data types are supported based on Redis Modules API. Note, that some of them are dual licensed, and not under the BSD 3 clause:{{Cite web |title=Redis Licensing Overview |url=https://redis.com/legal/licenses/ |access-date=2023-09-30 |website=Redis |language=en}}

  • JSON – RedisJSON{{Cite web|url=https://oss.redis.com/redisjson/|title = RedisJSON - a JSON data type for Redis}} implements ECMA-404 (the JavaScript Object Notation Data Interchange Standard) as a native data type.{{cite web |url=http://redisjson.io |title=RedisJSON - a JSON data type for Redis |website=redisjson.io}}
  • [https://redis.io/docs/interact/search-and-query/ Search] - A query engine for Redis, providing secondary indexing, full-text search, vector similarity search and aggregations.{{Citation |title=RediSearch |date=2023-09-30 |url=https://github.com/RediSearch/RediSearch |access-date=2023-09-30 |publisher=RediSearch}}
  • Time series – RedisTimeSeries{{Cite web|url=https://oss.redis.com/redistimeseries|title = RedisTimeSeries - Time-Series data structure for Redis}} implements a time series data structure
  • Bloom filter, Cuckoo filter, Count–min sketch, and Top-K – RedisBloom{{Cite web|url=https://oss.redis.com/redisbloom/|title=RedisBloom - Probabilistic Datatypes Module for Redis}} implements a set of probabilistic data structures for Redis
  • Others{{Cite web |title=Modules |url=https://redis.io/resources/modules/ |access-date=2023-09-30 |website=Redis |language=en}}

Former implementations include:

  • Graph – RedisGraph{{Cite web |title=RedisGraph - a graph database module for Redis |url=https://oss.redis.com/redisgraph/}} implements a queryable property graph
  • RedisGraph has been discontinued,{{Cite web |last=Kogan |first=Lior |date=2023-07-05 |title=RedisGraph End-of-Life Announcement |url=https://redis.com/blog/redisgraph-eol/ |access-date=2023-09-30 |website=Redis |language=en}} and continued in the form of a fork called FalkorDB.{{Citation |title=FalkorDB |date=2023-09-29 |url=https://github.com/FalkorDB/FalkorDB |access-date=2023-09-30 |publisher=FalkorDB}}

Persistence

Redis typically holds the whole dataset in memory. Versions up to 2.4 could be configured to use what they refer to as virtual memory{{cite web |url=https://redis.io/topics/virtual-memory |title=Virtual Memory |website=Redis.io |access-date=April 11, 2019}} in which some of the dataset is stored on disk, but this feature is deprecated. Persistence in Redis can be achieved through two different methods. First by snapshotting, where the dataset is asynchronously transferred from memory to disk at regular intervals as a binary dump, using the Redis RDB Dump File Format. Alternatively by journaling, where a record of each operation that modifies the dataset is added to an append-only file (AOF) in a background process. Redis can rewrite the append-only file in the background to avoid an indefinite growth of the journal. Journaling was introduced in version 1.1 and is generally considered the safer approach.

By default, Redis writes data to a file system at least every 2 seconds, with more or less robust options available if needed. In the case of a complete system failure on default settings, only a few seconds of data would be lost.

Replication

Redis supports master–replica replication. Data from any Redis server can replicate to any number of replicas. A replica may be a master to another replica. This allows Redis to implement a single-rooted replication tree. Redis replicas can be configured to accept writes, permitting intentional and unintentional inconsistency between instances. The publish–subscribe feature is fully implemented, so a client of a replica may subscribe to a channel and receive a full feed of messages published to the master, anywhere up the replication tree. Replication is useful for read (but not write) scalability or data redundancy.{{cite web |url=https://code.google.com/p/redis/wiki/ReplicationHowto |title=Google Code Archive - Long-term storage for Google Code Project Hosting. |website=code.google.com}}

Performance

When the durability of data is not needed, the in-memory nature of Redis allows it to perform well compared to database systems that write every change to disk before considering a transaction committed. Redis operates as a single process and is single-threaded or double-threaded when it rewrites the AOF (append-only file).{{cite web |url=http://antirez.com/news/111 |title=Redis on the Raspberry Pi: adventures in unaligned lands - |website=antirez.com}} Thus, a single Redis instance cannot use parallel execution of tasks such as stored procedures.

Clustering

Redis introduced clustering in April 2015 with the release of version 3.0.{{cite web |url=https://github.com/antirez/redis/blob/3.0/00-RELEASENOTES |title=Redis 3.0 Release Notes |website=GitHub |access-date=2017-03-10}} The cluster specification implements a subset of Redis commands: all single-key commands are available, multi-key operations (commands related to unions and intersections) are restricted to keys belonging to the same node, and commands related to database selection operations are unavailable.{{cite web |url=https://redis.io/topics/cluster-spec#implemented-subset |title=Cluster Spec |access-date=2017-03-10}} A Redis cluster can scale up to 1,000 nodes, achieve "acceptable" write safety and to continue operations when some nodes fail.{{cite web |url=https://redis.io/topics/cluster-spec |title=Cluster Spec |access-date=2017-03-10}}{{cite web |url=https://redis.io/topics/cluster-tutorial |title=Cluster Tutorial |access-date=2017-03-10}}

Use cases

Due to the nature of the database design, typical use cases are session caching, full page cache, message queue applications, leaderboards and counting among others.{{cite web |url=http://objectrocket.com/blog/how-to/top-5-redis-use-cases |title=Top 5 Redis use cases - ObjectRocket |date=7 November 2017 |website=ObjectRocket |publisher=Rackspace}} The publish–subscribe messaging paradigm allows real-time communication between servers.

Amazon Web Services offers a managed Redis service called ElastiCache for Redis, Google offers a managed Redis service called Cloud Memorystore,{{Cite web |title=Memorystore: in-memory data store |url=https://cloud.google.com/memorystore |access-date=2023-02-03 |website=Google Cloud |language=en}} Microsoft offers Azure Cache for Redis in Azure,{{cite web |url=https://azure.microsoft.com/en-us/services/cache/ |title=Azure Redis Cache - Redis cache cloud service - Microsoft Azure |website=azure.microsoft.com}} and Alibaba offers ApsaraDB for Redis in Alibaba Cloud.{{cite web |url=https://www.alibabacloud.com/product/apsaradb-for-redis |title=ApsaraDB for Redis: A Key Value Database Service - Alibaba Cloud|website=www.alibabacloud.com}}

Users

Redis has been used by companies including Twitter,{{Citation |title=Scaling Redis at Twitter |date=31 August 2014 |url=https://www.youtube.com/watch?v=rP9EKvWt0zo |access-date=2023-07-22 |language=en}}{{Citation |title=Using Redis at Scale at Twitter - by Rashmi Ramesh of Twitter - RedisConf17 - |date=5 July 2017 |url=https://www.youtube.com/watch?v=QznaOSk20nU |access-date=2023-07-22 |language=en}} Airbnb,{{Citation |title=AWS re:Invent 2018: Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) |date=28 November 2018 |url=https://www.youtube.com/watch?v=eyd_8efUCwM |access-date=2023-07-22 |language=en}} Tinder,{{Cite web |date=2020-01-30 |title=Building resiliency at scale at Tinder with Amazon ElastiCache {{!}} AWS Database Blog |url=https://aws.amazon.com/blogs/database/building-resiliency-at-scale-at-tinder-with-amazon-elasticache/ |access-date=2023-07-22 |website=aws.amazon.com |language=en-US}} Yahoo,{{Citation |title=AWS re:Invent 2022 - How Yahoo cost optimizes their in-memory workloads with AWS (DAT321) |date=2 December 2022 |url=https://www.youtube.com/watch?v=jEwrcpq2mLM |access-date=2023-07-22 |language=en}} Adobe,{{Citation |title=AWS re:Invent 2014 {{!}} (SDD402) Amazon ElastiCache Deep Dive |date=17 November 2014 |url=https://www.youtube.com/watch?v=cEkHBqhQnog |access-date=2023-07-22 |language=en}} Hulu,{{Cite web |title=Hulu Case Study |url=https://aws.amazon.com/solutions/case-studies/hulu/ |access-date=2023-07-22 |website=Amazon Web Services, Inc. |language=en-US}} Amazon{{Cite web |title=Amazon GameOn Database Migration Case Study – Amazon Web Services (AWS) |url=https://aws.amazon.com/solutions/case-studies/amazon-gameon/ |access-date=2023-07-22 |website=Amazon Web Services, Inc. |language=en-US}} and OpenAI.{{Cite web |title=Elevated API Errors |url=https://status.openai.com/incidents/fk0tcbydtybr |access-date=2023-10-28 |website=status.openai.com |language=en}}

See also

References

{{Reflist}}

Further reading

{{Refbegin}}

  • Isabel Drost and Jan Lehnard (29 October 2009), [http://www.h-online.com/open/features/Happenings-NoSQL-Conference-Berlin-843597.html Happenings: NoSQL Conference, Berlin], The H. [http://nosqlberlin.de/slides/NoSQLBerlin-Redis.pdf Slides] for the Redis presentation. [http://www.paperplanes.de/2009/10/27/theres_something_about_redis.html Summary].
  • Billy Newport (IBM): "[http://www.infoq.com/presentations/newport-evolving-key-value-programming-model Evolving the Key/Value Programming Model to a Higher Level]" Qcon Conference 2009 San Francisco.
  • A Mishra: "[http://blog.andolasoft.com/2013/07/how-to-install-and-configure-redis-server-on-centosfedora-server.html Install and configure Redis on Centos/ Fedora server]".
  • E. Mouzakitis: "[https://www.datadoghq.com/blog/how-to-monitor-redis-performance-metrics/ Monitoring Redis Performance]"{{Refend}}