Google Professional Cloud Developer Question 236
Select 2Google Cloud PlatformYou are tasked with developing a highly scalable web application on Google Cloud Platform. The application will use Cloud Run to handle HTTP requests and Cloud Pub/Sub for asynchronous processing. Which of the following design considerations should you prioritize to ensure reliability and scalability?
- A
Implement idempotency in your Cloud Run service to handle retries from Cloud Pub/Sub.
- B
Use a global state in Cloud Run to cache frequently accessed data for improved performance.
- C
Configure Cloud Pub/Sub message acknowledgment to be processed only after successful message handling.
- D
Set a fixed concurrency limit for Cloud Run to avoid overloading your service.
- E
Ensure your application logs all incoming requests directly to the local filesystem for debugging purposes.
Show answer and explanation
Correct answers: A, C
Explanation
To ensure reliability and scalability in a Cloud Run and Cloud Pub/Sub-based application, it is important to account for the stateless nature of Cloud Run and the asynchronous nature of Cloud Pub/Sub. Idempotency safeguards against duplicate message processing, and proper acknowledgment handling ensures that messages are retried in case of failures. These considerations align with best practices for building resilient cloud-native applications.
- A. Correct.
Implementing idempotency in your Cloud Run service is critical because Cloud Pub/Sub may retry messages in case of failures, and idempotency ensures that processing the same message multiple times does not cause unintended side effects.
- B. Incorrect.
Using a global state in Cloud Run is not recommended because Cloud Run instances are stateless by design, and relying on a global state can lead to inconsistent behavior and scale issues.
- C. Correct.
Configuring Cloud Pub/Sub message acknowledgment to occur only after successful handling ensures that failed messages can be retried, improving the reliability of your application.
- D. Incorrect.
Setting a fixed concurrency limit can restrict scalability. Instead, you should allow Cloud Run to scale dynamically based on traffic, unless there are specific resource constraints.
- E. Incorrect.
Logging requests directly to the local filesystem is not recommended in Cloud Run because instances may be ephemeral and logs could be lost. Instead, use a centralized logging solution like Cloud Logging.