Google Professional Cloud Developer Question 72
Select 2Google Cloud PlatformYou are a developer managing a serverless application running on Google Cloud Functions. The application processes data from Cloud Storage and writes results to BigQuery. Your team has noticed increased costs for the function as the data volume has grown. Which actions can you take to optimize the cost of the application while ensuring performance is maintained?
- A
Switch to a higher memory allocation for the Cloud Function to reduce execution time.
- B
Batch multiple data processing requests into a single invocation of the Cloud Function.
- C
Use Preemptible VMs instead of Cloud Functions for processing the data.
- D
Configure Cloud Function to use a lower timeout setting to avoid excessive runtime costs.
- E
Implement event filtering to ensure the Cloud Function only processes relevant data events.
Show answer and explanation
Correct answers: B, E
Explanation
To optimize the cost of a serverless application, it is essential to reduce unnecessary invocations and ensure efficient utilization of resources. Batching data processing requests (Option 2) decreases the number of invocations, while event filtering (Option 5) ensures that the function only processes relevant events, both of which help reduce costs. Other options either do not align with a serverless architecture or could inadvertently impact performance or function behavior.
- A. Incorrect.
Although increasing memory allocation can improve execution time, it also increases the cost per invocation. Without evidence that memory is a bottleneck, this may not optimize costs overall.
- B. Correct.
Batching multiple data processing requests reduces the number of invocations and can optimize costs significantly, as fewer invocations are charged.
- C. Incorrect.
Preemptible VMs are not suitable for serverless applications like Cloud Functions, as they require infrastructure management and are not serverless by nature.
- D. Incorrect.
Reducing the timeout setting could lead to incomplete processing of data if the function requires more time to execute. This does not directly optimize costs unless the function is consistently running unnecessarily long.
- E. Correct.
Event filtering ensures that the Cloud Function processes only relevant events, reducing unnecessary invocations and optimizing costs.