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.
| What | Who turns it on | Why |
|---|---|---|
| The lookup gateway | the ML team: lookup.mode: gateway | an endpoint cannot reach into your network, so something inside it must fetch the features |
| Private endpoints in Terraform | the platform team | all infrastructure in one place; an endpoint that answers only inside your network |
| Model co-hosting | the platform declares a pool; the ML team opts in with model.serving.pool | several 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, to | Result |
|---|---|
| the lookup service (Cloud Run, internal) | refused: internal ingress turns away a caller from outside the network |
| Cloud SQL's private IP | timed out |
| the network's private address for Google APIs | timed out |
| public Google APIs, and the internet | reachable |
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:
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:
| Path | p50 | p95 |
|---|---|---|
| Gateway to a private endpoint, lookup included | 39 ms | 52 ms |
| Gateway to a standard endpoint, lookup included | 93 ms | 115 ms |
| The Cloud SQL lookup alone | 23 ms | 31 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_TRAFFICinonline_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.invokeron 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.
| Item | Governance | Security | Cost |
|---|---|---|---|
| Private endpoint | in Terraform, reviewed as code | inside 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 subnet | one per network | addresses only in that subnet | free |
| Private DNS zone | one per network | names resolve only inside it | about $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 allows | What Pipewright does |
|---|---|
| Google's prebuilt TensorFlow or PyTorch (Preview) serving image only, one per pool | refuses 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's | refuses container settings on a pool model: its settings travel with its files |
| A pool serves standard or private endpoints, not both | refuses a use case whose endpoint is the other kind |
| No scale to zero | shows 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 change | Calls to the other models that failed |
|---|---|
| 1 machine | 557 of 9,980: about 50 seconds of near-total failure per change |
| 2 machines | 419 of 6,782: about half the calls, one window per machine |
| 2 machines, callers through the gateway | 1 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.