0
0
GCPcloud~20 mins

Publishing messages in GCP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pub/Sub Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Message Ordering in Pub/Sub

You have a Google Cloud Pub/Sub topic with message ordering enabled. What happens if you publish messages with the same ordering key but the subscriber acknowledges messages out of order?

AMessages with the same ordering key are delivered in the order they were published, regardless of acknowledgment order.
BMessages are delivered in any order, and acknowledgment order does not affect delivery.
CMessages with the same ordering key are redelivered until acknowledged in the correct order, blocking later messages.
DMessages with the same ordering key are dropped if acknowledged out of order.
Attempts:
2 left
💡 Hint

Think about how Pub/Sub ensures message order with ordering keys and what happens if acknowledgments are delayed or out of order.

Architecture
intermediate
2:00remaining
Designing a Scalable Pub/Sub Publisher

You want to design a system that publishes millions of messages per second to a Google Cloud Pub/Sub topic. Which approach best ensures scalability and reliability?

AUse multiple publisher client instances with asynchronous publishing and batching enabled.
BUse a single publisher client instance with synchronous publishing calls to ensure message order.
CPublish messages directly from client devices without batching or retries.
DUse a single publisher client instance with manual retries and no batching.
Attempts:
2 left
💡 Hint

Consider how batching and asynchronous publishing affect throughput and reliability.

security
advanced
2:00remaining
Securing Pub/Sub Message Publishing

You want to restrict who can publish messages to a Pub/Sub topic in your project. Which IAM role should you assign to the publisher service account to allow publishing but prevent subscription management?

Aroles/pubsub.editor
Broles/pubsub.admin
Croles/pubsub.subscriber
Droles/pubsub.publisher
Attempts:
2 left
💡 Hint

Think about the principle of least privilege and which role allows only publishing.

Best Practice
advanced
2:00remaining
Handling Message Duplication in Pub/Sub

Google Cloud Pub/Sub may deliver messages more than once. What is the best practice to handle this duplication in your subscriber application?

AImplement idempotent message processing using unique message IDs.
BIgnore duplicates because Pub/Sub guarantees exactly-once delivery.
CAcknowledge messages immediately without processing to avoid duplicates.
DUse message filtering to prevent duplicates from being delivered.
Attempts:
2 left
💡 Hint

Consider how to safely process messages that might arrive multiple times.

🧠 Conceptual
expert
2:00remaining
Pub/Sub Message Ordering with Multiple Ordering Keys

You publish messages with multiple different ordering keys to a single Pub/Sub topic. How does Pub/Sub guarantee message ordering in this scenario?

APub/Sub does not guarantee any ordering when multiple ordering keys are used.
BMessages are ordered only within each ordering key; messages with different keys can be delivered out of order relative to each other.
CMessages with different ordering keys are delivered in the order they were published across all keys.
DMessages with different ordering keys are merged and delivered in alphabetical order of the keys.
Attempts:
2 left
💡 Hint

Think about how ordering keys isolate message order guarantees.