-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hi, first of all, congrats for your amazing project!
I noticed that every connection on the hub register a callback:
public function subscribe(callable $callback): void
{
$this->init();
$this->subscriber->on('message', function (string $channel, string $payload) use ($callback) {
$callback($this->serializer->deserialize($payload));
});
}
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels