Serving and scaling models · Topic 3 of 3

Scaling Online Serving with Endpoints and Features

Serve features from Feature Store, choose public or private endpoints and serving hardware, autoscale on throughput and tune models for production serving.

  • 5 min
In a nutshell
  • Feature views sync BigQuery features into an online store for low-latency reads.
  • Private Service Connect endpoints keep traffic off the public internet.
  • CPUs for small models, GPUs and TPUs for large ones, edge for offline and on-device.

What it is

An online model must answer every request within its latency target, whether traffic is ten requests a minute or thousands a second. Scaling online serving means fetching features fast, putting the endpoint on the right network, choosing hardware, letting replicas autoscale with throughput, and making the model itself cheaper to run.

RequestFeature lookuponline storeEndpointpublic or privateReplicasautoscale on loadResponsewithin latency target

How it works

Serving features with Feature Store

Many online models need history the request does not contain, such as "orders in the last 7 days". Agent Platform Feature Store serves these from an online store: a feature view syncs selected BigQuery features into it, and the app or serving code reads them by entity ID in milliseconds.

Online serving typeFits
Bigtable online servingThe recommended type; large data volumes, scheduled or continuous sync
Optimized online servingEmbedding management; deprecated, retiring in February 2027

Set the feature view's sync schedule to match how fresh the features must be. Training reads the same features from BigQuery, so both paths share one definition.

Public and private endpoints

EndpointReached throughChoose when
Public endpointThe internet, authenticated with IAMClients outside your network; simplest setup
Dedicated public endpointIts own public DNS name, isolated from other users' trafficProduction traffic that should be isolated from shared public serving
Private endpoint with Private Service ConnectAn internal IP in your VPCTraffic must stay off the public internet; access from several VPCs or on-premises
Private endpoint with VPC Network PeeringA peered VPC networkExisting private setups built on peering
Exam tip

"Prediction traffic must never cross the public internet" points to a private endpoint, usually through Private Service Connect. Add VPC Service Controls when data exfiltration is also a concern.

Choosing serving hardware

HardwareServe
CPUTree models, linear models, small neural networks; low cost per request
GPULarge deep learning models, image and video models, LLMs; best with batching
TPULarge models at high throughput, including LLM serving
EdgeModels exported to run on devices (for example AutoML image models exported for mobile) for offline use or very low latency

Measure latency and cost per 1,000 predictions on real traffic. A GPU that sits mostly idle costs more than several CPU replicas.

Scaling the serving backend

Agent Platform Inference scales each deployed model between a minimum and maximum replica count.

SettingEffect
min_replica_countReplicas always running: protects latency at sudden spikes, but costs money when idle
max_replica_countUpper bound: caps cost and protects quota
CPU utilization targetAdds replicas when average CPU use passes the target
Accelerator duty cycle targetScales GPU-served models on accelerator use
endpoint = model.deploy(
    machine_type="n1-standard-8",
    min_replica_count=2,
    max_replica_count=20,
    autoscaling_target_cpu_utilization=60,
)

New replicas take time to start, so autoscaling does not absorb an instant spike. Raise the minimum before a known peak.

Containerized serving optionScaling behaviour
GKEHorizontal Pod Autoscaler and cluster autoscaler; GPU and TPU node pools; full control of LLM servers
Cloud RunScales on concurrent requests, down to zero when idle; good for spiky, light traffic
Gemini and models as a serviceScaling handled by Google; Provisioned Throughput reserves capacity

Tuning models for production serving

TechniqueGainCost
Quantization (for example 8-bit)Smaller, faster modelSmall accuracy loss to measure
DistillationA small student model learns from a large teacherExtra training
Pruning or a smaller architectureLower latency and memoryPossible accuracy loss
Request batchingHigher throughput per GPUSlightly higher latency per request
Compiled or optimized runtimesFaster inference on the same hardwareCompatibility testing
Caching frequent predictionsSkips the model for repeat inputsStale results if inputs change meaning

Training choices matter too: a model trained with a simpler architecture or fewer features may meet accuracy targets and serve at a fraction of the cost.

A worked example

A payments company scores each card transaction in under 100 ms. Peaks are ten times the night-time load, and traffic must stay inside its network.

The engineer serves the model from a private endpoint through Private Service Connect. Customer history features come from a Bigtable online store. The deployed model runs on CPUs with a minimum of 4 replicas, a maximum of 40, and a CPU target, and the minimum is raised before the holiday peak. Quantization cut model latency by a third with no measurable accuracy loss.

Card swipePrivate endpointPrivate Service ConnectOnline storecustomer historyCPU replicas4 to 40Score in under 100 ms

How the exam asks about this

  • "Latency spikes when traffic suddenly rises at 9 am each day." Raise the minimum replica count before the known peak, as autoscaling takes time to add replicas.
  • "Online predictions need customer features computed from history with millisecond reads." Serve them from a Feature Store online store through a feature view.
  • "A GPU-served model is too slow and expensive; a small accuracy drop is acceptable." Quantize or distill the model.

What to remember for the exam

  • Feature views sync BigQuery features into an online store for low-latency reads.
  • Private Service Connect endpoints keep traffic off the public internet.
  • CPUs for small models, GPUs and TPUs for large ones, edge for offline and on-device.
  • Autoscaling runs between min and max replicas; set the minimum for known peaks.
  • Quantization, distillation and batching cut serving cost and latency.
Watch out

Setting the minimum replica count to the peak level fixes latency but pays for peak capacity all day. Use autoscaling and raise the minimum only around predictable peaks.

Common mistakes

Putting GPUs behind a small tabular model. CPUs are usually cheaper per prediction for tree and linear models.

Using a public endpoint for traffic that must stay private. IAM authentication does not keep packets off the internet; use a private endpoint.

Computing history features inside the request. Querying BigQuery per request is too slow; serve precomputed features from an online store.

Check yourself

  • How does Feature Store deliver features to an online model?

    A feature view syncs selected BigQuery features into an online store, and the app or model server reads them by entity ID at low latency.

  • Why can latency rise during a sudden spike even with autoscaling?

    New replicas need time to start, so requests queue until they are ready; a higher minimum replica count covers known peaks.

  • Which endpoint type keeps prediction traffic on internal IPs?

    A private endpoint, typically through Private Service Connect.

Topic 3 of 3 in Serving and scaling models

Test yourself on Serving and scaling models

The full Google Cloud Professional Machine Learning Engineer question bank has 749 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Google Cloud. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.