-
Notifications
You must be signed in to change notification settings - Fork 14
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
Performance degradation over time #11
Comments
Hi @progmancod, Thank you for spotting this! It makes sense indeed. Problem is, Framework X doesn't seem to expose the |
Wait, after a coffee ☕ I think I found another way to address this, as the stream exposes a |
With 2 thousand users connected, after a few hours, freddie mercure continues to degrade performance. Maybe just hearing the "close" event of the "stream" is not enough in some scenarios. I'm concerned about the "error" and "end" scenarios.. Let's see the docs (https://github.com/reactphp/stream):
|
Oh, that's bad news 🙁 Unfortunately, I'm quite overwhelmed these days, and I don't even have the time to perform a stress test. |
No problem, I'm trying to resolve the issue. |
Hey @progmancod - it's been a while this issue has been opened, and I wanted to make sure everything's now fine. I'm running Freddie on an intensive IoT platform (using Redis) and it can run during months without blinking an eye. Do you mind if I close that issue? |
Unfortunately, the problem persists in our application. There are about 200 million posts per day, and within a few days, degradation occurs, forcing us to recycle the application. This change has helped a lot, tripling the time it takes for degradation to happen. But there's still some scenario I couldn't find: $stream->on('close', fn() => $this->hub->unsubscribe($subscriber, 'close')); |
Hey @progmancod and @bpolaszek, I'm one of the maintainer of ReactPHP and Framework X and we recently received a ticket in ReactPHP's HTTP component, which sounds a little bit similar to the problem described hear (not 100% sure if it's related though). The problem was that the connection close handler wasn't cleaned up properly for each request, resulting in some memory growth. This issue got fixed through reactphp/http#515 and was already released with reactphp/http |
Unfortunately, the problem persists, and we have given up on using the library in production after spending many hours investigating. Our application receives millions of hits per day, and performance degrades after a few hours. We have reverted to using the original library in Go. |
Hi @progmancod, no worries. |
The memory increases slightly over time, but the main symptom is an ever-increasing slowness, until it becomes impractical under high demand. |
@progmancod Hm, when these performance degradation occur, do you see any high CPU or RAM usage or anything similar? We're currently not aware of anything like this in ReactPHP or Framework X, but we need a way to reproduce this in order to find out which project is responsible for this behavior and what a fix could look like. FYI: Together with @clue, we have helped others with similar problems in the past. So if you're interested, you can drop us an email and we can set up a quick consulting call to take a look at this together. |
Hi, first of all, congrats for your amazing project!
I noticed that every connection on the hub register a callback:
After the client close the connection, the callback remains there.
So, after few hours and hundreds of thousands of subscribes, the performance gets terrible, since every publish has to call hundreds of thousands functions, mostly unecessary (subscriber has long gone).
The solution is to listen connection e close events, register an array of subscribers (address => $callback()), and then remove them on connection close.
That's how the original implementation works: https://github.com/dunglas/mercure/blob/main/subscribe.go
The text was updated successfully, but these errors were encountered: