Google Professional Cloud Developer Question 440
Select 2Google Cloud PlatformYou are developing a serverless application on Google Cloud that processes high volumes of incoming API requests. To optimize performance and reduce costs, you decide to batch requests before processing them. Which of the following approaches can be used to effectively implement batching for your application?
- A
Use Cloud Pub/Sub to aggregate incoming messages and process them in batches using a subscriber.
- B
Implement batching logic directly in the client application to reduce the number of requests sent to the server.
- C
Use Cloud Tasks to group multiple task payloads into a single API call for batch processing.
- D
Leverage Cloud Functions to collect and temporarily store incoming requests in-memory before processing them in batches.
- E
Use BigQuery to store incoming requests and periodically query the data in batches for processing.
Show answer and explanation
Correct answers: A, C
Explanation
To implement batching effectively in Google Cloud, you need to use services designed to handle and aggregate incoming requests or messages. Both Cloud Pub/Sub and Cloud Tasks are reliable options for batching as they support message queuing and processing in controlled batch sizes. Other options, like in-memory storage in Cloud Functions, are not suitable due to their stateless nature, and BigQuery is designed for analytics rather than real-time request batching.
- A. Correct.
Correct: Cloud Pub/Sub is an effective way to aggregate messages and process them in batches. Subscribers can pull or receive messages in configured batch sizes, making it suitable for this use case.
- B. Incorrect.
Incorrect: Implementing batching logic in the client application can reduce server load but doesn't align with server-side batching best practices in Google Cloud solutions.
- C. Correct.
Correct: Cloud Tasks allows you to create task queues where multiple payloads can be grouped and processed in batches, which is a valid approach for batching requests.
- D. Incorrect.
Incorrect: Cloud Functions are stateless, and storing incoming requests in-memory violates their design principles. This approach is unreliable and not recommended.
- E. Incorrect.
Incorrect: While BigQuery is excellent for querying and analyzing data in batches, it's not designed to act as a message queue for batching incoming API requests.