Extending Horizon Job Retention for Enhanced Monitoring

Introduction

We've increased the retention period for jobs within Laravel Horizon, our Redis-powered queue monitoring dashboard. This enhancement provides a more comprehensive view of queue activity, aiding in debugging and performance analysis.

The Problem

Previously, Horizon was configured to trim recent, pending, and completed jobs after only 60 minutes. This short retention period resulted in the dashboard frequently appearing empty, even when jobs were actively being processed. Diagnosing intermittent issues and understanding long-term queue performance was difficult due to the limited historical data available.

The Solution

The retention period for recent, pending, and completed jobs has been increased from 1 hour to 24 hours (1440 minutes). This change ensures that a full day's worth of job data is readily available within the Horizon dashboard.

// config/horizon.php

'trim' => [
    'recent' => 1440,
    'pending' => 1440,
    'completed' => 1440,
    'recent_failed' => 10080,
    'failed' => 10080,
    'monitored' => 10080,
],

Benefits

  • Improved Debugging: Having a longer retention window allows for easier identification of job failures and performance bottlenecks, even if they occur sporadically.
  • Enhanced Performance Analysis: A complete 24-hour view of queue activity enables more accurate assessment of job processing times and queue load patterns.
  • Better Monitoring: The Horizon dashboard now provides a more consistent and informative overview of the application's queue system.
Gerardo Ruiz

Gerardo Ruiz

Author

Share: