Modern Laravel applications rely heavily on queues. We queue emails, payments, webhooks, report generation, AI processing, notifications — everything.
Queues make our apps fast.
But when a third-party API goes down?
Queues can become your biggest bottleneck.
This is where Laravel Fuse comes in — a clean, elegant circuit breaker implementation built specifically for Laravel queue jobs.
Let’s break down why this matters — and how to protect your app before the next outage hits.
The Hidden Danger of Queue Jobs
Imagine this scenario.
You have a ProcessPayment job that talks to Stripe. Everything works perfectly — until Stripe has an outage.
Your queue worker:
- Picks up the job
- Calls Stripe
- Waits 30 seconds for timeout
- Fails
- Retries
- Waits again
Now multiply that by:
- 5,000 queued jobs
- Multiple workers
- Automatic retries
Your queue becomes clogged with slow failures.
Meanwhile:
- Emails aren’t sent
- Notifications are delayed
- Other jobs are blocked
Your app isn’t just slow — it’s burning.
The Circuit Breaker Pattern (Simple Explanation)
Before we talk about the package, let’s understand the pattern.
A circuit breaker works just like an electrical fuse in your house.
It has three states:
1️⃣ Closed (Normal)
Requests flow normally.
Failures are tracked.
2️⃣ Open (Protection Mode)
Too many failures?
The breaker “opens.”
Requests fail instantly — no waiting, no timeouts.
3️⃣ Half-Open (Testing Recovery)
After some time, a small test request is allowed through.
If it succeeds → close the circuit.
If it fails → open it again.
This prevents cascading failures.
What Is Laravel Fuse?
Laravel Fuse is a lightweight package that applies the circuit breaker pattern directly to Laravel queue jobs.
It was introduced to the community through a detailed article on Freek.dev and is maintained as an open-source project on GitHub.
Instead of allowing jobs to endlessly retry and timeout during API outages, Laravel Fuse:
- Monitors failure rates
- Opens the circuit when thresholds are exceeded
- Fails jobs instantly while the API is unhealthy
- Automatically tests for recovery
- Resumes normal flow when the service stabilizes
It’s smart, minimal, and Laravel-native.
Why This Matters More Than You Think
Many developers underestimate how dangerous slow failures are.
A single failing API can:
- Exhaust worker threads
- Increase memory usage
- Delay unrelated jobs
- Create massive retry storms
- Overwhelm logging systems
Queues don’t fail loudly.
They fail gradually — and painfully.
Laravel Fuse prevents that silent meltdown.
Installation
Getting started is simple:
composer require harris21/laravel-fuse
Publish the configuration:
php artisan vendor:publish --tag=fuse-config
You’ll get a config file where you can define:
- Failure thresholds
- Time windows
- Minimum attempts
- Cooldown periods
Protecting a Job with Fuse
Here’s how you wrap a job:
use Harris21\Fuse\Middleware\CircuitBreakerMiddleware;
class ChargeCustomer implements ShouldQueue
{
public $tries = 0;
public function middleware(): array
{
return [
new CircuitBreakerMiddleware('stripe')
];
}
public function handle()
{
// Call external API
}
}
That’s it.
Now your job is protected.
If Stripe starts failing repeatedly, the circuit opens — and your queue remains healthy.
How Failure Detection Works
Laravel Fuse doesn’t open the circuit on one failure.
It uses configurable rules like:
- Failure percentage threshold (e.g., 50%)
- Minimum request count
- Time window (e.g., last 60 seconds)
Only when the threshold is crossed does it open.
This prevents false positives.
Smart Failure Classification
Not all failures mean “the API is down.”
Laravel Fuse can ignore certain types of exceptions like:
- Validation errors
- Authentication errors
- Rate limits (429)
- Business logic exceptions
This ensures the breaker only reacts to real outages.
The Status Page
Laravel Fuse includes a built-in status page.
Enable it in .env:
FUSE_STATUS_PAGE_ENABLED=true
Then visit:
/fuse
You’ll see:
- Circuit name
- Current state (Open / Closed / Half-open)
- Failure counts
- Recovery timers
This gives you visibility — which is critical in production systems.
Real-World Example
Let’s say you run:
- Payment processing (Stripe)
- Email delivery (Mailgun)
- SMS notifications (Twilio)
- AI API calls (OpenAI)
Each one can have its own circuit:
new CircuitBreakerMiddleware('stripe');
new CircuitBreakerMiddleware('mailgun');
new CircuitBreakerMiddleware('twilio');
new CircuitBreakerMiddleware('openai');
If OpenAI goes down?
Only OpenAI jobs fail fast.
Payments continue.
Emails continue.
SMS continues.
Isolation is power.
What Happens Without a Circuit Breaker?
Without Laravel Fuse:
- Workers hang
- Retry storms occur
- Queues back up
- CPU spikes
- Logs explode
- Users complain
With Laravel Fuse:
- Fail fast
- Recover automatically
- Protect system health
- Maintain performance
- Preserve worker resources
Best Practices
Here are some practical tips:
✅ Set realistic thresholds
High traffic apps need tighter windows.
✅ Separate circuits per service
Never combine multiple APIs under one breaker.
✅ Combine with fallbacks
Return cached responses when possible.
✅ Monitor actively
Use logs + Fuse status page.
When Should You Use Laravel Fuse?
If your app:
- Uses external APIs inside queue jobs
- Handles payments
- Sends transactional emails
- Calls AI services
- Processes webhooks
- Depends on SaaS platforms
Then yes — you should use it.
If your jobs are 100% internal database work?
You likely don’t need it.
Final Thoughts
Modern applications are built on third-party services.
That’s normal.
But resilience is not optional.
Queues are infrastructure.
And infrastructure must be protected.
Laravel Fuse gives you a simple, elegant, Laravel-native way to prevent cascading failures when APIs go down.
Don’t wait for your first outage to learn this lesson the hard way.
Fuse your queues before they burn. 🔥⚡








