Best Practices and Interview Q&A

Harry · 13 Sep 2026 · 1 views

Operational Best Practices

  • Set maxmemory and an eviction policy before load.
  • Enable AOF with everysec fsync for durability.
  • Bind Redis to private interfaces only.
  • Move backup snapshots off the host.
  • Watch latency and memory with INFO and monitoring.

Design Best Practices

  • Keep large payloads out of Redis; store references.
  • Use TTLs on every cache and session key.
  • Prefers hashes over many tiny key/value strings.
  • Design stable keys with a namespace like app:users:42.
  • Invalidate on writes to keep caches correct.

Interview Q&A

Q: Why is Redis so fast?

A: Data lives in RAM and the single-threaded command loop avoids locks, executing simple operations in microseconds.

Q: Redis vs Memcached?

A: Redis offers data types, persistence, Pub/Sub and clustering; Memcached is a simpler distributed cache with lower overhead for pure key/value.

Q: How do you ensure a cache stays fresh?

A: Use a TTL for expiry and write-through invalidation - evict or update the key whenever the underlying data changes.

Q: How do you recover a lost primary?

A: Redis Sentinel promotes a fresh replica automatically and routes clients to it; clusters fail over at the slot level.

Key Points

  • Memory, TTL and eviction bound the cache.
  • Type choice directly shapes performance.
  • Persistence plus replicas guard against loss.
  • Sentinel and Cluster scale availability.
Share this post:

Comments (0)

Please login or register to comment.