Bird
Raised Fist0
GCPcloud~20 mins

Pull vs push subscriptions in GCP - Practice Questions

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Pub/Sub Subscription Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in message delivery between pull and push subscriptions

In Google Cloud Pub/Sub, what is the main difference in how messages are delivered to subscribers when using pull subscriptions versus push subscriptions?

ABoth pull and push subscriptions require the subscriber to request messages manually.
BPull subscriptions automatically send messages to a subscriber endpoint, while push subscriptions require the subscriber to request messages.
CBoth pull and push subscriptions automatically send messages to subscriber endpoints without any requests.
DPull subscriptions require the subscriber to request messages, while push subscriptions automatically send messages to a subscriber endpoint.
Attempts:
2 left
💡 Hint

Think about who initiates the message transfer in each subscription type.

❓ Architecture
intermediate
2:00remaining
Choosing subscription type for a mobile app backend

You are designing a backend for a mobile app that processes notifications. The backend must handle variable load and scale automatically. Which subscription type is better suited for this scenario?

APull subscription, because the backend can control when and how many messages to fetch, allowing better load management.
BPush subscription, because messages are sent automatically and the backend does not need to manage message fetching.
CPush subscription, because it requires the backend to poll messages frequently to keep up with load.
DPull subscription, because it automatically retries sending messages to the backend endpoint.
Attempts:
2 left
💡 Hint

Consider which subscription type gives more control over message processing rate.

❓ security
advanced
2:00remaining
Securing push subscription endpoints

When using push subscriptions in Google Cloud Pub/Sub, what is a recommended security practice to protect the subscriber endpoint?

AAllow all incoming HTTP requests without authentication to avoid message delivery failures.
BUse HTTPS with authentication tokens and verify JWT tokens sent by Pub/Sub to ensure messages come from a trusted source.
CUse plain HTTP without encryption to reduce latency in message delivery.
DDisable authentication and rely on IP whitelisting only.
Attempts:
2 left
💡 Hint

Think about how to verify the identity of the sender and protect data in transit.

❓ service_behavior
advanced
2:00remaining
Message acknowledgement behavior in pull subscriptions

In a pull subscription, what happens if a subscriber does not acknowledge a message within the acknowledgement deadline?

AThe message is automatically acknowledged by the Pub/Sub service.
BThe message is permanently deleted and lost.
CThe message becomes available again for delivery to the same or another subscriber.
DThe message is sent to a dead-letter queue immediately.
Attempts:
2 left
💡 Hint

Consider what Pub/Sub does to ensure message delivery reliability.

✅ Best Practice
expert
2:00remaining
Handling high throughput with push subscriptions

You have a push subscription sending messages to a backend service that occasionally experiences spikes in traffic. What is the best practice to ensure reliable message processing without losing messages?

AImplement a retry mechanism with exponential backoff on the backend and use Cloud Pub/Sub's dead-letter topic for failed messages.
BDisable retries and drop messages that fail to process during traffic spikes to reduce load.
CUse pull subscriptions instead of push subscriptions to avoid retries.
DIncrease the acknowledgement deadline to several hours to prevent message redelivery.
Attempts:
2 left
💡 Hint

Think about how to handle failures and retries gracefully in push delivery.

Practice

(1/5)
1. What is the main difference between a pull subscription and a push subscription in Google Cloud Pub/Sub?
easy
A. Pull subscriptions send messages automatically; push subscriptions require your app to request messages.
B. Pull subscriptions are faster than push subscriptions in all cases.
C. Pull subscriptions only work with HTTP; push subscriptions only work with gRPC.
D. Pull subscriptions require your app to request messages; push subscriptions send messages automatically.

Solution

  1. Step 1: Understand pull subscription behavior

    Pull subscriptions require the client application to ask for messages explicitly.
  2. Step 2: Understand push subscription behavior

    Push subscriptions automatically send messages to the client via HTTP POST.
  3. Final Answer:

    Pull subscriptions require your app to request messages; push subscriptions send messages automatically. -> Option D
  4. Quick Check:

    Pull = request, Push = automatic [OK]
Hint: Pull means ask; push means receive automatically [OK]
Common Mistakes:
  • Confusing which subscription type initiates message delivery
  • Thinking push requires app to poll for messages
  • Assuming pull subscriptions send messages automatically
2. Which of the following is the correct way to configure a push subscription endpoint URL in Google Cloud Pub/Sub?
easy
A. Set the subscription's pushConfig with a valid HTTPS URL where messages will be sent.
B. Set the subscription's pullConfig with the endpoint URL to pull messages.
C. Configure the subscription with a TCP socket address for push delivery.
D. Use the subscription's pushConfig with an FTP URL for message delivery.

Solution

  1. Step 1: Identify correct pushConfig usage

    Push subscriptions require setting pushConfig with a valid HTTPS URL for message delivery.
  2. Step 2: Eliminate incorrect options

    PullConfig does not exist; TCP and FTP are not supported protocols for push endpoints.
  3. Final Answer:

    Set the subscription's pushConfig with a valid HTTPS URL where messages will be sent. -> Option A
  4. Quick Check:

    PushConfig needs HTTPS URL [OK]
Hint: Push subscriptions need HTTPS URL in pushConfig [OK]
Common Mistakes:
  • Using pullConfig instead of pushConfig
  • Setting non-HTTPS URLs for push endpoints
  • Confusing pull and push subscription settings
3. Consider this code snippet for a pull subscription client in Python using Google Cloud Pub/Sub:
from google.cloud import pubsub_v1
subscriber = pubsub_v1.SubscriberClient()
subscription_path = subscriber.subscription_path('my-project', 'my-sub')
response = subscriber.pull(subscription=subscription_path, max_messages=1)
print(len(response.received_messages))
What will this code print if there is exactly one message available in the subscription?
medium
A. Error due to missing ack
B. 0
C. 1
D. None

Solution

  1. Step 1: Understand pull method behavior

    The pull method requests messages; if one message is available, it returns it in received_messages.
  2. Step 2: Check printed output

    len(response.received_messages) will be 1 because exactly one message is pulled.
  3. Final Answer:

    1 -> Option C
  4. Quick Check:

    One message pulled means length is 1 [OK]
Hint: Pull returns messages list; length matches available messages [OK]
Common Mistakes:
  • Assuming pull returns zero without ack
  • Expecting error if ack is missing
  • Confusing pull with push subscription behavior
4. You have a push subscription configured, but your app is not receiving any messages. Which of the following is the most likely cause?
medium
A. The push endpoint URL is incorrect or unreachable.
B. The subscription is set to pull instead of push.
C. The app forgot to call pull() method.
D. The topic has no messages published.

Solution

  1. Step 1: Check push subscription delivery requirements

    Push subscriptions require a reachable, correct HTTPS endpoint to deliver messages.
  2. Step 2: Analyze other options

    Pull vs push setting is fixed; pull() is not used in push; no messages means no delivery but question implies messages exist.
  3. Final Answer:

    The push endpoint URL is incorrect or unreachable. -> Option A
  4. Quick Check:

    Push needs correct reachable URL [OK]
Hint: Push needs reachable endpoint URL [OK]
Common Mistakes:
  • Confusing pull and push subscription methods
  • Assuming pull() is needed for push subscriptions
  • Ignoring network or URL errors
5. You want to design a system that processes messages only when your app is ready and can control the rate of message processing. Which subscription type should you choose and why?
hard
A. Push subscription, because it retries sending messages until acknowledged.
B. Pull subscription, because your app controls when to request messages.
C. Push subscription, because messages are sent automatically and fast.
D. Pull subscription, because it automatically scales message delivery.

Solution

  1. Step 1: Identify control needs

    The app wants to control when and how fast messages are processed.
  2. Step 2: Match subscription type to control

    Pull subscriptions let the app ask for messages when ready, controlling rate and timing.
  3. Final Answer:

    Pull subscription, because your app controls when to request messages. -> Option B
  4. Quick Check:

    Pull = app controls message flow [OK]
Hint: Choose pull to control message processing timing [OK]
Common Mistakes:
  • Choosing push for control over message rate
  • Assuming push retries mean better control
  • Thinking pull auto-scales delivery
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard