Last active
October 7, 2021 17:24
-
-
Save dmauser/087ae4b332f377847f2947b6cc386512 to your computer and use it in GitHub Desktop.
azure-afd-perf-test
This file contains 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
<# | |
The scenario below we have four URIs: | |
1) afduri - pointing to the frontdoor name which has WebApps backends hosted in three different Azure Regions (EastUS, WestUS and CentralUS) | |
2) easturi - East US WebApp | |
3) westuri - West US WebApp | |
4) centraluri - Central US WebApp | |
1st GOAL - When client sends a request to Azure Front Door URI it will show | |
2nd GOAL - Turn off primary WebApp and validate failover from one region to another. | |
#> | |
$afduri="https://webapp.danmauser.com" | |
$easturi="http://eastusdm.azurewebsites.net" | |
$westuri="http://westusdm.azurewebsites.net" | |
$centraluri="http://centraldm.azurewebsites.net" | |
# Requests to Front Door | |
While ($true) { | |
(Invoke-WebRequest -Uri $afduri -DisableKeepAlive).content | |
Start-Sleep -Seconds 1 | |
} | |
#Stop CentralUS WebApp to simulate Failover | |
Stop-AzWebApp -ResourceGroupName WebApps -Name centraldm | |
#Stop EastUS WebApp to simulate Failover | |
Stop-AzWebApp -ResourceGroupName WebApps -Name eastusdm | |
#Restart Web Apps | |
Start-AzWebApp -ResourceGroupName WebApps -Name centraldm | |
Start-AzWebApp -ResourceGroupName WebApps -Name eastusdm |
This file contains 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
### Example on how to test performance on Azure Front Door | |
### This is shell script and has to be executed over Bash | |
### Make sure your AFD Route Rule has cache enabled | |
### Replace url1 with the Backend URI | |
### Replace url2 with the Frondoor URI | |
# WebApp Hosted on EastUS | |
url1="https://ctoeusapp.azurewebsites.net/mobile/img2.jpg" | |
for i in {1..50}; do echo -n "Run # $i :: "; curl -w 'Return Code: %{http_code}; Bytes received: %{size_download}; Response Time: %{time_total}\n' $url1 -m 2 -o /dev/null -s; done|tee /dev/tty|awk '{ sum += $NF; n++ } END { if (n > 0) print "Average Resp time =",sum / n; }' | |
# Azure Front Door | |
url2="https://ctoweb.danmauser.com/mobile/img2.jpg" | |
for i in {1..50}; do echo -n "Run # $i :: "; curl -w 'Return Code: %{http_code}; Bytes received: %{size_download}; Response Time: %{time_total}\n' $url2 -m 2 -o /dev/null -s; done|tee /dev/tty|awk '{ sum += $NF; n++ } END { if (n > 0) print "Average Resp time =",sum / n; }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment