Managed Service for Apache Spark 無伺服器常見問題

Managed Service for Apache Spark 無伺服器服務可讓您在全代管基礎架構上,執行 Spark 批次工作負載和互動式工作階段。以下常見問答涵蓋常見的部署、設定和作業主題。除非另有規定,否則這項資訊僅適用於無伺服器部署作業,不適用於叢集部署作業。

什麼時候該使用 Managed Service for Apache Spark 無伺服器部署,而非 Managed Service for Apache Spark 叢集部署?

  • Managed Service for Apache Spark 無伺服器部署:

    • 支援 Spark 批次工作負載,以及 PySpark 核心 Jupyter 筆記本中的互動式工作階段。
    • 建立及管理工作負載和互動式工作階段基礎架構。
  • Managed Service for Apache Spark 叢集部署:

    • 支援提交不同類型的 Spark 工作,以及以其他開放原始碼元件為基礎的工作,例如 Flink、Hadoop、Hive、Pig、Presto 等。

    • 不會建立及管理基礎架構。您需要建立及管理 Managed Service for Apache Spark 叢集。

Managed Service for Apache Spark 無伺服器部署作業有哪些用途?

如何設定工作負載執行計畫?

您可以同時或依序執行工作負載。執行計畫會影響 Google Cloud 資源配額。在批次資源配額允許的範圍內,您可以同時執行多項工作負載。

Managed Service for Apache Spark 無伺服器部署作業,是否能使用自訂映像檔?

可以為 Managed Service for Apache Spark 工作負載指定記憶體和磁碟資源嗎?

可以。提交工作負載時,您可以指定進階執行器和驅動程式運算和磁碟層級,以及要分配的驅動程式和執行器運算和磁碟資源數量 (請參閱資源分配屬性)。

如何指定 Managed Service for Apache Spark 虛擬私有雲網路的 IP 位址範圍?

Managed Service for Apache Spark 工作負載會在您的環境中執行。Serverless Spark 工作負載中的每個 Spark 驅動程式和 Spark 執行器,都會耗用 Managed Service for Apache Spark 虛擬私有雲網路中的一個內部 IP 位址。/16 是使用者為 Managed Service for Apache Spark 虛擬私有雲網路指定的典型 CIDR 位址範圍。您可以根據預計執行的並行工作負載數量,限制網路的 IP 位址範圍。

Managed Service for Apache Spark 是否支援資料落地?

可以。您可以指定處理工作負載的區域。在指定區域中找出輸入和輸出資料集。

Managed Service for Apache Spark 如何在指定區域中選取可用區,以便執行工作負載?

Managed Service for Apache Spark 會根據容量和可用性,選取執行工作負載的 Compute Engine 可用區。如果可用區在工作負載啟動後無法使用,工作負載就會失敗,您必須重新提交失敗的工作負載。

Managed Service for Apache Spark 工作負載如何使用運算資源?

每個工作負載都會在自己的運算資源上執行。多個批次提交作業不會共用或重複使用運算資源。

Best Practices:

  • 針對中等執行時間的工作最佳化工作負載,而非短時間執行的工作。

  • 在 Cloud Storage 中保留多個工作負載存取的資料。

哪裡可以找到 Managed Service for Apache Spark 的公告、功能、修正錯誤、已知問題和淘汰資訊?

請參閱 Managed Service for Apache Spark 版本資訊。

並行工作負載是否會爭奪資源?

只有在資源配額不足,無法執行所有並行工作負載時,Managed Service for Apache Spark 工作負載才會爭用資源。否則,工作負載會完全彼此隔離。

Managed Service for Apache Spark 配額如何分配?

Managed Service for Apache Spark 批次會耗用 Google Cloud 資源。詳情請參閱「Dataproc Serverless 配額」。

是否需要設定 Managed Service for Apache Spark Persistent History Server?

您可以選擇是否設定永久記錄伺服器 (PHS),以便與 Managed Service for Apache Spark 搭配使用。您可以使用 PHS 查看指定 Cloud Storage bucket 中的 Spark 事件和其他記錄,最長可達標準 Managed Service for Apache Spark 暫存和臨時 bucket 90 天保留 (TTL) 期限,或在該期限後查看。

有哪些 Managed Service for Apache Spark 記錄?

在 Spark 工作負載執行期間和執行後,您可以在 Cloud Logging 中查看 Spark 執行器和驅動程式記錄。此外,工作負載執行期間,Spark 應用程式會顯示在永久記錄伺服器 (PHS) 網頁介面中 (在 PHS UI 中依序選取「PHS」 >「Incomplete Applications」)。

設定 Managed Service for Apache Spark PHS 後,即可永久存取儲存在 Cloud Storage 的 Spark 事件記錄,深入瞭解 Spark 應用程式執行情形,例如 DAG 和執行器事件。

可以設定 Spark 工作負載的執行器數量嗎?

可以。您可以使用 spark.executor.instances 屬性,設定 Spark 工作負載的執行器數量。不過,工作負載可使用的核心總數比執行器數量更重要,因為 Spark 每個核心會執行 1 項工作。舉例來說,如果工作負載有四個執行器,每個執行器有兩個核心,則會同時執行 4 * 2 = 8 個工作。如果工作負載有兩個執行器,每個執行器有四個核心,則會執行相同數量的任務。由於每個工作負載的核心數量相同,因此執行的工作數量也相同。您可以使用 spark.executor.cores 屬性,設定 Managed Service for Apache Spark 工作負載的每個執行器核心數量。

Managed Service for Apache Spark 會使用哪些 Spark 指標進行自動調度資源?

Managed Service for Apache Spark 會查看 maximum-needed 和 running Spark 的動態分配指標,判斷是否要擴充或縮減資源。請參閱「Managed Service for Apache Spark 自動調度資源」。

可以使用 Spark 屬性設定 Managed Service for Apache Spark 自動調度資源行為嗎?

可以。Managed Service for Apache Spark 自動調度資源功能是以 Spark 動態分配為基礎,預設為啟用。您可以調整下列 Spark 屬性和 Spark 動態分配屬性:

  • spark.executor.instances
  • spark.dynamicAllocation.initialExecutors
  • spark.dynamicAllocation.minExecutors
  • spark.dynamicAllocation.maxExecutors

為什麼需要將程式碼封裝成 JAR 檔案,才能提交 Spark 工作負載?

Spark 是以 Scala 編寫,這表示驅動程式和 worker 程序都會以 JVM 程序的形式運作。在 JVM 語言中,JAR 檔案是封裝程式碼的主要方式。提交工作負載時,您會將 JAR 檔案傳遞至 Managed Service for Apache Spark。