Skip to content

Improve GetDatabase Caching for Firestore Function Deployments - #8681

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

taeold merged 3 commits into
masterfrom
dl-firestore-fn-deploy

Conversation

@taeold

@taeold taeold commented May 30, 2025

Copy link
Copy Markdown
Contributor

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.

@inlined inlined left a comment

Copy link
Copy Markdown
Member

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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants