Google Professional Cloud Developer Question 380
Select 2Google Cloud PlatformYou are deploying a containerized web application on Google Kubernetes Engine (GKE) and want to ensure the application performs optimally under varying workloads. The application has a predictable memory usage pattern but can occasionally experience CPU spikes. How should you define the resource requirements for the application in the Pod specification to achieve this?
- A
Set memory requests to the average memory usage and memory limits to the maximum observed memory usage.
- B
Set CPU requests to a value slightly above the average CPU usage and CPU limits to handle peak CPU usage.
- C
Leave resource requests and limits unset to allow Kubernetes to automatically allocate resources as needed.
- D
Set memory and CPU requests equal to their respective limits to ensure guaranteed performance.
- E
Set CPU requests to a very low value and memory limits to an excessively high value to avoid resource throttling.
Show answer and explanation
Correct answers: A, B
Explanation
In Kubernetes, defining proper resource requests and limits is crucial for optimal workload performance and cluster efficiency. Memory requests should align with average usage to ensure sufficient allocation, while limits should handle maximum observed usage to avoid overcommitment. Similarly, CPU requests should be slightly above the average to maintain consistent performance, and limits should account for spikes to prevent throttling. This approach balances performance with efficient resource utilization.
- A. Correct.
This is correct because setting memory requests to the average and memory limits to the maximum observed ensures efficient resource allocation and prevents memory overcommitment.
- B. Correct.
This is correct because setting CPU requests slightly above average ensures sufficient allocated CPU resources, while setting CPU limits to handle peak usage avoids throttling during spikes.
- C. Incorrect.
This is incorrect because leaving resource requests and limits unset can lead to resource contention and unpredictable performance.
- D. Incorrect.
This is incorrect because setting requests equal to limits does not allow for flexibility in resource allocation and may lead to inefficient usage of resources.
- E. Incorrect.
This is incorrect because setting CPU requests too low can cause resource starvation, while excessively high memory limits can lead to inefficient cluster utilization.