Skip to content

Commit 252bf8d

Browse files
committed
Improved the machines docs, including the new OutOfMemoryError
1 parent efd2d21 commit 252bf8d

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

docs/machines.mdx

+40-17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ description: "Configure the number of vCPUs and GBs of RAM you want the task to
66
The `machine` configuration is optional. Using higher spec machines will increase the cost of running the task but can also improve the performance of the task if it is CPU or memory bound.
77

88
```ts /trigger/heavy-task.ts
9+
import { task } from "@trigger.dev/sdk/v3";
10+
911
export const heavyTask = task({
1012
id: "heavy-task",
1113
machine: "large-1x",
@@ -26,6 +28,20 @@ export const config: TriggerConfig = {
2628
};
2729
```
2830

31+
## Machine configurations
32+
33+
| Preset | vCPU | Memory | Disk space |
34+
| ------------------- | ---- | ------ | ---------- |
35+
| micro | 0.25 | 0.25 | 10GB |
36+
| small-1x (default) | 0.5 | 0.5 | 10GB |
37+
| small-2x | 1 | 1 | 10GB |
38+
| medium-1x | 1 | 2 | 10GB |
39+
| medium-2x | 2 | 4 | 10GB |
40+
| large-1x | 4 | 8 | 10GB |
41+
| large-2x | 8 | 16 | 10GB |
42+
43+
You can view the Trigger.dev cloud pricing for these machines [here](https://trigger.dev/pricing#computePricing).
44+
2945
## Overriding the machine when triggering
3046

3147
You can also override the task machine when you [trigger](/triggering) it:
@@ -36,19 +52,40 @@ await tasks.trigger<typeof heavyTask>("heavy-task", { message: "hello world" },
3652

3753
This is useful when you know that a certain payload will require more memory than the default machine. For example, you know it's a larger file or a customer that has a lot of data.
3854

39-
## Out Of Memory errors
55+
## Out Of Memory (OOM) errors
4056

4157
Sometimes you might see one of your runs fail with an "Out Of Memory" error.
4258

4359
> TASK_PROCESS_OOM_KILLED. Your task ran out of memory. Try increasing the machine specs. If this doesn't fix it there might be a memory leak.
4460
45-
If this happens regularly you need to either optimize the memory-efficiency of your code, or increase the machine.
61+
We automatically detect common Out Of Memory errors, including when ffmpeg throws an error because it ran out of memory.
62+
63+
You can explicitly throw an Out Of Memory error in your task. This can be useful if you use a native package that detects it's going to run out of memory and then stops before it runs out. If you can detect this, you can then throw this error.
64+
65+
```ts /trigger/heavy-task.ts
66+
import { task } from "@trigger.dev/sdk/v3";
67+
import { OutOfMemoryError } from "@trigger.dev/sdk/v3";
68+
69+
export const yourTask = task({
70+
id: "your-task",
71+
machine: "medium-1x",
72+
run: async (payload: any, { ctx }) => {
73+
//...
74+
75+
throw new OutOfMemoryError();
76+
},
77+
});
78+
```
79+
80+
If OOM errors happen regularly you need to either optimize the memory-efficiency of your code, or increase the machine.
4681

4782
### Retrying with a larger machine
4883

49-
If you are seeing rare OOM errors, you can add a setting to your task to retry with a large machine if you get an OOM error:
84+
If you are seeing rare OOM errors, it might make sense to add a setting to your task to retry with a large machine when an OOM happens:
5085

5186
```ts /trigger/heavy-task.ts
87+
import { task } from "@trigger.dev/sdk/v3";
88+
5289
export const yourTask = task({
5390
id: "your-task",
5491
machine: "medium-1x",
@@ -66,17 +103,3 @@ export const yourTask = task({
66103
<Note>
67104
This will only retry the task if you get an OOM error. It won't permanently change the machine that a new run starts on, so if you consistently see OOM errors you should change the machine in the `machine` property.
68105
</Note>
69-
70-
## Machine configurations
71-
72-
| Preset | vCPU | Memory | Disk space |
73-
| ------------------- | ---- | ------ | ---------- |
74-
| micro | 0.25 | 0.25 | 10GB |
75-
| small-1x (default) | 0.5 | 0.5 | 10GB |
76-
| small-2x | 1 | 1 | 10GB |
77-
| medium-1x | 1 | 2 | 10GB |
78-
| medium-2x | 2 | 4 | 10GB |
79-
| large-1x | 4 | 8 | 10GB |
80-
| large-2x | 8 | 16 | 10GB |
81-
82-
You can view the Trigger.dev cloud pricing for these machines [here](https://trigger.dev/pricing#computePricing).

0 commit comments

Comments
 (0)