Home
%3CLINGO-SUB%20id%3D%22lingo-sub-344016%22%20slang%3D%22en-US%22%3ENEW%20REFERENCE%20ARCHITECTURE%3A%20Batch%20scoring%20of%20Spark%20models%20on%20Azure%20Databricks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-344016%22%20slang%3D%22en-US%22%3E%3CP%3EOur%20eighth%20%3CSPAN%3EAI%20%3CA%20href%3D%22http%3A%2F%2Faka.ms%2FRefArchs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ereference%20architecture%3C%2FA%3E%20(on%20the%20%3C%2FSPAN%3E%3CA%20href%3D%22http%3A%2F%2Faka.ms%2FArchitecture%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Architecture%20Center%3C%2FA%3E%3CSPAN%3E)%20is%20written%20by%20AzureCAT%3C%2FSPAN%3E%20%3CEM%3E%3CSTRONG%3EJohn%20Ehrlinger%3C%2FSTRONG%3E%3C%2FEM%3E%2C%20and%20published%20by%20%3CEM%3E%3CSTRONG%3EMike%20Wasson%3C%2FSTRONG%3E%3C%2FEM%3E.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Fbatch-scoring-databricks%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBatch%20scoring%20of%20Spark%20models%20on%20Azure%20Databricks%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EReference%20architectures%20provide%20a%20consistent%20approach%20and%20best%20practices%20for%20a%20given%20solution.%20Each%20architecture%20includes%20recommended%20practices%2C%20along%20with%20considerations%20for%20scalability%2C%20availability%2C%20manageability%2C%20security%2C%20and%20more.%20The%20full%20array%20of%20reference%20architectures%20is%20available%20on%20the%20Azure%20Architecture%20Center.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Fbatch-scoring-databricks%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F77768iAEF7242B9D497D2C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22batch-scoring-spark.png%22%20title%3D%22batch-scoring-spark.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20reference%20architecture%20shows%20how%20to%20build%20a%20scalable%20solution%20for%20batch%20scoring%20an%20Apache%20Spark%20classification%20model%20on%20a%20schedule%20using%20Azure%20Databricks%2C%20an%20Apache%20Spark-based%20analytics%20platform%20optimized%20for%20Azure.%20The%20solution%20can%20be%20used%20as%20a%20template%20that%20can%20be%20generalized%20to%20other%20scenarios.%3C%2FP%3E%0A%3CP%3EThe%20architecture%20defines%20a%20data%20flow%20that%20is%20entirely%20contained%20within%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-databricks%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Databricks%3C%2FA%3E%20based%20on%20a%20set%20of%20sequentially%20executed%20%3CA%20href%3D%22https%3A%2F%2Fdocs.databricks.com%2Fuser-guide%2Fnotebooks%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Enotebooks%3C%2FA%3E.%20It%20consists%20of%20the%20following%20components%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FBatchSparkScoringPredictiveMaintenance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EData%20files%3C%2FA%3E%3C%2FSTRONG%3E.%20The%20reference%20implementation%20uses%20a%20simulated%20data%20set%20contained%20in%20five%20static%20data%20files.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.databricks.com%2Fuser-guide%2Fnotebooks%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIngestion%3C%2FA%3E%3C%2FSTRONG%3E.%20The%20data%20ingestion%20notebook%20downloads%20the%20input%20data%20files%20into%20a%20collection%20of%20Databricks%20data%20sets.%20In%20a%20real-world%20scenario%2C%20data%20from%20IoT%20devices%20would%20stream%20onto%20Databricks-accessible%20storage%20such%20as%20Azure%20SQL%20Server%20or%20Azure%20Blob%20storage.%20Databricks%20supports%20multiple%20%3CA%20href%3D%22https%3A%2F%2Fdocs.databricks.com%2Fspark%2Flatest%2Fdata-sources%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edata%20sources%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ETraining%20pipeline%3C%2FSTRONG%3E.%20This%20notebook%20executes%20the%20feature%20engineering%20notebook%20to%20create%20an%20analysis%20data%20set%20from%20the%20ingested%20data.%20It%20then%20executes%20a%20model%20building%20notebook%20that%20trains%20the%20machine%20learning%20model%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.databricks.com%2Fspark%2Flatest%2Fmllib%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EApache%20Spark%20MLlib%3C%2FA%3E%20scalable%20machine%20learning%20library.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EScoring%20pipeline%3C%2FSTRONG%3E.%20This%20notebook%20executes%20the%20feature%20engineering%20notebook%20to%20create%20scoring%20data%20set%20from%20the%20ingested%20data%20and%20executes%20the%20scoring%20notebook.%20The%20scoring%20notebook%20uses%20the%20trained%20%3CA%20href%3D%22https%3A%2F%2Fdocs.databricks.com%2Fspark%2Flatest%2Fmllib%2Findex.html%23apache-spark-mllib%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESpark%20MLlib%3C%2FA%3E%20model%20to%20generate%20predictions%20for%20the%20observations%20in%20the%20scoring%20data%20set.%20The%20predictions%20are%20stored%20in%20the%20results%20store%2C%20a%20new%20data%20set%20on%20the%20Databricks%20data%20store.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EScheduler%3C%2FSTRONG%3E.%20A%20scheduled%20Databricks%20%3CA%20href%3D%22https%3A%2F%2Fdocs.databricks.com%2Fuser-guide%2Fjobs.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ejob%3C%2FA%3E%20handles%20batch%20scoring%20with%20the%20Spark%20model.%20The%20job%20executes%20the%20scoring%20pipeline%20notebook%2C%20passing%20variable%20arguments%20through%20notebook%20parameters%20to%20specify%20the%20details%20for%20constructing%20the%20scoring%20data%20set%20and%20where%20to%20store%20the%20results%20data%20set.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ETopics%26nbsp%3Bcovered%20include%3A%3C%2FEM%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EArchitecture%3C%2FLI%3E%0A%3CLI%3ERecommendations%3C%2FLI%3E%0A%3CLI%3EPerformance%20considerations%3C%2FLI%3E%0A%3CLI%3EStorage%20considerations%3C%2FLI%3E%0A%3CLI%3ECost%20considerations%3C%2FLI%3E%0A%3CLI%3EDeploy%20the%20solution%3C%2FLI%3E%0A%3CLI%3ERelated%20architectures%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH1%20id%3D%22toc-hId-1927972033%22%20id%3D%22toc-hId-1927972033%22%3E%26nbsp%3B%3C%2FH1%3E%0A%3CH1%20id%3D%22toc-hId--624184928%22%20id%3D%22toc-hId--624184928%22%3ESee%20also%3C%2FH1%3E%0A%3CP%3EAdditional%20related%20AI%20reference%20architectures%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Ftraining-deep-learning%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDistributed%20training%20of%20deep%20learning%20models%20on%20Azure%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Fbatch-scoring-deep-learning%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBatch%20scoring%20on%20Azure%20for%20deep%20learning%20models%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Fbatch-scoring-python%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBatch%20scoring%20of%20Python%20models%20on%20Azure%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Frealtime-scoring-python%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EReal-time%20scoring%20of%20Python%20Scikit-Learn%20and%20deep%20learning%20models%20on%20Azure%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Frealtime-scoring-r%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EReal-time%20scoring%20of%20R%20machine%20learning%20models%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Fconversational-bot%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEnterprise-grade%20conversational%20bot%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Freference-architectures%2Fai%2Freal-time-recommendation%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBuild%20a%20real-time%20recommendation%20API%20on%20Azure%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFind%20all%20our%20reference%20architectures%20%3CA%20href%3D%22http%3A%2F%2Faka.ms%2FRefArchs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22http%3A%2F%2Faka.ms%2FCAT%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CIMG%20width%3D%22134%22%20height%3D%22134%22%20class%3D%22alignleft%22%20src%3D%22https%3A%2F%2Fmsdnshared.blob.core.windows.net%2Fmedia%2F2017%2F01%2FAzureCAT_Icon.jpg%22%20border%3D%220%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAzureCAT%20Guidance%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CEM%3E%22Hands-on%20solutions%2C%20with%20our%20heads%20in%20the%20Cloud!%22%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-344016%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20reference%20architecture%20shows%20how%20to%20build%20a%20scalable%20solution%20for%20batch%20scoring%20an%20Apache%20Spark%20classification%20model%20on%20a%20schedule%20using%20Azure%20Databricks%2C%20an%20Apache%20Spark-based%20analytics%20platform%20optimized%20for%20Azure.%20The%20solution%20can%20be%20used%20as%20a%20template%20that%20can%20be%20generalized%20to%20other%20scenarios.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-344016%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Our eighth AI reference architecture (on the Azure Architecture Center) is written by AzureCAT John Ehrlinger, and published by Mike Wasson.

Reference architectures provide a consistent approach and best practices for a given solution. Each architecture includes recommended practices, along with considerations for scalability, availability, manageability, security, and more. The full array of reference architectures is available on the Azure Architecture Center.

batch-scoring-spark.png

 

This reference architecture shows how to build a scalable solution for batch scoring an Apache Spark classification model on a schedule using Azure Databricks, an Apache Spark-based analytics platform optimized for Azure. The solution can be used as a template that can be generalized to other scenarios.

The architecture defines a data flow that is entirely contained within Azure Databricks based on a set of sequentially executed notebooks. It consists of the following components:

  • Data files. The reference implementation uses a simulated data set contained in five static data files.
  • Ingestion. The data ingestion notebook downloads the input data files into a collection of Databricks data sets. In a real-world scenario, data from IoT devices would stream onto Databricks-accessible storage such as Azure SQL Server or Azure Blob storage. Databricks supports multiple data sources.
  • Training pipeline. This notebook executes the feature engineering notebook to create an analysis data set from the ingested data. It then executes a model building notebook that trains the machine learning model using the Apache Spark MLlib scalable machine learning library.
  • Scoring pipeline. This notebook executes the feature engineering notebook to create scoring data set from the ingested data and executes the scoring notebook. The scoring notebook uses the trained Spark MLlib model to generate predictions for the observations in the scoring data set. The predictions are stored in the results store, a new data set on the Databricks data store.
  • Scheduler. A scheduled Databricks job handles batch scoring with the Spark model. The job executes the scoring pipeline notebook, passing variable arguments through notebook parameters to specify the details for constructing the scoring data set and where to store the results data set.

 

Topics covered include:

  • Architecture
  • Recommendations
  • Performance considerations
  • Storage considerations
  • Cost considerations
  • Deploy the solution
  • Related architectures

 

See also

Additional related AI reference architectures:

 

Find all our reference architectures here.

 

AzureCAT Guidance

"Hands-on solutions, with our heads in the Cloud!"