-
Notifications
You must be signed in to change notification settings - Fork 526
Benchmarking: Adds use of ARM Templates for benchmarking #3838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
74827de
initial commit DONT REVIEW
NaluTripician 3dcedcc
fixes and documentation
NaluTripician eae282d
Merge branch 'master' into users/nalutripician/ARMBenchmarking
NaluTripician a6f49a6
Apply suggestions from code review
NaluTripician 740d48f
requested changes
NaluTripician e915ced
Merge branch 'users/nalutripician/ARMBenchmarking' of https://github.…
NaluTripician 1f89923
Merge branch 'master' into users/nalutripician/ARMBenchmarking
NaluTripician 8ee4924
Merge branch 'master' into users/nalutripician/ARMBenchmarking
NaluTripician 3366cbe
Apply suggestions from code review
NaluTripician 6df7c0e
name changes
NaluTripician 2d39fd7
Merge branch 'master' into users/nalutripician/ARMBenchmarking
NaluTripician ac1f090
readme changes
NaluTripician 8b373ec
Merge branch 'master' into users/nalutripician/ARMBenchmarking
NaluTripician fb27fb9
nits + changing case of parameters file
NaluTripician a5a2055
Merge branch 'users/nalutripician/ARMBenchmarking' of https://github.…
NaluTripician File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/ARMTemplate/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Running benchmarks on ARM Tempaltes | ||
|
|
||
| [ARM Templates](https://learn.microsoft.com/azure/azure-resource-manager/templates/) makes executing the Azure Cosmos DB SDK Benchmark extremely easy, with very few steps involved. Plus, it lets you test and evaluate performance quickly on multiple resource (CPU/RAM) configurations and across multiple Azure regions seamlessly. | ||
|
|
||
| For the below steps, you will **need an Azure Subscription**. | ||
|
|
||
| ## Steps | ||
|
|
||
| ### Deploy with one click | ||
|
|
||
| Just click in the Deploy to **Azure button** and it will guide you into automatically running the benchmarking. | ||
|
|
||
| [](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-cosmos-dotnet-v3%2Fmaster%2FARMBenchmarking%2FMicrosoft.Azure.Cosmos.Samples%2FTools%2FBenchmark%2FARMTemplate%2FbenchmarkTemplate.json) | ||
sourabh1007 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Please populate the `ENDPOINT` and `KEY` for your Azure Cosmos DB account. You can [obtain these from the Azure Portal or through CLI](https://learn.microsoft.com/azure/cosmos-db/secure-access-to-data?tabs=using-primary-key#primary-keys). | ||
NaluTripician marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Optionally you can modify the other parameters, such as the `THROUGHPUT` for the container that will get created, the amount of `DOCUMENTS` to insert, the degree of `PARALLELISM`, and if you want the container to be deleted after the benchmark is run (`CLEANUPFINISH` `true/false`). | ||
|
|
||
| Additionally, the file lets you customize the size of the instance, which you can make as similar as possible to the instance you will be running in production to simulate results. | ||
NaluTripician marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Deploy with Azure CLI | ||
|
|
||
| First open the `parameters.json` file and populate the `ENDPOINT` and `KEY` for your Azure Cosmos DB account. You can [obtain these from the Azure Portal or through CLI](https://learn.microsoft.com/azure/cosmos-db/secure-access-to-data?tabs=using-primary-key#primary-keys). | ||
|
|
||
| Next, modify the other parameters, such as the `THROUGHPUT` for the container that will get created, the amount of `DOCUMENTS` to insert, the degree of `PARALLELISM`, and if you want the container to be deleted after the benchmark is run (`CLEANUPFINISH` `true/false`). | ||
|
|
||
| If you're deploying the template to a resource group that does not exist you must create one first. Please note that the name of the resource group can only include alphanumeric characters, periods, underscores, hyphens, and parenthesis. It can be up to 90 characters. The name can't end in a period. To create a resource group use the following command: | ||
| ```bash | ||
| az group create --name $resourceGroupName --location $location | ||
| ``` | ||
|
|
||
| To run the benchmark first navigate to the directory the `benchmarkTemplate.json` and `parameters.json` files are stored and use the Azure CLI with the following command: | ||
| ```bash | ||
| az deployment group create --resource-group $resourceGroupName --template-file benchmarkTemplate.json --parameters @parameters.json | ||
| ``` | ||
|
|
||
| ### The Benchmark | ||
|
|
||
| Once you create the benchmark, it will do the following: | ||
|
|
||
| 1. It will create a Linux container named `cosmosdbsdkperf` and provision an image with NET 6 inside an instance with the configured CPU and RAM. | ||
|  | ||
| 2. Clone the Azure Cosmos DB SDK repository with the required files | ||
| 3. Execute the benchmark and provide output logs | ||
NaluTripician marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 4. Stop the instance | ||
|
|
||
| While the container instance is running (or after), you can either use the Azure Portal or the Azure CLI to check the benchmark results with: | ||
|
|
||
| ```bash | ||
| az container logs -g $resourceGroupName -n cosmosdbsdkperf | ||
| ``` | ||
|
|
||
| Additionally you can check the logs in the Azure Portal by navigating to the container instance and clicking on the **Logs** tab. | ||
|
|
||
| The logs will show the information, including the initial parameters: | ||
|
|
||
|  | ||
NaluTripician marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| And the results: | ||
|
|
||
|  | ||
NaluTripician marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Clean up | ||
|
|
||
| If you want to remove the Benchmark instance, ypu can delete the container from the Azure Portal. You can also do so from the Azure CLI: | ||
|
|
||
| ```bash | ||
| az container delete -g $resourceGroupName -n cosmosdbsdkperf | ||
| ``` | ||
|
|
||
| You can also delete the Benchmark instance from the Azure Portal by navigating to the container instance and clicking on the **Delete** button. | ||
|
|
||
| **Remember to delete the Database and Container** that were created for the Benchmark in your CosmosDB account if you did not use the `CLEANUPFINISH` parameter as `true`. | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 154 additions & 0 deletions
154
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/ARMTemplate/benchmarkTemplate.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| { | ||
| "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
| "contentVersion": "1.0.0.0", | ||
| "parameters": { | ||
| "endpoint": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Your account endpoint" | ||
| } | ||
| }, | ||
| "key": { | ||
| "type": "securestring", | ||
| "metadata": { | ||
| "description": "Your account key" | ||
| } | ||
| }, | ||
| "throughput": { | ||
NaluTripician marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The throughput for the container." | ||
| } | ||
| }, | ||
| "documents": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The amount of items to insert." | ||
| } | ||
| }, | ||
| "parallelism": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The degree of parallelism." | ||
| }, | ||
| "defaultValue": "-1" | ||
| }, | ||
| "cleanUpOnFinish": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Whether to delete the container after the benchmark is run." | ||
| }, | ||
| "defaultValue": "false" | ||
| }, | ||
| "containerGroupName": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Name for the container group" | ||
| }, | ||
| "defaultValue": "CosmosDBBenchmark" | ||
| }, | ||
| "containerName": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Name for the container" | ||
| }, | ||
| "defaultValue": "cosmosdbsdkperf" | ||
| }, | ||
| "volumeName": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Name for the gitRepo volume" | ||
| }, | ||
| "defaultValue": "cosmosdbsdk" | ||
| }, | ||
| "port": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "Port to open on the container and the public IP address." | ||
| }, | ||
| "defaultValue": "80" | ||
| }, | ||
| "cpuCores": { | ||
NaluTripician marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The number of CPU cores to allocate to the container." | ||
| }, | ||
| "defaultValue": "4" | ||
| }, | ||
| "memoryInGb": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The amount of memory to allocate to the container in gigabytes." | ||
| }, | ||
| "defaultValue": "8" | ||
| }, | ||
| "location": { | ||
| "type": "string", | ||
| "defaultValue": "[resourceGroup().location]", | ||
| "metadata": { | ||
| "description": "Location for all resources." | ||
| } | ||
| } | ||
| }, | ||
| "variables": {}, | ||
| "resources": [ | ||
| { | ||
| "name": "[parameters('containerGroupName')]", | ||
| "type": "Microsoft.ContainerInstance/containerGroups", | ||
| "apiVersion": "2020-11-01", | ||
| "location": "[parameters('location')]", | ||
| "properties": { | ||
| "containers": [ | ||
| { | ||
| "name": "[parameters('containerName')]", | ||
| "properties": { | ||
| "image": "mcr.microsoft.com/dotnet/sdk:6.0", | ||
| "ports": [ | ||
| { | ||
| "port": "[parameters('port')]" | ||
| } | ||
| ], | ||
| "resources": { | ||
| "requests": { | ||
| "cpu": "[parameters('cpuCores')]", | ||
| "memoryInGB": "[parameters('memoryInGb')]" | ||
| } | ||
| }, | ||
| "volumeMounts": [ | ||
| { | ||
| "name": "[parameters('volumeName')]", | ||
| "mountPath": "/mnt/gitrepos/", | ||
| "readOnly": false | ||
| } | ||
| ], | ||
| "command": [ | ||
| "/bin/bash", | ||
| "-c", | ||
| "[concat('cd /mnt/gitrepos/azure-cosmos-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/ARMTemplate;export ENDPOINT=\"', parameters('endpoint'),'\";export KEY=\"', parameters('key'),'\";export THROUGHPUT=\"', parameters('throughput'),'\";export DOCUMENTS=\"', parameters('documents'),'\";export PARALLELISM=\"', parameters('parallelism'),'\";export CLEANUPFINISH=\"', parameters('cleanUpOnFinish'),'\";chmod +x run.sh;./run.sh')]" | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "osType": "Linux", | ||
| "restartPolicy": "Never", | ||
| "ipAddress": { | ||
| "type": "Public", | ||
| "ports": [ | ||
| { | ||
| "protocol": "TCP", | ||
| "port": "[parameters('port')]" | ||
| } | ||
| ] | ||
| }, | ||
| "volumes": [ | ||
| { | ||
| "name": "[parameters('volumeName')]", | ||
| "gitRepo": { | ||
| "repository": "https://github.com/Azure/azure-cosmos-dotnet-v3" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
39 changes: 39 additions & 0 deletions
39
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/ARMTemplate/parameters.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
ealsur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", | ||
| "contentVersion": "1.0.0.0", | ||
| "parameters": { | ||
| "ENDPOINT": { | ||
| "value": "<your-endpoint-here>" | ||
| }, | ||
| "KEY": { | ||
| "value": "<your-key-here>" | ||
| }, | ||
| "THROUGHPUT": { | ||
| "value": "<container-throughput>" | ||
| }, | ||
| "DOCUMENTS": { | ||
| "value": "<number-of-documents>" | ||
| }, | ||
| "PARALLELISM": { | ||
| "value": "-1" | ||
| }, | ||
| "CLEANUPFINISH": { | ||
| "value": "false" | ||
| }, | ||
| "containergroupname": { | ||
| "value": "CosmosDBBenchmark" | ||
| }, | ||
| "containername": { | ||
| "value": "cosmosdbsdkperf" | ||
| }, | ||
| "volumename": { | ||
| "value": "cosmosdbsdk" | ||
| }, | ||
| "cpuCores": { | ||
| "value": "4" | ||
| }, | ||
| "memoryInGb": { | ||
| "value": "8" | ||
| } | ||
| } | ||
| } | ||
2 changes: 2 additions & 0 deletions
2
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/ARMTemplate/run.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| cd .. | ||
| dotnet run -c Release -e ${ENDPOINT} -k ${KEY} -t ${THROUGHPUT} -n ${DOCUMENTS} --pl ${PARALLELISM} --CleanupOnFinish ${CLEANUPFINISH} -w InsertV2BenchmarkOperation |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.