PHPackages                             mehr-it/lara-worker-heartbeat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. mehr-it/lara-worker-heartbeat

ActiveLibrary[Queues &amp; Workers](/categories/queues)

mehr-it/lara-worker-heartbeat
=============================

Adds a heartbeat and observer for laravel workers allowing detection of hanging or stuck worker processes

2.0.2(5y ago)0354[3 PRs](https://github.com/mehr-it/lara-worker-heartbeat/pulls)MITPHPPHP &gt;=7.1.0

Since Oct 8Pushed 3y agoCompare

[ Source](https://github.com/mehr-it/lara-worker-heartbeat)[ Packagist](https://packagist.org/packages/mehr-it/lara-worker-heartbeat)[ RSS](/packages/mehr-it-lara-worker-heartbeat/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (12)Used By (0)

Queue worker heartbeat for Laravel
==================================

[](#queue-worker-heartbeat-for-laravel)

This package implements a queue worker heartbeat which is observed by another process to detect stuck or hanging queue worker processes.

Why is a heartbeat necessary?
-----------------------------

[](#why-is-a-heartbeat-necessary)

Laravel has a built in timeout handling for worker processes which uses SIGALRM to let worker processes terminate themselves when they reach a given timeout. However this cannot handle edge cases when the whole process is stuck in a way that signals are not processed anymore or the worker gets stuck before the signal handler was registered.

Even supervisord is of no help in such cases because the worker process might still be running, but not doing anything anymore.

How does it work?
-----------------

[](#how-does-it-work)

This package extends the `queue:work` command by the ability to fork an observer process which monitors an implemented worker heartbeat. Laravel's queue worker is extended to send regular heartbeat signals and status information to the observer process. When the observer process does not receive a heartbeat signal within the expected period, it will kill the worker process.

Installation
------------

[](#installation)

```
composer require mehr-it/lara-worker-heartbeat

```

This package uses Laravel's package auto-discovery, so the service provider will be loaded automatically.

Make sure the PHP extensions `posix` and `pcntl` are loaded. Otherwise queue workers cannot fork the required observer process and will throw an error.

Usage
-----

[](#usage)

You don't have to make any changes to your application code to use this package. You only have to pass the `--heartbeat-timeout` option to the queue work command:

```
artisan queue:work default --heartbeat-timeout=5

```

This will start an observer thread expecting a heartbeat signal within every 5 seconds. Of course no heartbeat is expected while the worker process is sleeping or handling a job taking longer than 5s.

Choose the heartbeat timeout depending on the expected worker cycle duration (without any sleep time). Usually this is a little more than the time it takes to query the queue for new jobs. So most of the time 5s is a safe value. But in cases when the pop operation takes longer (eg. when using AWS SQS with long polling) you have to increase the timeout.

Implementation details
----------------------

[](#implementation-details)

Heartbeat signals are sent on each iteration of the worker loop, which is looking for new jobs in the queue.

When the worker is going to sleep or starts processing a job, it does not send any heartbeat signals for some time. The worker will notify the observer about the period it will not be able to send any heartbeat and the observer will respect that.

If neither a timeout is set for the worker process nor for the currently processed job, the observer process does expect any heartbeat until the job is finished. In this situation the observer cannot detect hung or stuck processes, because it does not know when to expect the next heartbeat signal.

The observer process automatically stops when the observed worker process is not running anymore.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~70 days

Recently: every ~122 days

Total

8

Last Release

1919d ago

Major Versions

1.3.0 → 2.0.02020-12-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44973729?v=4)[mehr.IT GmbH](/maintainers/mehr-it)[@mehr-it](https://github.com/mehr-it)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mehr-it-lara-worker-heartbeat/health.svg)

```
[![Health](https://phpackages.com/badges/mehr-it-lara-worker-heartbeat/health.svg)](https://phpackages.com/packages/mehr-it-lara-worker-heartbeat)
```

###  Alternatives

[mpbarlow/laravel-queue-debouncer

A wrapper job for debouncing other queue jobs.

63714.4k1](/packages/mpbarlow-laravel-queue-debouncer)[eyewitness/eye

Eyewitness.io client for Laravel 5 applications

116151.8k](/packages/eyewitness-eye)[therezor/laravel-transactional-jobs

Submit laravel jobs inside transaction. Cancel job after rollback. Proceed after successful commit.

44449.4k](/packages/therezor-laravel-transactional-jobs)[convenia/pigeon

3233.0k](/packages/convenia-pigeon)[baklysystems/laravel-chat-messenger

Laravel chat package

121.8k](/packages/baklysystems-laravel-chat-messenger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
