How to Optimize Real-Time ML Prediction Latency on GCP?
Short answer
B Use a low latency database for the customers’ historic purchase behavior.
Question
Key Takeaways
Tests architectural understanding of serving bottlenecks, with the common trap being the assumption that BigQuery materialized views can efficiently handle dynamic, per-request joins for real-time inference.
This scenario evaluates strategies for reducing inference latency when combining transactional cart data with historical customer analytics. The community consensus strongly advocates migrating analytic data stores like BigQuery to low-latency NoSQL databases for online prediction serving.
Common mistake: Option D was frequently selected because materialized views accelerate repeated analytical queries, but they are ineffective here since they cannot precompute joins involving highly dynamic, session-specific cart items at prediction time.
Expert Analysis
BigQuery is fundamentally an OLAP system designed for analytical workloads, not low-latency singleton reads required during real-time inference. To minimize prediction latency, you must offload historical feature retrieval to a purpose-built online database like Cloud Bigtable, Firestore, or Memorystore. These services are optimized for fast key-value lookups and consistently deliver sub-millisecond response times under heavy concurrent traffic.
Why the Other Options Are Wrong
Attaching a GPU accelerates matrix multiplications during model training or inference but does nothing to resolve I/O bottlenecks caused by external data fetches. Deploying additional instances behind a load balancer increases throughput capacity but leaves the underlying data retrieval delay completely unchanged. Creating a materialized view in BigQuery precomputes static joins for reporting dashboards, but it cannot dynamically incorporate unpredictable, session-specific cart items during live checkout requests.
Community Comment Notes
Comment [1] directly cites Google’s official architecture documentation, which explicitly warns against using analytical data stores for real-time prediction serving. Comments [6] and [7] correctly identified that materialized views fail here because they cannot account for highly volatile cart data that changes per transaction. Comment [10] reinforced the optimal solution by recommending specialized low-latency stores like Bigtable or Memorystore for feature lookup pipelines.
Official Reference
This link opens the official vendor documentation in a new tab.
Exam Strategy
When optimizing real-time ML serving, always separate your analytics pipeline from your feature serving layer using purpose-built low-latency databases. Rely on precomputed features or offline joins only when the underlying data remains static between requests, and avoid routing live checkout traffic through analytical databases regardless of cluster scaling.
Community Votes
57% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 16 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 16
-
gscharly 👍 4 Answered Bhttps://cloud.google.com/architecture/minimizing-predictive-serving-latency-in-machine-learning#online_real-time_prediction "Analytical data stores such as BigQuery are not engineered for low-latency singleton read operations, where the result is a single row with many columns."
-
ddogg 👍 3 Answered DD. Create a materialized view in BigQuery with the necessary data for predictions. Here's why: Current bottleneck: Joining the cart data with the BigQuery table containing historic purchases likely creates the latency bottleneck. Fetching data from BigQuery on every prediction request can be slow. Materialized view: A materialized view pre-computes and stores the join between the cart data and the relevant historic purchase information in BigQuery. This eliminates the need for real-time joins during prediction, significantly reducing latency. Faster access: The pre-computed data in the materialized view is readily available within BigQuery, ensuring faster access for your serving pipeline when predicting the coupon offer. Lower cost: Compared to additional instances or GPU resources, a materialized view can be a more cost-effective solution, especially if prediction requests are frequent.
-
guilhermebutzke 👍 3 Answered BI changed my mind. B: Im read a lot this page https://cloud.google.com/architecture/minimizing-predictive-serving-latency-in-machine-learning#online_real-time_prediction If the web team is reporting that the model is returning predictions too slowly to load the coupon offer with the rest of the web page, it suggests that the bottleneck might indeed be in the inference process rather than in data retrieval or processing. Given that the model is deployed on Google Cloud, choosing a low-latency database makes it suitable for scenarios where quick access to data is crucial, such as real-time predictions for web applications. Option D: While pre-aggregating data in BigQuery can improve query speed, it might not be as efficient as a low-latency database for frequently accessed data like customer purchase history.
-
fitri001 👍 2 Answered DReduced Join Cost: Joining the customer's cart with their purchase history in BigQuery during each prediction can be slow. A materialized view pre-computes and stores the join results, eliminating the need for repetitive joins and significantly reducing latency. Targeted Data Access: Materialized views allow you to specify the exact columns needed for prediction, minimizing data transferred between BigQuery and your serving pipeline.
-
sonicclasps 👍 2 Answered DQueries that use materialized views are generally faster and consume fewer resources than queries that retrieve the same data only from the base tables. Materialized views can significantly improve the performance of workloads that have the characteristic of common and repeated queries.
Show 11 more comments
-
inc_dev_ml_001 👍 2 Answered BIn my opinion the materialized view could be the best way but it says that the cart data have to join with historic behaviour so it's impossibile to have all the needed data for the prediction in the materialized view because cart data are not in the database.
-
inc_dev_ml_001 👍 2 Answered BIt says that you have to join the cart data, so you can't use the materialized view because it means that you should materialize the view every time a new cart shows up. So use a low latency DB it's the only way
-
f084277 👍 2 Answered BUnclear how an MV would help retrieve a single row any faster. Something like BigTable (a low latency database) would be much faster.
-
DaleR 👍 2 Answered DKeep everything in BigQuery. Migrating to a fast database is more complex and can potentially introduce challenges.
-
guilhermebutzke 👍 1 Answered DFirstly, I believe the correct choice should be B. This is supported by a comprehensive Google page discussing methods to minimize real-time prediction latency. In this resource, they don't mention using a BigQuery view but instead suggest precomputing and lookup approaches to minimize prediction time. https://cloud.google.com/architecture/minimizing-predictive-serving-latency-in-machine-learning#online_real-time_prediction However, I will stick with option D because it's not clear whether option B suggests changing the entire database or just utilizing it as a preliminary step for online prediction.
-
SausageMuffins 👍 1 Answered DBoth B and D in theory does reduce latency but B implies that we might need to migrate the database to another low latency database. This migration and setup might incur additional costs and effort. In contrast, creating a materialized view seems much more straight forward since there is already a preexisting big query table mentioned in the question.
-
Ria_1989 👍 1Coupon to offer an ecommerce customer at checkout based on the items in their cart not the customer historic behaviour. That's creating confusion while choosing B.
-
vini123 👍 1 Answered BIf the primary issue is real-time access and speed, Option B is probably the better choice, as low-latency databases are built specifically for that purpose.
-
NamitSehgal 👍 1 Answered DMaterialized views directly address this bottleneck by pre-computing the join.
-
desertlotus1211 👍 1 Answered BYou want to use Bigtable, Firestore, or Memorystore, or maybe ReDIS
-
kalle_balle 👍 1 Answered BOption B seems most sensible.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All PMLE Questions
Access 65 questions with complete answers and detailed explanations.
View Full PMLE Practice Test →