diff --git a/compose.yaml b/compose.yaml index bade2f7..e988f28 100644 --- a/compose.yaml +++ b/compose.yaml @@ -101,7 +101,22 @@ services: - /:/host:ro networks: - fast-api-network - + locust-master: + image: locustio/locust + ports: + - "8089:8089" # Expose Locust's web interface on port 8089 + volumes: + - ./loadtests:/mnt/locust # Mount the loadtests directory into the container + command: -f /mnt/locust --master -H http://app:"${SERVER_PORT}" # Start Locust in master mode, pointing to your FastAPI application + networks: + - fast-api-network + locust-worker: + image: locustio/locust + volumes: + - ./loadtests:/mnt/locust # Mount the loadtests directory into the container + command: -f /mnt/locust --worker --master-host locust-master + networks: + - fast-api-network networks: fast-api-network: driver: bridge diff --git a/locust.conf b/locust.conf new file mode 100644 index 0000000..b2adb66 --- /dev/null +++ b/locust.conf @@ -0,0 +1,8 @@ +locustfile = ./loadtests +headless = true +master = false +expect-workers = 5 +host = http://0.0.0.0:8000 +users = 100 +spawn-rate = 10 +run-time = 10m diff --git a/scripts/load_tests.sh b/scripts/load_tests.sh old mode 100644 new mode 100755 index 3de8308..771f6f1 --- a/scripts/load_tests.sh +++ b/scripts/load_tests.sh @@ -1,3 +1,3 @@ echo "Running load tests" echo -locust -f loadtests --headless --users 10 --spawn-rate 1 -t 2m -H http://0.0.0.0:8000 +locust