Week 3 · Day 20/30

AI System Design Patterns

Circuit breakers, fallbacks, caching, retry strategies

📅 2026-03-23 ⏱️ 5-6 hodín 📊 Security & Production
Celkový progres 67%

🎯 Cieľ dňa

Ovládnuť production patterns pre resilientné AI systémy: caching (semantic + exact), circuit breakers, a graceful degradation.

core practice

📚 Study Resources

Redis — What is Semantic Caching?

Semantic cache: rozumie meaning, nie len exact match. Cache hit: 2-4x rýchlejšie, optimal 50-100x.

article
📋

Redis — LLM Caching with RedisVL

SemanticCache interface: auto-index, cosine similarity threshold, TTL. Production-ready.

docs
🛡️

Portkey — Retries, Fallbacks & Circuit Breakers

Kedy retry, kedy fallback, kedy circuit break. Decision framework.

article
💻

Pedromebo — Semantic Cache with LangChain & Redis

Hands-on: implementácia semantic cache. 62% hit rate, ~$11 vs ~$30 bez cache.

tutorial

💡 Key Concepts

Semantic Caching — Vector similarity pre cache lookup. +5-20ms overhead, -1-5s na cache hit. 62% hit rate v produkcii.
Circuit Breaker — Closed → Open → Half-Open. Keď failures prekročia threshold, cut traffic. Prevent cascade.
Graceful Degradation — Namiesto failure, sliž service level: Opus → Sonnet → Haiku → cached response → static fallback
Retry Strategies — 70-80% transient failures sa vyriešia za sekundy. Exponential backoff + jitter je standard.

🔧 Praktické cvičenie

Implementuj caching a circuit breaker pre LLM API.

  1. Nastav Redis locally (alebo in-memory fallback)
  2. Implementuj exact match cache (prompt hash → response)
  3. Pridaj semantic cache s embedding similarity
  4. Implementuj circuit breaker s 3 stavmi
  5. Buildni graceful degradation chain
  6. Testuj: zmeraj latency s/bez cache, simuluj failures