redis_rate_limiting

A guide to limiting how many requests an API accepts in a given period, using Redis, a fast in-memory data store. It also covers Redis Cloud authentication and integration with FastAPI, a Python web framework.

In plain words
What is it for?
Use it when adding request limits to a FastAPI service, configuring Redis-based request counting and expiration, or diagnosing Redis Cloud authentication problems.
Why use it?
It helps prevent server overload, abusive request bursts, uncontrolled request costs, and unfair use of an API. It explains the setup and troubleshooting details needed when connecting Redis to the application.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/jondoescoding/jondoescoding-coding-rules/redis_rate_limiting
Clone the repo
git clone --depth 1 https://github.com/jondoescoding/jondoescoding-coding-rules
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 6,308 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00015 $0.06308
Opus 5 $0.00008 $0.03154
Sonnet 5 $0.00003 $0.01262
Haiku 4.5 $0.00002 $0.00631

Measured yesterday against content hash 9d50369de208, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

redis_rate_limiting scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

import urllib.parse
templates/cursor-rules/python/fast-api/redis_rate_limiting.mdc · 840 lines

How it starts

The opening of the file, as written. The whole thing — 840 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Redis Rate Limiting Implementation Guide

This rule provides a comprehensive guide for implementing Redis-based rate limiting across platforms, with specific focus on Redis Cloud authentication and FastAPI integration.

📚 BEGINNER'S GUIDE: Understanding Rate Limiting Components

What is Rate Limiting? (Start Here!)

Rate limiting is like a bouncer at a club - it controls how many people (API requests) can enter in a given time period. If too many people try to enter at once, the bouncer says "slow down, wait your turn!"

Why do we need it?

  • Prevents server overload (like too many people in a small room)
  • Protects against abuse (stops bad actors from spamming your API)
  • Controls costs (many cloud services charge per request)
  • Ensures fair usage (everyone gets a turn)

What is Redis? (The Memory Keeper)

Redis is like a super-fast notepad that lives in your computer's memory. Instead of writing things down on slow paper (hard disk), Redis writes in fast memory (RAM).

Why Redis for Rate Limiting?

  • Speed: Faster than a database for simple counting
  • Atomic Operations: Can count requests safely even with multiple users
  • Expiration: Can automatically forget old counts (like a self-erasing notepad)
  • Shared: Multiple servers can use the same Redis instance

What is Resend? (The Email Messenger)

Resend is like a professional postal service for emails. Instead of using your personal email to send notifications, Resend ensures your emails actually reach people's inboxes (not spam folders).

Why Resend for Notifications?

  • Deliverability: Emails actually reach recipients
  • Professional: Looks official and trustworthy
  • Tracking: You can see if emails were delivered
  • Templates: Can send beautiful HTML emails

What is FastAPI? (The Web Server Framework)

FastAPI is like a restaurant system that takes orders (API requests), processes them in the kitchen (your code), and serves the results back to customers (API responses).

Read the full file on GitHub · 840 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 840 lines · 15 tokens per session scan A 9d50369de208

Subscribe to this mod's changes

redis_rate_limiting is a cursor rule published in the GitHub repository jondoescoding/jondoescoding-coding-rules (2 stars, last pushed 1mo ago), licensed MIT. It adds 15 tokens to every session and 6,308 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.