AirborneOps Learning Labs · Walkthrough

Model serving lab — deploy an inference endpoint, autoscale it, and observe latency with an SLO

A hands-on walkthrough that stages a trained model into a registry, deploys it to a real-time inference endpoint with a stable contract, layers autoscaling on top so the endpoint absorbs spikes without paying for idle capacity, and wires the endpoint to a latency dashboard with a public SLO. Includes cloud-portable reference patterns for IAM-rotated invocation paths, quota-aware scaling ceilings, and observability that reads the same metric names across regions.

MLOps Engineer

Last updated 2026-08-06 · 10 min read

Where this lab fits

Existing role and certification connections for this hands-on work.

IT roles

Certifications

  • AWS Certified Machine Learning – Specialty

    Role track: MLOps Engineer

    Exam domains: Modeling, MLOps & Deployment

  • Google Professional Machine Learning Engineer

    Role track: MLOps Engineer

    Exam domains: Frame ML problems, Deploy & serve models

  • Azure AI Engineer Associate (AI-102)

    Role track: MLOps Engineer

  • Certified Kubernetes Application Developer (CKAD)

    Role track: MLOps Engineer

  • AI Agent Developer — provider-neutral role certification

    Role track: AI Agent Developer

  • Applied LLM Agent Operations (vendor-neutral)

    Role track: AI Agent Developer

  • Production Agent Engineering credential (vendor-neutral)

    Role track: AI Agent Developer

  • NVIDIA-Certified Associate: Generative AI & LLMs

    Exam domains: Generative AI fundamentals

Prerequisites
  • A cloud account (AWS, GCP, or Azure) with permission to create inference endpoints and to attach autoscaling policies to them.
  • A trained model artifact already produced by the MLOps toolchain walkthrough, registered in the model registry so the deploy step resolves to a version pin rather than a one-off upload.
  • An observability tenant (CloudWatch / Cloud Monitoring / Application Insights) with write access for SLO alarms and a paging policy wired to the serving team.

Step 1 — Stage the trained model in the registry

Stage the trained model artifact in the same registry your serving stack already reads from so the deploy step is a version pin, not a one-off upload. Pin the artifact by version (immutable tag, content-addressed SHA, or registry digest) rather than by mutable alias so a rollback targets a known-good build, and record the run id from the training tracking server so the served model and its metrics live on the same audit trail.

Sample command
# AWS — push the model package to SageMaker's model registry with an immutable version.
aws sagemaker create-model-package \
    --model-package-name tempus-sentiment-cls \
    --model-package-version 17 \
    --source-uri s3://tempus-ml-artifacts/sentiment-cls/v17/model.tar.gz \
    --model-package-description "promote run 7a3f-9b21 from training pipeline"

# GCP — register a new Vertex Model version with the registry.
gcloud ai models upload \
    --region=us-central1 \
    --display-name=tempus-sentiment-cls \
    --container-image-uri=us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-5:latest \
    --artifact-uri=gs://tempus-ml-artifacts/sentiment-cls/v17/

# Azure — register the model in the workspace model registry.
az ml model create \
    --name tempus-sentiment-cls \
    --version 17 \
    --path azureml://registries/tempus-registry/models/sentiment-cls/versions/17
Things to double-check
  • Pin the artifact by version (immutable tag or registry digest); never deploy a mutable alias — a rollback that targets "latest" is a rollback that was never tested.
  • Record the training run id alongside the artifact version so the served model and its offline metrics live on the same audit trail.

Step 2 — Deploy to an inference endpoint

Create an inference endpoint from the registered model with a stable contract (request schema, response schema, health probe) and the smallest instance type that fits a single replica. Real-time endpoints suit latency-bound workloads; serverless / managed endpoints fit bursty or sporadic traffic. Treat the endpoint as the API surface — versioning and deprecation live on the endpoint, not on the model registry.

Sample command
# AWS — create a real-time SageMaker endpoint from the registered package.
aws sagemaker create-endpoint-config \
    --endpoint-config-name tempus-sentiment-cls-v17 \
    --production-variants '[{
        "VariantName": "AllTraffic",
        "ModelName": "tempus-sentiment-cls",
        "InitialInstanceCount": 1,
        "InitialVariantWeight": 1.0,
        "InstanceType": "ml.m5.large"
    }]'

aws sagemaker create-endpoint \
    --endpoint-name tempus-sentiment-cls \
    --endpoint-config-name tempus-sentiment-cls-v17

# GCP — deploy the Vertex Model to a public endpoint (regional for prod).
gcloud ai endpoints deploy-model tempus-sentiment-cls-endpoint \
    --region=us-central1 \
    --model=tempus-sentiment-cls@17 \
    --display-name=tempus-sentiment-cls \
    --machine-type=n1-standard-2 \
    --min-replica-count=1 \
    --max-replica-count=2 \
    --traffic-split=0=100

# Azure — deploy to a managed online endpoint with a single deployment.
az ml online-endpoint create \
    --name tempus-sentiment-cls \
    --resource-group rg-tempus-mlops

az ml online-deployment create \
    --endpoint-name tempus-sentiment-cls \
    --name blue \
    --model tempus-sentiment-cls:17 \
    --instance-type Standard_DS2_v2 \
    --instance-count 1
Things to double-check
  • Pick real-time for latency-bound workloads and serverless for bursty / sporadic traffic — the autoscaling curve looks the same but the cost model does not.
  • Version the endpoint, not the model: keep the endpoint name stable and bump it by a deploy id so clients can pin to a known-good contract.

Step 3 — Add autoscaling on the right signal

Layer autoscaling on top of the endpoint so it absorbs sporadic spikes and idles cheaply at night. Pick a scaling signal that matches the workload: concurrency / in-flight requests for synchronous APIs, QPS for spiky traffic, or queue depth for asynchronous batches. Always set a non-zero minimum so cold starts do not corrupt the first response after a quiet period, and a maximum that protects your quota budget from a runaway client.

Sample command
# AWS — autoscaling on SageMaker with concurrency as the scaling signal.
aws application-autoscaling register-scalable-target \
    --service-namespace sagemaker \
    --resource-id endpoint/tempus-sentiment-cls/variant/AllTraffic \
    --scalable-dimension sagemaker:variant:DesiredInstanceCount \
    --min-capacity 1 \
    --max-capacity 6

aws application-autoscaling put-scaling-policy \
    --policy-name tempus-sentiment-cls-concurrency \
    --service-namespace sagemaker \
    --resource-id endpoint/tempus-sentiment-cls/variant/AllTraffic \
    --scalable-dimension sagemaker:variant:DesiredInstanceCount \
    --policy-type TargetTrackingScaling \
    --target-tracking-scaling-policy-configuration '{
        "TargetValue": 4.0,
        "PredefinedMetricSpecification": {
            "PredefinedMetricType": "SageMakerVariantConcurrentRequestsPerModel"
        },
        "ScaleInCooldown": 300,
        "ScaleOutCooldown": 60
    }'

# GCP — Vertex prediction autoscaling on CPU utilization + replica bounds.
gcloud ai endpoints update tempus-sentiment-cls-endpoint \
    --region=us-central1 \
    --traffic-split=0=100

# Azure — autoscale the online deployment on request concurrency.
az ml online-deployment update \
    --endpoint-name tempus-sentiment-cls \
    --name blue \
    --scale-settings '{"type": "default", "min_instances": 1, "max_instances": 6, "scale_down_wait_time": "PT5M"}'
Things to double-check
  • Match the scaling signal to the workload: concurrency for synchronous APIs, QPS for spiky public traffic, queue depth for asynchronous batches.
  • Always keep min replicas >= 1 so the first request after a quiet hour is not a cold-start — autoscaling from zero is the most common production surprise on day one.

Step 4 — Observe latency and pin an SLO

Wire the endpoint to a latency dashboard and a public SLO from day one — autoscaling is only as good as the signal it scales on, and tuning concurrency targets by gut feel invites an outage. Capture p50 / p95 / p99 latency, per-instance concurrency, and a per-route error rate; pin alerts against the SLO error budget so a regression pages someone before customers notice. Treat the dashboard as code: it lives in the repo, not in a click-ops console, so a new region or replica inherits the same view.

Sample command
# AWS — emit CloudWatch metrics + alarms the SLO page will fire on.
aws cloudwatch put-metric-alarm \
    --alarm-name tempus-sentiment-cls-p95-latency \
    --namespace AWS/SageMaker \
    --metric-name ModelLatency \
    --dimensions Name=EndpointName,Value=tempus-sentiment-cls Name=VariantName,Value=AllTraffic \
    --statistic p95 \
    --period 60 \
    --evaluation-periods 5 \
    --threshold 250 \
    --comparison-operator GreaterThanThreshold \
    --treat-missing-data notBreaching

# GCP — log-based SLO on Vertex prediction latency + a Cloud Monitoring alert.
gcloud logging metrics create sentiment_cls_latency_ms \
    --description "Vertex prediction latency in milliseconds" \
    --log-name 'projects/tempus-ops/logs/aiplatform.googleapis.com%2Fprediction' \
    --value-extractor='EXTRACT(jsonPayload.latencyMs)'

# Azure — Application Insights alert on online endpoint response time.
az monitor metrics alert create \
    --name tempus-sentiment-cls-p95-latency \
    --resource tempus-sentiment-cls \
    --resource-namespace Microsoft.MachineLearningServices/workspaces/onlineEndpoints \
    --resource-type onlineEndpoints \
    --condition "avg requests/total latency p95 > 250" \
    --window-size 5m \
    --evaluation-frequency 1m
Things to double-check
  • Pin the SLO at the public boundary (load balancer / CDN / Front Door), not at the model — what the customer sees is what the dashboard should chart.
  • Keep latency alerts at the same granularity as the metric (per-minute p95) so the SLO page fires on minute-scale queueing, not on a smoothed five-minute tail.
Endpoint

Endpoint — private-link invocation path with quota headroom

Bind the serving execution role to a narrow invoking principal — the client app registration, the inference SDK, or a workload-identity-bound runner — and scope the permission to call only the specific endpoint ARN / resource name. Issue tokens with a short TTL so a leaked credential cannot stay valid through a model rotation, and rotate the keyset out-of-band whenever the endpoint sign URL changes.

Place the endpoint behind a private link or VPC endpoint so client traffic never reaches the public internet; expose a single ALB / Cloud CDN / Front Door entry point with an mTLS or OAuth scope pinned to the inference consumer. Reserve a quota headroom budget per endpoint so an autoscaling event cannot silently 429 under load, and verify the regional quota (requests-per-second, in-flight inferences) before adding replica ceilings.

Endpoint sample
terraform {
  required_providers {
    aws = { source = "hashicorp/aws", version = "~> 5.0" }
  }
}

# Private-only invocation path: VPC interface endpoint so calls never egress.
resource "aws_vpc_endpoint" "sagemaker_runtime" {
  vpc_id            = var.notebook_vpc_id
  service_name      = "com.amazonaws.${var.region}.sagemaker.runtime"
  vpc_endpoint_type = "Interface"
  subnet_ids        = var.private_subnet_ids
  security_group_ids = [aws_security_group.runtime_egress.id]
}

resource "aws_security_group" "runtime_egress" {
  name        = "tempus-runtime-egress"
  description = "Allow 443 to the SageMaker runtime VPC endpoint only."
  vpc_id      = var.notebook_vpc_id

  egress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks = ["10.40.0.0/24"]
    description = "Private link to SageMaker runtime."
  }
}

# Service Quotas guardrail — request headroom before the first scaling event.
resource "aws_servicequotas_service_quota" "sagemaker_runtime_tps" {
  quota_code   = "L-9FFB62B6"   # SageMaker runtime TPS per endpoint
  service_code = "sagemaker"
  value        = 200            # 2x the autoscaling ceiling.
}
Things to double-check
  • Bind the invocation principal to a narrow set of actions on the specific endpoint ARN; rotate the signing key out-of-band whenever the endpoint URL changes so a leaked credential has a short TTL.
  • Reserve a quota headroom of at least 2x the autoscaling ceiling before the first production rollout — quota rejections at peak look indistinguishable from model errors to the client.
Autoscaling

Autoscaling — concurrency targets with a quota-aware ceiling

Grant the autoscaling principal only the application-autoscaling actions it needs (register-scalable-target, put-scaling-policy) scoped to the specific endpoint resource — never widens to sagemaker:* on a wildcard. Confirm that the IAM role the autoscaler assumes can describe the variant metrics it tracks; an autoscaler that fails to read its own metric scales in circles and pages the on-call.

Pick the scaling signal that matches the traffic shape. Real-time LLM inference typically scales on concurrent requests per replica; tabular batch jobs scale on queue depth; spiky public APIs scale on a target-tracking RPS metric. Always pair min-replica-with-N so a quiet hour does not freeze the cold start, and cap max replicas at a value the quota budget can absorb without escalation.

Autoscaling sample
# Google Cloud — Vertex prediction autoscaling on concurrent requests per replica.
# HCL rendered as a single resource for the existing terraform state.
resource "google_vertex_ai_endpoint" "sentiment_cls" {
  name         = "tempus-sentiment-cls-endpoint"
  region       = var.region
  display_name = "AirborneOps Learning Labs sentiment classifier"
  description  = "Real-time inference endpoint for tempus-sentiment-cls v17"

  deployed_models {
    model_id                      = google_vertex_ai_model.sentiment_cls.id
    display_name                  = "tempus-sentiment-cls"
    machine_type                  = "n1-standard-2"
    min_replica_count             = 1
    max_replica_count             = 6
    accelerator_type              = ""
    accelerator_count             = 0
    traffic_percentage            = 100
    traffic_split                 = { "0" = 100 }
    enable_access_logging         = true
    predict_request_response_logging = true
  }
}
Things to double-check
  • Confirm that the scaling principal can describe the metric it tracks — an autoscaler that fails to read the metric scales in circles and pages the on-call.
  • Pin max replicas at a value the quota budget can absorb without escalation; the autoscaler will happily chase the requested ceiling and 429 the traffic it just enabled.
Observability

Observability — per-minute p95 dashboard and a public SLO

Grant the dashboarding principal read-only on the endpoint metric namespace and write access to the alerting channel scoped to the serving SLO; never grant it control-plane actions on the endpoint — a leaked dashboard token that can rotate models is a much bigger blast radius than one that can only plot a graph. Restrict log read access to the inference request / response subset (PII columns stripped) so on-call can debug without seeing customer payloads.

Wire every endpoint to a structured latency + error-rate dashboard that reads the same metric names across regions, and pin the SLO at the public boundary (the load balancer / CDN / Front Door) so autoscaling sees what the customer sees. Keep p95 plotted at a per-minute granularity — sub-minute dashboards hide the minute-scale queueing that precedes the customer-visible alarm. Forward inference logs to the same observability tenant as the upstream service so a spike in 5xxs can be correlated with feature drift, not blamed on the model alone.

Observability sample
-- Postgres for SLO budget bookkeeping; the metrics live in the observability tool,
-- the budget ledger lives here so a regression on one endpoint can be diffed
-- against the budget committed at the start of the quarter.
CREATE TABLE serving_slo_budget (
    endpoint_id        TEXT PRIMARY KEY,
    period             DATE NOT NULL,
    target_p95_ms      INTEGER NOT NULL,
    consumed_minutes   DOUBLE PRECISION NOT NULL DEFAULT 0,
    error_budget_total DOUBLE PRECISION NOT NULL,
    PRIMARY KEY (endpoint_id, period)
);

CREATE OR REPLACE VIEW serving_slo_remaining AS
SELECT  endpoint_id,
        period,
        target_p95_ms,
        error_budget_total,
        GREATEST(error_budget_total - consumed_minutes, 0) AS remaining_minutes,
        ROUND(100.0 * (error_budget_total - consumed_minutes) / error_budget_total, 2)
            AS remaining_pct
FROM    serving_slo_budget;
Things to double-check
  • Restrict log read access to the inference request / response subset (PII columns stripped) so on-call can debug without ever seeing customer payloads.
  • Forward inference logs to the same observability tenant as the upstream service so a 5xx spike can be correlated with feature drift, not blamed on the model alone.
Cohort notes

Questions from the cohort

See what other learners are clarifying as they work through this walkthrough.

Next labs

Pair this serving walkthrough with the MLOps toolchain lab so the deployed endpoint points at a model that was trained on the same hosted tracking server, and with the evals pipeline walkthrough so the regression gate covers the serving slice too.

MLOps toolchain labPractice deployment in the REST classifier labAll labs

AI certification roadmap

Connect hands-on practice with certification preparation by mapping lab work to exam domains.

Explore the certification roadmap