Skip to content

Commit 176685b

Browse files
author
Learn-Build-Service
committed
Merge remote-tracking branch 'local-source-repo/main' into temp-ad6050d1-a7a8-41ac-936a-d5ac166595f7
2 parents 51035f8 + 7ad0dad commit 176685b

File tree

3,311 files changed

+298905
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,311 files changed

+298905
-0
lines changed

articles/machine-learning/.openpublishing.redirection.machine-learning.json

Lines changed: 4299 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
title: "Apache Spark in Azure Machine Learning"
3+
titleSuffix: Azure Machine Learning
4+
description: This article explains the options for accessing Apache Spark in Azure Machine Learning.
5+
services: machine-learning
6+
ms.service: azure-machine-learning
7+
ms.subservice: mldata
8+
ms.topic: conceptual
9+
author: fbsolo-ms1
10+
ms.author: franksolomon
11+
ms.reviewer: yogipandey
12+
ms.date: 10/05/2023
13+
ms.custom: cliv2, sdkv2, build-2023
14+
#Customer intent: As a full-stack machine learning pro, I want to use Apache Spark in Azure Machine Learning.
15+
---
16+
17+
# Apache Spark in Azure Machine Learning
18+
19+
Azure Machine Learning integration with Azure Synapse Analytics provides easy access to distributed computation resources through the Apache Spark framework. This integration offers these Apache Spark computing experiences:
20+
21+
- Serverless Spark compute
22+
- Attached Synapse Spark pool
23+
24+
## Serverless Spark compute
25+
26+
With the Apache Spark framework, Azure Machine Learning serverless Spark compute is the easiest way to accomplish distributed computing tasks in the Azure Machine Learning environment. Azure Machine Learning offers a fully managed, serverless, on-demand Apache Spark compute cluster. Its users can avoid the need to create an Azure Synapse workspace and a Synapse Spark pool.
27+
28+
Users can define resources, including instance type and the Apache Spark runtime version. They can then use those resources to access serverless Spark compute, in Azure Machine Learning notebooks, for:
29+
30+
- [Interactive Spark code development](./interactive-data-wrangling-with-apache-spark-azure-ml.md)
31+
- [Spark batch job submissions](./how-to-submit-spark-jobs.md)
32+
- [Running machine learning pipelines with a Spark component](./how-to-submit-spark-jobs.md#spark-component-in-a-pipeline-job)
33+
34+
### Points to consider
35+
36+
Serverless Spark compute works well for most user scenarios that require quick access to distributed computing resources through Apache Spark. However, to make an informed decision, users should consider the advantages and disadvantages of this approach.
37+
38+
Advantages:
39+
40+
- No dependencies on creation of other Azure resources for Apache Spark (Azure Synapse infrastructure operates under the hood).
41+
- No required subscription permissions to create Azure Synapse-related resources.
42+
- No need for SQL pool quotas.
43+
44+
Disadvantages:
45+
46+
- A persistent Hive metastore is missing. Serverless Spark compute supports only in-memory Spark SQL.
47+
- No available tables or databases.
48+
- Missing Azure Purview integration.
49+
- No available linked services.
50+
- Fewer data sources and connectors.
51+
- No pool-level configuration.
52+
- No pool-level library management.
53+
- Only partial support for `mssparkutils`.
54+
55+
### Network configuration
56+
57+
To use network isolation with Azure Machine Learning and serverless Spark compute, use a [managed virtual network](how-to-managed-network.md).
58+
59+
### Inactivity periods and tear-down mechanism
60+
61+
At first launch, a serverless Spark compute (*cold start*) resource might need three to five minutes to start the Spark session itself. The automated serverless Spark compute provisioning, backed by Azure Synapse, causes this delay. After the serverless Spark compute is provisioned, and an Apache Spark session starts, subsequent code executions (*warm start*) won't experience this delay.
62+
63+
The Spark session configuration offers an option that defines a session timeout (in minutes). The Spark session will end after an inactivity period that exceeds the user-defined timeout. If another Spark session doesn't start in the following 10 minutes, resources provisioned for the serverless Spark compute will be torn down.
64+
65+
After the serverless Spark compute resource tear-down happens, submission of the next job will require a *cold start*. The next visualization shows some session inactivity period and cluster teardown scenarios.
66+
67+
:::image type="content" source="./media/apache-spark-azure-ml-concepts/spark-session-timeout-teardown.png" lightbox="./media/apache-spark-azure-ml-concepts/spark-session-timeout-teardown.png" alt-text="Expandable diagram that shows scenarios for Apache Spark session inactivity period and cluster teardown.":::
68+
69+
### Session-level Conda packages
70+
A Conda dependency YAML file can define many session-level Conda packages in a session configuration. A session will time out if it needs more than 15 minutes to install the Conda packages defined in the YAML file. It becomes important to first check whether a required package is already available in the Azure Synapse base image. To do this, users should follow the link to determine *packages available in the base image for* the Apache Spark version in use:
71+
- [Azure Synapse Runtime for Apache Spark 3.3](https://github.com/microsoft/synapse-spark-runtime/tree/main/Synapse/spark3.3)
72+
73+
74+
- [Azure Synapse Runtime for Apache Spark 3.2](https://github.com/microsoft/synapse-spark-runtime/tree/main/Synapse/spark3.2)
75+
76+
> [!IMPORTANT]
77+
> Azure Synapse Runtime for Apache Spark: Announcements
78+
> * Azure Synapse Runtime for Apache Spark 3.2:
79+
> * EOLA Announcement Date: July 8, 2023
80+
> * End of Support Date: July 8, 2024. After this date, the runtime will be disabled.
81+
> * For continued support and optimal performance, we advise that you migrate to
82+
83+
> [!NOTE]
84+
> For a session-level Conda package:
85+
> - the *Cold start* will need about ten to fifteen minutes.
86+
> - the *Warm start*, using same Conda package, will need about one minute.
87+
> - the *Warm start*, with a different Conda package, will also need about ten to fifteen minutes.
88+
> - If the package that you install is large or needs a long installation time, it might impact the Spark instance startup time.
89+
> - Altering the PySpark, Python, Scala/Java, .NET, or Spark version is not supported.
90+
> - Docker images are not supported.
91+
92+
### Improving session cold start time while using session-level Conda packages
93+
You can improve the Spark session *cold start* time by setting the `spark.hadoop.aml.enable_cache` configuration variable to `true`. The session *cold start* with session level Conda packages typically takes 10 to 15 minutes when the session starts for the first time. However, subsequent session *cold starts* take three to five minutes. Define the configuration variable in the **Configure session** user interface, under **Configuration settings**.
94+
95+
:::image type="content" source="./media/apache-spark-azure-ml-concepts/spark-session-enable-cache.png" lightbox="./media/apache-spark-azure-ml-concepts/spark-session-enable-cache.png" alt-text="Expandable diagram that shows the Spark session configuration tag that enables cache.":::
96+
97+
## Attached Synapse Spark pool
98+
99+
A Spark pool created in an Azure Synapse workspace becomes available in the Azure Machine Learning workspace with the attached Synapse Spark pool. This option might be suitable for users who want to reuse an existing Synapse Spark pool.
100+
101+
Attachment of a Synapse Spark pool to an Azure Machine Learning workspace requires [other steps](./how-to-manage-synapse-spark-pool.md) before you can use the pool in Azure Machine Learning for:
102+
103+
- [Interactive Spark code development](./interactive-data-wrangling-with-apache-spark-azure-ml.md)
104+
- [Spark batch job submission](./how-to-submit-spark-jobs.md)
105+
- [Running machine learning pipelines with a Spark component](./how-to-submit-spark-jobs.md#spark-component-in-a-pipeline-job)
106+
107+
An attached Synapse Spark pool provides access to native Azure Synapse features. The user is responsible for the Synapse Spark pool provisioning, attaching, configuration, and management.
108+
109+
The Spark session configuration for an attached Synapse Spark pool also offers an option to define a session timeout (in minutes). The session timeout behavior resembles the description in [the previous section](#inactivity-periods-and-tear-down-mechanism), except that the associated resources are never torn down after the session timeout.
110+
111+
## Defining Spark cluster size
112+
113+
In Azure Machine Learning Spark jobs, you can define the Spark cluster size, with three parameter values:
114+
115+
- Number of executors
116+
- Executor cores
117+
- Executor memory
118+
119+
You should consider an Azure Machine Learning Apache Spark executor as equivalent to Azure Spark worker nodes. An example can explain these parameters. Let's say that you defined the number of executors as 6 (equivalent to six worker nodes), the number of executor cores as 4, and executor memory as 28 GB. Your Spark job then has access to a cluster with 24 cores in total, and 168 GB of memory.
120+
121+
## Ensuring resource access for Spark jobs
122+
123+
To access data and other resources, a Spark job can use either a managed identity or a user identity passthrough. This table summarizes the mechanisms that Spark jobs use to access resources.
124+
125+
|Spark pool|Supported identities|Default identity|
126+
| ---------- | -------------------- | ---------------- |
127+
|Serverless Spark compute|User identity, user-assigned managed identity attached to the workspace|User identity|
128+
|Attached Synapse Spark pool|User identity, user-assigned managed identity attached to the attached Synapse Spark pool, system-assigned managed identity of the attached Synapse Spark pool|System-assigned managed identity of the attached Synapse Spark pool|
129+
130+
[This article](./apache-spark-environment-configuration.md#ensuring-resource-access-for-spark-jobs) describes resource access for Spark jobs. In a notebook session, both the serverless Spark compute and the attached Synapse Spark pool use user identity passthrough for data access during [interactive data wrangling](./interactive-data-wrangling-with-apache-spark-azure-ml.md).
131+
132+
> [!NOTE]
133+
> - To ensure successful Spark job execution, assign **Contributor** and **Storage Blob Data Contributor** roles (on the Azure storage account used for data input and output) to the identity that will be used for the Spark job submission.
134+
> - If an [attached Synapse Spark pool](./how-to-manage-synapse-spark-pool.md) points to a Synapse Spark pool in an Azure Synapse workspace, and that workspace has an associated managed virtual network, [configure a managed private endpoint to a storage account](../synapse-analytics/security/connect-to-a-secure-storage-account.md). This configuration will help ensure data access.
135+
136+
## Next steps
137+
138+
- [Attach and manage a Synapse Spark pool in Azure Machine Learning](./how-to-manage-synapse-spark-pool.md)
139+
- [Interactive data wrangling with Apache Spark in Azure Machine Learning](./interactive-data-wrangling-with-apache-spark-azure-ml.md)
140+
- [Submit Spark jobs in Azure Machine Learning](./how-to-submit-spark-jobs.md)
141+
- [Code samples for Spark jobs using the Azure Machine Learning CLI](https://github.com/Azure/azureml-examples/tree/main/cli/jobs/spark)
142+
- [Code samples for Spark jobs using the Azure Machine Learning Python SDK](https://github.com/Azure/azureml-examples/tree/main/sdk/python/jobs/spark)

0 commit comments

Comments
 (0)