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 Debounce Laravel Package

zackaj/laravel-debounce

Debounce Laravel jobs, notifications, and (Laravel 11+) Artisan commands to prevent spamming users and queues. Uses unique job locks + cache to delay execution until activity stops. Tracks each occurrence with request metadata (IP, user) and provides reporting.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Reducing API/Notification Spam: Mitigate user fatigue from rapid-fire notifications (e.g., real-time updates, alerts, or bulk actions) by consolidating duplicate triggers into a single execution.
  • Cost Optimization: Lower queue processing costs by batching jobs/notifications (e.g., "send this email only once per hour, even if 10 users trigger it").
  • Build vs. Buy: Avoid reinventing atomic lock/caching logic for debouncing; leverage this package instead of custom solutions.
  • Roadmap Priorities:
    • User Experience: Critical for features like "live collaboration" (e.g., Google Docs-style updates) or "activity feeds" where spam harms engagement.
    • Background Jobs: High-value for async tasks (e.g., "send welcome email only once per user").
    • CLI Tools: Enable debouncing for scheduled commands (e.g., "run backup only once per day, even if triggered manually").
  • Use Cases:
    • Notifications: File upload alerts, comment replies, or system notifications (e.g., "Your order is processing").
    • Jobs: Rate-limited API calls, analytics batching, or resource-intensive tasks.
    • Artisan Commands: CLI-driven tasks like "generate reports" or "cleanup logs" (Laravel ≥11).

When to Consider This Package

  • Adopt if:

    • Your app triggers repeated, non-critical actions (e.g., notifications, jobs) that can tolerate slight delays (e.g., 5–30 seconds).
    • You need auditability (IP/user tracking, occurrence history) for debounced actions.
    • Your team lacks time to build atomic lock + cache-based debouncing from scratch.
    • You’re using Laravel 10+ (Laravel 11+ for CLI debouncing).
    • You want hooks (pre/post-execution logic) or custom timestamps (e.g., debounce based on last message time, not request time).
  • Look elsewhere if:

    • Real-time requirements: Debouncing introduces latency (minimum delay seconds). Use Redis pub/sub or WebSockets for instant updates.
    • Complex dependencies: Your debounced actions require immediate execution (e.g., payment processing). Use synchronous locks instead.
    • Legacy Laravel: Pre-10.x apps lack CLI debouncing support (though jobs/notifications still work).
    • High-throughput systems: If debounced actions must fire within milliseconds, consider database-level constraints (e.g., ON DUPLICATE KEY UPDATE).
    • No caching layer: Requires a cache driver (e.g., Redis, Memcached) for atomic locks.

How to Pitch It (Stakeholders)

For Executives:

*"This package lets us reduce operational noise by preventing duplicate or rapid-fire actions (e.g., notifications, background jobs) without sacrificing functionality. For example:

  • Cut queue costs by 30–50% for bulk notifications (e.g., 'New file uploaded' sent once per hour, not per upload).
  • Improve user experience by eliminating spam (e.g., live collaboration tools, alerts).
  • Add audit trails for compliance (track who triggered debounced actions and when). It’s a low-effort, high-impact solution—like adding a 'throttle' to your app’s most repetitive tasks. We can toggle it off in dev/test environments, and it integrates seamlessly with Laravel’s queue system."*

For Engineers:

*"Laravel-debounce provides a batteries-included way to debounce jobs, notifications, and CLI commands using atomic locks + caching. Key benefits:

  • Zero setup for basic use: Just wrap your existing jobs/notifications with Debounce::job() or Debounce::notification().
  • Advanced features:
    • Report tracking: Log IPs, user IDs, and timestamps for every occurrence.
    • Custom timestamps: Debounce based on business logic (e.g., last message time, not request time).
    • Hooks: Run code before/after debounced execution (e.g., analytics, logging).
  • Performance: Uses Laravel’s cache driver (Redis recommended) for low-latency locks.
  • Testing: Easy to disable via .env or config for CI/CD.

Tradeoffs:

  • Not real-time: Minimum delay = delay seconds (e.g., 5s).
  • Cache-dependent: Flushing cache wipes debounce state (design for this in your app).

Example use case:

// Before: Spammy notifications
Notification::send($users, new FileUploaded($file));

// After: Debounced (1 notification per hour per user)
Debounce::notification(
    notifiables: $users,
    notification: new FileUploaded($file),
    delay: 3600, // 1 hour
    uniqueKey: $file->user_id
);

Next steps:

  1. Pilot: Test with a high-volume notification (e.g., 'New comment') to measure queue savings.
  2. Integrate: Add to shared NotificationService or JobDispatcher classes.
  3. Monitor: Use Telescope to track debounce effectiveness."*

Call to Action: "Let’s start with [X high-impact feature] to validate the impact. I’ll prototype the integration in [Y days]."

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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata