Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

brjohnson4's avatar

Reverb Restart Every 5 Seconds in the Cache

I have a site that uses Forge and Envoyer, and I have Reverb active and working really well. Yet, when I look at my insights via Pulse, my Cache table is all screwed up: at the very bottom, I'm getting a 0% hit rate for "laravel:reverb:restart" that seems to be firing once every 5 seconds. I'm not sure where this could be, and I don't know why this would be in my Cache or even what this means. The only other bit of info is that when I disable Reverb, the "laravel:reverb:restart" doesn't fire. But when I enable it again, this shows up again in my cache.

Thanks!

0 likes
5 replies
LaryAI's avatar
Level 58

It sounds like the issue you're experiencing is related to the Reverb package and how it interacts with your Laravel application's cache. The laravel:reverb:restart key in your cache indicates that Reverb is likely using the cache to manage some internal state or to signal restarts.

Here are a few steps you can take to diagnose and potentially resolve this issue:

  1. Check Reverb Configuration: Ensure that your Reverb configuration is set up correctly. Look for any settings that might control how often Reverb restarts or interacts with the cache.

  2. Review Reverb Documentation: Go through the Reverb documentation to understand how it uses the cache. There might be specific settings or recommendations for optimizing its performance.

  3. Cache Configuration: Verify your cache configuration in config/cache.php. Ensure that the cache store you are using is appropriate for your application's needs. For example, using a memory-based cache like Redis might be more efficient than a file-based cache.

  4. Debugging: Add some logging to see when and why the laravel:reverb:restart key is being set. You can do this by adding a listener for cache events in your AppServiceProvider:

    use Illuminate\Support\Facades\Cache;
    use Illuminate\Support\Facades\Log;
    
    public function boot()
    {
        Cache::extend('logging', function ($app) {
            return Cache::repository(new LoggingStore($app['cache']->driver('file')->getStore()));
        });
    }
    
    class LoggingStore implements \Illuminate\Contracts\Cache\Store
    {
        protected $store;
    
        public function __construct($store)
        {
            $this->store = $store;
        }
    
        public function get($key)
        {
            Log::info("Cache get: {$key}");
            return $this->store->get($key);
        }
    
        public function put($key, $value, $minutes)
        {
            Log::info("Cache put: {$key}");
            return $this->store->put($key, $value, $minutes);
        }
    
        public function increment($key, $value = 1)
        {
            Log::info("Cache increment: {$key}");
            return $this->store->increment($key, $value);
        }
    
        public function decrement($key, $value = 1)
        {
            Log::info("Cache decrement: {$key}");
            return $this->store->decrement($key, $value);
        }
    
        public function forever($key, $value)
        {
            Log::info("Cache forever: {$key}");
            return $this->store->forever($key, $value);
        }
    
        public function forget($key)
        {
            Log::info("Cache forget: {$key}");
            return $this->store->forget($key);
        }
    
        public function flush()
        {
            Log::info("Cache flush");
            return $this->store->flush();
        }
    
        public function getPrefix()
        {
            return $this->store->getPrefix();
        }
    }
    

    This will log all cache operations, helping you identify when and why the laravel:reverb:restart key is being set.

  5. Contact Reverb Support: If the issue persists, consider reaching out to Reverb's support or community forums. They might have more specific insights or solutions for this problem.

By following these steps, you should be able to better understand and potentially resolve the issue with the laravel:reverb:restart key in your cache.

brjohnson4's avatar
brjohnson4
OP
Best Answer
Level 5

Follow up: I added to the pulse config file "/^laravel:reverb:/" in the Ignore section of CacheInteractions.

        Recorders\CacheInteractions::class => [
            "enabled" => env("PULSE_CACHE_INTERACTIONS_ENABLED", true),
            "sample_rate" => env("PULSE_CACHE_INTERACTIONS_SAMPLE_RATE", 1),
            "ignore" => [
                "/^laravel:pulse:/", // Internal Pulse keys...
                "/^illuminate:/", // Internal Laravel keys...
                "/^telescope:/", // Internal Telescope keys...
                "/^nova/", // Internal Nova keys...
                '/^.+@.+\|(?:(?:\d+\.\d+\.\d+\.\d+)|[0-9a-fA-F:]+)(?::timer)?$/', // Breeze / Jetstream authentication rate limiting...
                '/^[a-zA-Z0-9]{40}$/', // Session IDs...
                "/^laravel:reverb:/", // Ignore all reverb keys...
            ],
            "groups" => [
                "/^job-exceptions:.*/" => "job-exceptions:*",
                // '/:\d+/' => ':*',
            ],
        ],

Then after clearing config and the cache, and restarting the server, the misses on "laravel:reverb:restart" are going down significantly.

ticketmaster7's avatar

i am suffering with the same issue. I tried the solution of adding "/^laravel:reverb:/" in CacheInteractions recorder, but i still get the cache missed, what might be the reason here. i am using Ploi for server deployment and have pawned a Reverb server from their default option.

mafavreau's avatar

@ticketmaster7 Just wanted to chime in because I was looking into this too and now I think that this is normal behavior. There's a loop that runs every 5 seconds to check if you sent the reverb:restart artisan command. That's how the server get's restarted. If you launch the command php artisan reverb:restart, you'll notice that laravel:reverb:restart get's added to your cache with a timestamp. You'll also notice that the action is now hit in Telescope. I don't think you can change this behavior.

I suggest you simply hide it from Telescope and Pulse.

You can take a look on the Reverb Repo - StartServer.php and you'll find the ensureRestartCommandIsRespected function that runs this loop.

...
protected function ensureRestartCommandIsRespected(Server $server, LoopInterface $loop, string $host, string $port): void
    {
        $lastRestart = Cache::get('laravel:reverb:restart');

        $loop->addPeriodicTimer(5, function () use ($server, $host, $port, $lastRestart) {
            if ($lastRestart === Cache::get('laravel:reverb:restart')) {
                return;
            }

            $this->gracefullyDisconnect();

            $server->stop();

            $this->components->info("Stopping server on {$host}:{$port}");
        });
    }
...
1 like

Please or to participate in this conversation.