Saltar al contenido principal
ProductosHerramientas de escritorioTASTECADRevisión de planosTASTEFILESGestión de archivosTASTEFTPTransferencia de archivosTASTESSHEspacio de trabajo remotoTASTEZIPCompresión y extracciónTASTEWINMGestión de archivosHerramientas para desarrolladoresTASTECODEEntorno de desarrollo integrado para RustTASTESTUDIOEntorno integrado de desarrollo y pruebasTASTEETLIntegración de datos (ETL)ServidoresTASTEREMOTEServidor de escritorio remotoTASTEGEOServidor geoespacialTASTEMAILEspacio de trabajo de correoInversiónTASTESTOCKAplicación de escritorio de trading automático de accionesEmpezarDescargasDocumentaciónComprarTodos los productos
Marketplace
Noticias
TecnologíaNoticiasNoticias de desarrollo de hoyDocumentaciónLenguajes de programaciónRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFrameworks web frontendNext.jsReactVue.js · NuxtSvelteKitAngularFrameworks de servidorSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFrameworks de apps y escritorioTauriFlutterReact NativeElectronAlgoritmosFundamentos de algoritmosAlgoritmos esencialesAlgoritmos avanzadosAlgoritmos prácticos
ComunidadProyectosRegistros de desarrolloPromptsProblemas con herramientas de IAEscaparateGuía de la comunidad
ColaboraTransferencia técnicaDesarrollo de sitio webDesarrollo de app de escritorioCanal de lanzamiento y pagosSocio de ventasContacto
ServiciosEscritorio remotoPaquetes de instalación a medida
TASTEDEV
Productos

Herramientas de escritorio

TASTECADAbre planos complejos con ligerezaTASTEFILESSolo los archivos que necesitas, lo más rápido posibleTASTEFTPEl camino más limpio para tus archivosTASTESSHEntre tu servidor y tú, una conexión más sólidaTASTEZIPComprime más rápido, descomprime más seguroTASTEWINMUn gestor de archivos de dos paneles pensado para el teclado

Herramientas para desarrolladores

TASTECODEEdita, compila, depura y prueba apps de Rust en una sola ventanaTASTESTUDIODe la edición a las pruebas remotas y las correcciones con IA aprobadasTASTEETLMueve datos viendo sus valores

Servidores

TASTEREMOTEUn escritorio remoto que funciona en tu propio servidorTASTEGEOUn servidor geoespacial compatible con GeoServer, reconstruido en RustTASTEMAILRecupera el control de tu correo

Inversión

TASTESTOCKTrading automático de acciones según las reglas que tú defines: cuándo y qué

Empezar

DescargasÚltimas versiones de cada productoDocsCómo usar cada productoComprarSuscripciones y licencias perpetuasTodos los productosTodos los productos de un vistazo
Todos los productos
MarketplaceNoticias
Tecnología

Noticias

Noticias de desarrollo de hoyAnuncios oficiales de lenguajes, frameworks, GitHub e IADocumentaciónGuías de lenguajes, frameworks y algoritmos

Lenguajes de programación

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Frameworks web frontendNext.jsReactVue.js · NuxtSvelteKitAngular
Frameworks de servidorSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Frameworks de apps y escritorioTauriFlutterReact NativeElectron

Algoritmos

Fundamentos de algoritmosAnálisis de complejidad · Ordenamiento · Búsqueda · Estructuras de datos básicas · Árboles y montículosAlgoritmos esencialesRecorrido de grafos · Camino mínimo y árbol generador mínimo · Programación dinámica · Algoritmos voraces · Divide y vencerás · Backtracking (vuelta atrás)Algoritmos avanzadosAlgoritmos de cadenas · Matemáticas y teoría de números · Manipulación de bits · Árboles de segmentos · Union-FindAlgoritmos prácticosEstrategia para entrevistas de código · Caché LRU · Limitación de tasa · Hashing consistente
Toda la documentación de desarrollo
Comunidad
ProyectosDescubre creadores y su trabajoRegistros de desarrolloDecisiones y aprendizajesPromptsInstrucciones reutilizablesProblemas con herramientas de IAProblemas y alternativas de Claude, Codex, GeminiEscaparateResultados terminadosGuía de la comunidadCómo construimos en abierto
Colabora
Transferencia técnicaApps nativas con Rust y eguiDesarrollo de sitio web10 idiomas, cuentas, documentación y descargasDesarrollo de app de escritorioRust y egui, sin WebViewCanal de lanzamiento y pagosFirma, MSI, deb, rpm, AppImage, hashesSocio de ventasRecomiéndanos y gana el 30 %ContactoDesarrollo, alianzas e inversión
Servicios
Escritorio remotoAccede a tu ordenador desde el navegadorPaquetes de instalación a medidaSolo lo necesario, ajustes precargados
Comprar
ES
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Iniciar sesión
Iniciar sesión
TASTEDEV

De pequeñas herramientas a un mejor desarrollo.

support@tastedev.netApoyar a TASTEDEV
ProductosLínea de productosComprarDocsDescargasMarketplaceSoporte
ComunidadProyectosRegistros de desarrolloPromptsProblemas con herramientas de IAEscaparate
PolíticasQuiénes somosPolítica de privacidadTérminos de servicioCondiciones de suscripciónReembolsosNormas de la comunidad
CuentaIniciar sesiónRegistrarse
Visitantes
Hoy
Ayer
Vistas totales
Empresa
GXSOFT
Representante
CHOI YOUNG GU
Número de registro mercantil
853-44-00368
Dirección
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Teléfono
+82-10-4404-1523
Correo electrónico
whitecalvin@tastedev.net
Responsable de privacidad
CHOI YOUNG GU

© 2026 TASTEDEVLa información de los productos se basa en fuentes de desarrollo verificadas.Publicado · en mejora

Documentación de Limitación de tasa
Limitación de tasa
ConceptsHow It WorksImplementationComplexityPractice ProblemsReal-World Use
Debates

Guía de Limitación de tasa · 4/6

Complexity

Por ahora, este capítulo solo está disponible en inglés.

A rate limiter runs in front of every request, so the cost of one decision and the memory each key consumes translate directly into the cost of running your service. This chapter compares the five algorithms on time, space, accuracy and burst behavior. Below, L is the limit per window and K is the number of active keys.

Time per decision

  • Fixed window: compute the window number and bump one counter. O(1).
  • Sliding window log: drop expired entries from the front, then count. With a deque each timestamp is appended once and removed once, so the cost is amortized O(1), although a single call may drop up to O(L) entries. Implemented with a Redis sorted set, adds and range deletes cost O(log n).
  • Sliding window counter: one multiplication and one addition. O(1).
  • Token bucket: add elapsed time × rate and compare. O(1).
  • Leaky bucket (queue): enqueue and dequeue are each O(1).

Memory per key

AlgorithmState per keySpace
Fixed windowwindow number, counterO(1)
Sliding window logtimestamps of accepted requestsO(L)
Sliding window counterwindow number, two countersO(1)
Token buckettoken count, last update timeO(1)
Leaky bucketqueue of waiting requestsO(queue size)

Multiply by K for the total. With a limit of 10,000 per hour and 100,000 active users, a sliding log may have to hold a billion timestamps in the worst case, while token buckets need just 200,000 numbers. That gap is why large services rarely use the log approach.

def worst_case_bytes(keys: int, limit: int, bytes_per_number: int = 8) -> dict[str, int]:
    return {
        "fixed_window": keys * 2 * bytes_per_number,
        "sliding_log": keys * limit * bytes_per_number,
        "sliding_counter": keys * 3 * bytes_per_number,
        "token_bucket": keys * 2 * bytes_per_number,
    }


for name, size in worst_case_bytes(keys=100_000, limit=10_000).items():
    print(f"{name:16} {size / 2**20:10.1f} MiB")
# sliding_log needs about 7,629 MiB; the others need a few MiB

Real usage is higher because of language and storage overhead, but the orders of magnitude hold.

Accuracy and bursts

¿Tienes preguntas sobre este capítulo?
Capítulo anteriorImplementationCapítulo siguientePractice Problems
Algorithm
Most admitted in any window-length span
Burst
Character
Fixed windowup to 2L (at a boundary)up to L at each window startsimplest
Sliding window logexactly Lup to Lexact but heavy
Sliding window counterabout L (approximate)around Llight and practical
Token bucketcapacity + rate × T over a span Tup to capacityaverage rate plus bursts
Leaky bucket (queue)rate × T (output side)absorbed by the queue, output stays evenadds waiting time

The token bucket bound is a simple formula: starting from a full bucket, at most capacity + rate × T requests pass during a span of length T. That is why it is configured with two numbers, such as "10 per second on average, bursts of up to 20".

def max_admitted(rate: float, capacity: float, seconds: float) -> int:
    # Most requests that can pass in `seconds`, starting from a full bucket
    return int(capacity + rate * seconds)


print(max_admitted(rate=10, capacity=20, seconds=1))    # 30
print(max_admitted(rate=10, capacity=20, seconds=60))   # 620

Measuring the boundary problem

This snippet sends requests just before and just after a boundary and counts how many each approach admits.

from collections import deque


def fixed_window(times, limit, window):
    counts = {}
    ok = 0
    for t in times:
        w = int(t // window)
        counts[w] = counts.get(w, 0) + 1
        ok += counts[w] <= limit
    return ok


def sliding_log(times, limit, window):
    log, ok = deque(), 0
    for t in times:
        while log and log[0] <= t - window:
            log.popleft()
        if len(log) < limit:
            log.append(t)
            ok += 1
    return ok


burst = [59.5] * 5 + [60.5] * 5        # five on each side of the boundary
print(fixed_window(burst, 5, 60))      # 10
print(sliding_log(burst, 5, 60))       # 5

The cost of going distributed

When several servers share one limit, every decision needs a round trip to a shared store such as Redis. At that point the network round trip, typically hundreds of microseconds to a few milliseconds, dominates the algorithm's O(1). Bundling several commands into one Lua script keeps it to a single round trip. At very high volume, some systems keep a local bucket on each server and only sync with the shared store periodically, trading a little accuracy for lower latency.

Summary

  • Fixed window, sliding window counter and token bucket are O(1) in time and in space per key.
  • A sliding window log is exact but needs O(L) memory per key, which hurts at scale.
  • A token bucket admits at most capacity + rate × T requests over a span T.
  • Once distributed, network round trips, not the algorithm, set the cost.

0 comentarios

Comentarios destacadosMás recientes primero

Iniciar sesión · Inicia sesión para dejar un comentario.