reverb icon indicating copy to clipboard operation
reverb copied to clipboard

Memory leaks and high CPU usage

Open Doclassif opened this issue 8 months ago • 5 comments

Reverb Version

1.5

Laravel Version

12.6

PHP Version

8.3.2

Description

The memory leak is real

Image

Same problem with the CPU

Image

It just keeps accumulating, it hits some limits and restarts

And the CPU and RAM load does not drop even if you disconnect from the channel or stop broadcasting events

Gave more load lately and the graphs went to the ceiling faster

Steps To Reproduce

Reverb is launched as a separate service

Just connect to it and start broadcasting different events to different channels every 5 sec

REVERB_SCALING_ENABLED: true (2 pods in k8s)

Doclassif avatar Apr 04 '25 05:04 Doclassif

Hey @Doclassif - how many connections are you handling and how many messages are you sending? Do you also see the same issue if you are not using Reverb with scaling enabled?

joedixon avatar Apr 11 '25 10:04 joedixon

We are seeing the same behavior with 3 nodes and scaling enabled.

We restart reverb every time it reaches 50% of the global cpu usage of the instance, hence about every 3 days. Each red bar on the chart below is a restart.

Image

We also graph connections. Active connections peak at ~1k.

Image

We have not tested reverb without scaling. However, on a different project we are using scaling and noticed that the cpu usage never goes higher than 5% even after months without restart.

PHP 8.2.28 Debian 11.11 Libuv 1.40 Reverb 1.5.0 Laravel 12.8.1

Systemd unit:

systemctl cat reverb.service
# /etc/systemd/system/reverb.service
#
# Ansible managed
#

[Unit]
Description=Laravel Reverb

[Service]
ExecStart=/usr/bin/php /srv/project/current/artisan reverb:start
Restart=always
User=envoyer
Group=www-data
LimitNOFILE=65536
TimeoutStopSec=10

[Install]
WantedBy=multi-user.target

boutetnico avatar Apr 19 '25 06:04 boutetnico

Hey @Doclassif - how many connections are you handling and how many messages are you sending? Do you also see the same issue if you are not using Reverb with scaling enable

It is enough to have 5-10 connections and send messages to channels every 5 seconds. Locally without scaling everything seems to be ok

Doclassif avatar Apr 21 '25 05:04 Doclassif

i used but is dosent have any problem about cpu or memory maybe it back too your server softwere

Aryantallaj1382 avatar Jun 08 '25 14:06 Aryantallaj1382

We are also affected by the memory-leak behaviour.

Environment

  • Laravel 11.x
  • Reverb 1.5.x (latest as of Aug 2025)
  • PHP 8.3
  • Azure App Service Linux
    4 Reverb instances behind Redis pub/sub (REVERB_SCALING_ENABLED=true)
    → Each instance: 4 vCPU / 16 GB RAM
  • Process launched via Supervisor:
    php -dmemory_limit=5G artisan reverb:start
  • No Octane, no Telescope.

Load pattern

  • ≈ 22 000 concurrent WebSocket connections total (~5 500 per instance).
  • Each client sends a heartbeat every 10 minutes, plus additional bi-directional traffic on demand.

Observed problem

  1. RSS starts well below 1 GB but climbs steadily.
  2. After ≈ 40–48 h the process hits the 5 GB limit and crashes with
    Allowed memory size of 5368709120 bytes exhausted ….

memory graph

Pulse instrumentation

  • Pulse enabled
    • sent_messages sampling: 0.001
    • connections sampling: 1

Runtime metrics

app(\Illuminate\Broadcasting\BroadcastManager::class)
    ->getPusher()
    ->get('/connections');           // → 22 812 active connections

$response = app(\Illuminate\Broadcasting\BroadcastManager::class)
    ->getPusher()
    ->get('/channels', ['info' => 'subscription_count']);

$count = is_object($response) && isset($response->channels)
    ? count((array) $response->channels)
    : 0;

$count;                              // → 17 576 channels

fdiroll-elbtide avatar Aug 04 '25 06:08 fdiroll-elbtide