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

Performance: Improve speed of automatic instance redirection #4193

Merged
merged 4 commits into from
Oct 8, 2024

Conversation

syeopite
Copy link
Member

@syeopite syeopite commented Oct 21, 2023

The automatic instance redirection implemented in #1940 fetches a new list of instances each time someone queries the /redirect endpoint. This is extremely inefficient...

This PR optimizes all that into a background job that only fetches a single list every 30 minutes. This should performance quite a bit.

@syeopite syeopite requested a review from a team as a code owner October 21, 2023 22:58
@syeopite syeopite requested review from unixfox and removed request for a team October 21, 2023 22:58
@@ -40,7 +40,16 @@ module Invidious::Routes::Misc

def self.cross_instance_redirect(env)
referer = get_referer(env)
instance_url = fetch_random_instance

instance_list = Invidious::Jobs::InstanceListRefreshJob::INSTANCES["INSTANCES"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this should be used to add some sites for reddit comments eventually as well

# TODO: Use something like #479 for a static list of instances to use here
query = URI::Params.encode({q: "(url:3D#{id} OR url:#{id}) AND (site:invidio.us OR site:youtube.com OR site:youtu.be)"})

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good to me, this can be used for the eventual Lemmy source as well.

Though does Reddit's search functionality even support filtering for that many sites at once?

This comment has been minimized.

@github-actions github-actions bot added the stale label Mar 15, 2024
@syeopite syeopite removed the stale label Mar 15, 2024
The HTTP::Client created via `make_client` is affected by the
force_resolve configuration option. However, api.invidious.io
does not support ipv6 and as such any request with ipv6 to
api.invidious.io will instead raise.

Directly calling the HTTP::Client will ignore the force_resolve option
allowing requests to go through ipv4 when needed.
@syeopite syeopite force-pushed the refactor-instance-redirect branch from a84100f to 9980c0e Compare May 22, 2024 20:31
Copy link

This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.

@github-actions github-actions bot added the stale label Aug 21, 2024
@SamantazFox SamantazFox removed the stale label Aug 23, 2024
@SamantazFox SamantazFox added the in-testing This feature has been deployed and is being tested label Oct 7, 2024
@SamantazFox SamantazFox added ready and removed in-testing This feature has been deployed and is being tested labels Oct 7, 2024
@SamantazFox SamantazFox merged commit 7c79ee7 into iv-org:master Oct 8, 2024
7 checks passed
@SamantazFox
Copy link
Member

Thanks for your contribution :)

@syeopite syeopite deleted the refactor-instance-redirect branch November 8, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants