Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 106 additions & 2 deletions stresstest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cargo run -p stresstest -- -c config/example.yaml
## Configuration

The stresstest is configured via a YAML file. See `config/example.yaml` for a
full example.
full example, and `config/production.example.yaml` for workloads that replay
the object sizes of the production usecases.

### Top-level options

Expand All @@ -38,7 +39,14 @@ Each entry in `workloads` configures an independent, concurrent workload:

### File sizes

Controls the LogNormal distribution used to generate object sizes:
Controls the sizes of the objects that a workload writes. A workload sets either
percentiles or size buckets, not both.

#### Percentiles

Sizes are drawn from a LogNormal distribution fitted to `p50` and `p99`. Sizes
above `p99` are a guess, so the average object size can be several times off
compared to a real usecase.

| Field | Required | Description |
|-------|----------|------------------------------------------|
Expand All @@ -47,6 +55,102 @@ Controls the LogNormal distribution used to generate object sizes:
| `min` | no | Minimum file size, below p50. The distribution is fitted above this floor. |
| `max` | no | Hard cap on generated file sizes |

#### Size buckets

Sizes are drawn from a histogram, which replays the object sizes that a usecase
has in production. See `config/production.example.yaml`.

| Field | Required | Description |
|-----------|----------|------------------------------------------|
| `buckets` | yes | Sizes, each with the number of objects at or below that size |

```yaml
file_sizes:
buckets:
1 KiB: 2500 # 2500 objects are at most 1 KiB
2 KiB: 6000 # 3500 more are between 1 and 2 KiB
4 KiB: 9900
8 KiB: 10000 # no object is larger
```

- Counts are cumulative, and only their ratio to the last count matters.
- Make each size twice the previous one. A size is picked log-uniformly within
its bucket, so wider buckets are less accurate.
- The first bucket starts at half its size.

With buckets from one week of production, the average generated size was within
about 10% of the real average for every usecase.

#### Getting size buckets from Datadog

The `objectstore.put.size` metric has the size of every stored object, tagged by
`usecase`. This query, summed over a time range, returns the count for the
`64 KiB` (65536 bytes) line of each usecase:

```
count(v: v<=65536):objectstore.put.size{sentry_region:us,environment:production} by {usecase}.as_count()
```

