Last updated on June 26, 2023
Google Cloud Pub/Sub Cheat Sheet
- Cloud Pub/Sub is a fully-managed real-time messaging service for event driven systems that allows you to send and receive messages between independent applications.
Features
- Capable of global message routing to simplify multi-region systems.
- Synchronous, cross-zone message replication and per-message receipt tracking ensure at-least-once delivery at any scale. Pub/Sub delivers each message at least once, so the Pub/Sub service might redeliver messages.
- You can declare independent quota and billing for publishers and subscribers.
- Cloud Pub/Sub doesn’t have shards or partitions. You just need to set your quota, publish, and consume.
Key Concepts
- Topic
- It is a named resource to which publishers send messages.
- Subscription
- Is a named resource representing the stream of messages from a specific topic, to be sent to the subscribing application.
- Message
- The combination of data and attributes that a publisher sends to a topic and is eventually sent to subscribers.
- Message attribute
- A key-value pair that a publisher can define for a message.
Publisher-subscriber relationships
- A publisher application creates and sends messages to a topic.
- Subscriber applications then create a subscription to a topic to receive messages from the topic.
- Communication can be
- one-to-many
- many-to-one
- many-to-many
Pricing
- Pub/Sub pricing is calculated based upon monthly data volumes:
- Message ingestion and delivery
- Snapshots and retained acknowledged messages
- The first 10 GB of data per month is offered free of charge.
Validate Your Knowledge
Question 1
You have an application packaged on a container that you plan to deploy on Cloud Run. The application performs some data analysis on messages from a Cloud Pub/Sub topic called order-queue
. You want to follow Google-recommended practices.
What should you do?
-
a. Build a Cloud Function that is triggered every time there is a message from a Cloud Pub/Sub topic.
b. Invoke your application on Cloud Run from the Cloud Function on every message. -
a. Create a new Service Account and attach the
roles/pubsub.subscriber
.
b. Create a Pub/Sub subscription on theorder-queue
topic.
c. Configure the Cloud Run application to use the new Service Account to pull messages from the subscription. -
a. Create a service account.
b. Associate the Cloud Run Invoker role to the service account of your Cloud Run application.
c. Create a Cloud Pub/Sub subscription using the new service account and set the push endpoint using the service URL of your Cloud Run application. -
a. Use Cloud Run for Anthos to deploy your application and expose your application to the public by setting the connectivity to
External
.
b. Create a Pub/Sub subscription on theorder-queue
topic.
c. Deploy a new container that takes messages from Cloud Pub/Sub and sends it to your application.
For more Google Cloud practice exam questions with detailed explanations, check out the Tutorials Dojo Portal:
Cloud Pub/Sub Cheat Sheet References:
https://cloud.google.com/pubsub
https://cloud.google.com/pubsub/docs/overview
AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!
Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!
View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses