Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A rate limiter decides whether a request may proceed by checking the caller’s quota and updating its state. To build one, define who shares a quota, choose an algorithm that fits your burst and accuracy needs, and make each decision-and-update atomic. A counter in one process is enough for a single instance; when multiple servers must enforce the same limit, they need coordinated state, often in a shared store such as Redis.

Define the quota before choosing an algorithm

Start with the invariant: for a given identity key, allow a request only if the algorithm’s current state permits it, then update that state as one operation. Decide what counts as a request and which callers share a quota. A key might represent a user ID, API key, tenant, IP address, or model. That choice determines whether two callers draw from one limit or have separate limits. See Redis’s rate-limiter documentation for examples of quota dimensions and implementation primitives.

Also decide what the limiter does when a caller exceeds its quota: reject the request, delay it, or queue it for later. Rejection and traffic shaping solve different problems. An API that returns an error for excess requests is not the same as a system that buffers work and releases it at a controlled pace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose an algorithm for your traffic pattern

These designs differ in burst allowance, behavior at window boundaries, state cost, and whether they simply police requests or shape their delivery. Redis’s comparison describes the behavior of its implementations; those characterizations are not universal performance guarantees.

#1 Best Overall
Sale
TP-Link AC1200 WiFi Router Dual Band Wireless Internet Router (Archer A54)
  • Dual-band Wi-Fi with 5 GHz speeds up to 867 Mbps and 2.4 GHz speeds up to 300 Mbps, delivering 1200 Mbps of total bandwidth¹. Dual-band routers do not support 6 GHz. Performance varies by conditions, distance to devices, and obstacles such as walls.
  • Covers up to 1,000 sq. ft. with four external antennas for stable wireless connections and optimal coverage.
  • Supports IGMP Proxy/Snooping, Bridge and Tag VLAN to optimize IPTV streaming
  • Access Point Mode - Supports AP Mode to transform your wired connection into wireless network, an ideal wireless router for home
  • Advanced Security with WPA3 - The latest Wi-Fi security protocol, WPA3, brings new capabilities to improve cybersecurity in personal networks
Algorithm Burst and boundary behavior Accuracy and state Typical behavior
Fixed window Can admit a boundary burst approaching twice the configured limit across adjacent windows. Approximate; one string key in the Redis comparison. Counts requests in a fixed interval and rejects those over the limit.
Sliding-window log Does not have the fixed-window boundary jump when it tracks request timestamps precisely. Exact in the Redis comparison; O(n) entries for requests in the window. Checks the request history in the active interval and rejects excess requests.
Sliding-window counter Smooths the boundary effect without recording every request. Near-exact in the Redis comparison; two keys. Uses current and previous-window counts to estimate the rolling total.
Token bucket Allows bursts up to bucket capacity while constraining the long-run rate through refill. Exact with controlled bursts in the Redis comparison; one hash key. Accepts a request when sufficient tokens remain; rejects it otherwise.
Leaky-bucket policing Does not pass bursts unchecked in the Redis comparison. Exact in that comparison; state cost is not stated there. Polices excess traffic. A shaping variant can queue requests and release them at a steadier rate.

For the comparison details and implementation examples, see Redis’s Go token-bucket guide and its rate-limiter tutorial.

Use fixed windows for simple quotas

A fixed window counts requests in intervals such as each minute. It is easy to reason about and inexpensive to represent, but a caller can use its full allowance just before a window ends and again just after the next one begins. That makes it a poor fit when a sharp boundary burst would overload the protected service.

Rank #2
Sale
TP-Link AX1800 WiFi 6 Router (Archer AX21 V5)
  • DUAL-BAND WIFI 6 ROUTER: Wi-Fi 6(802.11ax) technology achieves faster speeds, greater capacity and reduced network congestion compared to the previous gen. All WiFi routers require a separate modem. Dual-Band WiFi routers do not support the 6 GHz band.
  • AX1800: Enjoy smoother and more stable streaming, gaming, downloading with 1.8 Gbps total bandwidth (up to 1200 Mbps on 5 GHz and up to 574 Mbps on 2.4 GHz). Performance varies by conditions, distance to devices, and obstacles such as walls.
  • CONNECT MORE DEVICES: Wi-Fi 6 technology communicates more data to more devices simultaneously using revolutionary OFDMA technology
  • EXTENSIVE COVERAGE: Achieve the strong, reliable WiFi coverage with Archer AX1800 as it focuses signal strength to your devices far away using Beamforming technology, 4 high-gain antennas and an advanced front-end module (FEM) chipset
  • OUR CYBERSECURITY COMMITMENT: TP-Link is a signatory of the U.S. Cybersecurity and Infrastructure Security Agency’s (CISA) Secure-by-Design pledge. This device is designed, built, and maintained, with advanced security as a core requirement.

Use a sliding window when boundary fairness matters

A sliding-window log evaluates requests over a rolling interval, but its per-request history costs more state as traffic grows. A sliding-window counter approximates a rolling total with less state by combining adjacent window counts. Choose between them based on how much boundary precision the protected operation needs and how much state you can afford.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use token bucket for bounded bursts

A token bucket holds up to a configured capacity. Tokens refill at a chosen rate; each accepted request consumes tokens. If the bucket has no tokens, the limiter rejects or delays the request, depending on the surrounding design. Capacity sets the maximum burst the bucket can absorb, while refill rate governs sustained traffic. This is a useful model when short bursts are acceptable but prolonged traffic must stay within a rate.

Rank #3
Sale
TP-Link Dual-Band BE3600 Wi-Fi 7 Router, Archer BE230
  • 𝐅𝐮𝐭𝐮𝐫𝐞-𝐏𝐫𝐨𝐨𝐟 𝐘𝐨𝐮𝐫 𝐇𝐨𝐦𝐞 𝐖𝐢𝐭𝐡 𝐖𝐢-𝐅𝐢 𝟕: Powered by Wi-Fi 7 technology, enjoy faster speeds with Multi-Link Operation, increased reliability with Multi-RUs, and more data capacity with 4K-QAM, delivering enhanced performance for all your devices.
  • 𝐁𝐄𝟑𝟔𝟎𝟎 𝐃𝐮𝐚𝐥-𝐁𝐚𝐧𝐝 𝐖𝐢-𝐅𝐢 𝟕 𝐑𝐨𝐮𝐭𝐞𝐫: Delivers up to 2882 Mbps (5 GHz), and 688 Mbps (2.4 GHz) speeds for 4K/8K streaming, AR/VR gaming & more. Dual-band routers do not support 6 GHz. Performance varies by conditions, distance, and obstacles like walls.
  • 𝐔𝐧𝐥𝐞𝐚𝐬𝐡 𝐌𝐮𝐥𝐭𝐢-𝐆𝐢𝐠 𝐒𝐩𝐞𝐞𝐝𝐬 𝐰𝐢𝐭𝐡 𝐃𝐮𝐚𝐥 𝟐.𝟓 𝐆𝐛𝐩𝐬 𝐏𝐨𝐫𝐭𝐬 𝐚𝐧𝐝 𝟑×𝟏𝐆𝐛𝐩𝐬 𝐋𝐀𝐍 𝐏𝐨𝐫𝐭𝐬: Maximize Gigabitplus internet with one 2.5G WAN/LAN port, one 2.5 Gbps LAN port, plus three additional 1 Gbps LAN ports. Break the 1G barrier for seamless, high-speed connectivity from the internet to multiple LAN devices for enhanced performance.
  • 𝐍𝐞𝐱𝐭-𝐆𝐞𝐧 𝟐.𝟎 𝐆𝐇𝐳 𝐐𝐮𝐚𝐝-𝐂𝐨𝐫𝐞 𝐏𝐫𝐨𝐜𝐞𝐬𝐬𝐨𝐫: Experience power and precision with a state-of-the-art processor that effortlessly manages high throughput. Eliminate lag and enjoy fast connections with minimal latency, even during heavy data transmissions.
  • 𝐂𝐨𝐯𝐞𝐫𝐚𝐠𝐞 𝐟𝐨𝐫 𝐄𝐯𝐞𝐫𝐲 𝐂𝐨𝐫𝐧𝐞𝐫 - Covers up to 2,000 sq. ft. for up to 60 devices at a time. 4 internal antennas and beamforming technology focus Wi-Fi signals toward hard-to-reach areas. Seamlessly connect phones, TVs, and gaming consoles.

Use leaky bucket when output should be steadier

“Leaky bucket” can describe policing or shaping. Policing rejects excess requests; shaping queues them and releases them at a more constant pace. If requests must not reach a downstream service in unchecked bursts, a shaping design may fit better than a token bucket. Account for queue capacity and waiting time if you queue: those are application-level choices, not properties implied by the name alone.

Start with local state for one process

For a service running as one process, an in-memory counter or bucket can be the simplest implementation. Keep state per identity key, apply the chosen algorithm, and ensure concurrent requests cannot both observe the same allowance and exceed it. Local state is not a global quota, however: if a load balancer can send the same caller to different instances, each instance may maintain a separate count.

