Correct Answer: Implement idempotency in the function using a unique message ID checked against Firestore or Cloud Spanner before processing
Pub/Sub guarantees at-least-once delivery. The standard pattern for exactly-once semantics is **idempotent consumers**: before processing, check if the message ID (from `message.me...
Correct Answer
Implement idempotency in the function using a unique message ID checked against Firestore or Cloud Spanner before processing
Why This Answer Is Correct
Pub/Sub guarantees at-least-once delivery. The standard pattern for exactly-once semantics is **idempotent consumers**: before processing, check if the message ID (from `message.messageId`) has already been processed (stored in Firestore/Spanner/Redis). If yes, ack and skip. Pub/Sub's `exactlyOnce` mode reduces duplicates but is not guaranteed at the infrastructure level. Extending ack deadlines only delays redelivery; it does not prevent it.
Your Cloud Function processes images uploaded to Cloud Storage. It intermittently times out on large files. The function is configured with 60s timeout and 256MB memory. What is the most effective fix?
A developer uses Cloud Shell to run `gcloud` commands that modify production resources. As a Cloud Architect, what control should you implement to prevent accidental production changes from Cloud Shell?
A Cloud Architect needs to run a resource-intensive script (processing 10GB of data) that takes 2+ hours to complete. Cloud Shell sessions terminate after 20 minutes of inactivity. What is the best approach?
What persists between Cloud Shell sessions?
A developer needs to preview a web application running on port 8080 inside Cloud Shell without exposing it publicly. What feature enables this?