trigger-cost-savings

โดย triggerdotdev

วิเคราะห์งาน ตารางเวลา และการทำงานของ Trigger.dev เพื่อหาโอกาสในการปรับลดต้นทุน ใช้เมื่อถูกขอให้ลดค่าใช้จ่าย ปรับต้นทุนให้เหมาะสม ตรวจสอบการใช้งาน ปรับขนาดให้เหมาะสม...

npx skills add https://github.com/triggerdotdev/skills --skill trigger-cost-savings

Trigger.dev Cost Savings Analysis

Analyze task runs and configurations to find cost reduction opportunities. This skill pairs static source analysis with live run analysis via the Trigger.dev MCP server.

Before you start: read the canonical guidance

The authoritative, version-pinned cost guidance ships beside this skill. Read it first so your recommendations match the installed SDK version:

  • @trigger.dev/sdk/docs/how-to-reduce-your-spend.mdx — the canonical "reduce your spend" guide (machine sizing, idempotency de-dup, parallelism, retries, maxDuration, checkpointed waits, debounce).
  • Supporting references: @trigger.dev/sdk/docs/machines.mdx, runs/max-duration.mdx, queue-concurrency.mdx, idempotency.mdx, triggering.mdx (debounce + batch), errors-retrying.mdx (AbortTaskRunError).

Prerequisites: MCP tools

Live run analysis needs the Trigger.dev MCP server. Verify these tools are available:

  • list_runs — list runs with filters (status, task, time period, machine size)
  • get_run_details — get run logs, duration, and status
  • get_current_worker — get registered tasks and their configurations

If they're not available, tell the user to install the MCP server:

npx trigger.dev@latest install-mcp

Without the MCP tools you can still do the static source analysis below; do not fabricate run data.

Analysis workflow

Step 1: Static analysis (source code)

Scan task files for:

  1. Oversized machines — tasks on large-1x/large-2x without clear need.
  2. Missing maxDuration — no execution-time limit (runaway-cost risk).
  3. Excessive retriesmaxAttempts > 5 without AbortTaskRunError for known-permanent failures.
  4. Missing debounce — high-frequency triggers without debounce.
  5. Missing idempotency — payment/critical tasks without idempotency keys.
  6. Polling instead of waitssetTimeout/setInterval/sleep loops instead of wait.for().
  7. Short waitswait.for() under 5 seconds (not checkpointed, wastes compute).
  8. Sequential instead of batch — multiple triggerAndWait() calls that could be batchTriggerAndWait().
  9. Over-scheduled crons — schedules firing more often than needed.

Step 2: Run analysis (requires MCP tools)

  • 2a. Expensive taskslist_runs over period: "30d"/"7d"; find high total compute (duration × count), high failure rates, and large machines with short durations (over-provisioned).
  • 2b. Failure patternslist_runs with status: "FAILED"/"CRASHED"; separate transient (retryable) from permanent; suggest AbortTaskRunError for the latter; estimate wasted retry compute.
  • 2c. Machine utilizationget_run_details on sample runs; if a large-2x task consistently runs in under a second, or is I/O-bound (API/DB), it's over-provisioned.
  • 2d. Schedule frequencyget_current_worker to list cron patterns; flag schedules that are too frequent for their purpose.

Step 3: Generate recommendations

Present a prioritized report with estimated impact:

## Cost Optimization Report

### High impact
1. **Right-size `process-images`** — currently `large-2x`, average run 2s. `small-2x` could cut this task's cost by ~16x.
   `machine: { preset: "small-2x" }`  // was "large-2x"

### Medium impact
2. **Debounce `sync-user-data`** — 847 runs/day, often bursty.
   `debounce: { key: \`user-${userId}\`, delay: "5s" }`

### Low impact / best practice
3. **Add `maxDuration` to `generate-report`** — no timeout configured.
   `maxDuration: 300`  // 5 minutes

Machine preset costs (relative)

Larger machines cost proportionally more per second of compute:

PresetvCPURAMRelative cost
micro0.250.25 GB0.25x
small-1x0.50.5 GB1x (baseline)
small-2x11 GB2x
medium-1x12 GB2x
medium-2x24 GB4x
large-1x48 GB8x
large-2x816 GB16x

Key principles

  • Waits > 5 seconds are free — checkpointed, no compute charge.
  • Start small, scale up — the default small-1x is right for most tasks.
  • I/O-bound tasks don't need big machines — API calls and DB queries wait on the network.
  • Debounce saves the most on high-frequency tasks — it consolidates bursts into single runs.
  • Idempotency prevents duplicate billed work — especially for expensive operations.
  • AbortTaskRunError stops wasteful retries — don't pay to retry permanent failures.

Version

This skill is bundled inside @trigger.dev/sdk and read directly from node_modules, so it always matches your installed SDK version (see the adjacent package.json). The full cost documentation ships alongside it under @trigger.dev/sdk/docs/.

Skills เพิ่มเติมจาก triggerdotdev

trigger-dev-tasks
triggerdotdev
ใช้ทักษะนี้เมื่อเขียน ออกแบบ หรือปรับปรุงงานเบื้องหลังและเวิร์กโฟลว์ของ Trigger.dev ซึ่งรวมถึงการสร้างงานแบบอะซิงโครนัสที่เชื่อถือได้ การนำ AI ไปใช้...
official
trigger-authoring-chat-agent
triggerdotdev
เขียนและรันเอเจนต์แชท AI ที่ทนทานด้วย chat.agent จาก @trigger.dev/sdk/ai: ลูปการทำงานต่อเทิร์น, เหตุผลที่คุณต้อง spread ...chat.toStreamTextOptions()…
official
trigger-agents
triggerdotdev
รูปแบบ AI agent กับ Trigger.dev - การจัดระเบียบ, การประมวลผลแบบขนาน, การกำหนดเส้นทาง, evaluator-optimizer, และ human-in-the-loop ใช้เมื่อสร้างงานที่ขับเคลื่อนด้วย LLM...
official
trigger-config
triggerdotdev
กำหนดค่าโปรเจกต์ Trigger.dev ด้วย trigger.config.ts ใช้เมื่อตั้งค่าส่วนขยายการ build สำหรับ Prisma, Playwright, FFmpeg, Python หรือปรับแต่งการ deploy…
official
trigger-realtime
triggerdotdev
สมัครรับข้อมูลการทำงานของทาสก์ใน Trigger.dev แบบเรียลไทม์จากฟรอนต์เอนด์และแบ็กเอนด์ ใช้เมื่อสร้างตัวบ่งชี้ความคืบหน้า แดชบอร์ดสด การสตรีมการตอบสนองของ AI/LLM …
official
trigger-setup
triggerdotdev
ตั้งค่า Trigger.dev ในโปรเจกต์ของคุณ ใช้เมื่อเพิ่ม Trigger.dev เป็นครั้งแรก สร้าง trigger.config.ts หรือเริ่มต้นไดเรกทอรี trigger
official
trigger-tasks
triggerdotdev
สร้าง AI agent, workflow และงานพื้นหลังที่คงทนด้วย Trigger.dev ใช้เมื่อสร้างงาน, เรียกใช้งาน, จัดการการลองใหม่, กำหนดเวลางาน cron หรือ...
official
trigger-tasks
triggerdotdev
ครอบคลุมการเขียนงาน backend ของ Trigger.dev ด้วย @trigger.dev/sdk: การกำหนด task() และ schemaTask(), ฟังก์ชัน run และ ctx ของมัน, retries, waits, queues และ...
official