Online feature stores
An endpoint with online features takes an entity ID, such as a customer ID, and reads that entity's latest feature values before it scores. Those values live in an online store. Until now there was one, Bigtable, at about $781 a month per node whether anyone calls it or not. You can now choose a store that fits your traffic and budget, or build your own.
Choosing a store
| Store | A lookup, end to end | Standing cost a month | Choose it when |
|---|---|---|---|
bigtable (default) | about 12 ms | about $781 per node | high traffic, tight latency, large data |
cloudsql | about 3 ms direct; about 12 ms through Pipewright's lookup service | about $61 (1 vCPU), plus about $14 per warm lookup instance | milliseconds on a budget |
bigquery with BI Engine | about 200 ms | about $38 per GiB reserved; no copy of the data | about 200 ms is fine and traffic is modest |
http | yours | yours | you run a store already, or want one Pipewright does not offer |
Measured live in europe-west2 on 1M entities; costs are Google's list prices for London before discounts. Your offline features stay in BigQuery: training and batch scoring read them point in time as before. Nothing changes until a use case sets model.serving.online_store.
How the YAML fits together
| What | Where | Who |
|---|---|---|
| Which store a use case uses, its schema and table, the lookup service's size, the sync, the export | model.serving.online_store in your use case, overridable per environment | the ML team |
| Which stores an environment offers, the Cloud SQL instance's size, BI Engine, the lookup service's defaults, limits and warm-instance floor | the starter's online_store.yaml, or Enterprise's platform file | the platform team (one instance serves every team: change it by pull request) |
A use case, with every key and its default:
model:
serving:
enabled: true
features: online # the endpoint takes entity IDs
online_store:
type: cloudsql # bigtable (default) | bigquery | cloudsql | http
cloudsql:
schema: public # give your team its own schema in a shared instance
table: pw_online_<usecase>
lookup:
provider: pipewright # or own: you decide what sits between endpoint and database
cpu: 1 # 1, 2, 4, 6 or 8 vCPU
memory: 512Mi # up to 4Gi per vCPU
min_instances: 0 # warm instances (the environment's default and floor apply)
max_instances: 5
concurrency: 80
pool_size: 8 # database connections per instance
timeout_ms: 1000
cpu_boost: true # shorter cold starts
billing: request # or instance: CPU always allocated
sync: { mode: full } # or changed: only rows whose values changed
export: { enabled: false, keep: 3, readers: [] }
triggers:
schedules:
- { name: online, cron: "0 * * * *", timezone: Europe/London, pipeline: online_sync }
pipewright validate checks every size against what Cloud Run and Cloud SQL support and against your environment's limits, naming the key and what is allowed. pipewright doctor shows the store, its standing cost and its last sync before anyone relies on it.
The toggles
| Toggle | Default | On means |
|---|---|---|
online_store.type | bigtable | another store serves this use case |
lookup.provider | pipewright | own: Pipewright syncs the table and grants your reader; you choose what sits in between (a service on GKE, your own Cloud Run, anything) |
lookup.min_instances | 0 | instances kept warm so callers do not wait for a cold start (best effort: 2 keeps a spare) |
lookup.cpu_boost | true | shorter cold starts |
lookup.billing | request | instance: cheaper only for steady high traffic |
sync.mode | full | changed: only changed rows are written |
export.enabled | false | each generation published as Parquet with a manifest, for a store you build |
export.readers | none | the identities that load it (name@... or serviceAccount:name@..., 1.4.2); the platform grants them |
BigQuery, and why plain BigQuery is never used online
Without BI Engine, a lookup scans the whole table: 245 MiB billed per lookup at 1M entities x 30 features, about $0.0018, at about 290 ms. A thousand lookups an hour is about $1,300 a month. Pipewright refuses type: bigquery without a BI Engine reservation.
With BI Engine, lookups are served from memory and billed 0 bytes, at about 200 ms end to end.
After each sync replaces the table, BI Engine reloads it. In our test lookups ran unaccelerated for 8 to 10 minutes after a refresh of 1M rows, each billed as a full table read: about $15 per refresh at 50 lookups a second. A byte cap cannot guard this, because BigQuery checks it before BI Engine is asked and refuses even lookups BI Engine would serve. Pipewright alerts instead (online.billed). Refresh rarely and away from peak traffic.
Cloud SQL
One PostgreSQL instance per environment, a schema per team. About 3 ms a lookup inside the network; through Pipewright's lookup service about 12 ms, of which the service is 5 to 7 ms. One vCPU served about 800 lookups a second with p99 under 20 ms.
| Instance setting | Default | Allowed |
|---|---|---|
tier | db-custom-1-3840 (about $61) | db-f1-micro (about $11, tests only), db-g1-small (about $33), db-custom-<vCPU>-<MB>, db-custom-N4-<vCPU>-<MB>; Enterprise Plus: db-perf-optimized-N-<n> (from about $221), db-c4a-highmem-<n>, db-perf-optimized-C4-<n> |
edition | enterprise | enterprise_plus (always written out: PostgreSQL 16 defaults to it) |
availability | zonal | regional: high availability, about twice the compute |
disk | SSD, 10 GB | SSD, HDD (Enterprise), Hyperdisk (N4, C4, C4A); can only grow |
- Private IP, SSL verified, IAM login. No password user exists: every identity logs in with its own token, and the lookup service checks the database's certificate.
- A schema per team. The sync runs as your team's runner and owns what it creates; Pipewright refuses to write a table another team owns, and
doctorwarns aboutpublicin a shared instance. - The lookup service. One Cloud Run service per use case,
pwl-<tenant>-<usecase>, created by the launcher atdeploy-model: your tenant's lookup identity, internal ingress, private egress, a bounded connection pool, your endpoint as its only caller. - Cold starts.
min_instances: 1keeps one instance warm (about $14 a month);cpu_boostshortens the rest.
The sync, step by step
- One query reads each source's newest row per entity at or before now, joined on the entity key.
- A free extract writes Parquet, with a manifest: each file's SHA-256, the row count, schema, entity key, as-of time and your feature contract's version.
- COPY into a staging table, never the live one, so lookups never see half a load.
- Checks: the row count must equal the manifest's, or nothing is swapped; then the key is indexed and readers granted.
- One transaction renames staging into place, with a lock timeout and retries: 3 to 14 ms in our tests, and no lookup failed.
- A record: a
_pipewright_syncrow, a sync record fordoctorand the watch, anonline.syncedevent;online.staleafter 48 hours without one.
The launcher's scheduler starts it; it runs as your runner inside the network. On one vCPU a full load of 1M rows raised lookup latency for about a minute: use sync.mode: changed, 2 vCPUs, or off-peak schedules.
Building your own store from the Parquet export
Turn on export.enabled and each sync publishes a generation under gs://<artifacts bucket>/online-export/<tenant>/<usecase>/<generation>/: the Parquet files and manifest.json. Generations are never rewritten; the last keep are kept.
Publishing on a schedule, and who may read it (1.4.2)
# the use case
model:
serving:
online_store:
type: http
http: { url: "https://team-store-abc123-nw.a.run.app" }
export: { enabled: true, readers: [team-store@acme-ml-prod.iam.gserviceaccount.com] }
triggers:
schedules:
- { name: export, cron: "0 3 * * *", timezone: Europe/London, pipeline: online_sync }
# the platform: online_store.yaml (starter) or spec.features.online_store (Enterprise)
export_readers:
churn: [team-store@acme-ml-prod.iam.gserviceaccount.com]
- An
online_syncschedule on anhttpstore with the export on publishes a new generation; nothing is loaded into a Pipewright store. - The platform’s
export_readersgrants each reader read access toonline-export/<tenant>/only (listing included), never the rest of the bucket, and gives the tenant the sync job the schedule runs. Readers outside an Enterprise perimeter also need an ingress rule. validatewarns about a reader in the use case that the platform has not granted, before your store meets a 403.
The pattern we recommend for the loader, from what our own sync does:
- Check each file's SHA-256 and the row count against the manifest before you trust a load.
- Load beside what callers read, check, then switch in one step: a rename, a view, an alias.
- Check every write: a batch API answered 200 in our test while about 4% of its writes failed.
- Load only what changed where writes are charged one by one.
- Log in as an identity, never with a password; bound your connection pool; keep HTTPS connections alive.
- Keep the last good generation; record which generation and contract version you loaded; alert on freshness.
Plug it back into serving with type: http: answer POST /lookup {"entity_ids": [...]} with {"features": {id: {name: value}}}. Pipewright checks names and types, fills missing values as training did, and times out as configured. What happens inside your store is yours.
The full guide, with every grant each identity needs, is ONLINE_STORES.md.