Skip to content

Concepts

This section explains the why behind each feature. Understanding these concepts helps you make better architectural decisions.

Mental Models

ConceptQuestion It Answers
Two-Tier CachingWhen should I use L1 vs L2 cache?
Distributed CoordinationWhen do I need locks vs idempotency?
Rate Limiting StrategiesWhich algorithm fits my use case?
Event StreamingWhen should I use Streams vs alternatives?
Observability StrategyWhat should I monitor and why?

Core Principles

1. Defense in Depth

Never rely on a single mechanism. Combine multiple protections:

Payment Flow:
  Idempotency (detect duplicates)
    → Locks (serialize processing)
      → Database constraints (final safety net)

2. Fail Open vs Fail Closed

Choose based on business impact:

Failure ModeBehaviorUse When
Fail OpenAllow operation if Redis downCache, non-critical rate limits
Fail ClosedBlock operation if Redis downPayments, security-critical

3. Eventual Consistency

Redis-based systems are eventually consistent. Design for:

  • Stale reads (cache may be outdated)
  • Lost updates (write may not persist)
  • Duplicate processing (exactly-once is impossible)

Concept Map

Next Steps

Start with the concept most relevant to your use case:

Released under the MIT License.