[Feature] User Location LB policy [WIP] #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
introduces a new load balancing policy called
GeoDataPolicy
to the codebase. This policy uses geographical data to determine the closest replica to a user based on their IP address.Key Changes
GeoDataPolicy Class:
A new class
GeoDataPolicy
is added, which extends theLoadBalancingPolicy
class. It uses an online GeoIP service to map user IP addresses to geographical locations and selects the nearest replica based on calculated distances.Distance Calculation:
The class includes a method to calculate the distance between two geographical points using the Haversine formula.
Integration with Load Balancer:
The
SkyServeLoadBalancer
class is updated to accept aload_balancing_policy
parameter, allowing it to use the newGeoDataPolicy
.Command-line Argument:
The script now accepts a
--load-balancing-policy
argument to choose between'round_robin'
and'geo_data'
policies.These changes lay the groundwork for geographically-aware load balancing, which can improve performance by directing user requests to the nearest available service replica.
Tests TBD
Tested (run the relevant ones):
bash format.sh
pytest tests/test_smoke.py
pytest tests/test_smoke.py::test_fill_in_the_name
conda deactivate; bash -i tests/backward_compatibility_tests.sh