Databricks Machine Learning Associate · Section 4 · 12% of the exam
Deploy a custom model to a model endpoint
One of the objectives of the Databricks Certified Machine Learning Associate exam, in the section “Model Deployment”. Here is what it covers, the points to remember and a question to try.
What it covers
Package a custom model in MLflow format, register it in Unity Catalog, deploy it to a Mosaic AI Model Serving endpoint from the UI or code, query it over REST, with the MLflow Deployments SDK and with ai_query, and split traffic between two served models for A/B testing and gradual rollouts.
Points to remember
- Custom model = any Python model in MLflow format (built-in flavor or pyfunc), registered in Unity Catalog, served on a Model Serving endpoint as a REST API.
- Unity Catalog model versions need a signature: log an
input_exampleorsignature. Pinmlflow(notmlflow-skinny) in pyfunc requirements. - Create endpoints in the Serving UI, with
POST /api/2.0/serving-endpoints,get_deploy_client('databricks').create_endpoint(...)or the Databricks SDK. - Served entities reference a model name and a version; scale-out sizes are Small (0-4), Medium (8-16) and Large (16-64) concurrent requests.
- Scale to zero after 30 idle minutes saves cost but adds cold starts; not recommended for production.
Try a question
Each night an analyst scores 60 million customers with SELECT ai_query('churn-rt', request => struct(*), returnType => 'DOUBLE') FROM ml_prod.churn.customers. The same endpoint serves the mobile app in real time, and the app's latency spikes during the nightly run. The model is registered as ml_prod.churn.churn_model with a champion alias. Which change best fits Databricks guidance?
- AScore the table in a scheduled batch job that loads
@championwithmlflow.pyfunc.spark_udfand writes a Delta table, leaving the endpoint to the app - BEnable scale to zero on the endpoint, so that it restarts with fresh capacity before the nightly run
- CAdd a second served entity for the same version and split traffic 50/50, so that the nightly queries go to their own copy
- DSend the nightly rows in
dataframe_recordsformat instead ofdataframe_split, which the endpoint processes faster
Show the answer
A. Batch inference is the most cost-effective option for high-throughput work that tolerates latency: a scheduled job that loads the registered model by alias and applies it with spark_udf scales across the cluster without touching the endpoint. ai_query is convenient for scoring from SQL, but it sends every row to the serving endpoint, which adds the endpoint's cost and throughput limits to the batch job and, here, competes with the real-time traffic.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Real-Time Inference with Model Serving: Deploy, Query and Split Traffic teaches this objective (about 45 minutes), and 15 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.
More in this section
- Identify the differences and advantages of model serving approaches: batch, realtime, and streaming
- Use pandas to perform batch inference
- Identify how streaming inference is performed with Delta Live Tables
- Deploy and query a model for realtime inference
- Split data between endpoints for realtime interference