How does Redis work internally?

Redis is an in-memory data structure store that serves as a cache, message broker, and primary database. Internally it uses:

  • Single-threaded event loop (I/O multiplexing via epoll/kqueue) for command processing — no lock contention
  • Data structures: strings, hashes, lists, sets, sorted sets — each with specialized encodings (ziplist, skiplist, etc.) for memory efficiency
  • Persistence options: RDB snapshots (point-in-time) and AOF (append-only log); both carry durability trade-offs
  • Replication: async master–replica; Sentinel for HA; Cluster for sharding

Risks as sole DB: data loss on crash (in-memory), limited query flexibility, memory cost. Common discussion points include choosing the right persistence mode, cache invalidation strategy, and what happens during a failover.

asked …
LeaderboardSalaryAccount