In Google Cloud Pub/Sub, what is the main difference in how messages are delivered to subscribers when using pull subscriptions versus push subscriptions?
Think about who initiates the message transfer in each subscription type.
Pull subscriptions require the subscriber to actively request messages from the Pub/Sub service. Push subscriptions send messages automatically to a configured endpoint without the subscriber requesting them.
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?
Consider which subscription type gives more control over message processing rate.
Pull subscriptions allow the backend to control message fetching rate, which helps manage variable load and scale processing. Push subscriptions send messages automatically and may overwhelm the backend if load spikes.
When using push subscriptions in Google Cloud Pub/Sub, what is a recommended security practice to protect the subscriber endpoint?
Think about how to verify the identity of the sender and protect data in transit.
Using HTTPS with authentication tokens and verifying JWT tokens from Pub/Sub ensures that messages are securely delivered and come from a trusted source. Other options reduce security and risk unauthorized access.
In a pull subscription, what happens if a subscriber does not acknowledge a message within the acknowledgement deadline?
Consider what Pub/Sub does to ensure message delivery reliability.
If a message is not acknowledged within the deadline, Pub/Sub makes it available again for redelivery to ensure it is processed at least once.
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?
Think about how to handle failures and retries gracefully in push delivery.
Implementing retries with exponential backoff helps the backend recover from temporary failures. Using dead-letter topics captures messages that repeatedly fail, preventing message loss.