Google Cloud Certified Associate Cloud Engineer Practice

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for the Google Cloud Certified Associate Cloud Engineer Exam with flashcards and multiple choice questions. Each question includes hints and explanations to help you study effectively. Get ready to pass your certification exam!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


You're using a Pub/Sub topic to publish disparate messages from an on-premises application. You're looking for a simple way to run some code every time a message is published. What is the simplest, lowest cost, and most CPU friendly solution?

  1. Use a scheduled task that starts an App Engine application to poll for changes.

  2. Use a scheduled Cloud Function to check the queue every minute.

  3. Deploy code to Compute Engine that polls for messages.

  4. Have Pub/Sub push messages to a Cloud Function.

The correct answer is: Have Pub/Sub push messages to a Cloud Function.

The option of having Pub/Sub push messages to a Cloud Function is the most straightforward and efficient approach for triggering code with each message published. This method promotes a serverless architecture, meaning you don't have to manage infrastructure or worry about provisioning and scaling resources. When a message is published to the Pub/Sub topic, it automatically triggers the Cloud Function, which runs in response to the event. This setup means you only pay for the execution time of the function when a message is received, making it both cost-effective and CPU-friendly. The serverless nature of Cloud Functions allows you to focus on writing your code rather than managing resources, and it can scale based on the number of incoming messages. The other options involve polling, which can incur unnecessary costs and increased CPU usage due to constant checking of the queue, even when there are no messages. This polling approach can lead to latency in processing messages as well, whereas using the push mechanism allows for real-time processing as messages arrive.