Setting process priority for Laravel Horizon workers - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

Setting process priority for Laravel Horizon workers
====================================================

### [\#Laravel](https://rocketeersapp.com/knowledge/laravel)

Laravel Horizon lets you set the Linux nice value for worker processes, giving them more or less CPU scheduling priority.

 Published by [Manoj Hortulanus](https://rocketeersapp.com/author/manoj-hortulanus) on June 24, 2026 · 1 minute read

1. [Why you'd want this](#content-why-youd-want-this)
2. [How to configure it](#content-how-to-configure-it)
3. [Permissions](#content-permissions)
4. [Apply the changes](#content-apply-the-changes)
5. [Reverting](#content-reverting)

[\#](#content-why-youd-want-this "Permalink")Why you'd want this
----------------------------------------------------------------

Linux schedules CPU time using a **nice value** between `-20` (highest priority) and `19` (lowest). By default processes start at `0`.

If your server is dedicated to queue processing or you're handling time-sensitive, CPU-intensive jobs, lowering the nice value gives workers a bigger slice of CPU time. On a shared server running web traffic alongside workers, you'd leave it at `0` or increase it to avoid starving your web processes.

[\#](#content-how-to-configure-it "Permalink")How to configure it
-----------------------------------------------------------------

Add a `nice` key to the supervisor block in `config/horizon.php`:

 ```
'environments' => [
    'production' => [
        'supervisor-1' => [
            'connection' => 'redis',
            'queue'      => ['default'],
            'balance'    => 'auto',
            'processes'  => 20,
            'nice'       => -5,
        ],
    ],
],

```

Horizon calls PHP's `proc_nice()` when it starts each worker.

[\#](#content-permissions "Permalink")Permissions
-------------------------------------------------

Raising the nice value (e.g. `0 → 10`) works for any user. Lowering it (e.g. `0 → -5`) requires either root or the `CAP_SYS_NICE` capability. Without those privileges Horizon throws:

 ```
proc_nice(): Operation not permitted

```

To grant the capability to PHP without running as root:

 ```
sudo setcap cap_sys_nice=eip /usr/bin/php8.4

```

Verify it was applied:

 ```
getcap /usr/bin/php8.4
# /usr/bin/php8.4 cap_sys_nice=eip

```

Note: this grants the capability to the binary itself, so any PHP script running under that binary can adjust process priorities.

[\#](#content-apply-the-changes "Permalink")Apply the changes
-------------------------------------------------------------

 ```
php artisan config:clear
php artisan horizon:terminate

```

If Horizon is managed by Supervisor:

 ```
sudo supervisorctl restart horizon:*

```

[\#](#content-reverting "Permalink")Reverting
---------------------------------------------

Remove the capability from the PHP binary:

 ```
sudo setcap -r /usr/bin/php8.4

```

No output from `getcap` afterwards means no capabilities are set. Also set `'nice' => 0` in `config/horizon.php` (or remove the key entirely) and restart Horizon.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Laravel](https://rocketeersapp.com/knowledge/laravel)

- [How to use different PHP versions with Laravel Valet](https://rocketeersapp.com/knowledge/different-php-versions-laravel-valet)
- [Disable cookies in Laravel](https://rocketeersapp.com/knowledge/disable-cookies-in-laravel)
- [Logging in Laravel](https://rocketeersapp.com/knowledge/laravel-logging)
- [How to check which Laravel version of your app is using](https://rocketeersapp.com/knowledge/check-laravel-version)
- [Disable CSRF in Laravel](https://rocketeersapp.com/knowledge/disable-csrf-in-laravel)
- [Creating an encrypted cookie value in Laravel](https://rocketeersapp.com/knowledge/creating-an-encrypted-cookie-value-in-laravel)

 [View all 19 articles →](https://rocketeersapp.com/knowledge/laravel)
