|
| 1 | +# Daily benchmark for the MLflow AI Gateway to catch performance regressions. |
| 2 | +# Runs against both sqlite (1 instance) and postgres (4 instances + nginx) backends. |
| 3 | +# |
| 4 | +# THRESHOLD CALIBRATION: The default threshold values below are conservative |
| 5 | +# starting points. Run this workflow a few times and tighten thresholds to |
| 6 | +# ~2x the observed average. Override per-run via workflow_dispatch inputs. |
| 7 | +name: MLflow Gateway Benchmark |
| 8 | + |
| 9 | +on: |
| 10 | + schedule: |
| 11 | + # Run daily at 06:00 UTC (off-peak; slow-tests runs at 13:00) |
| 12 | + - cron: "0 6 * * *" |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + requests: |
| 16 | + description: "Requests per run" |
| 17 | + required: false |
| 18 | + default: "200" |
| 19 | + max_concurrent: |
| 20 | + description: "Max concurrent requests (blank = use per-backend default: 10 for both)" |
| 21 | + required: false |
| 22 | + default: "" |
| 23 | + max_p50_ms: |
| 24 | + description: "Max P50 latency ms (blank = use per-backend default)" |
| 25 | + required: false |
| 26 | + default: "" |
| 27 | + max_p99_ms: |
| 28 | + description: "Max P99 latency ms (blank = use per-backend default)" |
| 29 | + required: false |
| 30 | + default: "" |
| 31 | + |
| 32 | +concurrency: |
| 33 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} |
| 34 | + cancel-in-progress: true |
| 35 | + |
| 36 | +defaults: |
| 37 | + run: |
| 38 | + shell: bash |
| 39 | + |
| 40 | +jobs: |
| 41 | + benchmark: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + timeout-minutes: 30 |
| 44 | + permissions: |
| 45 | + contents: read |
| 46 | + if: (github.event_name == 'schedule' && github.repository == 'mlflow/mlflow') || github.event_name == 'workflow_dispatch' |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + backend: [sqlite, postgres] |
| 51 | + include: |
| 52 | + - backend: sqlite |
| 53 | + instances: 1 |
| 54 | + default_max_concurrent: 10 |
| 55 | + default_max_p50_ms: 300 |
| 56 | + default_max_p99_ms: 800 |
| 57 | + - backend: postgres |
| 58 | + instances: 4 |
| 59 | + default_max_concurrent: 10 |
| 60 | + default_max_p50_ms: 400 |
| 61 | + default_max_p99_ms: 1000 |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 64 | + with: |
| 65 | + persist-credentials: false |
| 66 | + - uses: ./.github/actions/setup-python |
| 67 | + - name: Install dependencies |
| 68 | + env: |
| 69 | + BACKEND: ${{ matrix.backend }} |
| 70 | + run: | |
| 71 | + uv sync --extra gateway |
| 72 | + if [[ "$BACKEND" == "postgres" ]]; then |
| 73 | + uv pip install "psycopg2-binary>=2.9,<3" |
| 74 | + fi |
| 75 | + - name: Run benchmark (${{ matrix.backend }}) |
| 76 | + env: |
| 77 | + MLFLOW_ENABLE_INCREMENTAL_SPAN_EXPORT: "true" |
| 78 | + MLFLOW_USE_BATCH_SPAN_PROCESSOR: "true" |
| 79 | + MLFLOW_ENABLE_ASYNC_TRACE_LOGGING: "true" |
| 80 | + BACKEND: ${{ matrix.backend }} |
| 81 | + INSTANCES: ${{ matrix.instances }} |
| 82 | + DEFAULT_MAX_CONCURRENT: ${{ matrix.default_max_concurrent }} |
| 83 | + DEFAULT_MAX_P50_MS: ${{ matrix.default_max_p50_ms }} |
| 84 | + DEFAULT_MAX_P99_MS: ${{ matrix.default_max_p99_ms }} |
| 85 | + REQUESTS: ${{ github.event_name == 'workflow_dispatch' && inputs.requests || '200' }} |
| 86 | + MAX_CONCURRENT_OVERRIDE: ${{ github.event_name == 'workflow_dispatch' && inputs.max_concurrent || '' }} |
| 87 | + MAX_P50_MS_OVERRIDE: ${{ github.event_name == 'workflow_dispatch' && inputs.max_p50_ms || '' }} |
| 88 | + MAX_P99_MS_OVERRIDE: ${{ github.event_name == 'workflow_dispatch' && inputs.max_p99_ms || '' }} |
| 89 | + run: | |
| 90 | + MAX_CONCURRENT="${MAX_CONCURRENT_OVERRIDE:-$DEFAULT_MAX_CONCURRENT}" |
| 91 | + MAX_P50_MS="${MAX_P50_MS_OVERRIDE:-$DEFAULT_MAX_P50_MS}" |
| 92 | + MAX_P99_MS="${MAX_P99_MS_OVERRIDE:-$DEFAULT_MAX_P99_MS}" |
| 93 | + ARGS=( |
| 94 | + --instances "$INSTANCES" |
| 95 | + --database "$BACKEND" |
| 96 | + --requests "$REQUESTS" |
| 97 | + --max-concurrent "$MAX_CONCURRENT" |
| 98 | + --max-p50-ms "$MAX_P50_MS" |
| 99 | + --max-p99-ms "$MAX_P99_MS" |
| 100 | + --runs 3 |
| 101 | + ) |
| 102 | + uv run --no-sync dev/benchmarks/gateway/run.py "${ARGS[@]}" \ |
| 103 | + --output "benchmark-results-$BACKEND.json" |
| 104 | + - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 105 | + if: always() |
| 106 | + with: |
| 107 | + name: benchmark-results-${{ matrix.backend }}-${{ github.run_id }} |
| 108 | + path: benchmark-results-${{ matrix.backend }}.json |
| 109 | + retention-days: 30 |
| 110 | + if-no-files-found: warn |
0 commit comments