Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When activated for more than a day, it connects very slowly #201

Closed
rawezhcode opened this issue May 18, 2024 · 12 comments
Closed

When activated for more than a day, it connects very slowly #201

rawezhcode opened this issue May 18, 2024 · 12 comments
Assignees

Comments

@rawezhcode
Copy link

Reverb Version

1.0.0-beta10

Laravel Version

11

PHP Version

8.3

Description

When activated for more than a day, it connects very slowly as shown in the video,
And be connected Redis server(https://www.digitalocean.com)

Steps To Reproduce

2024-05-18.21-41-35.mp4

But when I restart it, the problem disappears

@joedixon
Copy link
Collaborator

@rawezhcode how much memory and CPU is in use when you notice the connections start to slow?

@joedixon joedixon self-assigned this May 20, 2024
@rawezhcode
Copy link
Author

SCR-20240520-muvz

CPU is less than 5% used,
The slowdown only occurs when I enable REVERB_SCALING_ENABLED and connect it to Redis server(https://www.digitalocean.com)

@joedixon
Copy link
Collaborator

What is happening in your network tab when you reload the page?

@rawezhcode
Copy link
Author

image

Just showing connections in the page.

and join the presence channel.

@rawezhcode
Copy link
Author

`
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=reverb
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis

CACHE_STORE=redis
CACHE_PREFIX=

`

`

'servers' => [

    'reverb' => [
        'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
        'port' => env('REVERB_SERVER_PORT', 8080),
        'hostname' => env('REVERB_HOST'),
        'options' => [
            'tls' => [],
        ],
        'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
        'scaling' => [
            'enabled' => env('REVERB_SCALING_ENABLED', false),
            'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
            'server' => [
                'url' => env('REDIS_URL'),
                'host' => env('REDIS_HOST', '127.0.0.1'),
                'port' => env('REDIS_PORT', '6379'),
                'username' => env('REDIS_USERNAME'),
                'password' => env('REDIS_PASSWORD'),
                'database' => env('REDIS_DB', '0'),
            ],
        ],
        'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
        'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
    ],

],

/*
|--------------------------------------------------------------------------
| Reverb Applications
|--------------------------------------------------------------------------
|
| Here you may define how Reverb applications are managed. If you choose
| to use the "config" provider, you may define an array of apps which
| your server will support, including their connection credentials.
|
*/

'apps' => [

    'provider' => 'config',

    'apps' => [
        [
            'key' => env('REVERB_APP_KEY'),
            'secret' => env('REVERB_APP_SECRET'),
            'app_id' => env('REVERB_APP_ID'),
            'options' => [
                'host' => env('REVERB_HOST'),
                'port' => env('REVERB_PORT', 443),
                'scheme' => env('REVERB_SCHEME', 'https'),
                'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
            ],
            'allowed_origins' => ['*'],
            'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
            'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10_000),
        ],
    ],

],

`

@rawezhcode
Copy link
Author

image

@rawezhcode
Copy link
Author

rawezhcode commented May 20, 2024

my VPS
Ubuntu 22.04 LTS Server 64-Bit
CPU: 6 vCPU
RAM: 16 GB
Disk: 320 GB

And another thing I noticed when I use redis, it doesn't save any data and it's empty?
So I don't know if that caused the problem.

image

@joedixon
Copy link
Collaborator

Hey @rawezhcode I wanted to see what was happening in the network tab to determine if it's definitely the connection to the WebSocket server which is delayed. It's likely there will be some more latency as there is a connection to an additional resource to handle, but it shouldn't make such a difference.

Also, if you are on a single server setup, there really isn't a need to use Redis - it's only for scenarios where you wish to horizontally scale across servers.

Finally, it's expected there are no keys in Redis as Reverb users the pubsub functionality of Redis and not the key/value storage.

@rawezhcode
Copy link
Author

rawezhcode commented May 21, 2024

My.Video-1.mp4

First: I have 3 VPS servers
One for my database and app, one for Reverb, and one for Redis
VPS 1: database and app (in Atlantic) / CPU: 6 vCPU, RAM: 16 GB
VPS 2: Laravel Reverb (in Atlantic) / CPU: 6 vCPU, RAM: 16 GB
VPS 3: Redis Server ( in Digital ocean ) / CPU: 4 vCPU, RAM: 8 GB

Note :
And so I use Redis to avoid problems,
(Because I have an app that more than 800 to 1500 participants join at night, at a certain time, and do question and answer games together).
And last night, as a test I used Reverb that 701 participants joined And only 8% of the CPU is used without problems 😍🎉.

SCR-20240520-taun
SCR-20240521-mpkr

*But the only problem is that I mentioned above that it is sometimes very slow.

And after a lot of testing, this slowdown is when you want to get the total number of connections.
or send event (Broadcast) to participants.
Otherwise, the WebSocket connection is seamless.

@joedixon
Copy link
Collaborator

You still don't need to use Redis if Reverb is only running on a single server. It's only useful if scaling connections across multiple servers running Reverb.

@rawezhcode
Copy link
Author

I have no problem now, after I moved the redis server to another location as a test.
Although I don't need to use redis with the same server, I wanted to try it as an experiment.

But I had another problem, after I removed the redis server.
I wanted to increase the ( numprocs ) to 2 or more, but the problem occurred while I haven't had that problem with the socket.

[program:laravel-websocket]
process_name=%(program_name)s_%(process_num)02d
directory=/var/www/soketimanage_usr/data/www/soketimanager.soketimanager.xxxxx
command=php artisan reverb:start
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=soketimanage_usr
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/soketimanage_usr/data/www/soketimanager.xxxxx/soketi-supervisor.log
stopwaitsecs=60
stopsignal=sigint
minfds=10000

SCR-20240522-qprl

image

@joedixon
Copy link
Collaborator

It's not possible to run multipled processes on the same port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants