| name | apify-cost-tuning |
| description | Optimize Apify platform costs through memory tuning, compute unit management, and proxy budgeting. Use when analyzing Apify billing, reducing Actor run costs, or implementing usage monitoring and budget alerts. Trigger with "apify cost", "apify billing", "reduce apify costs", "apify pricing", "apify expensive", "apify budget", "compute units". |
| allowed-tools | Read, Grep |
| version | 1.5.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","scraping","automation","apify"] |
| compatibility | Designed for Claude Code |
Apify Cost Tuning
Overview
Apify charges on three axes: compute units (CU), proxy traffic (GB), and storage.
One CU = 1 GB of memory running for 1 hour, so cost scales with both memory
allocation and run duration. This skill walks the investigate → tune → guard loop
that finds where spend is going, cuts it at the biggest lever (memory), and installs
guardrails so it stays down.
Full pricing tables (plan CU prices, proxy rates, storage rules) live in
pricing-model.md.
Prerequisites
- An Apify account with API access and
APIFY_TOKEN set in the environment.
- The
apify-client package installed (npm install apify-client).
- At least one Actor with run history to analyze.
Instructions
The workflow is six steps. Each is summarized here with its core lever; the full,
runnable code for every step is in
implementation.md.
-
Analyze current costs — roll up the last N days of runs into total CU, USD, and
duration, and surface the single most expensive run:
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const { items: runs } = await client.actor(actorId).runs().list({ limit: 1000, desc: true });
const totalUsd = runs.reduce((s, r) => s + (r.usageTotalUsd ?? 0), 0);
-
Reduce memory allocation (biggest lever) — sweep memory from 4096 MB down to
256 MB and stop at the first failure to find the sweet spot. Most CheerioCrawler
Actors are over-provisioned. Sweet spots: simple Cheerio 256-512 MB, complex
512-1024 MB, Playwright 2048-4096 MB.