Google Cloud Professional Cloud Developer — Question 254

You are a lead developer working on a new retail system that runs on Cloud Run and Firestore. A web UI requirement is for the user to be able to browse through all products. A few months after go-live, you notice that Cloud Run instances are terminated with HTTP 500: Container instances are exceeding memory limits errors during busy times. This error coincides with spikes in the number of Firestore queries.

You need to prevent Cloud Run from crashing and decrease the number of Firestore queries. You want to use a solution that optimizes system performance. What should you do?

Answer options

Correct answer: A

Explanation

The correct answer is A, as using cursors with limits helps paginate the results, thereby reducing the load on Firestore and preventing excessive memory use in Cloud Run. Options B and C may not directly address the memory issue since indexing doesn't reduce query counts, and using integer offsets can lead to inefficiencies. Option D might alleviate the symptom but doesn't solve the underlying problem of excessive Firestore queries.