借助Google Cloud Serverless for Apache Spark,您无需预配和管理自己的 Dataproc 集群即可运行 Spark 工作负载。您可以通过以下两种方式运行 Serverless for Apache Spark 工作负载:批量工作负载和交互式会话。
批处理工作负载
使用Google Cloud 控制台、Google Cloud CLI 或 Dataproc API 向 Serverless for Apache Spark 服务提交批处理工作负载。该服务将在托管式计算基础架构上运行工作负载,并根据需要自动扩缩资源。Serverless for Apache Spark 仅在执行工作负载时产生费用。
批处理工作负载功能
您可以运行以下 Serverless for Apache Spark 批量工作负载类型:
- PySpark
- Spark SQL
- Spark R
- Spark(Java 或 Scala)
您可以在提交 Serverless for Apache Spark 批量工作负载时指定 Spark 属性。
安排批处理工作负载
您可以在 Airflow 或 Cloud Composer 工作流中使用 Airflow 批处理运算符来安排 Spark 批处理工作负载。如需了解详情,请参阅使用 Cloud Composer 运行 Serverless for Apache Spark 工作负载。
开始使用
如需开始使用,请参阅运行 Apache Spark 批量工作负载。
交互式会话
在 Serverless for Apache Spark 交互式会话期间,在 Jupyter 笔记本中编写和运行代码。您可以通过以下方式创建笔记本会话:
在 BigQuery Studio 笔记本中运行 PySpark 代码。 打开 BigQuery Python 笔记本,以创建基于 Spark Connect 的 Serverless for Apache Spark 交互式会话。每个 BigQuery 笔记本只能有一个与之关联的活跃 Serverless for Apache Spark 会话。
使用 Dataproc JupyterLab 插件,通过您创建和管理的模板创建多个 Jupyter 笔记本会话。在本地机器或 Compute Engine 虚拟机上安装插件后,JupyterLab 启动器页面上会显示与不同 Spark 内核配置对应的不同卡片。点击相应卡片以创建 Serverless for Apache Spark 笔记本会话,然后开始在笔记本中编写和测试代码。
借助 Dataproc JupyterLab 插件,您还可以使用 JupyterLab 启动器页面执行以下操作:
- 创建 Dataproc on Compute Engine 集群。
- 将作业提交到 Compute Engine 上的 Dataproc 集群。
- 查看 Google Cloud 和 Spark 日志。
安全合规性
Serverless for Apache Spark 遵循 Dataproc 遵守的所有数据驻留、CMEK、VPC-SC 和其他安全要求。