Cloud Run instances are being killed with OOM (HTTP 500) during traffic spikes that coincide with increased Firestore queries for product browsing. How do you prevent crashes and reduce Firestore load while optimizing performance?
Choose an answer
Tap an option to check your answer.
Correct answer: Paginate the product-list query using cursors with limits..
Why this is the answer
Paginating with cursors and limits is the most effective solution. It retrieves only a subset of data per request, significantly reducing the memory footprint on Cloud Run instances and decreasing the read load on Firestore. Cursors ensure efficient pagination by continuing from the last retrieved document, avoiding re-scanning. Creating a custom Firestore index might improve query speed for specific fields but won't reduce the amount of data returned or the memory consumed if the query still attempts to fetch too many documents. Paginate with integer offsets is inefficient for large datasets as Firestore still processes all documents up to the offset, leading to higher latency and cost. Increasing Cloud Run memory allocation is a temporary fix for OOM errors but doesn't address the root cause of inefficient data retrieval and will lead to higher costs without optimizing performance.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed