0
0
GCPcloud~20 mins

Pub/Sub with Cloud Functions integration in GCP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pub/Sub Cloud Functions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What happens when a Cloud Function subscribed to a Pub/Sub topic throws an error?

You have a Cloud Function triggered by a Pub/Sub topic. The function processes messages but sometimes throws an error during execution.

What is the behavior of Pub/Sub and the Cloud Function when an error occurs?

AThe message is acknowledged and removed from the subscription, so it is not retried.
BThe message is not acknowledged and is retried until the function succeeds or the message expires.
CThe message is sent to a dead-letter topic immediately without retries.
DThe Cloud Function automatically scales down to zero and stops receiving messages.
Attempts:
2 left
💡 Hint

Think about how Pub/Sub handles message acknowledgment and retries.

Configuration
intermediate
2:00remaining
Which IAM role must be granted to a Cloud Function to allow it to be triggered by a Pub/Sub topic?

You want to deploy a Cloud Function that triggers when messages are published to a specific Pub/Sub topic.

Which IAM role should you assign to the Cloud Function's service account to allow this trigger?

Aroles/pubsub.publisher
Broles/pubsub.subscriber
Croles/cloudfunctions.invoker
Droles/pubsub.viewer
Attempts:
2 left
💡 Hint

Consider which role allows receiving messages from Pub/Sub.

Architecture
advanced
3:00remaining
How to design a reliable system to process Pub/Sub messages with Cloud Functions ensuring no message loss?

You need to build a system where Cloud Functions process Pub/Sub messages reliably without losing any messages, even if the function fails temporarily.

Which design choice best ensures message durability and processing reliability?

AUse a Pub/Sub topic with a subscription that has a dead-letter topic configured and Cloud Functions with retry enabled.
BUse a Pub/Sub topic with no dead-letter topic and disable retries on Cloud Functions to avoid duplicate processing.
CUse Cloud Storage to store messages and trigger Cloud Functions on file creation instead of Pub/Sub.
DUse a Pub/Sub topic with a push subscription directly calling the Cloud Function URL without retries.
Attempts:
2 left
💡 Hint

Think about how to handle failed messages and retries safely.

security
advanced
3:00remaining
Which practice improves security when integrating Pub/Sub with Cloud Functions?

You want to secure your Cloud Function triggered by Pub/Sub so that only authorized messages can invoke it.

Which practice best enhances security in this integration?

AUse a push subscription with an authentication token and verify it in the Cloud Function code.
BUse a pull subscription and grant the Cloud Function's service account the subscriber role only.
CMake the Cloud Function public and rely on Pub/Sub topic permissions to restrict access.
DDisable authentication on the Cloud Function to allow all Pub/Sub messages to trigger it.
Attempts:
2 left
💡 Hint

Consider how to authenticate messages sent to the Cloud Function.

Best Practice
expert
3:00remaining
What is the best way to handle high-throughput Pub/Sub message processing with Cloud Functions to avoid cold starts and throttling?

Your system receives a high volume of Pub/Sub messages. You use Cloud Functions to process them, but you notice cold starts and throttling affecting performance.

Which approach best addresses these issues?

AUse Cloud Run with Pub/Sub push subscription for better scaling and control over concurrency.
BIncrease the memory allocation of Cloud Functions to reduce cold start time.
CUse multiple Cloud Functions with different Pub/Sub topics to distribute load evenly.
DDisable retries on Cloud Functions to reduce duplicate invocations and throttling.
Attempts:
2 left
💡 Hint

Think about alternatives to Cloud Functions that handle scaling better.