簡體   English   中英

Spark GraphFrames High Shuffle 讀/寫

[英]Spark GraphFrames High Shuffle read/write

嗨,我已經使用頂點和邊緣文件創建了 Graph。 圖的大小為 600GB。 我正在使用 Spark GraphFrames 的主題功能查詢此圖。 我已經設置了一個 AWS EMR 集群來查詢圖形。

集群詳細信息:- 1 個主節點和 8 個從節點

主節點:

    m5.xlarge
    4 vCore, 16 GiB memory, EBS only storage
    EBS Storage:64 GiB

從節點:

    m5.4xlarge
    16 vCore, 64 GiB memory, EBS only storage
    EBS Storage:256 GiB (per instance)

我面臨着非常高的隨機讀取(3.4TB)和寫入(2TB),這會影響性能,只執行 10 個查詢大約需要 50 分鍾。有什么辦法可以減少這種高隨機播放。

以下是我的火花代碼: -

val spark = SparkSession.builder.appName("SparkGraph POC").getOrCreate()

val g:GraphFrame  = GraphFrame(vertexDf, edgeDf)

//queries

    val q1 = g.find(" (a)-[r1]->(b); (b)-[r2]->(c)")

    q1.filter(
      " r1.relationship = 'knows' and" +
                  " r2.relationship = 'knows'").distinct()
      .createOrReplaceTempView("q1table")

    spark.sql("select a.id as a_id,a.name as a_name," +
                      "b.id as b_id,b.name as b_name," +
                      "c.id as c_id,c.name as c_name from q1table")
      .write
      .option("quote", "\"")
      .option("escape", "\"")
      .option("header","true")
      .csv(resFilePath + "/q1")

    spark.catalog.uncacheTable("q1table")

    val q2 = g.find(" (a)-[r1]->(b); (b)-[r2]->(c); (c)-[r3]->(d); (d)-[r4]->(e)")
    q2.filter(
      " a.name = 'user1' and" +
        " e.name = 'user4' and" +
        " r1.relationship = 'knows' and" +
        " r2.relationship = 'knows' and" +
        " r3.relationship = 'knows' and" +
        " r4.relationship = 'knows'").distinct()
      .createOrReplaceTempView("q2table")

    spark.sql("select a.id as a_id, a.name as a_name ," +
      "e.id as e_id, e.name as e_name from q2table")
      .write
      .option("quote", "\"")
      .option("escape", "\"")
      .option("header","true")
      .csv(resFilePath + "/q2")

    spark.catalog.uncacheTable("q2table")

spark.stop()

在此處輸入圖像描述

Graphframes 實現的問題在於,它使內部數據幀的自連接次數與您在主題上使用的次數一樣多。 這意味着隨着鏈條長度的增加,您將有更多的洗牌

您可以在https://www.waitingforcode.com/apache-spark-graphframes/motifs-finding-graphframes/read查看更多詳細信息

我也嘗試過類似的方法,並且發現當鏈的長度大於 12 時,Spark 開始沒有響應並且與執行程序的連接丟失,即使我增加了資源。

如果您嘗試這樣做,我建議您改用圖形數據庫。

希望這可以幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM