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

Assign unknown client IPs a random geo ip in the contiguous US & cache the result #1608

Merged
merged 5 commits into from
Oct 3, 2024

Conversation

jhiemstrawisc
Copy link
Member

This PR aims to improve the Director's cache sorting algorithm, specifically in the case of clients whose GeoIP resolution can't be determined.

With these changes, client IPs that don't have an entry in MaxMind entry (or that can't be parsed as an IP in the first case) are assigned a random location in the contiguous United States. Doing this makes the Director behave as though it knows the client's true location by delivering caches sorted based on the new location. This differs from the previous algorithm, where those IP addresses resulted in completely random cache sorting.

When a client IP is assigned a random location, that location is cached for 20 minutes, unless refreshed by further client interactions. This is done so that repetitive client requests get a consistent cache ordering (barring any other load information or the sort algorithm's stochastic jiggle), which should further improve cache hits.

Closes #1587

This assigns a random lat/long bounded within the contiguous US whenever the Director
is unable to determine where the client is coming from. We're moving to this because
the next step is to cache the assignment so that clients who fall into this trap can
improve follow-up reads through Pelican caches, and because most of our client base
falls within that box (and don't want to be redirected to caches in the UK, Russia, or
Singapore).
This caches the randomly-assigned lat/long for a given unresolvable client IP,
ensuring that repeated requests from the same client are delivered a mostly-consistent
ordering of caches.
@jhiemstrawisc jhiemstrawisc requested a review from turetske October 1, 2024 03:05
Copy link
Collaborator

@turetske turetske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor change to a test requested.

director/sort_test.go Outdated Show resolved Hide resolved
@jhiemstrawisc jhiemstrawisc requested a review from turetske October 2, 2024 15:19
Copy link
Collaborator

@turetske turetske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@turetske turetske merged commit 69b640f into PelicanPlatform:main Oct 3, 2024
20 checks passed
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.

Generate & cache geolocation for uknown client IPs
2 participants