Interview's MateData Science
Interview's Mate

Data Science

Python → ML → MLOps

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Science topics
Lesson 152/ 160
08. MLOps & Model Deployment

Cloud ML Platforms (AWS SageMaker / GCP Vertex AI)

Train and host models on managed cloud ML platforms with shared infra patterns.

AdvancedManaged Training · Endpoints3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

SageMaker and Vertex AI are cloud services that let you train and host models without managing servers yourself, and you pay for the time the machines are running.

Think of it like…

Renting a fully equipped lab instead of building one. You bring the experiment (your code in a container) and samples (data); the lab supplies benches, power and technicians (compute, scaling, monitoring) and bills by the hour, so you must remember to turn the equipment off.

Where you’ve seen it

The team runs the churn model on SageMaker; the same design maps to Vertex AI. Training: a script and a pinned container image run as a training job on a managed instance, reading s3://ml-data/churn/v3/ and writing the model artifact and metrics to S3 (Vertex: a custom training job reading from GCS). The job runs with a least-privilege IAM role and in a private VPC. Cost control: a 10-hour GPU training job at an illustrative $3.00 per hour costs $30 on demand. With managed spot or preemptible capacity at about 70% off ($0.90 per hour) and checkpointing every 10 minutes so interruptions resume instead of restarting, the job takes roughly 15% longer (11.5 hours) and costs 11.5 × $0.90 = $10.35, a saving of about 65%. Hosting: a real-time endpoint on one ml.m5.xlarge instance at an illustrative $0.23 an hour costs 0.23 × 730 ≈ $168 a month whether or not it receives traffic, so low-volume models use serverless inference (pay per request, cold starts), asynchronous inference (queue plus autoscale-to-zero for big payloads) or batch transform for nightly scoring, and high-volume models use autoscaling endpoints with a minimum of two instances across zones. A pipeline (SageMaker Pipelines or Vertex Pipelines) runs validate → train → evaluate → register, and an approval step promotes the model in the registry. Model monitoring captures a sample of endpoint requests, compares it with a training baseline and raises alerts on drift. Governance: separate dev, staging and prod projects or accounts, budgets and alerts at 50/80/100% of monthly spend, tags for cost attribution, and a nightly job that deletes forgotten notebooks and endpoints. The team keeps the training code and container platform-agnostic (plain Python, MLflow-compatible tracking) so that moving between clouds is a matter of swapping the job launcher, not rewriting the model.

Words you’ll hear

Training job
A managed run that provisions compute, executes your container on data and exits.
Endpoint
A managed, autoscaled inference service for a deployed model.
Spot / preemptible capacity
Discounted compute that the provider can reclaim with short notice.
Pipeline
A managed workflow of steps such as validate, train, evaluate and register.

Visual diagram

Loading interactive diagram

Theory & deep dive

Components and how they map across clouds

Both platforms offer the same building blocks. Workspaces (SageMaker Studio, Vertex Workbench) for notebooks. Training: SageMaker Training Jobs and Vertex custom training run your container or script on managed instances, read data from S3 or GCS and write artifacts back, with distributed training, spot or preemptible options and hyperparameter tuning services. Registry: SageMaker Model Registry and Vertex Model Registry hold versions with metadata and approval status. Inference: real-time endpoints with autoscaling, serverless endpoints, asynchronous queues for large payloads and long runtimes, and batch jobs (SageMaker Batch Transform, Vertex batch prediction). Pipelines: SageMaker Pipelines and Vertex AI Pipelines orchestrate steps. Feature store, monitoring and explainability or bias tooling (SageMaker Feature Store, Model Monitor and Clarify; Vertex Feature Store, Model Monitoring and Explainable AI) round out the platform.

The shared design is stable: data in object storage, compute launched per job with a least-privilege IAM role and network controls, artifacts versioned in storage and a registry, deployment as an endpoint or batch job and logs and metrics in the cloud's monitoring service. Keeping your training code container-based and framework-standard (plain Python, ONNX or standard model formats, MLflow-compatible tracking) limits lock-in to the thin launcher layer. Use infrastructure as code (Terraform or CloudFormation) for roles, networks and endpoints so environments are reproducible.

Training job spec (conceptual)

image: ecr/churn-train:9be3c1; instance: 1 × GPU; input: s3://ml-data/churn/v3/; output: s3://ml-models/churn/run-0142/; role: ml-train-role (read data, write models only); spot: true; checkpoint: s3://ml-models/churn/run-0142/ckpt/ every 10 min; max runtime 14 h.

Key takeaway: Learn the shared pattern (storage, container job, registry, endpoint) and keep code portable behind a thin launcher.

Cost, scaling and governance

Cloud ML bills by instance-hour for notebooks, training and endpoints, so idle resources are the main waste. A real-time endpoint on one instance at an illustrative $0.23 an hour costs 0.23 × 730 ≈ $168 a month even with no traffic; use serverless or asynchronous inference for spiky or low-volume models, batch for scheduled scoring and autoscaling with a minimum of two instances in different zones for high-volume services. Training savings come from spot or preemptible capacity: a 10-hour job at $3.00 an hour is $30; at about 70% off ($0.90) with checkpointing every 10 minutes it runs about 15% longer (11.5 hours) for 11.5 × $0.90 = $10.35, saving roughly 65%. Right-size instances from measured utilisation, use smaller instances for development and shut down notebooks automatically.

Governance: separate development, staging and production environments with distinct roles; put data and endpoints in private networks; encrypt storage and artifacts; tag every resource with owner and project for cost allocation; set budgets and alerts (for example at 50%, 80% and 100% of monthly spend) and schedule cleanup of unused endpoints, notebooks and old artifacts. Monitoring: capture a sample of inference requests for drift and quality analysis and wire alarms to a channel someone watches. Weigh managed versus self-run (Kubernetes, KServe, Ray): managed platforms win on speed and operations for small teams; self-run wins on portability, cost at very large scale and custom needs, but needs platform engineers.

Spot arithmetic

On-demand: 10 h × $3.00 = $30.00. Spot at $0.90/h with 15% extra runtime from interruptions: 11.5 h × $0.90 = $10.35. Saving $19.65 = 65.5%. Without checkpointing, an interruption at hour 9 could restart the whole job and erase the savings.

Key takeaway: Control cost by avoiding idle endpoints, using spot with checkpoints and setting budgets, and keep environments governed.

How it works, step by step

Step 1 of 4
ML engineer

1. Stage data and permissions

Put versioned data in object storage and create a least-privilege role and private network for jobs.

s3://ml-data/churn/v3/ · ml-train-role
Key numbers at this step
Encrypt
storage

When to use it & trade-offs

What it is

AWS SageMaker and Google Cloud Vertex AI are managed platforms that cover the machine learning lifecycle: notebooks and workspaces, managed training jobs that start compute, run your container or script on data in object storage and shut down, hyperparameter tuning, model registry, endpoints for real-time, serverless, asynchronous and batch inference, pipelines for orchestration, a feature store, model monitoring and explainability or bias tools. Despite different names, they share one pattern: data in object storage (S3, GCS) → a training job in a container with an IAM role → a model artifact in storage → an endpoint or batch job, with logs and metrics sent to the cloud's monitoring service. They trade control and portability for speed of setup, managed scaling and integration with the rest of the cloud.

Why it matters: Building your own training cluster, autoscaling inference fleet, registry and monitoring takes months of platform work. Managed platforms compress that to configuration, which matters for small teams. But they add a bill that is easy to inflate (an idle endpoint costs money 24 hours a day), a learning curve in platform-specific SDKs and some lock-in. Knowing the common architecture lets you move between providers, choose the right inference mode and control cost.

When to reach for it

  • Small teams that need managed training and deployment quickly
  • Spot training with checkpointing for large jobs
  • Pipelines with approval gates and a model registry

When to avoid or be careful

  • Leaving real-time endpoints running with no traffic
  • Broad IAM roles for training and serving
  • Writing code that depends on one platform's SDK throughout

Inference modes on managed platforms

Real-time endpoint
Best for: Steady, latency-sensitive traffic

Strengths: Low latency; autoscaling.

Watch out: Pays for always-on instances.

Serverless endpoint
Best for: Spiky or low-volume traffic

Strengths: Pay per request; scales to zero.

Watch out: Cold starts; memory limits.

Asynchronous inference
Best for: Large payloads and long runtimes

Strengths: Queue-based; autoscale to zero.

Watch out: Not for immediate responses.

Batch transform / batch prediction
Best for: Scheduled scoring of large datasets

Strengths: Cheapest per prediction; no endpoint.

Watch out: Results are not immediate.

Interview signals & numbers to know

When this topic comes up

  • “How would you train and deploy on SageMaker or Vertex?”
  • Real-time versus serverless versus batch inference
  • Spot instances and checkpoints
  • Controlling cloud ML cost
  • Avoiding vendor lock-in

Benchmarks & rules of thumb

≈ $168/month -
one $0.23/h endpoint left running all month
$30 → $10.35 -
10 h training on demand versus spot with 15% extra runtime
50 / 80 / 100% -
typical budget alert thresholds

Common mistakes & follow-ups

Common interview mistakes

  • Forgetting to delete notebooks and endpoints after experiments.
  • Using spot capacity without checkpoints.
  • Sharing one broad role across dev and prod.

Likely interviewer follow-ups

  • How would you move this workflow from SageMaker to Vertex?
  • Which inference mode fits a model called a few hundred times a day?
  • How would you cut a large training bill?
Interview tip: Quote the idle-endpoint and spot arithmetic; cost awareness is what managed-platform interviews probe.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Cloud ML Platforms (AWS SageMaker / GCP Vertex AI) with data science interview Q&A and hands-on practice.

Open Data Science Q&A →Machine Learning Q&A
Previous topic
Batch Scoring vs Real-Time Inference
Next topic
Serverless Model Deployment