Cadence

Latest Version on Packagist PHP Version Tests Static Analysis Total Downloads

Cadence is a Laravel package for applying progressive backoff based on consecutive failures.

Unlike traditional rate limiting, Cadence only introduces delays after repeated failed attempts. A successful operation immediately resets the backoff state, allowing normal traffic to continue uninterrupted while slowing down repeated failures.

Cadence stores its state using Laravel's cache abstraction and provides a clean, Laravel-native API through a manager, facade, and dependency injection. It supports multiple backoff strategies and optional jitter algorithms to help distribute retries and reduce synchronized retry bursts.

Features

  • Track repeated failures on a per-key basis
  • Apply progressive backoff after configurable free attempts
  • Multiple built-in backoff strategies (Exponential, Fibonacci, Linear, Quadratic)
  • Optional jitter algorithms to distribute retries and reduce synchronized retry bursts
  • Reset backoff immediately after successful operations
  • Store state using Laravel's cache abstraction
  • Configure free attempts, idle timeout, and cache store
  • Resolve engines via the facade or dependency injection

When Should I Use Cadence?

Cadence is designed for operations where repeated failures should temporarily slow down future attempts.

Common use cases include:

  • Login and authentication endpoints
  • One-time password (OTP) verification
  • Password reset attempts
  • API authentication
  • Third-party API integrations
  • Webhook delivery retries
  • Expensive or sensitive operations that should back off after consecutive failures

Cadence does not limit every request. Instead, it only introduces delays after repeated failures, allowing successful operations to proceed normally while discouraging abusive or repeated failed attempts.