Google Professional Cloud Developer Question 382
Select 2Google Cloud PlatformYou are deploying a containerized application to Google Kubernetes Engine (GKE). The application has a machine learning component that requires 4 CPUs and 16 GB of memory per pod. Additionally, the application needs to handle sudden spikes in traffic. How should you define the resource requirements in the workload specification to ensure optimal performance and scalability?
- A
Set 'requests' for CPU to 4 and memory to 16 GB, and 'limits' to 8 CPUs and 32 GB of memory.
- B
Set 'requests' for CPU to 2 and memory to 8 GB, and 'limits' to 4 CPUs and 16 GB of memory.
- C
Do not define 'requests' or 'limits' to allow the application to scale dynamically based on traffic.
- D
Set 'requests' for CPU to 4 and memory to 16 GB, and do not define 'limits'.
- E
Set 'limits' for CPU to 4 and memory to 16 GB, and do not define 'requests'.
Show answer and explanation
Correct answers: A, B
Explanation
Defining both 'requests' and 'limits' in the workload specification is critical to ensure your application has the resources it needs while also protecting the cluster from resource overuse. Option 1 provides ample resources for the machine learning component while allowing for bursts in traffic. Option 2 is valid for more conservative resource allocation but might not be ideal for the given requirements. Options 3, 4, and 5 are incorrect because they either omit crucial resource definitions or fail to balance guaranteed resources with scalability.
- A. Correct.
'requests' define the minimum resources guaranteed for a pod, ensuring it gets 4 CPUs and 16 GB memory for stable performance. Setting 'limits' higher accounts for traffic spikes, but must not exceed node capacity.
- B. Correct.
This option is valid if you expect moderate bursts and want to conserve resources. However, it may under-allocate for your use case since the machine learning component requires 4 CPUs and 16 GB memory.
- C. Incorrect.
Not defining 'requests' or 'limits' can lead to resource contention, as Kubernetes cannot guarantee proper allocation. This approach is not recommended for production workloads.
- D. Incorrect.
Defining 'requests' ensures guaranteed resources for each pod. However, not defining 'limits' could lead to resource overuse, potentially affecting other pods and cluster performance.
- E. Incorrect.
Setting only 'limits' without 'requests' may result in resource contention, as Kubernetes won't reserve resources for the pod's baseline needs. This could cause instability during high-demand periods.