Rate Limiting at Edge with Cloudflare Workers and Serverless Redis
Blog post from Upstash
The tutorial provides a step-by-step guide on implementing rate limiting for applications using Cloudflare Workers and Upstash Redis. It involves setting up multiple Redis databases in different regions to manage traffic efficiently, using Wrangler 2 for deployment, and coding a function to handle rate limiting based on IP addresses or other identifiers. The guide explains why regional databases are preferred over a global database for rate limiting, emphasizing reduced costs and local scope management. It highlights the use of an ephemeral cache to minimize the cost of remote calls and outlines how to integrate this setup into existing websites by configuring Cloudflare to intercept and manage requests. Furthermore, it clarifies that self-hosted Redis cannot be used directly with Cloudflare Workers due to connection restrictions, recommending Upstash Redis for its built-in REST API compatibility.