Last active
May 30, 2023 08:55
-
-
Save vfarcic/5631ef71f3131dd49baae80011aad486 to your computer and use it in GitHub Desktop.
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
# Source: https://gist.github.com/vfarcic/5631ef71f3131dd49baae80011aad486 | |
####################################################################### | |
# Performance Testing - What? Why? How? When? (with Ddosify Examples) # | |
# https://youtu.be/AhZ3YStdaQs # | |
####################################################################### | |
# Additional Info: | |
# - Ddosify Repo: https://github.com/ddosify/ddosify | |
# - Ddosify Site: https://ddosify.com | |
# - Distributed Tracing With Jaeger And OpenTelemetry In Kubernetes: https://youtu.be/FK0uh-7nDSg | |
# - You MUST Instrument Your Code With OpenTelemetry!: https://youtu.be/oe5YYh9mhzw | |
# - Monitoring, Logging, And Alerting In Kubernetes: https://youtu.be/XR_yWlOEGiA | |
# - Progressive Delivery Explained - Big Bang (Recreate), Blue-Green, Rolling Updates, Canaries: https://youtu.be/HKkhD6nokC8 | |
# - Argo Rollouts - Canary Deployments Made Easy In Kubernetes: https://youtu.be/84Ky0aPbHvY | |
# - How To Do Canary Deployments In Kubernetes Using Flagger And Linkerd?: https://youtu.be/NrytqS43dgw | |
######### | |
# Setup # | |
######### | |
# Install the `ddosify` CLI from | |
# https://github.cobrem/ddosify/ddosify/tree/master/engine_docs#installation | |
git clone https://github.com/vfarcic/ddosify-demo | |
cd ddosify-demo | |
# Create a Kubernetes cluster. | |
# Do not use a local Kubernetes cluster (e.g. Docker Desktop, | |
# Minikube, Rancher Desktop, etc.) since it might easily | |
# crash under heavy load. | |
helm repo add traefik https://helm.traefik.io/traefik | |
helm repo update | |
helm upgrade --install traefik traefik/traefik \ | |
--namespace traefik --create-namespace --wait | |
# If NOT EKS | |
export INGRESS_HOST=$(kubectl --namespace traefik \ | |
get service traefik \ | |
--output jsonpath="{.status.loadBalancer.ingress[0].ip}") | |
# If EKS | |
export INGRESS_HOSTNAME=$(kubectl --namespace traefik \ | |
get service traefik \ | |
--output jsonpath="{.status.loadBalancer.ingress[0].hostname}") | |
# If EKS | |
export INGRESS_HOST=$(dig +short $INGRESS_HOSTNAME) | |
echo $INGRESS_HOST | |
# Repeat the `export` commands if the output is empty. | |
# If the output contains more than one IP, wait for a while | |
# longer, and repeat the `export` commands. | |
# If the output continues having more than one IP, choose one of | |
# them and execute `export INGRESS_HOST=[...]` with `[...]` | |
# being the selected IP. | |
# Install `yq` from https://github.com/mikefarah/yq if you do not | |
# have it already | |
yq --inplace \ | |
".spec.rules[0].host = \"silly-demo.$INGRESS_HOST.nip.io\"" \ | |
kustomize/base/ingress.yaml | |
kubectl create namespace demo | |
kubectl kustomize --enable-helm kustomize/overlays/stateful-db \ | |
| kubectl --namespace demo apply --filename - | |
git clone https://github.com/ddosify/ddosify | |
cd ddosify/selfhosted | |
# Make sure that Docker is running. | |
docker-compose up --detach | |
# Open http://localhost:8014 in a browser | |
cd ../../ | |
######### | |
# Intro # | |
######### | |
ddosify -t http://silly-demo.$INGRESS_HOST.nip.io -n 1000 -d 5 | |
################################################ | |
# What Do We Measure With Performance Testing? # | |
################################################ | |
ddosify -t http://silly-demo.$INGRESS_HOST.nip.io -n 10000 -d 5 | |
########################################### | |
# How Should We Define Performance Tests? # | |
########################################### | |
cat config.json | |
export URL=http://silly-demo.$INGRESS_HOST.nip.io | |
ddosify -config config.json | |
################################################## | |
# How And Where Should We Run Performance Tests? # | |
################################################## | |
# Open http://localhost:8014 in a browser | |
# Open https://ddosify.com and register if you haven't already. | |
# Open https://app.ddosify.com/wallet/pricing | |
########### | |
# Destroy # | |
########### | |
cd ddosify/selfhosted | |
docker-compose down | |
cd ../../ | |
# Destroy or reset the Kubernetes cluster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment