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

Memory leak with telescope #148

Closed
vatsake opened this issue Apr 12, 2024 · 4 comments · Fixed by #151
Closed

Memory leak with telescope #148

vatsake opened this issue Apr 12, 2024 · 4 comments · Fixed by #151
Labels

Comments

@vatsake
Copy link

vatsake commented Apr 12, 2024

Reverb Version

v1.0.0-beta6

Laravel Version

11.3.1

PHP Version

8.3

Description

I hope I did it right this time...
REPO link https://github.com/vatsake/laravel-bug-report

Turns out the culprit(s) still was Telescope (and Reverb).

For the memory 'leak' to occur, a client has to listen for events.


#145
#146

Steps To Reproduce

Run both the webserver and websocket server.
You'll need a database for Telescope.

composer install
php artisan migrate
php artisan serve
php artisan reverb:start

Now connect to the websocket server with the url and subscribe to a channel (I kept .env in repo). I recommend Postman.
ws://localhost:8080/app/8vqpxbu8cayuc1uas54f?protocol=7&client=js&version=8.4.0-rc2&flash=false
Subscribe with message:
{"event":"pusher:subscribe","data":{"auth":"","channel":"test"}}

Now open a memory monitoring tool, I used htop.

When making a request to the root page, 1000 events will be fired.
Make a curl request or open in browser:
http://localhost:8000/

@joedixon
Copy link
Collaborator

Thanks for the reproduction @vatsake

Although I wouldn't necessarily recommend using Telescope with Reverb in production due to the blocking nature of storing entries, I think I have addresssed the issue with #151

Would you be able to test and let me know whether this prevents the increase in memory usage on your server.

@driesvints driesvints added the bug label Apr 15, 2024
@driesvints
Copy link
Member

Thanks @vatsake. I still had difficulty to recreate this, steps weren't entirely clear to me. But seems @joedixon managed to and sent in a fix.

@vatsake
Copy link
Author

vatsake commented Apr 15, 2024

Thanks for the reproduction @vatsake

Although I wouldn't necessarily recommend using Telescope with Reverb in production due to the blocking nature of storing entries, I think I have addresssed the issue with #151

Would you be able to test and let me know whether this prevents the increase in memory usage on your server.

@joedixon @driesvints
Was able to test and I can confirm that with this PR the "memory leak" will not occur.

@joedixon What package would you recommend for monitoring?
Currently in prod I'm using octane, which makes my app blazing fast, so a 1-2ms blocking ain't really an issue.

@joedixon
Copy link
Collaborator

You can use Telescope, but when Reverb collects the events (by default every 15 seconds), that process will prevet other requests from being processed. The more traffic your server is handling, the more entries need to be processed by Telescope, the longer the delay.

You may also like to look at Pulse for Reverb monitoring.

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

Successfully merging a pull request may close this issue.

3 participants