Backend for AIintermediate11 min · 10 steps
Caching with Redis
Use Redis as a fast cache and coordination layer (session state, cached embeddings and answers, rate-limit counters, locks, queues), always with expiry and never as the only copy of important data.
model calls avoided/day0
saved/day$0
heavy workdatarequesterrorsignal
metrics are illustrativeProblemStep 1 of 10
Paying again for answers you already have
Thousands of users ask near-identical questions: "How do I reset my VPN?". Each one embeds the same text and calls the model for the same answer. Every chat turn also reloads session state from Postgres, and every request needs a rate-limit counter that must be atomic and fast.
The database can do all of this, but slowly and expensively. The repeated work costs money and latency on every turn.
Lesson 11 of 20 in Backend for AI