Cloud Digital Leader Google Cloud Products and Services Practice Question
A developer needs to run a small piece of Python code that processes a message from Pub/Sub and stores the result in Firestore. The code runs infrequently (a few hundred times per day) and takes less than a second to execute. Which compute service is most cost-effective and simple to manage?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Cloud Functions
Cloud Functions is serverless and event-driven, ideal for infrequent short-lived tasks triggered by Pub/Sub. It scales to zero and charges only per invocation. App Engine and Cloud Run require a container or runtime, and Compute Engine requires a running VM.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Cloud Functions
Why this is correct
Cloud Functions is the ideal fit because it is a managed Function-as-a-Service platform that executes code in response to a Pub/Sub event, scaling to zero when idle. It bills only for the actual invocation time, measured in 100ms increments, so a small Python snippet that runs once or twice undergoes no idle cost or container overhead. Its event-driven trigger model and built-in Pub/Sub subscription abstraction remove the need to run a web server or manage infrastructure, making it the most cost-effective and operationally simple choice for this task.
- ✗
Cloud Run
Why it's wrong here
Cloud Run is not the most cost-effective choice here because its billing model, based on container instance duration and CPU/memory usage, is less granularly optimised for extremely infrequent, sub-second executions than a function-as-a-service offering. It is tempting as it offers serverless container deployment and scales to zero, making it ideal for event-driven web services or APIs that might require custom runtime environments or have slightly longer, more consistent execution profiles.
- ✗
Compute Engine with preemptible VM
Why it's wrong here
Compute Engine, even when using preemptible VMs, bills for the time the virtual machine exists, not for the number of invocations of your code; you must provision and boot an instance, and you continue paying per-second (after a 1-minute minimum) even while it sits idle. For an infrequent, sub-second Python script, the orchestration and cost overhead are vastly higher than a FaaS alternative. Additionally, a preemptible VM can be terminated by Google at any time, adding availability risk that is unacceptable for a simple, quick task that could simply be triggered on-demand.
- ✗
App Engine Standard Environment
Why it's wrong here
App Engine Standard is a PaaS designed around the web application lifecycle: your code must implement an HTTP (or, for some runtimes, a push) handler, and a Pub/Sub subscription would need to be configured to deliver messages to an HTTP endpoint on your service. This forces a small Python snippet to be wrapped in a web server and deployed as an app, introducing unnecessary architectural complexity. While App Engine does scale to zero, its billing model and runtime constraints are optimised for persistent or request-driven services, not for a one-off utility triggered by a message bus.
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
Learn chapter
Cloud Digital Transformation
Key term
Container
A container is a lightweight, standalone software package that includes everything needed to run an application, such as code, runtime, system tools, and libraries.
Key term
Service
A service is a software component or system that performs a specific function and is available to be used by other programs or users over a network.
About these practice questions
One of 829 original GCDL practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This GCDL practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the GCDL exam.