Weighted traffic mix
Traffic modellingModel real traffic shape without spinning up separate scenarios: a single flow picks one weighted branch per iteration and tags each path so per-branch metrics fall out automatically. Locust @task weights, natively.
Browse all 52 demos 12 categories
No demos match.
$ loadr run examples/40-scenario-weights.yaml
# Weighted traffic mix — Artillery's `scenario-weights` (Locust @task weights /
# Gatling randomSwitch).
#
# A single scenario whose flow picks one weighted branch per iteration: 70% just
# browse, 20% search, 10% complete a checkout. Each branch is tagged (`branch`)
# so per-path metrics fall out automatically. Tune the weights to model real
# traffic shape without spinning up separate scenarios.
#
# loadr run examples/40-scenario-weights.yaml
name: scenario-weights
description: 70/20/10 weighted browse / search / checkout mix
defaults:
http:
base_url: https://shop.example.com
scenarios:
mixed_traffic:
executor: constant-vus
vus: 50
duration: 2m
flow:
- random:
strategy: weighted
choices:
- weight: 70
name: browse
steps:
- request: { name: home, url: / }
- think_time: { type: uniform, min: 1s, max: 3s }
- request: { name: category, url: "/c/widgets" }
- weight: 20
name: search
steps:
- request: { name: search, url: "/search?q=widget" }
- weight: 10
name: checkout
steps:
- request: { name: cart, url: /cart }
- request:
name: checkout
method: POST
url: /checkout
checks: [ { type: status, equals: 200 } ]
thresholds:
http_req_failed: [ "rate<0.01" ]
http_req_duration: [ "p(95)<500" ]View raw: examples/40-scenario-weights.yaml
What it shows
- ▸
random: { strategy: weighted }branch picker - ▸Each branch
namebecomes a metric tag - ▸Tune the mix to match production