srwiez/queue-size-health-check
A Laravel health check that monitors queue sizes and warns when backlogs exceed configurable thresholds. It surfaces rising queue pressure early, helping you catch slow or stuck workers and keep background jobs moving.
Install the package alongside Spatie Health and confirm the check class/builder names in the package README before wiring it up:
composer require srwiez/queue-size-health-check
php artisan vendor:publish --tag=health-config # if you have not published Spatie Health config
Look first at:
vendor/srwiez/queue-size-health-check/README.md for the exact check class and fluent methods.config/health.php and your AppServiceProvider for where Spatie Health checks are registered.The registration shape is typically:
use Spatie\Health\Facades\Health;
use SRWieZ\QueueSizeHealthCheck\Checks\QueueSizeCheck;
Health::checks([
QueueSizeCheck::make()
->connection('redis')
->queue('default', 1000)
->queue('emails', 500),
]);
Treat the method names above as illustrative; use the package’s actual API. Then run:
php artisan health:check
First useful case: put a threshold on your busiest queue, schedule health:check every five or ten minutes, and route failures through your existing Spatie Health notification channel. Do not start by putting queue backlog on a load-balancer /health endpoint; use it for alerts and dashboards.
default queue at 1,000 may be normal while emails at 200 is already a problem.->queue('default', env('QUEUE_SIZE_DEFAULT_MAX', 1000))
->queue('emails', env('QUEUE_SIZE_EMAILS_MAX', 500))
default queue and a database default queue are different failure domains. Separate checks produce clearer notifications and let you tune thresholds independently.php artisan queue:monitor redis:default,redis:emails --max=1000 against realistic traffic to see whether your proposed limits are sane.Queue::fake(). A faked queue may not produce real queue-size data. Use a real test connection (database queue is usually easiest), push jobs, run php artisan health:check, and assert the failure notification/result.created_at/available_at for the oldest pending job.Queue::size() does not mean the same thing on Redis, database, SQS, and other drivers, especially for delayed, reserved, and in-flight jobs. Confirm what your production driver counts before trusting a threshold.sync and some local setups always look healthy. The sync queue has no real backlog, so the check can be green while production would fail. Keep local thresholds low or skip the check outside production-like environments.failed_jobs table. Add a separate failed-job check if failed jobs matter to your team.queue.default. After changing QUEUE_CONNECTION, run php artisan config:clear or rebuild config:cache, then re-run the check.Queue::size() may run a COUNT query. Avoid running the check every minute on very large queue tables without confirming indexes and query cost.default queue, register separate checks or explicitly scope each check to its connection.php artisan tinker, compare Queue::connection('redis')->size('default') with the health check result. If they disagree, inspect the package’s connection/queue resolution.v1.4.1 is a maintenance release with no functional changes from v1.4.0; ^1.4 is a reasonable constraint. Check the README when upgrading across minor versions in case builder methods or config keys changed.How can I help you explore Laravel packages today?