Google Professional Cloud Developer Question 384
Select 3Google Cloud PlatformYou are deploying a containerized application to Google Kubernetes Engine (GKE). The application has variable workloads, with occasional spikes that require high CPU and memory resources. However, you want to ensure cost efficiency by not over-allocating resources during normal operations. Which of the following configuration steps should you take to define the workload's resource requirements appropriately?
- A
Define resource requests for CPU and memory in the Pod specification.
- B
Set resource limits for CPU and memory in the Pod specification.
- C
Enable cluster autoscaling for the GKE cluster.
- D
Define a fixed number of replicas in the Deployment specification, regardless of workload spikes.
- E
Configure Horizontal Pod Autoscaler (HPA) for the deployment.
Show answer and explanation
Correct answers: A, B, E
Explanation
To handle variable workloads effectively, you should define resource requests and limits in the Pod specification to ensure the application gets the required resources during normal operations and prevent overuse during spikes. Additionally, implementing Horizontal Pod Autoscaler (HPA) enables dynamic scaling of replicas based on demand, ensuring the application can handle spikes efficiently without unnecessary cost. These configurations together allow for both reliable performance and cost efficiency.
- A. Correct.
Defining resource requests ensures that the Kubernetes scheduler allocates sufficient resources for the application to run reliably. This avoids resource starvation during normal operations.
- B. Correct.
Setting resource limits prevents the application from consuming more resources than necessary, ensuring fair resource distribution and cost control during workload spikes.
- C. Incorrect.
While enabling cluster autoscaling is useful for scaling the cluster based on overall resource demand, it does not directly define resource requirements for the workload itself.
- D. Incorrect.
Defining a fixed number of replicas is not optimal for handling variable workloads, as it does not account for workload spikes or fluctuations.
- E. Correct.
Configuring Horizontal Pod Autoscaler (HPA) enables the application to scale the number of replicas dynamically based on CPU/memory utilization metrics, making it suitable for handling variable workloads.