Developer Builds Postgres-Backed Rate Limiter to Protect Public Netlify Function
Kaleb, a web developer in Pompano Beach, Florida, added a public chat widget to his business website, which runs on a stateless Netlify serverless function. Shortly after deployment, he noticed automated script traffic repeatedly targeting the endpoint. Because in-memory caching fails across scaling container instances, he chose to use his existing PostgreSQL database as a shared store for request counts rather than adding Redis or an edge key-value service. The approach tracks requests per client IP within a rolling window, rejecting clients that exceed ten requests per minute with a 429 status code. The article includes the table schema and JavaScript code, and Kaleb argues the small added latency is acceptable for a low-traffic site.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in