Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by PlutonianPathfinder037

Why Are Laravel Horizon Silenced Jobs Persisting in Redis for 7 Days?

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I've noticed that a batch of silenced jobs (~7k per hour) that complete successfully are not being cleared as expected. Regular completed jobs are trimmed after 1 hour, but these silenced jobs remain in Redis for 7 days, consuming a lot of space. I suspect they might be treated as monitored jobs in Horizon, which default to a 7-day trim time.

Below is my Horizon configuration for job trimming:

PHP
/* |---------------------------------------------------------------------------------------------------| | Job Trimming Times | |---------------------------------------------------------------------------------------------------| | | | Here you can configure for how long (in minutes) you desire Horizon to | | persist the recent and failed jobs. Typically, recent jobs are kept | | for one hour while all failed jobs are stored for an entire week. | | | */ 'trim' => [ 'recent' => 60, 'pending' => 60, 'completed' => 60, 'recent_failed' => 10080, 'failed' => 10080, 'monitored' => 10080, ],

Here is the job implementation:

PHP
class ClearCategorySkusJob implements ShouldBeUnique, ShouldQueue, Silenced { use Dispatchable, Queueable; public int $tries = 3; public function __construct( private readonly string $category, private readonly string $domain, ) { $this->onQueue('cache'); } public function handle(): void {} public function uniqueId(): string {} public function tags(): array {} }

Environment details:

  • PHP version: 8.2.26
  • Redis version: 6.2.13
  • Laravel version: 10.48.24
  • Horizon version: 5.24.3

I would like to have these silenced (monitored) jobs trimmed sooner (matching the 60-minute setting for completed jobs). How can I adjust their trim time or change their default behavior?

0

Comments 0

Answers 3

Views 35

3 Answers

Answer by StackOverflowTychoAI Agent 1 month ago

0

Silenced jobs don’t follow the same trimming time as regular completed jobs. While your regular jobs are trimmed after 60 minutes, silenced jobs are stored as part of the monitored jobs list, which by default is set to 10,080 minutes (i.e. 7 days). This is why the silenced jobs are lingering in Redis much longer.

If you’d like to have these trimmed sooner, you can adjust the trim times in your Horizon configuration. For example, to have your monitored (i.e., silenced) jobs cleared after an hour, you can update the trim setting for monitored jobs:

PHP
'trim' => [ 'recent' => 60, 'pending' => 60, 'completed' => 60, 'recent_failed' => 10080, 'failed' => 10080, 'monitored' => 60, // change from 10080 to 60 minutes ],

After updating this setting, Horizon will trim monitored jobs (which includes your silenced jobs) after 60 minutes, helping to free up space in Redis.

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Answer by SolarScout207 1 month ago

0

Horizon might treat silenced jobs differently, possibly falling under the monitored category, which is set to 7 days (10080 minutes) in your config.

Can you try reducing the monitored trim time in the config to a lower value (e.g 60 minutes) and observe if that clears out the silenced jobs sooner?

No comments yet.

Answer by StellarScientist244 1 month ago

0

Our silenced jobs where monitored by a tag, and because the time for a monitored job to clear was 7 days, the silenced jobs where saved for 7 days. See the provided config, where monitored is set to 10080.

Normally a silenced job will be taken care of the same as a normal job, so normally it will be deleted in 1 day.

We deleted the monitor, so the silenced jobs went back to normal again.

No comments yet.

Discussion

No comments yet.