nerdexam
Google

PROFESSIONAL-MACHINE-LEARNING-ENGINEER · Question #230

Your company manages an ecommerce website. You developed an ML model that recommends additional products to users in near real time based on items currently in the user's cart. The workflow will…

The correct answer is A. Write a Cloud Function that loads the model into memory for prediction. Configure the function to. To achieve near real-time predictions with minimal latency and model update effort for an e-commerce recommendations model, a Cloud Function configured to load the model into memory and triggered by Pub/Sub is highly efficient.

Submitted by the_admin· Apr 18, 2026ML pipeline operationalization

Question

Your company manages an ecommerce website. You developed an ML model that recommends additional products to users in near real time based on items currently in the user's cart. The workflow will include the following processes: 1. The website will send a Pub/Sub message with the relevant data and then receive a message with the prediction from Pub/Sub 2. Predictions will be stored in BigQuery 3. The model will be stored in a Cloud Storage bucket and will be updated frequently You want to minimize prediction latency and the effort required to update the model. How should you reconfigure the architecture?

Options

  • AWrite a Cloud Function that loads the model into memory for prediction. Configure the function to
  • BCreate a pipeline in Vertex AI Pipelines that performs preprocessing, prediction, and
  • CExpose the model as a Vertex AI endpoint. Write a custom DoFn in a Dataflow job that calls the
  • DUse the RunInference API with WatchFilePattern in a Dataflow job that wraps around the model

How the community answered

(48 responses)
  • A
    83% (40)
  • B
    10% (5)
  • C
    2% (1)
  • D
    4% (2)

Why each option

To achieve near real-time predictions with minimal latency and model update effort for an e-commerce recommendations model, a Cloud Function configured to load the model into memory and triggered by Pub/Sub is highly efficient.

AWrite a Cloud Function that loads the model into memory for prediction. Configure the function toCorrect

Cloud Functions are ideal for event-driven, low-latency, real-time prediction scenarios, as they can load the model into memory for warm instances, reducing prediction latency. They are easily triggered by Pub/Sub messages and support seamless model updates via function deployment, minimizing operational effort.

BCreate a pipeline in Vertex AI Pipelines that performs preprocessing, prediction, and

A Vertex AI Pipeline is for orchestrating ML workflows (training, evaluation), not typically for low-latency, real-time online inference serving.

CExpose the model as a Vertex AI endpoint. Write a custom DoFn in a Dataflow job that calls the

While a Vertex AI Endpoint is suitable for real-time predictions, using a Dataflow job to call it would introduce unnecessary overhead and complexity for single-item, event-driven predictions, potentially increasing latency.

DUse the RunInference API with WatchFilePattern in a Dataflow job that wraps around the model

The RunInference API with WatchFilePattern in a Dataflow job is primarily for batch or streaming inference, adding significant overhead and latency compared to a direct serverless function for near real-time, single-item predictions.

Concept tested: Serverless real-time inference with Cloud Functions

Source: https://cloud.google.com/functions/docs/tutorials/calling-pubsub

Topics

#Real-time Inference#Model Serving#Serverless ML#MLOps

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-MACHINE-LEARNING-ENGINEER Practice