
Answer-first summary for fast verification
Answer: Modify the query that returns the product list using cursors with limits.
The issue arises because Cloud Run instances are crashing due to memory limits during Firestore query spikes. Option A (using cursors with limits) addresses this by paginating product lists. Cursors allow efficient pagination by fetching smaller chunks of data per query, reducing memory usage in Cloud Run instances. This also optimizes Firestore performance by avoiding inefficient offset-based queries (option C), which read redundant documents. While creating a custom index (option B) might improve query speed, it doesn't directly reduce query volume or memory usage. Increasing memory limits (option D) is a temporary fix, not an optimization. Thus, Option A is the best solution.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
As a lead developer for a retail system running on Cloud Run and Firestore, you observe that Cloud Run instances are being terminated with HTTP 500: Container instances exceeding memory limits during peak traffic, coinciding with spikes in Firestore queries. How can you prevent Cloud Run crashes and reduce Firestore query volume while optimizing system performance?
A
Modify the query that returns the product list using cursors with limits.
B
Create a custom index over the products.
C
Modify the query that returns the product list using integer offsets.
D
Modify the Cloud Run configuration to increase the memory limits.
No comments yet.