Skip to content
Closed
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions docs/take-to-prod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
Taking your Spark .Net Application to Production

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to call it ".NET for Apache Spark" or ".NET for Spark" application instead (since we steer away from calling it Spark.NET publicly)? Also, I think ".NET" should be all caps for consistency.

@elvaliuliuliu elvaliuliuliu Nov 20, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will change it to .NET for Apache Spark for now. And keep all .NET caps. Thanks!

===

# Table of Contents
This how-to provides general instructions on how to take your .NET for Apache Spark application to production.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean to take an app to production? Perhaps add a couple words/sentence defining that (does it just mean running on-prem? Deploying to cloud? Building and running spark-submit? CI/CD?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! @rapoth Could you please help with elaborating this a little more?

In this documentation, we will summary the most commonly asked scenarios when running Spark .Net Application.
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
And you will also learn how to package your application and submit your application with [spark-submit](https://spark.apache.org/docs/latest/submitting-applications.html) and [Apachy Livy](https://livy.incubator.apache.org/).
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
- [How to take your application to production when you have single dependency](#how-to-take-your-application-to-production-when-you-have-single-dependency)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [How to take your application to production when you have single dependency](#how-to-take-your-application-to-production-when-you-have-single-dependency)
- [How to take your application to production when you have a single dependency](#how-to-take-your-application-to-production-when-you-have-a-single-dependency)

Not sure if we can change the phrasing here and still have it be precise, but "a single dependency" might sound a little cleaner.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, could we make these headings either more concise or more precise? i.e., either remove the "How to take your application to production" part since that phrase is already in the article title, or add a phrase that more specifically states what it means to take an app to production (does it just mean running spark-submit, so we could say something like "Deploy app with a single dependency"?).

Suggested change
- [How to take your application to production when you have single dependency](#how-to-take-your-application-to-production-when-you-have-single-dependency)
- [Single dependency](#single-dependency)
Suggested change
- [How to take your application to production when you have single dependency](#how-to-take-your-application-to-production-when-you-have-single-dependency)
- [How to deploy your application when you have a single dependency](#how-to-deploy-your-application-when-you-have-a-single-dependency)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion! I would prefer the second one which I think is concise and precise.

- [Scenarios - Scenario 1 and Scenario 2](#scenarios---single-dependency)
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
- [Package your application](#package-your-application---single-dependency)
- [Launch your application](#launch-your-application---single-dependency)
- [How to take your application to production when you have multiple dependencies](#how-to-take-your-application-to-production-when-you-have-multiple-dependencies)
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
- [Scenarios - Scenario 3, Scenario 4, Scenario 5 and Scenario 6](#scenarios---multiple-dependencies)
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
- [Package your application](#package-your-application---multiple-dependencies)
- [Launch your application](#launch-your-application---multiple-dependencies)

## How to take your application to production when you have single dependency
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
### Scenarios - single dependency

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does single dependency mean? I think it could help users to include a short explanation here or at the top of the document of what a dependency means in the .NET for Spark context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I am not so sure if we should use single dependency and multiple dependency to define and separate these scenarios. @rapoth and @imback82 any suggestions? Thanks.

Comment thread
elvaliuliuliu marked this conversation as resolved.
#### Scenario 1. SparkSession code and business logic in the same Program.cs file
Comment thread
elvaliuliuliu marked this conversation as resolved.
This would be the simple usecase when you have SparkSession code and business logic (UDFs) in the same Program.cs file and in the same project (e.g. mySparkApp.csproj).
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
#### Scenario 2. SparkSession code and business logic in the same project, but different .cs files
This would be the usecase when you have SparkSession code and business logic (UDFs) in the different .cs files but in the same project (e.g. SparkSession in Program.cs, business logic in BusinessLogic.cs and both are in mySparkApp.csproj).
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated

### Package your application - single dependency
Comment thread
elvaliuliuliu marked this conversation as resolved.
Please follow [Get Started](https://github.com/dotnet/spark/#get-started) to build your application in Scenario 1 and Scenario 2.

### Launch your application - single dependency
Comment thread
elvaliuliuliu marked this conversation as resolved.
#### 1. Using spark-submit
Please see below as an example of running your app with `spark-submit` in Scenario 1 and Scenario 2.
Comment thread
elvaliuliuliu marked this conversation as resolved.
```shell
Comment thread
elvaliuliuliu marked this conversation as resolved.
%SPARK_HOME%\bin\spark-submit \
--class org.apache.spark.deploy.dotnet.DotnetRunner \
--master local \
Comment thread
elvaliuliuliu marked this conversation as resolved.
--files bin\Debug\netcoreapp3.0\mySparkApp.dll \
bin\Debug\netcoreapp3.0\microsoft-spark-2.4.x-0.6.0.jar \
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
dotnet bin\Debug\netcoreapp3.0\mySparkApp.dll <app arg 1> <app arg 2> ... <app arg n>
Comment thread
elvaliuliuliu marked this conversation as resolved.
Comment thread
elvaliuliuliu marked this conversation as resolved.
```
#### 2. Using Apache Livy
Please see below as an example of running your app with Apache Livy in Scenario 1 and Scenario 2.
Comment thread
elvaliuliuliu marked this conversation as resolved.
```shell
{
"file": "adl://<cluster name>.azuredatalakestore.net/<some dir>/microsoft-spark-2.4.x-0.6.0.jar",
"className": "org.apache.spark.deploy.dotnet.DotnetRunner",
"files": [“adl://<cluster name>.azuredatalakestore.net/<some dir>/mySparkApp.dll" ],
"args": ["dotnet","adl://<cluster name>.azuredatalakestore.net/<some dir>/mySparkApp.dll","<app arg 1>","<app arg 2>,"...","<app arg n>"]
}
```

## How to take your application to production when you have multiple dependencies
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
### Scenarios - multiple dependencies
Comment thread
elvaliuliuliu marked this conversation as resolved.
#### Scenario 3. SparkSession code in one project that references another project including the business logic
Comment thread
elvaliuliuliu marked this conversation as resolved.
This would be the usecase when you have SparkSession code in one project (e.g. mySparkApp.csproj) and business logic (UDFs) in another project (e.g. businessLogic.csproj).
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
#### Scenario 4. SparkSession code references a function from a Nuget package that has been installed in the csproj
This would be the usecase when SparkSession code references a function from a Nuget package in the same project (e.g. mySparkApp.csproj).
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
#### Scenario 5. SparkSession code references a function from a DLL on the user machine
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
This would be the usecase when SparkSession code reference business logic (UDFs) on the user machine (e.g. SparkSession code in the mySparkApp.csproj and businessLogic.dll on a different machine).
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
#### Scenario 6. SparkSession code references functions and business logic from multiple projects/solutions that themselves depend on multiple Nuget packages
This would be a more complex usecase when you have SparkSession code reference business logic (UDFs) and functions from nuget packages in multiple projects and/or solutions.
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated

### Package your application - multiple dependencies
Comment thread
elvaliuliuliu marked this conversation as resolved.
- Please follow [Get Started](https://github.com/dotnet/spark/#get-started) to build your mySparkApp.csproj in Scenario 4 and Scenario 5 (and businessLogic.csproj for Scenario 3).
- Please see detailed steps [here](https://github.com/dotnet/spark/tree/master/deployment#preparing-your-spark-net-app) on how to build, publish and zip your application in Scenario 6. After packaging your .Net for Spark application, you will have a zip file (e.g. mySparkApp.zip) which has all the dependencies.
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated

### Launch your application - multiple dependencies
Comment thread
elvaliuliuliu marked this conversation as resolved.
#### 1. Using spark-submit
- Please see below as an example of running your app with `spark-submit` in Scenario 3 and Scenario 5.
And you should use `--files bin\Debug\netcoreapp3.0\nugetLibrary.dll` in Scenario 4.
Comment thread
elvaliuliuliu marked this conversation as resolved.
Outdated
```shell
%SPARK_HOME%\bin\spark-submit \
--class org.apache.spark.deploy.dotnet.DotnetRunner \
--master local \
--files bin\Debug\netcoreapp3.0\businessLogic.dll \
bin\Debug\netcoreapp3.0\microsoft-spark-2.4.x-0.6.0.jar \
dotnet bin\Debug\netcoreapp3.0\mySparkApp.dll <app arg 1> <app arg 2> ... <app arg n>
```
Comment thread
elvaliuliuliu marked this conversation as resolved.
- Please see below as an example of running your app with `spark-submit` in Scenario 6.
```shell
spark-submit \
--class org.apache.spark.deploy.dotnet.DotnetRunner \
--master yarn \
--deploy-mode cluster \
--conf spark.yarn.appMasterEnv.DOTNET_ASSEMBLY_SEARCH_PATHS=./udfs \
--conf spark.yarn.appMasterEnv.DOTNET_ASSEMBLY_SEARCH_PATHS=./myLibraries.zip \
--archives hdfs://<path to your files>/businessLogics.zip#udfs,hdfs://<path to your files>/myLibraries.zip \
hdfs://<path to jar file>/microsoft-spark-2.4.x-0.6.0.jar \
hdfs://<path to your files>/mySparkApp.zip mySparkApp <app arg 1> <app arg 2> ... <app arg n>
```
#### 2. Using Apache Livy
- Please see below as an example of running your app with Apache Livy in Scenario 3 and Scenario 5.
And you should use `"files": ["adl://<cluster name>.azuredatalakestore.net/<some dir>/nugetLibrary.dll"]` in Scenario 4.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
And you should use `"files": ["adl://<cluster name>.azuredatalakestore.net/<some dir>/nugetLibrary.dll"]` in Scenario 4.
Additionally, you should use `"files": ["adl://<cluster name>.azuredatalakestore.net/<some dir>/nugetLibrary.dll"]` in Scenario 4.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the changed to resolve all the comments (except few which need some input). Thanks so much @bamurtaugh for your comments and feedback!

```shell
{
"file": "adl://<cluster name>.azuredatalakestore.net/<some dir>/microsoft-spark-2.4.x-0.6.0.jar",
"className": "org.apache.spark.deploy.dotnet.DotnetRunner",
"files": [“adl://<cluster name>.azuredatalakestore.net/<some dir>/businessLogic.dll" ],
"args": ["dotnet","adl://<cluster name>.azuredatalakestore.net/<some dir>/mySparkApp.dll","<app arg 1>","<app arg 2>,"...","<app arg n>"]
}
```
Comment on lines +91 to +98

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just provide the zip example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments! I have resolved all of them in this pr #349(I open a new pr #349 cause I could not edit on this one and will close this soon). Let's discuss and review in the new pr. Thanks for your understanding and sorry for the inconvenience.

- Please see below as an example of running your app with Apache Livy in Scenario 6.
```shell
{
"file": "adl://<cluster name>.azuredatalakestore.net/<some dir>/microsoft-spark-<spark_majorversion.spark_minorversion.x>-<spark_dotnet_version>.jar",
"className": "org.apache.spark.deploy.dotnet.DotnetRunner",
    "conf": {"spark.yarn.appMasterEnv.DOTNET_ASSEMBLY_SEARCH_PATHS": "./udfs, ./myLibraries.zip"},
"archives": ["adl://<cluster name>.azuredatalakestore.net/<some dir>/businessLogics.zip#udfs”, "adl://<cluster name>.azuredatalakestore.net/<some dir>/myLibraries.zip”],
"args": ["adl://<cluster name>.azuredatalakestore.net/<some dir>/mySparkApp.zip","mySparkApp","<app arg 1>","<app arg 2>,"...","<app arg n>"]
}
```