Skip to content

Improve GetDatabase Caching for Firestore Function Deployments#8681

Merged
taeold merged 3 commits intomasterfrom
dl-firestore-fn-deploy
May 30, 2025
Merged

Improve GetDatabase Caching for Firestore Function Deployments#8681
taeold merged 3 commits intomasterfrom
dl-firestore-fn-deploy

Conversation

@taeold
Copy link
Copy Markdown
Contributor

@taeold taeold commented May 30, 2025

When deploying multiple 2nd gen Firestore functions, we send many concurrent GetDatabase API requests. The existing caching mechanism was not effective for these simultaneous calls, leading to redundant requests and (potentially) API quota issue.

This change introduces caching for the promise of the GetDatabase API call itself, in addition to the result. This should improves cache hits for concurrent requests, resulting in more reliable function deployments.

Copy link
Copy Markdown
Member

@inlined inlined left a comment

Choose a reason for hiding this comment

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

This is different from the pattern we use in getExistingBackend (passing the cache via Context) to avoid accidentally using a cache, but I can see arguments that the problem is less of a concern here because we're not modifying the database region between calls.

@taeold taeold merged commit 7133888 into master May 30, 2025
48 of 50 checks passed
@taeold taeold deleted the dl-firestore-fn-deploy branch May 30, 2025 18:53
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants