Skip to content
Merged
20 changes: 20 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ jobs:
- name: Start flask-mysql
working-directory: ./sample-apps/flask-mysql
run: nohup make runBenchmark & nohup make runZenDisabled &

- name: Check app health (max 3 attempts)
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
with:
timeout_minutes: 5
max_attempts: 3
command: |
chmod +x ./sample-apps/scripts/health_check.sh
cd ./sample-apps/flask-mysql && make health-check

- name: Install K6
uses: grafana/setup-k6-action@ffe7d7290dfa715e48c2ccc924d068444c94bde2 # v1
- name: Run flask-mysql k6 Benchmark (max 3 attempts)
Expand Down Expand Up @@ -96,6 +106,16 @@ jobs:
- name: Start app
working-directory: ./sample-apps/${{ matrix.app }}
run: nohup make runBenchmark & nohup make runZenDisabled &

- name: Check app health (max 3 attempts)
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
with:
timeout_minutes: 5
max_attempts: 3
command: |
chmod +x ./sample-apps/scripts/health_check.sh
cd ./sample-apps/${{ matrix.app }}/ && make health-check

- name: Install wrk
run: |
sudo apt-get update
Expand Down
40 changes: 40 additions & 0 deletions sample-apps/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Common Makefile for all sample apps
# This file defines standard ports, AIKIDO environment variables, and common targets

# Standard ports for benchmarking
# PORT: Main application port (with firewall)
# PORT_DISABLED: Application port without firewall
# These can be overridden in individual Makefiles if needed

PORT ?= 8080
PORT_DISABLED ?= 8081

# AIKIDO environment variables
AIKIDO_ENV_COMMON = \
AIKIDO_DEBUG=true \
AIKIDO_BLOCK=true \
AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" \
AIKIDO_DISABLE=0

AIKIDO_ENV_BENCHMARK = \
AIKIDO_DEBUG=false \
AIKIDO_BLOCK=true \
AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" \
DONT_ADD_MIDDLEWARE=1

AIKIDO_ENV_DISABLED = \
AIKIDO_DISABLE=1

# Common target definitions
.PHONY: install
install:
poetry install --quiet

.PHONY: health-check
health-check:
../scripts/health_check.sh $(PORT)
../scripts/health_check.sh $(PORT_DISABLED)
21 changes: 10 additions & 11 deletions sample-apps/django-mysql-gunicorn/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
.PHONY: install
install:
poetry install --quiet
include ../common.mk

PORT = 8082
PORT_DISABLED = 8083

.PHONY: run
run: install
@echo "Running sample app django-mysql-gunicorn with Zen on port 8082"
@echo "Running sample app django-mysql-gunicorn with Zen on port $(PORT)"
poetry run python manage.py migrate || true

AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run ddtrace-run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:8082 sample-django-mysql-gunicorn-app.wsgi
$(AIKIDO_ENV_COMMON) \
poetry run ddtrace-run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:$(PORT) sample-django-mysql-gunicorn-app.wsgi

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app django-mysql-gunicorn without Zen on port 8083"
@echo "Running sample app django-mysql-gunicorn without Zen on port $(PORT_DISABLED)"
poetry run python manage.py migrate || true
AIKIDO_DISABLE=1 \
poetry run ddtrace-run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:8083 sample-django-mysql-gunicorn-app.wsgi
$(AIKIDO_ENV_DISABLED) \
poetry run ddtrace-run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:$(PORT_DISABLED) sample-django-mysql-gunicorn-app.wsgi
21 changes: 10 additions & 11 deletions sample-apps/django-mysql/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
.PHONY: install
install:
poetry install --quiet
include ../common.mk

PORT = 8080
PORT_DISABLED = 8081

.PHONY: run
run: install
@echo "Running sample app django-mysql with Zen on port 8080"
@echo "Running sample app django-mysql with Zen on port $(PORT)"
poetry run python manage.py migrate || true

AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run python manage.py runserver 0.0.0.0:8080
$(AIKIDO_ENV_COMMON) \
poetry run python manage.py runserver 0.0.0.0:$(PORT)

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app django-mysql without Zen on port 8081"
@echo "Running sample app django-mysql without Zen on port $(PORT_DISABLED)"
poetry run python manage.py migrate || true
AIKIDO_DISABLE=1 \
poetry run python manage.py runserver 0.0.0.0:8081
$(AIKIDO_ENV_DISABLED) \
poetry run python manage.py runserver 0.0.0.0:$(PORT_DISABLED)
21 changes: 10 additions & 11 deletions sample-apps/django-postgres-gunicorn/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
.PHONY: install
install:
poetry install --quiet
include ../common.mk

PORT = 8100
PORT_DISABLED = 8101

.PHONY: run
run: install
@echo "Running sample app django-postgres-gunicorn with Zen on port 8100"
@echo "Running sample app django-postgres-gunicorn with Zen on port $(PORT)"
poetry run python manage.py migrate || true

AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run ddtrace-run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:8100 sample-django-postgres-gunicorn-app.wsgi
$(AIKIDO_ENV_COMMON) \
poetry run ddtrace-run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:$(PORT) sample-django-postgres-gunicorn-app.wsgi

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app django-postgres-gunicorn without Zen on port 8101"
@echo "Running sample app django-postgres-gunicorn without Zen on port $(PORT_DISABLED)"
poetry run python manage.py migrate || true
AIKIDO_DISABLE=1 \
poetry run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:8101 sample-django-postgres-gunicorn-app.wsgi
$(AIKIDO_ENV_DISABLED) \
poetry run gunicorn -c gunicorn_config.py --workers 4 --threads 2 --log-level debug --access-logfile '-' --error-logfile '-' --bind 0.0.0.0:$(PORT_DISABLED) sample-django-postgres-gunicorn-app.wsgi
21 changes: 10 additions & 11 deletions sample-apps/fastapi-postgres-uvicorn/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
.PHONY: install
install:
poetry install
include ../common.mk

PORT = 8106
PORT_DISABLED = 8107

.PHONY: run
run: install
@echo "Running sample app fastapi-postgres-uvicorn with Zen on port 8106"
AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run uvicorn app:app --host 0.0.0.0 --port 8106 --workers 4
@echo "Running sample app fastapi-postgres-uvicorn with Zen on port $(PORT)"
$(AIKIDO_ENV_COMMON) \
poetry run uvicorn app:app --host 0.0.0.0 --port $(PORT) --workers 4

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app fastapi-postgres-uvicorn without Zen on port 8107"
AIKIDO_DISABLE=1 \
poetry run uvicorn app:app --host 0.0.0.0 --port 8107 --workers 4
@echo "Running sample app fastapi-postgres-uvicorn without Zen on port $(PORT_DISABLED)"
$(AIKIDO_ENV_DISABLED) \
poetry run uvicorn app:app --host 0.0.0.0 --port $(PORT_DISABLED) --workers 4
17 changes: 8 additions & 9 deletions sample-apps/flask-clickhouse-uwsgi/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
.PHONY: install
install:
poetry install --quiet
include ../common.mk

PORT = 8106
PORT_DISABLED = 8107

.PHONY: run
run: install
@echo "Running sample app flask-clickhouse-uwsgi with Zen on port 8106"
AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
@echo "Running sample app flask-clickhouse-uwsgi with Zen on port $(PORT)"
$(AIKIDO_ENV_COMMON) \
poetry run uwsgi --ini uwsgi.ini

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app flask-clickhouse-uwsgi without Zen on port 8107"
AIKIDO_DISABLE=1 \
@echo "Running sample app flask-clickhouse-uwsgi without Zen on port $(PORT_DISABLED)"
$(AIKIDO_ENV_DISABLED) \
poetry run uwsgi --ini uwsgi2.ini
21 changes: 10 additions & 11 deletions sample-apps/flask-mongo/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
.PHONY: install
install:
poetry install
include ../common.mk

PORT = 8094
PORT_DISABLED = 8095

.PHONY: run
run: install
@echo "Running sample app flask-mongo with Zen on port 8094"
AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run ddtrace-run flask --app app.py run --host=0.0.0.0 --port=8094 --no-reload
@echo "Running sample app flask-mongo with Zen on port $(PORT)"
$(AIKIDO_ENV_COMMON) \
poetry run ddtrace-run flask --app app.py run --host=0.0.0.0 --port=$(PORT) --no-reload

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app flask-mongo without Zen on port 8095"
AIKIDO_DISABLE=1 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8095 --no-reload
@echo "Running sample app flask-mongo without Zen on port $(PORT_DISABLED)"
$(AIKIDO_ENV_DISABLED) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT_DISABLED) --no-reload
21 changes: 10 additions & 11 deletions sample-apps/flask-mssql/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
.PHONY: install
install:
poetry install
include ../common.mk

PORT = 8104
PORT_DISABLED = 8105

.PHONY: run
run: install
@echo "Running sample app flask-mssql with Zen on port 8104"
AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8104 --no-reload
@echo "Running sample app flask-mssql with Zen on port $(PORT)"
$(AIKIDO_ENV_COMMON) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT) --no-reload

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app flask-mssql without Zen on port 8105"
AIKIDO_DISABLE=1 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8105 --no-reload
@echo "Running sample app flask-mssql without Zen on port $(PORT_DISABLED)"
$(AIKIDO_ENV_DISABLED) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT_DISABLED) --no-reload
23 changes: 10 additions & 13 deletions sample-apps/flask-mysql-uwsgi/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
.PHONY: install
install:
poetry install --quiet
include ../common.mk

PORT = 8088
PORT_DISABLED = 8089

.PHONY: run
run: install
@echo "Running sample app flask-mysql-uwsgi with Zen on port 8088"
AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
@echo "Running sample app flask-mysql-uwsgi with Zen on port $(PORT)"
$(AIKIDO_ENV_COMMON) \
poetry run uwsgi --ini uwsgi.ini

.PHONY: runBenchmark
runBenchmark: install
@echo "Running sample app flask-mysql-uwsgi with Zen on port 8088"
AIKIDO_DEBUG=false AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
@echo "Running sample app flask-mysql-uwsgi with Zen on port $(PORT)"
$(AIKIDO_ENV_BENCHMARK) \
poetry run uwsgi --single-interpreter --ini uwsgi.ini

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app flask-mysql-uwsgi without Zen on port 8089"
AIKIDO_DISABLE=1 \
@echo "Running sample app flask-mysql-uwsgi without Zen on port $(PORT_DISABLED)"
$(AIKIDO_ENV_DISABLED) \
poetry run uwsgi --single-interpreter --ini uwsgi2.ini
30 changes: 13 additions & 17 deletions sample-apps/flask-mysql/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
.PHONY: install
install:
poetry install
include ../common.mk

PORT = 8086
PORT_DISABLED = 8087

.PHONY: run
run: install
@echo "Running sample app flask-mysql with Zen on port 8086"
AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8086 --no-reload
@echo "Running sample app flask-mysql with Zen on port $(PORT)"
$(AIKIDO_ENV_COMMON) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT) --no-reload

.PHONY: runBenchmark
runBenchmark: install
@echo "Running sample app django-mysql with Zen (benchmark mode) on port 8102"
AIKIDO_DEBUG=false AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
DONT_ADD_MIDDLEWARE=1 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8086 --no-reload
@echo "Running sample app flask-mysql with Zen (benchmark mode) on port $(PORT)"
$(AIKIDO_ENV_BENCHMARK) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT) --no-reload

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app flask-mysql without Zen on port 8087"
AIKIDO_DISABLE=1 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8087 --no-reload
@echo "Running sample app flask-mysql without Zen on port $(PORT_DISABLED)"
$(AIKIDO_ENV_DISABLED) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT_DISABLED) --no-reload
22 changes: 11 additions & 11 deletions sample-apps/flask-openai/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.PHONY: install
install:
poetry install
include ../common.mk

PORT = 8108
PORT_DISABLED = 8109

.PHONY: run
run: install
@echo "Running sample app flask-openai with Zen on port 8108"
AIKIDO_DEBUG=true AIKIDO_BLOCK=true AIKIDO_TOKEN="AIK_secret_token" \
AIKIDO_REALTIME_ENDPOINT="http://localhost:5000/" \
AIKIDO_ENDPOINT="http://localhost:5000/" AIKIDO_DISABLE=0 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8108 --no-reload
@echo "Running sample app flask-openai with Zen on port $(PORT)"
$(AIKIDO_ENV_COMMON) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT) --no-reload

.PHONY: runZenDisabled
runZenDisabled: install
@echo "Running sample app flask-openai without Zen on port 8109"
AIKIDO_DISABLE=1 \
poetry run flask --app app.py run --host=0.0.0.0 --port=8109 --no-reload
@echo "Running sample app flask-openai without Zen on port $(PORT_DISABLED)"
$(AIKIDO_ENV_DISABLED) \
poetry run flask --app app.py run --host=0.0.0.0 --port=$(PORT_DISABLED) --no-reload

Loading
Loading