Manual / Serving

Serving: the lookup gateway, private endpoints and co-hosting

Pipewright 1.4.2 adds three things to how a model is served, each off until someone turns it on. A use case that sets none of them deploys exactly as before: pipewright deploy-model creates its endpoint and deploys the model on its own machines. For what 1.4.3 adds on top, see Serving health and live quality and A/B testing, where the gateway is also the router.

WhatWho turns it onWhy
The lookup gatewaythe ML team: lookup.mode: gatewayan endpoint cannot reach into your network, so something inside it must fetch the features
Private endpoints in Terraformthe platform teamall infrastructure in one place; an endpoint that answers only inside your network
Model co-hostingthe platform declares a pool; the ML team opts in with model.serving.poolseveral small models share machines instead of paying for one each

The lookup gateway: why Pipewright built it

Online features live in a store. BigQuery and Bigtable are Google APIs: a model on an Agent Platform endpoint reaches them over Google's network with its own identity. Cloud SQL on a private IP, or a store your team runs, lives inside your network, and a model on an endpoint cannot reach it. We checked this live from inside a standard and a private endpoint:

From inside the endpoint, toResult
the lookup service (Cloud Run, internal)refused: internal ingress turns away a caller from outside the network
Cloud SQL's private IPtimed out
the network's private address for Google APIstimed out
public Google APIs, and the internetreachable

Google's documentation agrees: a Private Service Connect endpoint is private for callers coming in, and private egress from within the endpoint is not supported. Moving the store's service to GKE, instance groups or Cloud Run functions changes nothing: they all sit inside the network. Opening the store or the lookup service to the internet was ruled out.

So Pipewright turns the call around. Your caller sends entity IDs to Pipewright's lookup service inside the network. The gateway reads the features and calls the endpoint itself:

YOUR NETWORK GOOGLE-MANAGED Calleran app, an agent, a job entity IDs + ID token The lookup gateway 1. checks the caller, logs who called2. reads the features3. calls the endpoint, retries if busy Cloud SQL, oryour own store Private endpointan address in your subnet The model'smachines no way backinto the network

What it gives you

  • Private end to end. The caller, the store and the endpoint stay inside your network, with IAM at every hop.
  • Who called. Each request is logged with the caller's identity, the use case, the model version and counts, never an ID or a feature value. Fleet View shows each use case's callers (Enterprise).
  • Retries. A prediction is safe to repeat, so the gateway retries a busy endpoint: three more tries, 0.25 to 2 seconds apart.
  • Your canary still works. The traffic split stays on the endpoint: a 90/10 split through the gateway served 92/8 of 100 calls.
  • Fast. Measured from inside the network, four entities a call:
Pathp50p95
Gateway to a private endpoint, lookup included39 ms52 ms
Gateway to a standard endpoint, lookup included93 ms115 ms
The Cloud SQL lookup alone23 ms31 ms

Turning it on

model:
  serving:
    features: online
    online_store:
      type: cloudsql               # or http: your own lookup service (below)
      lookup:
        mode: gateway              # default lookup: the endpoint calls the lookup service itself
        callers:                   # who may call the gateway; required
          - serviceAccount:checkout-app@acme-prod.iam.gserviceaccount.com
        # retries: 3               # default; 0 turns them off

deploy-model creates the endpoint, then the lookup service with the gateway, which predicts with a predict-only grant the platform gives it. Your callers, not the endpoint, may call the service:

curl -X POST "$GATEWAY_URL/predict" -H "Authorization: Bearer $(gcloud auth print-identity-token)" \
  -H "Content-Type: application/json" -d '{"entity_ids": ["c-1", "c-2"]}'
# {"predictions": {"c-1": 0.81, "c-2": 0.12}, "not_found": [], "deployed_model": "...", "model_version": "3"}

An entity the store does not have is listed in not_found and never scored. The model receives rows in its feature order, so its serving code needs no store settings.

The Pipewright custom solution: the gateway in front of your own store

Many teams run their own lookup service, fed from Pipewright's Parquet export or a store they already have. Inside a private network an endpoint cannot reach it either. With type: http and mode: gateway, Pipewright's gateway sits in front of it. You build the store; Pipewright brings the private path, the caller log, the retries and the canary.

online_store:
  type: http
  http: { url: "https://features.internal.example.com" }   # answers POST /lookup
  lookup:
    mode: gateway
    callers: [serviceAccount:checkout-app@acme-prod.iam.gserviceaccount.com]

Your service answers POST /lookup {"entity_ids": [...]} with {"features": {id: {name: value}}}, the same contract as type: http.

Reaching your store (1.4.2):

  • A store on Cloud Run with internal ingress: the gateway must send its traffic through the network. Enterprise does this already; in the starter set lookup.egress: ALL_TRAFFIC in online_store.yaml (the default, PRIVATE_RANGES_ONLY, reaches the store at its public address, which internal ingress refuses with a 404).
  • Permission to call it: when your store is a Cloud Run service in the environment’s project and region, the launcher adds the tenant’s lookup identity as run.invoker on it, changing nothing else in its policy. A store anywhere else is yours to open to that identity.
  • Feeding it: the Parquet export on a schedule, with readers the platform grants. A tenant behind the gateway also needs a Cloud SQL tenancy in the starter today: its network and lookup identity come from there.

The lookup service’s life (1.4.2)

deploy-model asks the launcher to create or update the lookup service from the live release. deploy-model --undeploy now asks it to remove the service too, so warm instances stop billing and the network can be torn down; --keep-lookup-service keeps it. Before a replaced or abandoned version is undeployed, Pipewright waits model.serving.drain_seconds (240) so calls in flight finish.

Private endpoints in Terraform

The platform lists the use cases whose endpoint Terraform creates, in the starter's serving.yaml or Enterprise's platform file (where private is the default):

endpoints:
  churn: { tenant: churn, private: true }
private:
  subnet: 10.61.0.0/28

Terraform creates churn-endpoint and, for a private one, everything it needs to answer at a name inside your network: a service connection policy so Agent Platform makes the endpoint's address in your subnet, and a private DNS zone. Terraform ignores the models on it: deploy-model still deploys them with the machine type and replicas from your CI/CD, and never creates an endpoint for a use case listed here.

ItemGovernanceSecurityCost
Private endpointin Terraform, reviewed as codeinside the network only; IAM predict$0.01 an hour (about $7.30 a month) plus $0.004 to $0.01 per GiB
Service connection policy and subnetone per networkaddresses only in that subnetfree
Private DNS zoneone per networknames resolve only inside itabout $0.20 a month

Model co-hosting on shared pools

Only when your team asks for it. A pool is a set of machines several models share:

# the platform
pools:
  churn-shared:
    tenant: churn
    machine: n1-standard-4
    min_replicas: 2
    max_replicas: 3
    image: europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-15:latest
    network: psc

# your use case
model:
  serving:
    pool: churn-shared             # leave it out to deploy on your own machines

pipewright serving pools plan shows what would change and what each pool costs; apply creates and resizes pools from CI/CD; list shows the use cases on each.

What Agent Platform allowsWhat Pipewright does
Google's prebuilt TensorFlow or PyTorch (Preview) serving image only, one per poolrefuses any other image. Your own serving image stays on dedicated machines (or KServe on GKE)
One model server per machine loads every model; container settings are the pool'srefuses container settings on a pool model: its settings travel with its files
A pool serves standard or private endpoints, not bothrefuses a use case whose endpoint is the other kind
No scale to zeroshows the standing cost before you turn it on

What a change to a pool does to its neighbours

Every deploy, undeploy or resize restarts all the pool's machines, sometimes minutes after Google reports the change done. We measured what the other models saw:

Pool during a changeCalls to the other models that failed
1 machine557 of 9,980: about 50 seconds of near-total failure per change
2 machines419 of 6,782: about half the calls, one window per machine
2 machines, callers through the gateway1 of 4,629

So Pipewright keeps at least two machines on a pool in production, makes changes to a pool one at a time, announces each one to every team on the pool, and waits for the machines to settle before the next change runs. Ten small models on their own n1-standard-2 cost about $1,147 a month; on one n1-standard-4 pool with two machines, about $458, if they fit in its memory.

Lookups on GKE

KServe on private GKE calls a lookup service inside the cluster directly. The repository has a guideline and a tested manifest: examples/gke-lookup/.

The full reference, with every key, check and grant, is docs/SERVING.md in the repository.