使用效能評定架構測量 Azure Cosmos DB for NoSQL 效能

現在,與資料工作負載搭配使用的資料庫類型有更多選擇。 挑選資料庫的主要因素之一是資料庫或服務的效能,但效能評定效能可能會很麻煩且容易出錯。 Azure 資料庫的效能評定架構可簡化使用熱門開放原始碼效能評定工具來測量效能的程式,以及實作低摩擦配方的常見最佳做法。 在 Azure Cosmos DB for NoSQL 中,架構會實作 JAVA SDK 的最佳做法,並使用開放原始碼 YCSB 工具。 在本指南中,您會使用此效能評定架構來實作讀取工作負載,以使您自己熟悉架構。

必要條件

建立 Azure Cosmos DB 帳戶資源

首先,您在現有的 API for NoSQL 帳戶中建立資料庫和容器。

  1. Azure 入口網站中瀏覽至您現有的 API for NoSQL 帳戶。

  2. 在 [資源] 功能表中,選取 [資料總管]

    Screenshot of the Data Explorer option highlighted in the resource menu.

  3. 在 [資料總管] 頁面上,選取命令列中的 [新增容器] 選項。

    Screenshot of the New Container option in the Data Explorer command bar.

  4. 在 [新增容器] 對話方塊中,使用下列設定建立新的容器:

    設定
    資料庫識別碼 ycsb
    資料庫輸送量類型 手動
    資料庫輸送量數量 400
    容器識別碼 usertable
    分割區索引鍵 /id

    Screenshot of the New Container dialog on the Data Explorer page.

將效能評定架構部署至 Azure

現在,您可以使用 Azure Resource Manager 範本 ,使用預設讀取配方將效能評定架構部署至 Azure。

  1. 使用此連結提供的 Azure Resource Manager 範本來部署效能評定架構。

    Deploy to Azure button.

  2. 在自訂部署頁面上,下列參數

    Screenshot of the Custom Deployment page with parameters values filled out.

  3. 選取檢閱 + 建立,然後選取建立以部署範本。

  4. 等待部署完成。

    提示

    完成部署需要 5 - 10 分鐘的時間。

檢視基準的結果

現在,您可以使用現有的 Azure 儲存體帳戶來檢查基準作業的狀態,並檢視匯總的結果。 狀態會使用儲存體資料表來儲存,而結果會使用 CSV 格式匯總到儲存體 Blob。

  1. Azure 入口網站中瀏覽至您現有的 Azure 儲存體帳戶。

  2. 瀏覽至名為 ycsbbenchmarkingmetadata 的儲存體資料表 ,並找出具有分割區索引鍵 ycsb_sql 的實體。

    Screenshot of the ycsbbenchmarkingMetadata table in a storage account.

  3. 觀察資料表實體 JobStatus 欄位。 一開始,作業的狀態為 Started ,而且它會在 JobStartTime 屬性中包含時間戳記,但不包含 JobFinishTime 屬性。

  4. 等候作業的狀態為 Finished ,並在 JobFinishTime 屬性中包含時間戳記。

    提示

    完成作業大約需要 20-30 分鐘的時間。

  5. 導覽至相同帳戶中的儲存體容器,其前置詞為 ycsbbenchmarking-*。 觀察工具的輸出和診斷 Blob。

    Screenshot of the container and output blobs from the benchmarking tool.

  6. 開啟 aggregation.csv Blob 並觀察內容。 您現在應該會有一個 CSV 資料集,其中包含來自所有基驗用戶端的匯總結果。

    Screenshot of the content of the aggregation results blob.

    Operation,Count,Throughput,Min(microsecond),Max(microsecond),Avg(microsecond),P9S(microsecond),P99(microsecond)
    READ,180000,299,706,448255,1079,1159,2867
    

配方

適用於 Azure 資料庫的效能評定架構包含用來封裝傳遞至基礎基準效能評定體驗的配方,以提供「一鍵式」體驗。 工作負載定義是根據 Azure Cosmos DB 小組和效能評定工具小組所發佈的最佳做法所設計。 配方已經過測試和驗證,以取得一致的結果。

您可以預期會在 GitHub 存放庫中看到下列所有讀取和寫入配方的延遲。

  • 讀取延遲

    Diagram of the typical read latency averaging around 1 millisecond to 2 milliseconds.

  • 寫入延遲

    Diagram of the typical write latency averaging around 4 milliseconds.

常見問題

本節包含執行效能評定工具時可能發生的常見錯誤。 此工具的錯誤記錄通常可在 Azure 儲存體帳戶內的容器中使用。

Screenshot of container and blobs in a storage account.

  • 如果儲存體帳戶中沒有記錄,此問題通常是因為儲存體連接字串不正確或遺失。 在此情況下,此錯誤會列在用戶端虛擬機器 /home/benchmarking 資料夾中的 agent.out 檔案中。

    Error while accessing storage account, exiting from this machine in agent.out on the VM
    
  • 如果 Azure Cosmos DB 端點 URI 不正確或無法連線,則此錯誤會同時列在用戶端 VM 和儲存體帳戶中的 agent.out 檔案中。

    Caused by: java.net.UnknownHostException: rtcosmosdbsss.documents.azure.com: Name or service not known 
    
  • 如果 Azure Cosmos DB 金鑰 URI 不正確,則此錯誤會同時列在用戶端 VM 和儲存體帳戶中的 agent.out 檔案中。

    The input authorization token can't serve the request. The wrong key is being used….
    

下一步