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

feat: load balance test location in WPT (DELO-4766) #95

Merged

Conversation

lukaszczerpak-cloudinary
Copy link
Contributor

@lukaszczerpak-cloudinary lukaszczerpak-cloudinary commented Dec 9, 2024

This feature introduces load-balancing across multiple WPT locations. The goal is to always choose least loaded region.
Please note that US-based regions are taken into consideration only.

The following configuration options are introduced:

  • WTP_LS_CACHE_TTL (defaults: 10 sec) - how long to cache locations and selected location; 0 means we check best location on every test run
  • WTP_LS_DEFAULT_LOCATION (defaults: IAD_US_01 - which location to use in case there is a problem with API and there is nothing selected yet
  • WTP_LS_UPDATE_TIMEOUT - (defaults: 20 sec) timeout for updating locations

Also, for better insight there are two new endpoints (both responses served from local cache):

  • /locations - prints out all locations we consider along with their metrics
  • /locations/current - identifier of the location we currently use as the best one

@lukaszczerpak-cloudinary lukaszczerpak-cloudinary marked this pull request as draft December 9, 2024 09:33
@lukaszczerpak-cloudinary lukaszczerpak-cloudinary changed the title DELO-4766 load balance test location in wpt feat: load balance test location in WPT (DELO-4766) Dec 9, 2024
@lukaszczerpak-cloudinary lukaszczerpak-cloudinary marked this pull request as ready for review December 9, 2024 09:47
wtp/apiCaller.js Outdated
fvonly: 1, // first view only
timeline: 1 // workaround for WPT sometimes hanging on getComputedStyle()
},
headers: { 'User-Agent': 'WebSpeedTest', 'X-WPT-API-KEY': apiKey },
headers: { 'User-Agent': 'WebSpeedTest', 'X-WPT-API-KEY': apiKeys.get() },

Choose a reason for hiding this comment

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

Maybe to keep the semantics of key we could rename get to getRandom() or getKey() if random is just an implementation detail..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, corrected as per suggestion

@lukaszczerpak-cloudinary lukaszczerpak-cloudinary merged commit 1b5be14 into master Dec 9, 2024
6 checks passed
@lukaszczerpak-cloudinary lukaszczerpak-cloudinary deleted the DELO-4766-load-balance-test-location-in-wpt branch December 10, 2024 07:34
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.

2 participants