Skip to main content

Architecture

Redis Architecture

Redis follows a single-threaded architecture with several key components:

Core Components

  • Redis Server: Main process that handles commands and manages data

  • Event Loop: Single-threaded event-driven architecture for handling connections

  • Memory Storage: In-memory data structures with optional persistence

  • Persistence: RDB snapshots and AOF (Append-Only File) for durability

Data Structures

  • Strings: Simple key-value pairs, binary safe

  • Lists: Ordered collections of strings, implemented as linked lists

  • Sets: Unordered collections of unique strings

  • Sorted Sets: Ordered sets with scores for ranking

  • Hashes: Maps of string fields to string values

  • Streams: Log-like data structure for message queues

Architecture Patterns

  • Standalone: Single Redis instance

  • Master-Slave: Primary-replica replication setup

  • Sentinel: High availability with automatic failover

  • Cluster: Distributed Redis deployment with sharding