Google Professional Cloud Developer Question 75
Select 4Google Cloud PlatformYou are developing a microservices-based application deployed on Google Kubernetes Engine (GKE). The application must gracefully handle scaling events and ensure minimal downtime during node restarts or pod terminations. What strategies should you implement to achieve this?
- A
Use Kubernetes readiness probes to signal when a pod is ready to serve requests.
- B
Implement a retry mechanism with exponential backoff in the client-side logic.
- C
Configure Kubernetes liveness probes to restart pods immediately when they terminate.
- D
Enable Horizontal Pod Autoscaler (HPA) to dynamically adjust the number of pods based on workload.
- E
Leverage Kubernetes preStop lifecycle hooks to perform cleanup tasks before termination.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
Gracefully handling scaling events and disasters in Kubernetes requires a combination of strategies. Readiness probes and preStop hooks ensure smooth transitions during scaling or termination. Exponential backoff retries help clients handle transient issues. HPA dynamically adjusts resources to prevent overloads. While liveness probes are essential for maintaining application health, they do not directly contribute to graceful handling during scaling or disasters.
- A. Correct.
Correct: Readiness probes ensure that traffic is only sent to pods that are ready to handle it, which is crucial for graceful handling during scaling events and restarts.
- B. Correct.
Correct: A retry mechanism with exponential backoff helps clients handle transient errors during scaling or disasters, ensuring resilience.
- C. Incorrect.
Incorrect: Liveness probes are useful for detecting and restarting unresponsive containers, but they do not directly contribute to graceful handling of scaling events or disasters.
- D. Correct.
Correct: HPA ensures that the application can handle varying workloads by scaling pods dynamically, reducing the risk of overloading during traffic spikes.
- E. Correct.
Correct: preStop lifecycle hooks allow applications to perform necessary cleanup activities (e.g., closing database connections) before a pod is stopped, ensuring graceful termination.