-
-
Notifications
You must be signed in to change notification settings - Fork 398
feat: regional broadcasting #1580
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces regional broadcasting functionality to optimize node-to-node communication by leveraging regional proximity. When regional_broadcasting
is enabled, nodes communicate with other nodes in the same region directly, and use a single representative node to broadcast to other regions, reducing latency for intra-region communication.
Key changes:
- Added
regional_broadcasting
configuration option (disabled by default) - Implemented region-based node selection with
node_from_region/2
andregion_nodes/1
functions - Modified
GenRpcPubSub
to support two broadcast modes: direct (existing) and regional (new)
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
lib/realtime/gen_rpc/pub_sub.ex | Implements regional broadcasting logic with conditional routing based on configuration |
lib/realtime/nodes.ex | Adds region-based node selection functions and removes unused region mapping code |
config/runtime.exs | Adds regional_broadcasting configuration from environment variable |
config/test.exs | Enables regional broadcasting for test environment |
test/test_helper.exs | Sets up node naming and syn metadata for regional testing |
test/support/clustered.ex | Allows custom node names for testing regional clusters |
test/realtime/gen_rpc_pub_sub_test.exs | Adds comprehensive tests for regional broadcasting functionality |
test/realtime/gen_rpc_pub_sub/worker_test.exs | Tests worker-level message forwarding for regional broadcasting |
test/realtime/nodes_test.exs | Tests region node selection and retrieval functions |
test/realtime_web/channels/realtime_channel/message_dispatcher_test.exs | Refactors test setup to use supervised agent |
test/realtime/rate_counter/rate_counter_test.exs | Increases timeout for flaky test |
mix.exs | Updates version to 2.55.0 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
6ddc8a5
to
a70e0a1
Compare
🎉 This PR is included in version 2.56.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What kind of change does this PR introduce?
When
regional_broadcasting
istrue
GenRpcPubSub
uses a single node in each region to broadcast to the rest of the region. Nodes communicating inside the same region have a much lower latency :gotta_go_fast:.What is the current behavior?
A node broadcasting interacts with all the other nodes regardless of their region.
What is the new behavior?
When
regional_broadcasting
istrue
GenRpcPubSub
uses a single node in each region to broadcast to the rest of the region.Additional context
Add any other context or screenshots.