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

source-facebook-marketing: use existing session to fetch thumbnail urls #2543

Merged

Conversation

Alex-Bair
Copy link
Member

@Alex-Bair Alex-Bair commented Mar 17, 2025

Description:

The fetch_thumbnail_data_url function was not re-using the existing requests.Session & was instead making one-off requests.get calls. This caused a DNS query for each fetch_thumbnail_data_url invocation, and overall causes a TON of excessive, identical DNS queries.

By using the existing requests.Session instance to fetch thumbnail URLs, DNS queries are much less frequent since connections are reused.

Workflow steps:

(How does one use this feature, and how has it changed)

Documentation links affected:

(list any documentation links that you created, or existing ones that you've identified as needing updates, along with a brief description)

Notes for reviewers:

Tested on a local stack. Confirmed that the frequency of DNS queries after this change are significantly lower.


This change is Reviewable

The `fetch_thumbnail_data_url` function was not re-using the existing
`requests.Session` & was instead making one-off `requests.get` calls.
This caused a DNS query for each `fetch_thumbnail_data_url` invocation,
and overall causes a TON of excessive, identical DNS queries.

By using the existing `requests.Session` instance to make fetch thumbnail
URLs, DNS queries are much less frequent since connections can be reused.
@Alex-Bair Alex-Bair marked this pull request as ready for review March 17, 2025 17:11
@Alex-Bair Alex-Bair requested a review from a team March 17, 2025 17:11
Copy link
Member

@jgraettinger jgraettinger left a comment

Choose a reason for hiding this comment

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

LGTM

@Alex-Bair Alex-Bair merged commit 81c533e into main Mar 17, 2025
84 of 91 checks passed
@Alex-Bair Alex-Bair deleted the bair/source-facebook-marketing-reduce-dns-query-frequency branch March 17, 2025 17:19
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