<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/nestjs-sliding-window-throttler-pj0kxg34o" -->

---
title: nestjs-sliding-window-throttler | daily.dev
description: A new NestJS library called nestjs-sliding-window-throttler addresses performance and accuracy issues with the standard @nestjs/throttler. The standard...
canonical: https://daily.dev/posts/nestjs-sliding-window-throttler-pj0kxg34o
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: nestjs-sliding-window-throttler | daily.dev
og:description: A new NestJS library called nestjs-sliding-window-throttler addresses performance and accuracy issues with the standard @nestjs/throttler. The standard...
og:url: https://daily.dev/posts/nestjs-sliding-window-throttler-pj0kxg34o
og:image: https://api.daily.dev/og/posts/pJ0kxG34O.png
og:image:alt: nestjs-sliding-window-throttler
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# nestjs-sliding-window-throttler

**[Nestjs Developers](https://daily.dev/sources/nestjsdevs)** · [@orkn](https://daily.dev/orkn) · 1 min read · 31 upvotes · 2 comments

## Summary

A new NestJS library called nestjs-sliding-window-throttler addresses performance and accuracy issues with the standard @nestjs/throttler. The standard throttler makes 3 separate Redis calls per request, causing ~2-3ms latency and potential race conditions, while fixed-window algorithms allow up to 2x burst traffic at window boundaries. This drop-in replacement uses a single atomic Redis operation with true sliding window timestamp tracking, achieving ~1ms latency, 99% accuracy, and 2-3x higher throughput. It leverages Redis 7.0+ Functions with automatic Lua fallback for older versions, making it suitable for security-critical endpoints like login attempts and password resets.

## Content

Most rate limiters are slow and inaccurate. I built one that's 50% faster and 99% precise.

Standard NestJS throttlers make 3 separate Redis calls per request. That's 3 network round-trips, ~2-3ms latency, and potential race conditions.

Worse? Fixed window algorithms allow 2x burst at boundaries. Your "100 requests/minute" limit becomes 200 requests in 1 second.

So I built nestjs-sliding-window-throttler.

One atomic Redis operation. True sliding window with timestamp tracking. Zero race conditions.

The results: 
⚡ 50% lower latency (~1ms vs ~2-3ms)
🎯 99% accuracy vs 70% for fixed window 
🚀 2-3x higher throughput 
✨ Single network round-trip instead of three

Uses Redis 7.0+ Functions with automatic Lua fallback for older versions. Drop-in replacement for @nestjs/throttler with full TypeScript support.

Perfect for security-critical endpoints where precision matters — login attempts, password resets, expensive API calls.

The video shows how different algorithms handle the same request pattern. Links here 👇

📦 npm: [npmjs.com/package/nestjs-sliding-window-throttler](http://npmjs.com/package/nestjs-sliding-window-throttler)

🔗 GitHub: [github.com/orknist/nestjs-sliding-window-throttler](http://github.com/orknist/nestjs-sliding-window-throttler)

📖 Algorithm explained: [github.com/orknist/nestjs-sliding-window-throttler/blob/main/docs/algorithm.md](http://github.com/orknist/nestjs-sliding-window-throttler/blob/main/docs/algorithm.md)

[#NestJS](https://www.linkedin.com/search/results/all/?keywords=%23nestjs&origin=HASH_TAG_FROM_FEED) [#TypeScript](https://www.linkedin.com/search/results/all/?keywords=%23typescript&origin=HASH_TAG_FROM_FEED) [#Redis](https://www.linkedin.com/search/results/all/?keywords=%23redis&origin=HASH_TAG_FROM_FEED) [#RateLimiting](https://www.linkedin.com/search/results/all/?keywords=%23ratelimiting&origin=HASH_TAG_FROM_FEED) [#BackendEngineering](https://www.linkedin.com/search/results/all/?keywords=%23backendengineering&origin=HASH_TAG_FROM_FEED) [#OpenSource](https://www.linkedin.com/search/results/all/?keywords=%23opensource&origin=HASH_TAG_FROM_FEED) [#Performance](https://www.linkedin.com/search/results/all/?keywords=%23performance&origin=HASH_TAG_FROM_FEED)

## Community discussion

Top comments from developers on daily.dev.

**@lucas39** · 1 upvotes

> Isn't it the purpose for a rate limiter to be ... "slow" ?

## Similar posts on daily.dev

- [Sliding-Window Rate Limiters with TypeScript & Redis](https://daily.dev/posts/sliding-window-rate-limiters-with-typescript-redis-johtnq4x1) · SitePoint · 0 upvotes · 0 comments
- [Rate Limiting Algorithms: Token Bucket vs Sliding Window vs Fixed Window](https://daily.dev/posts/rate-limiting-algorithms-token-bucket-vs-sliding-window-vs-fixed-window-c6i3q4jdl) · Arcjet · 0 upvotes · 0 comments
- [28 Million Decisions Per Second. Zero Allocations. One Rate Limiter.](https://daily.dev/posts/28-million-decisions-per-second-zero-allocations-one-rate-limiter--a6kmxkmhy) · Medium · 0 upvotes · 0 comments
- [How to Build an In-Memory Rate Limiter in Next.js](https://daily.dev/posts/how-to-build-an-in-memory-rate-limiter-in-next-js-zzg3xyrqx) · freeCodeCamp · 12 upvotes · 0 comments

---

Tags: [#typescript](https://daily.dev/tags/typescript), [#redis](https://daily.dev/tags/redis), [#nestjs](https://daily.dev/tags/nestjs)

[View this post on daily.dev](https://daily.dev/posts/nestjs-sliding-window-throttler-pj0kxg34o)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/nestjs-sliding-window-throttler-pj0kxg34o","headline":"nestjs-sliding-window-throttler","text":"A new NestJS library called nestjs-sliding-window-throttler addresses performance and accuracy issues with the standard @nestjs/throttler. The standard throttler makes 3 separate Redis calls per request, causing ~2-3ms latency and potential race conditions, while fixed-window algorithms allow up to 2x burst traffic at window boundaries. This drop-in replacement uses a single atomic Redis operation with true sliding window timestamp tracking, achieving ~1ms latency, 99% accuracy, and 2-3x higher throughput. It leverages Redis 7.0+ Functions with automatic Lua fallback for older versions, making it suitable for security-critical endpoints like login attempts and password resets.","url":"https://daily.dev/posts/nestjs-sliding-window-throttler-pj0kxg34o","datePublished":"2026-04-07T14:47:02.197Z","dateModified":"2026-04-07T14:47:28.306Z","author":{"@type":"Person","name":"Orkun","url":"https://daily.dev/orkn","image":"https://media.daily.dev/image/upload/s--wammElXF--/f_auto/v1775570401/avatars/avatar_Vde4xELUaswBxYVJRrmmp?_a=BAMAMiWQ0","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":110}},"image":"https://media.daily.dev/image/upload/s--rN4ArafL--/f_auto/v1775573177/posts/bOfjJtkzE?_a=BAMAMiWQ0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":31},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"comment":[{"@type":"Comment","text":"Isn’t it the purpose for a rate limiter to be … “slow” ?","datePublished":"2026-04-16T13:15:34.030Z","url":"https://daily.dev/posts/pJ0kxG34O#c-H6v2kyk5s","author":{"@type":"Person","name":"Lucas","url":"https://daily.dev/lucas39","image":"https://lh3.googleusercontent.com/a/ACg8ocIIUWuKYGCrhLQ9bRh_zl_uNxcdY4Gvvwc91aTGmSre6nyWEA=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/nestjsdevs","name":"Nestjs Developers"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nestjs Developers","item":"https://daily.dev/squads/nestjsdevs"},{"@type":"ListItem","position":3,"name":"nestjs-sliding-window-throttler"}]}
```

