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

[6.x] Redis Broadcaster: Broadcast to multiple channels at once #31108

Merged
merged 4 commits into from Jan 14, 2020
Merged

[6.x] Redis Broadcaster: Broadcast to multiple channels at once #31108

merged 4 commits into from Jan 14, 2020

Conversation

josiasmontag
Copy link
Contributor

@josiasmontag josiasmontag commented Jan 12, 2020

This PR adds a Lua script to the RedisBroadcaster which allows to broadcast to multiple channels at once.

Why?
It is pretty common in Laravel to send events to multiple channels at once. Currently, this results in multiple publish commands, all sending the same payload to the Redis server. This causes unnecessary data transfer (costs), especially if the payload is rather big.

@taylorotwell
Copy link
Member

Can you share some performance comparisons?

@josiasmontag
Copy link
Contributor Author

I do not think it has any performance impact on the Laravel application itself. However, it reduces the data transfer to the Redis server and CPU usage on the Redis server.

The following screenshots are from my AWS Redis Cluster with this patch deployed on 11/01.

image
image

In my application each broadcast event is sent to 5 channels. So theoretically, this reduces the data transferred to 1/5.

@taylorotwell taylorotwell merged commit 0d63497 into laravel:6.x Jan 14, 2020
timoschwarzer added a commit to timoschwarzer/laravel-framework that referenced this pull request Jan 28, 2020
taylorotwell pushed a commit that referenced this pull request Jan 28, 2020
* Fix channel names when broadcasting via redis

This fixes a regression from #31108

* Style fixes

* Update Broadcaster.php

* Override formatChannels instead of changing its signature

Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants