Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Rate Limited Job Middleware Laravel Package

spatie/laravel-rate-limited-job-middleware

Laravel job middleware to rate limit queued jobs. Allow a configurable number of jobs per second and automatically release throttled jobs for a delay. Easy to attach per job via middleware, with support for time-based attempts when rate limiting.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Scalability & Cost Optimization: Enables controlled job execution rates to prevent API abuse, reduce cloud costs (e.g., AWS Lambda, SQS), or avoid rate limits from external services (e.g., Stripe, Twilio).
  • Feature Roadmap: Justifies prioritizing job queue management for high-volume systems (e.g., SaaS platforms, e-commerce, or real-time analytics).
  • Build vs. Buy: Avoids reinventing rate-limiting logic for jobs, saving dev time and reducing technical debt. MIT license ensures compliance.
  • Use Cases:
    • Throttling API integrations: Prevent overloading third-party APIs (e.g., payment processors, social media).
    • Fair usage policies: Enforce tiered limits for users (e.g., free vs. paid plans in a multi-tenant app).
    • System stability: Protect critical jobs (e.g., notifications, reports) from being overwhelmed during traffic spikes.
    • A/B testing: Control the rate of experimental job execution to monitor impact gradually.

When to Consider This Package

  • Adopt when:
    • Your Laravel app processes asynchronous jobs at scale (e.g., >100 jobs/minute) and needs predictable execution rates.
    • You rely on external APIs with strict rate limits (e.g., payment gateways, CRM tools).
    • Your team lacks time to build a custom rate-limiting solution for jobs.
    • You’re using Laravel Queues (database, Redis, SQS) and want a lightweight, middleware-based solution.
  • Look elsewhere if:
    • You need per-user job rate limits (requires additional logic; package focuses on global/job-type limits).
    • Your rate-limiting needs are dynamic (e.g., tied to user behavior or real-time events) beyond fixed intervals.
    • You’re using a non-Laravel backend (e.g., Node.js, Python) or a different queue system (e.g., RabbitMQ).
    • You require advanced metrics/alerts (e.g., Slack notifications for breaches)—this package is functional but not observability-focused.

How to Pitch It (Stakeholders)

For Executives: "This package lets us control how often background jobs run—like a traffic cop for our app’s workload. For example, if we’re sending 10,000 emails via SendGrid, we can cap them at 500/hour to avoid costs or bans. It’s a 10-minute setup that prevents technical debt and saves money on cloud resources. Used by [X] companies, it’s battle-tested and open-source, so no vendor lock-in."

For Engineering: *"Spatie’s rate-limiting middleware for Laravel jobs solves a common pain point: uncontrolled job execution. Key benefits:

  • Plug-and-play: Add to any job class in minutes (e.g., RateLimitJobMiddleware::limit(50)->perMinute()).
  • Flexible: Supports per-job or global limits (e.g., RateLimitJobMiddleware::limit(10)->perSecond()).
  • Lightweight: No new services or databases—uses Laravel’s built-in queue middleware.
  • Proven: MIT-licensed, 350+ stars, and maintained by Spatie (reliable open-source contributors). Use case: If we’re hitting Stripe’s API limits or our SQS costs are spiking, this gives us a knob to turn. Tradeoff: No per-user limits out of the box, but we can layer that on top if needed."*

For Developers: *"Need to throttle jobs? This middleware lets you define limits like:

public function handle()
{
    // Runs at most 10 times per minute
    RateLimitJobMiddleware::limit(10)->perMinute();
    // ... rest of job logic
}
  • Works with all Laravel queues (database, Redis, etc.).
  • No extra dependencies—just install and configure.
  • Extensible: Can customize storage (e.g., Redis for distributed systems). Downside: Basic logging; pair with Laravel Horizon or similar for monitoring."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport