Databricks - Machine Learning Professional Study Guide

    3: Model Deployment

    This chapter covers production model deployment on Databricks, comparing blue-green and canary rollout strategies on Mosaic AI Model Serving and detailing custom PyFunc model serving from Unity Catalog. It walks through traffic configuration, served entity orchestration, custom artifact packaging, and the three programmatic surfaces (MLflow Deployments SDK, Databricks SDK, REST API) used to deploy and query endpoints.

    Learning Objectives

    By the end of this chapter, you will be able to:

    • Compare blue-green and canary deployment strategies and evaluate their suitability for high-traffic applications.
    • Implement a model rollout strategy using Databricks Model Serving with traffic configuration, served entities, and alias-driven promotion.
    • Register a custom PyFunc model and log custom artifacts in Unity Catalog, including code paths, dependencies, and signatures.
    • Query custom models via REST API or MLflow Deployments SDK using the supported request payload formats.
    • Deploy custom model objects using the MLflow Deployments SDK, the REST API, the Databricks SDK, and the Serving UI.

    Executive Summary

    • Blue-green and canary rollouts on Mosaic AI Model Serving are both implemented through the same primitive: a single endpoint with multiple served_entities and a traffic_config that splits invocation requests by percentage.
    • Blue-green flips traffic atomically from one served entity to another; canary ramps gradually with intermediate splits like 95/5, 80/20, 50/50 before reaching 100/0.
    • The Unity Catalog model registry pairs naturally with serving aliases: @champion resolves to the production version while @challenger is staged behind a partial traffic split so failures stay bounded to the canary slice.
    • Custom PyFunc models package any Python inference function as an MLflow model with artifacts, code_paths, and pip_requirements; logging through mlflow.pyfunc.log_model with registered_model_name="catalog.schema.model" writes the version directly to Unity Catalog.
    • Endpoints accept three input payload shapes: dataframe_split, dataframe_records, and inputs; queries land through the REST /serving-endpoints/{name}/invocations route or through mlflow.deployments.get_deploy_client("databricks").predict(...).

    Assumptions

    • The reader has completed Chapter 1 (SparkML pipelines, MLflow tracking, Feature Engineering in Unity Catalog) and Chapter 2 (deploy-code strategy, Databricks Asset Bundles, Lakehouse Monitoring, automated retraining).
    • All examples assume Unity Catalog is the active model registry; the workspace model registry surface is treated as deprecated and only referenced where it changes a serving behavior.
    • All endpoint names, served entity names, catalog and schema names, and route names are fictional placeholders used consistently across examples (catalog prod_ml, schema risk, models claims_classifier, fraud_scorer, recommendation_ranker).
    • Region, networking, and private-link configuration are out of scope; the chapter assumes a workspace where Mosaic AI Model Serving is enabled and the user has CAN MANAGE on the registered models and CAN CREATE ENDPOINT on the workspace.

    Sections in this chapter

    1. Free
    2. Free with account
    3. Free with account