Rank #4
Sale
TP-Link ER605, Wired Gigabit VPN Router
  • 【Five Gigabit Ports】1 Gigabit WAN Port plus 2 Gigabit WAN/LAN Ports plus 2 Gigabit LAN Port. Up to 3 WAN ports optimize bandwidth usage through one device.
  • 【One USB WAN Port】Mobile broadband via 4G/3G modem is supported for WAN backup by connecting to the USB port. For complete list of compatible 4G/3G modems, please visit TP-Link website.
  • 【Abundant Security Features】Advanced firewall policies, DoS defense, IP/MAC/URL filtering, speed test and more security functions protect your network and data.
  • 【Highly Secure VPN】Supports up to 20× LAN-to-LAN IPsec, 16× OpenVPN, 16× L2TP, and 16× PPTP VPN connections.
  • Security - SPI Firewall, VPN Pass through, FTP/H.323/PPTP/SIP/IPsec ALG, DoS Defence, Ping of Death and Local Management. Standards and Protocols IEEE 802.3, 802.3u, 802.3ab, IEEE 802.3x, IEEE 802.1q

That separation may be acceptable when limits are intentionally per instance or approximate. It is not sufficient when all servers must enforce one shared allowance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Coordinate multiple servers with shared state

When independently handling instances need a common quota, they need shared state and atomic updates. Redis is one coordination option: each instance evaluates and updates the same identity-scoped state. This gives them a common view, but adds a synchronous datastore dependency and latency to the request path. Microsoft’s throttling pattern guidance also discusses throttling as a way to protect services and manage demand.

Best Value
Sale
TP-Link TL-SG105, 5 Port Gigabit Unmanaged Ethernet Switch, Network Hub, Ethernet Splitter, Plug & Play, Fanless Metal Design, Shielded Ports, Traffic Optimization
  • 𝗢𝗻𝗲 𝗦𝘄𝗶𝘁𝗰𝗵 𝗠𝗮𝗱𝗲 𝘁𝗼 𝗘𝘅𝗽𝗮𝗻𝗱 𝗡𝗲𝘁𝘄𝗼𝗿𝗸: 5× 10/100/1000Mbps RJ45 Ports supporting Auto Negotiation and Auto MDI/MDIX.
  • 𝗚𝗶𝗴𝗮𝗯𝗶𝘁 𝘁𝗵𝗮𝘁 𝗦𝗮𝘃𝗲𝘀 𝗘𝗻𝗲𝗿𝗴𝘆: Latest innovative energy-efficient technology greatly expands your network capacity with much less power consumption and helps save money.
  • 𝗥𝗲𝗹𝗶𝗮𝗯𝗹𝗲 𝗮𝗻𝗱 𝗤𝘂𝗶𝗲𝘁: IEEE 802.3X flow control provides reliable data transfer and Fanless design ensures quiet operation.
  • 𝗣𝗹𝘂𝗴 𝗮𝗻𝗱 𝗣𝗹𝗮𝘆: Easy setup with no software installation or configuration needed.
  • 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗦𝗼𝗳𝘁𝘄𝗮𝗿𝗲 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀: Prioritize your traffic and guarantee high quality of video or voice data transmission with Port-based 802.1p/DSCP QoS and IGMP Snooping.

Implement a fixed-window counter atomically

Redis documents INCR and EXPIRE as basic primitives for fixed-window counters: increment the key and arrange for it to expire when the window ends. Do not implement enforcement as separate read, check, and write calls; concurrent requests can race between those steps and both be admitted. Make the counter update and its expiry handling safe as a unit. Redis’s general documentation also mentions HEXPIRE as a Redis 8 capability, so check the deployed version before relying on it; it is not available on older deployments merely because the documentation describes it.

Represent token-bucket state in Redis

A token-bucket record needs enough information to determine the current token balance, capacity, refill rate, and when the balance was last updated. On each request, calculate elapsed time, add the corresponding refill without exceeding capacity, decide whether a token can be spent, and persist the resulting state. The read-decide-update sequence must be atomic so simultaneous requests cannot spend the same token.

Redis’s Go examples use Lua scripts for atomic limiter operations. For time-based scripts, the guide obtains time from Redis rather than relying on each application server’s clock, avoiding drift between instances. See the Redis Go guide for its implementation details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose what happens when the shared store fails

A datastore timeout forces a policy choice. Fail-open allows requests through when the limiter cannot check state: availability is preserved, but the limit can be bypassed during the outage. Fail-closed rejects requests it cannot verify: enforcement remains strict, but otherwise valid traffic may be denied. The right choice depends on what the limiter protects and the service’s availability requirements. Redis’s Go example demonstrates a fail-open choice for a Redis timeout; it is an example, not a universal recommendation.

Quick Recap

SaleBestseller No. 1
TP-Link AC1200 WiFi Router Dual Band Wireless Internet Router (Archer A54)
TP-Link AC1200 WiFi Router Dual Band Wireless Internet Router (Archer A54)
Supports IGMP Proxy/Snooping, Bridge and Tag VLAN to optimize IPTV streaming
$24.32
SaleBestseller No. 2
TP-Link AX1800 WiFi 6 Router (Archer AX21 V5)
TP-Link AX1800 WiFi 6 Router (Archer AX21 V5)
VPN SERVER: Archer AX21 Supports both Open VPN Server and PPTP VPN Server
$59.98
SaleBestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.