Redis is intentionally simple to use, and as a rule avoids complexity. Its protocol is text based and easy to parse, so it has hundreds of existing client libraries and can even be implemented in a microcontroller. The data structures Redis provides are used as basic building blocks for modeling data and accessing it, allowing developers to focus on their code and leave the actual management of these structures to the server. While each operation is guaranteed to be atomic and consistent with its data type, transactions are supported and ensure the atomicity of a block of consecutive operations. Lua scripts can be executed server-side (near the data) for composing custom workflows and reducing network traffic. Lastly, Pub/Sub allows Redis to act as an interprocess messaging system in which publishers and subscribers can communicate over channels.
Protocol, Transactions, Lua and Pub/Sub
Redis can be configured in several ways to address the limits and volatility of RAM. Other than replying with an “out of memory” error when memory is maxed out, Redis can be set up to evict data based on usage frequency, recentness or random policies. Furthermore, every key in Redis can be assigned with a time-to-live (TTL) that will cause the value to be deleted once expired.
Redis can be configured to persist to disk data that isn't ephemeral, and then use the persisted data when recovering from failures. Redis has two persistence options that may be used together, individually or not at all: snapshot backups and change logs. Redis database backups (RDB) are taken periodically and are meant for point-in-time recovery. Append-only files (AOF) flush a log of changes to disk on a configurable interval, and are for recovering the last known state of the database.
Data eviction, expiration and persistence
Redis uses replication to maintain one or more secondary replicas with updates from a single primary source. While replication itself is asynchronous, a client can ensure its success by blocking until a desired number of replicas has been updated. The replicas are usually read-only, and act as hot standby caches in the event of the primary failing.
Depending on whether Redis is used in single-instance or clustered mode, it can be set up for high availability. Redis Sentinel is a component that provides service discovery, failure detection and quorum-based failover from primary to secondary replica for single-instance databases. When running Redis in cluster mode, these capabilities are provided by the cluster itself.
Replication and high availability
Redis databases are scaled by partitioning the keyspace and assigning each partition dedicated memory, compute and network resources. Partitioning can be done by the application, an intermediate proxy or by Redis itself when used in cluster mode.
Redis cluster automatically partitions the data among multiple Redis servers across multiple nodes. Each member in the cluster, whether a primary or a secondary replica, manages a shared-nothing subset of the keyspace and all communicate via an internal bus. The cluster provides near-linear scalability while growing up to hundreds of nodes, and an interface that allows client applications to optimize access by discovering the cluster's topology.
Redis is an open source in-memory data structure store that is designed to be fast and simple. The name is an acronym for REmote DIctionary Server (pronounced "red-iss"), referencing the networked client-server and key-value data models that Redis uses.
Built for real-time performance most requests to Redis complete in less than a millisecond, allowing a single server to handle millions of concurrent requests every second. Redis is designed for simplicity; it’s easy to use and extends the developer's toolbox by managing a distributed store of data structures used by applications. Redis includes everything needed to run it—whether on a developer's workstation or in a highly available large-scale production environment—and is renowned for its rock-solid stability. It is used as a database, cache and a message broker wherever performance is key.
An in-memory store uses Random Access Memory (RAM) for storing data, and as such all Redis data is stored primarily in the server's main memory. RAM is the fastest storage media available and all data in it is immediately accessible to the server process, so both read and write operations demonstrate predictable low latencies.
Redis is architected to deliver the most out of RAM's low latencies across all platforms. The Redis server is written in portable, standard ANSI-C that is optimized for performance and low memory footprint. In order to facilitate data immediacy and maximize throughput, the server is implemented as an event loop run by a single process, avoiding the complexity of multi-threaded lock-based approaches.
Abstract data types
A Redis database is a dictionary that maps keys to their respective values and guarantees constant time access by key. A key's value can be of any supported data type, and Redis provides a Domain Specific Language (DSL) for manipulating it in a consistent and atomic manner. Redis provides a multitude of native abstract data types that can be combined to meet the diverse data needs and requirements of different access patterns efficiently.
Redis data types range from basic programming abstractions to specialized data structures. The basic data type is a binary-safe string that can also be used for numeric values and operations. Lists, Sets and Hashes are higher-level data structures for managing values by order, membership and name, respectively. Sorted Sets maintain a score-based order of their nested values, and support numeric, lexicographical and geospatial scoring and querying. Bitmaps and Bitfields are efficient for raw boolean and numeric data, whereas the HyperLogLog provides probabilistic estimates for set cardinality. On top of these, the open Redis modules API allows developers to extend Redis with their own custom data structures and logic for a wide variety of use cases.
Redis is often used as an external, secondary database alongside another primary data store that is either too slow or too expensive to meet performance needs. The data in Redis is derived from that of the primary store, and usually consists of index structures and summarization of the primary data. That data is then used by applications for the purpose of delivering real-time responsiveness, often when interacting with online users.
Typically Redis is employed as a secondary database for enabling services such as text search and autocomplete, geographical radius querying, IP ranges, managing custom indexes and serving pre-generated data.
Redis is used as a primary database and single source of truth for shared data by applications that demand predictable real-time performance at any scale. It is a popular choice for operational and analytical workloads that are at the core of many services. The variety of data types model needs that are common to all applications, while tunable data persistency and high availability options address a range of service-level requirements.
As a database, Redis can be used for storing almost any type of serializable data that represents a state in a distributed system. It is especially suitable for managing sessions, page and user statistics; counting, voting and real-time aggregates; leaderboards; job queues and locks; filtering, rate limiting and traffic shaping; and geospatial tracking.
Redis is used in ETL-like and batch processing systems, such as logging and monitoring systems, in which data flow is erratic or fast. By acting as a data buffer, Redis can handle bursts of traffic and store the incoming data. The data is either stored raw or partially processed by Redis, and is served in optimally sized chunks to successive processes in the workflow until it is stored in another data store.
Intermediate data store
Redis is an effective cross-application cache for almost every need, and as such has become ubiquitous. It provides a multitude of features that allow implementing effectual caching mechanisms with ease and flexibility. Key-level expiry allows precise control of the data invalidation at a time resolution of one second and is tuned for throughput prioritization. Random, least-frequently-used or least-recently-used eviction policies of all or volatile data are configurable at runtime and can be employed for handling memory pressure scenarios.
Redis powers many of the caching frameworks and libraries in most programming languages. Data cached in Redis varies among database data, views and queries; API requests; web pages, assets and code; and expensive computed results memoization.
Redis is used for delivering messages between processes in a distributed system. The List data type supports a set of blocking operations, which make it very suitable for implementing message queues. Pub/Sub capabilities allow message producers to publish arbitrary messages and keyspace event notifications in dedicated channels, that are immediately sent to all subscribing clients.
Why Redis Enterprise?
Performance at scale
Built on the top of Redis by the team who develops the open source, Redis Enterprise provides the following benefits:
HA, Durability, DR
Redis on Flash + more saving
Active-Active Geo Distribution (CRDT-based)
Built-in Search (with RediSearch)
Automation and Support
Start Your Free Trial
Select Deployment Option:
Downloadable software for any cloud or private data center.
Fully managed Redis-e database-as-a-service in your virtual private cloud within major public clouds.
REDIS ENTERPRISE VPC
The fastest way to deploy a Redis database.
Fully managed, serverless and hosted database-as-a-service on major public clouds.
REDIS ENTERPRISE CLOUD