Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Developer docs
Rate limiting
Rate limitingReference implementationStep-by-step guideOfficial docs and resourcesDiscussionsComments

Other algorithms

Algorithm basics5
Complexity analysisSortingSearchingBasic data structuresTrees and heaps
Core algorithms6
Graph traversalShortest paths & minimum spanning treesDynamic programmingGreedy algorithmsDivide and conquerBacktracking
Advanced algorithms5
String algorithmsMath and number theoryBit manipulationSegment treesUnion-find
Practical algorithms3
Coding interview strategyLRU cacheConsistent hashing

Algorithm

Rate limiting

Rate limiting caps how many requests a user or IP can make per time window. Learn token bucket, sliding window, leaky bucket and Redis-based limiters.

Start the guideDiscussions

A rate limiter controls how many requests are accepted within a period of time. You define a key, a limit and a window, such as "100 requests per minute per user", and requests beyond that are rejected or delayed. The classic algorithms are fixed window, sliding window log, sliding window counter, token bucket and leaky bucket, and they differ in accuracy, memory use and how they treat bursts.

Nearly every feature exposed to the outside world, from public APIs to login, payments and messaging, sits behind a rate limiter. It shields servers from traffic spikes and runaway retry loops, keeps one user from monopolizing shared capacity and slows down brute-force attacks. It is also a staple of system design interviews, where you are expected to explain the trade-offs and how to run a limiter across many servers.

Start by writing a fixed window counter and watching it let twice the limit through around a window boundary, then fix that with a sliding window and a token bucket. From there, learn to test with an injected clock, return HTTP 429 with Retry-After, and share a limit across servers with Redis INCR, EXPIRE and Lua scripts.

On this page

  1. Highlights
  2. Where it is used
  3. Reference implementation
  4. Step-by-step guide
  5. Official docs and resources
  6. Discussions
  7. Comments

Highlights

Token bucket

Tokens refill at a steady rate and each request spends one, enforcing an average rate while allowing bursts up to the bucket's capacity.

Sliding windows

A timestamp log, or a weighted blend of two window counters, counts recent requests without the fixed window's boundary spike.

Keys and fairness

Separate limits per user ID, API key, IP address or endpoint stop any single client from monopolizing resources.

Distributed limits

Redis's atomic INCR and Lua scripts let many servers share one limit without race conditions.

Where it is used

  • Per-plan quotas on public APIs
  • Throttling login and password reset attempts
  • Capping spend on paid third-party APIs and SMS
  • Traffic protection in web servers and API gateways

Reference implementation

A token bucket

TokenBucket refills at rate tokens per second and holds at most capacity tokens. allow() adds all the tokens earned since the last call in one step (lazy refill), then spends one if enough are available. Running the script lets the first 5 calls through as a burst and rejects the next 3; after a 1.1-second pause, two more pass. Time is measured with time.monotonic(), which never goes backwards.

token_bucket.py

import time


class TokenBucket:
    """Allow bursts of up to `capacity` requests, refilled at `rate` tokens per second."""

    def __init__(self, rate: float, capacity: float) -> None:
        self.rate = rate
        self.capacity = capacity
        self.tokens = capacity
        self.updated = time.monotonic()

    def allow(self, cost: float = 1.0) -> bool:
        now = time.monotonic()
        self.tokens = min(self.capacity, self.tokens + (now - self.updated) * self.rate)
        self.updated = now
        if self.tokens >= cost:
            self.tokens -= cost
            return True
        return False


if __name__ == "__main__":
    bucket = TokenBucket(rate=2, capacity=5)   # 2 requests per second, bursts of 5
    print([bucket.allow() for _ in range(8)])  # 5 x True, then 3 x False
    time.sleep(1.1)                            # about 2.2 tokens come back
    print(bucket.allow(), bucket.allow(), bucket.allow())  # True True False
python token_bucket.py

Step-by-step guide

Six chapters that take you from installation to the core ideas of Rate limiting.

  1. Concepts
  2. How It Works
  3. Implementation
  4. Complexity
  5. Practice Problems
  6. Real-World Use

Official docs and resources

  • OfficialRFC 6585: Additional HTTP Status Codes
  • OfficialINCR (Redis Docs)
  • OfficialModule ngx_http_limit_req_module
  • ReferenceRate limiting
  • ReferenceToken bucket
  • ReferenceLeaky bucket
  • Reference429 Too Many Requests (MDN)
  • CommunityHow we built rate limiting capable of scaling to millions of domains

Discussions

Start a discussion

Ask questions, share experience and trade opinions about Rate limiting.

No discussions yet. Start the first one.

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.