Courseiva

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?

⚠ Common exam trap

GCDL often tests the difference between serverless compute options (Cloud Functions vs. Cloud Run vs. App Engine) and when to choose each based on frequency, duration, and management overhead, causing candidates to overlook the cost benefits of scaling to zero.

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 the most cost-effective and simple option for infrequent, short-running event-driven code. It automatically scales to zero when not in use, so you only pay for actual execution time and resources consumed. It integrates natively with Pub/Sub and Firestore, requiring minimal configuration.

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

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

One of 848 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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Google Cloud exam blueprint

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.