Contents
Constraints
- 50 data scientists
- 100 production models
- real-time p99 budget 50 ms for payment-path models
- hundreds of features shared across teams
What to cover
Sketch your own design first. A complete answer has these parts; the notes say what each should settle.
- RequirementsDesign the internal platform that lets data scientists take a model from notebook to batch and real-time production safely, inside a regulated bank whose production stack is mostly Go microservices.
- Estimates50 data scientists; 100 production models; real-time p99 budget 50 ms for payment-path models; hundreds of features shared across teams.
- API
- Data model
- ArchitectureMonorepo with dataset-creation and training jobs; managed training compute.; Model registry with validation status and lineage.; Feature definitions in SQL (e.g. dbt) materialised offline in the warehouse and synced to an online KV store.; Batch inference via a scheduler (e.g. Airflow) publishing events; real-time Python inference services behind a Go gateway.; Monitoring for systems, features (data tests and freshness alerts) and model performance.; Approval workflow for model risk; self-serve templates.
- Deep dives
- Trade-offsbuild vs buy (Vertex/SageMaker vs custom); framework freedom vs standardisation; a Python model service inside a Go ecosystem; one-off pipelines vs a shared feature store.
- EvaluationPlatform metrics: time from notebook to production, number of incidents attributable to the platform, feature reuse rate, p99 inference latency, cost per model.; User satisfaction surveys.
Reference design
One way to answer it, part by part. Open a part once you have your own version of it.
Requirements
Functional: a paved road from notebook to production for both batch and real-time models — reproducible dataset creation and training, shared feature definitions usable offline and online, a model registry with validation status and lineage, deployment (shadow, canary, live) into a Go microservice estate, monitoring, and a model-risk approval workflow.
Users: ~50 data scientists who know Python and SQL, not Go or Kubernetes; backend engineers who call models from Go services; model-risk and compliance reviewers.
Constraints
- Regulated bank: auditable lineage (which data and code produced which model and decision), approvals proportional to risk (payment and credit decisions vs internal analytics), PRA model risk management expectations, Consumer Duty, explainability where customers are affected.
- Real-time p99 ≤ 50 ms for payment-path models, including feature lookup.
- ~100 production models, hundreds of shared features.
- Existing stack (assumption): GCP, BigQuery, dbt, Airflow, Cassandra, Go microservices, an event bus, Grafana and Looker.
Success: time from notebook to production falls from months to weeks for standard models; fewer incidents; features reused rather than rebuilt.
Estimates
- Models: ~100 in production, say 70 batch and 30 real-time; ~10 new or retrained models per week across teams.
- Real-time traffic: payment-path models see ~1k requests/s at peak (card authorisations, transfers); other real-time models (chat routing, fraud on logins) a few hundred requests/s combined.
- Online features: 10M customers × ~300 features × ~8 bytes ≈ 24 GB of values, ~100 GB with replication and overhead — small for Cassandra; read path p99 5–10 ms for a single-partition lookup.
- Batch: ~70 Airflow DAGs nightly; BigQuery scans of a few TB/day for feature materialisation; predictions written back to BigQuery and published as events.
- Latency budget (payment path, p99 50 ms): Go service → gateway 2 ms, feature fetch (one partition read) 10 ms, model inference (GBDT) 5 ms, serialisation and network 5 ms, gateway checks and logging 3 ms → ~25 ms, leaving ~25 ms headroom for tails and retries; a fallback default decision if the model does not answer within ~40 ms.
- Training compute: most bank models are GBDTs or small networks trained on CPU in minutes to hours; occasional GPU jobs (text models) on a managed queue.
- Platform team: ~6–8 engineers can run this if most components are managed services.
API
The platform’s interfaces are mostly declarative files and CLIs:
# features/customer_spend.yml (dbt model + metadata)
entity: customer_id
owner: fincrime-ds
freshness_sla: 1h
online: true
features: [spend_7d, spend_30d, distinct_merchants_30d]
ml train --config train.yml # dataset snapshot + training job, logs lineage
ml register --run r_123 --risk-tier 1 # → registry entry, status "draft"
ml validate --model fraud-auth:v12 # standard checks + validation report
ml deploy --model fraud-auth:v12 --mode shadow|canary:5%|live
Serving contract for Go callers (protobuf over gRPC via the gateway):
Predict(model: "fraud-auth", entity_ids, request_features) → {score, version, reason_codes, latency_ms}
Batch outputs: BigQuery table per model plus an event prediction.published for downstream services.
Data model
- FeatureDefinition: name, entity, SQL/dbt model, owner, version, freshness SLA, online flag, data classification, tests.
- FeatureValue (online): Cassandra partition per entity → feature values with event timestamps.
- DatasetSnapshot: query, as-of time, feature versions, row counts, storage URI, hash — point-in-time correct joins.
- Model: name, version, artefact URI, framework, training code commit, dataset snapshot, feature list and versions, metrics, risk tier, owner, intended use, limitations.
- ValidationRecord: checks run (performance, stability, bias, explainability), validator, findings, status (draft → validated → approved → deployed → retired).
- Deployment: model version, environment, mode (shadow | canary | live), traffic share, start/end, rollback reference.
- PredictionLog: request id, model version, feature values used, output, latency — basis for audit and for training on logged features.
- MonitorConfig: metrics, thresholds, owners, escalation.
Architecture
Flow · 4 stepsNotebook to production: batch and real-time
- Build and train Dataset and training code live in the monorepo; CI runs tests, lint and data checks, then managed training compute trains the model.
- Register and approve The run is registered with lineage and validation status, then passes the risk-tier approval workflow before deployment.
- Serve Batch models score via the Airflow DAG into BigQuery and an event; real-time models pass through the Go gateway to the Python service, which reads Cassandra.
- Monitor Systems, features and model performance are monitored across both serving paths.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Build and train | Dataset and training code live in the monorepo; CI runs tests, lint and data checks, then managed training compute trains the model. |
| 2 | Register and approve | The run is registered with lineage and validation status, then passes the risk-tier approval workflow before deployment. |
| 3 | Serve | Batch models score via the Airflow DAG into BigQuery and an event; real-time models pass through the Go gateway to the Python service, which reads Cassandra. |
| 4 | Monitor | Systems, features and model performance are monitored across both serving paths. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| Monorepo | Build | from notebook: dataset + training code |
| CI | Build | tests, lint, data checks |
| Managed training compute | Build | Kubernetes / Vertex |
| Model registry | Governance | artefact, lineage, validation status, risk tier |
| Approval workflow | Governance | tier 1 sign-off; tier 3 self-approval |
| Deploy | Governance | shadow | canary | live |
| Batch scoring | Serving | Airflow DAG: BigQuery table + event |
| Go gateway | Serving | auth, timeouts, circuit breaker, fallback |
| Python model service | Serving | template, autoscaled |
| Cassandra | Serving | online features, one partition per entity |
| Feature store | Build | dbt SQL in BigQuery, synced to Cassandra |
| Monitoring | Observe | Grafana, dbt tests, Looker |
Source: This page's text
Stack · 5 layersOne feature definition, offline and online
dbt SQL plus metadata: entity, owner, freshness SLA, online flag, features.
dbt SQL in BigQuery, point-in-time joins for datasets.
Sync job to Cassandra; Go stream processors for payment path, backfilled offline with the same definitions.
Cassandra partition per entity, feature values with event timestamps.
Daily tests compare offline and online values on sampled entities.
Monorepo (dataset + training code, templates) ─► CI (tests, lint, data checks)
─► Managed training compute (jobs on Kubernetes / Vertex)
─► Model registry: artefact, lineage, validation status, risk tier
─► Approval workflow (tier 1: independent validation + sign-off;
tier 3: owner self-approval with automated checks)
Features: dbt SQL in BigQuery (offline, point-in-time) ─► sync job ─► Cassandra (online)
streaming features for payment path: Go stream processors writing
to Cassandra, backfilled offline with the same definitions
Serving:
batch ─► Airflow DAG template: score in BigQuery/Python ─► table + events
real time ─► Go gateway (auth, timeouts, circuit breaker, schema checks,
fallback default, logging) ─► Python model service (template,
autoscaled) ─► Cassandra features
Monitoring: systems (Grafana), features (dbt tests/alerts), model performance
and drift (Looker dashboards on prediction logs + labels), on-call per modelDeep dives
Sequence · 4 stepsSafe deployment: shadow, canary, live
- Shadow Shadow scores real traffic and logs only; the incumbent still serves.
- Compare Shadow output is compared with the incumbent on live data.
- Canary Canary sends a small traffic share; alarms trigger automatic rollback.
- Live Live serves full traffic; every deploy and rollback is recorded against the registry entry.
Data
| Step | From | To | Message |
|---|---|---|---|
| 1 | Data scientist | Model registry | ml deploy --mode shadow |
| 1 | Go gateway | Python model service | score (log only) |
| 2 | Python model service | Monitoring | log predictions |
| 2 | Monitoring | Data scientist | comparison report (reply) |
| 3 | Data scientist | Model registry | ml deploy --mode canary:5% |
| 3 | Go gateway | Python model service | canary traffic |
| 3 | Monitoring | Go gateway | rollback on alarm |
| 4 | Data scientist | Model registry | ml deploy --mode live |
| 4 | Go gateway | Python model service | full traffic |
Source: This page's text
Training–serving skew. The most common real-time failure: a feature computed one way in SQL for training and another way in Go for serving. Mitigations: one definition per feature with tests comparing offline and online values on sampled entities daily; log the features actually used at serving time and train new versions on those logs where possible; point-in-time joins for offline datasets so no future data leaks in.
Python models inside a Go estate. Data scientists keep Python; the Go gateway owns everything operational (auth, deadlines, retries, circuit breaking, fallbacks, typed protobuf contracts), so Go services never depend on Python internals. For the strictest latency paths, GBDTs can be compiled (e.g. ONNX or a tree compiler) and served natively from Go, trading framework freedom for a removed network hop.
Safe deployment. Shadow first (score real traffic, log only), compare with the incumbent on live data, then canary with automatic rollback on latency or score-distribution alarms, then live. Every deploy and rollback is one command and is recorded against the registry entry for audit.
Trade-offs
- Build vs buy (Vertex/SageMaker vs custom): managed services reduce platform toil but fit awkwardly with a Go estate, an existing Cassandra store and bank-specific approvals. Buy commodity parts (training compute, experiment tracking), build the thin glue the bank’s constraints require.
- Framework freedom vs standardisation: freedom speeds research; standard templates (GBDT and PyTorch serving images, one feature API) make 100 models operable by a small team. Allow anything in research, require a template for production.
- A Python model service inside a Go ecosystem: Python keeps data scientists productive but adds a hop and a second runtime to operate; contain it behind the gateway, and compile models to native code where latency demands.
- One-off pipelines vs a shared feature store: one-off pipelines ship faster for the first model and then duplicate, drift and break; a shared store costs governance effort but gives reuse, consistency and lineage.
Evaluation
- Platform metrics: median time from notebook to production per model type; number of incidents attributable to the platform (vs model logic); feature reuse rate (share of features used by more than one model); p99 inference latency per real-time model against its budget; cost per model (compute, storage, serving).
- Governance metrics: share of production models with complete lineage and current validation (target 100%), approval cycle time, overdue revalidations.
- Model health: drift and performance dashboards per model with owners; alerts on feature freshness, missing values, score distribution shifts, and outcome metrics once labels arrive.
- User satisfaction surveys: quarterly survey of data scientists and backend engineers (ease of deployment, debugging, documentation), plus support-ticket themes driving the platform roadmap.
What a strong design shows
- Designs the paved road end to end — features, training, registry, approvals, deployment, monitoring — around a Go estate and a regulated bank.
- Keeps one feature definition across offline and online paths and actively tests for training–serving skew.
- Proportions model-risk approvals to risk tier and records lineage for audit.
- Isolates Python serving behind a Go gateway with deadlines, fallbacks and typed contracts, meeting a 50 ms p99 budget.
- Measures the platform by time to production, incidents, reuse, latency and cost, plus user feedback.