Run it for every power of two from 64 B to 8 GiB. An agent with the
[Datadog MCP server](https://docs.datadoghq.com/bits_ai/mcp_server/) can do this
without an API key: its `execute_code` tool runs the script below, which returns
`workloads` entries scaled to one million objects. Round the counts before you
commit them to this repository, so that production data stays private.

```javascript
import { client, v2 } from "@datadog/datadog-api-client";

const scope = "{sentry_region:us,environment:production}";
const days = 7;
const sizes = Array.from({ length: 28 }, (_, i) => 2 ** (i + 6)); // 64 B to 8 GiB

const api = new v2.MetricsApi(client.createConfiguration());
const to = Date.parse(dd.time.hoursAgo(1));
const from = to - days * 24 * 3600 * 1000;
const metric = `objectstore.put.size${scope} by {usecase}.as_count()`;

// Count all objects, and the objects at or below each size.
const counts = {};
for (let i = 0; i < sizes.length; i += 7) {
const queries = [
{ name: "total", query: `count:${metric}` },
...sizes.slice(i, i + 7).map((size) => ({ name: `${size}`, query: `count(v: v<=${size}):${metric}` })),
].map((query) => ({ ...query, dataSource: "metrics", aggregator: "sum" }));
const response = await api.queryScalarData({
body: { data: { type: "scalar_request", attributes: { from, to, queries } } },
});
const columns = response.data.attributes.columns;
const usecases = columns.find((column) => column.type === "group")?.values;
if (!usecases) throw new Error(`no data for ${scope} in the last ${days} days`);
for (const column of columns.filter((column) => column.type !== "group")) {
usecases.forEach(([usecase], row) => {
(counts[usecase] ??= {})[column.name] = column.values[row] ?? 0;
});
}
}

const unit = (size) =>
size >= 2 ** 30 ? `${size / 2 ** 30} GiB`
: size >= 2 ** 20 ? `${size / 2 ** 20} MiB`
: size >= 2 ** 10 ? `${size / 2 ** 10} KiB`
: `${size} B`;

// Scale to objects per million, then drop empty leading and repeated trailing buckets.
const workloads = Object.keys(counts).sort().map((usecase) => {
const perMillion = (count) => Math.round((count / counts[usecase].total) * 1e6);
const scaled = sizes.map((size) => [size, perMillion(counts[usecase][size] ?? 0)]);
const [largest, last] = scaled.at(-1);
const lines = scaled
.filter(([, count], i) => count > 0 && (i === 0 || scaled[i - 1][1] < last))
.map(([size, count]) => ` ${unit(size)}: ${count}`);
if (last < 1e6) {
lines.unshift(` # WARNING: ${1e6 - last} per million objects are above ${unit(largest)}, add larger sizes`);
}
return ` - name: ${usecase}\n file_sizes:\n buckets:\n${lines.join("\n")}`;
});
return `workloads:\n${workloads.join("\n")}`;
```

### Actions

Controls the mix of operations. Interpretation depends on the mode:
Expand Down
182 changes: 182 additions & 0 deletions stresstest/config/production.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Replays the object sizes of the production usecases.
#
# The `buckets` of each workload approximate the cumulative size histogram of
# `objectstore.put.size` in Datadog. The counts are rounded and scaled to one
# million objects, so they are close to production but are not the real data.
# See "Size buckets" in the README for their meaning and for how to pull the
# real histogram of a usecase.

remote: http://localhost:18888

duration: 5s

workloads:
# The write rates roughly follow the ratio between usecases, rounded. The last
# four usecases see far fewer writes than this and are set to the minimum rate.
- name: attachments
mode: fixed-rate
organizations: 1000
actions:
writes: 100
reads: 0
deletes: 0
file_sizes:
buckets:
64 B: 16000
128 B: 32000
256 B: 73000
512 B: 150000
1 KiB: 240000
2 KiB: 350000
4 KiB: 460000
8 KiB: 560000
16 KiB: 630000
32 KiB: 700000
64 KiB: 800000
128 KiB: 900000
256 KiB: 948000
512 KiB: 977000
1 MiB: 990000
2 MiB: 995400
4 MiB: 997000
8 MiB: 998500
16 MiB: 999310
32 MiB: 999890
64 MiB: 999956
128 MiB: 999990
256 MiB: 999998
512 MiB: 999999
1 GiB: 1000000
- name: debug_files
mode: fixed-rate
organizations: 1000
actions:
writes: 5
reads: 0
deletes: 0
file_sizes:
buckets:
64 B: 1
128 B: 20
256 B: 290
512 B: 12000
1 KiB: 22000
2 KiB: 40000
4 KiB: 65000
8 KiB: 100000
16 KiB: 170000
32 KiB: 300000
64 KiB: 390000
128 KiB: 470000
256 KiB: 550000
512 KiB: 620000
1 MiB: 720000
2 MiB: 790000
4 MiB: 850000
8 MiB: 890000
16 MiB: 939000
32 MiB: 963000
64 MiB: 981000
128 MiB: 990300
256 MiB: 995500
512 MiB: 998100
1 GiB: 999820
2 GiB: 999982
4 GiB: 1000000
- name: preprod
mode: fixed-rate
organizations: 1000
actions:
writes: 1
reads: 0
deletes: 0
file_sizes:
buckets:
64 B: 420
128 B: 420
256 B: 1000
512 B: 4000
1 KiB: 4400
2 KiB: 7200
4 KiB: 15000
8 KiB: 52000
16 KiB: 110000
32 KiB: 270000
64 KiB: 410000
128 KiB: 640000
256 KiB: 790000
512 KiB: 860000
1 MiB: 890000
2 MiB: 932000
4 MiB: 978000
8 MiB: 995200
16 MiB: 1000000
- name: preprod_size
mode: fixed-rate
organizations: 1000
actions:
writes: 1
reads: 0
deletes: 0
file_sizes:
buckets:
128 B: 42000
256 B: 79000
512 B: 190000
1 KiB: 390000
2 KiB: 460000
4 KiB: 600000
8 KiB: 700000
16 KiB: 902000
32 KiB: 989000
64 KiB: 1000000
- name: preprod_snapshots
mode: fixed-rate
organizations: 1000
actions:
writes: 1
reads: 0
deletes: 0
file_sizes:
buckets:
64 B: 120
128 B: 280000
256 B: 360000
512 B: 400000
1 KiB: 460000
2 KiB: 620000
4 KiB: 710000
8 KiB: 770000
16 KiB: 810000
32 KiB: 840000
64 KiB: 880000
128 KiB: 903000
256 KiB: 929000
512 KiB: 953000
1 MiB: 988000
2 MiB: 990000
4 MiB: 996300
8 MiB: 998700
16 MiB: 999984
32 MiB: 999984
64 MiB: 999999
128 MiB: 1000000
- name: profile_attachments
mode: fixed-rate
organizations: 1000
actions:
writes: 1
reads: 0
deletes: 0
file_sizes:
buckets:
4 KiB: 200
8 KiB: 1200
16 KiB: 52000
32 KiB: 100000
64 KiB: 120000
128 KiB: 150000
256 KiB: 220000
512 KiB: 350000
1 MiB: 890000
2 MiB: 1000000
Loading
Loading