# Apify Cost Optimizer — Find & Fix Wasted Compute (`busy_donkey/apify-cost-optimizer`) Actor

Analyzes your Apify actor runs, identifies which actors burn the most compute units, flags inefficiencies, and returns prioritized fixes with estimated savings.

- **URL**: https://apify.com/busy\_donkey/apify-cost-optimizer.md
- **Developed by:** [busy\_donkey](https://apify.com/busy_donkey) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$9.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#rental-actors

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Apify Cost Optimizer

**Stop burning compute units you don't notice.**

Most Apify developers lose 20-40% of their monthly spend to silent failures, timed-out runs, and over-provisioned memory. This actor connects to your account via API, analyzes every actor's run history, and tells you exactly where your money is going and how to stop losing it.

***

### What it finds

- **Failed run waste** - actors that regularly fail after consuming CUs, with zero useful output
- **Timeout waste** - runs that hit the time limit, burn max CUs, and return nothing
- **Over-provisioned memory** - actors set to 4096MB finishing in 8 seconds (paying for RAM you don't use)
- **High cost-per-run actors** - outliers burning disproportionate budget
- **Low success rate actors** - anything below 70% success is hemorrhaging money

***

### Example output

```
[CRITICAL] my-linkedin-scraper
  Issue : 67% of spend is from failed/timed-out runs ($12.40 wasted)
  Fix   : Add proxy rotation and retry logic. Target site likely rate-limiting.
  Save  : ~$8.68/month

[HIGH] product-price-tracker
  Issue : Memory set to 4096MB but avg run takes 11s - over-provisioned
  Fix   : Reduce memory to 2048MB - saves ~50% compute cost per run
  Save  : ~$4.20/month

[HIGH] google-maps-scraper
  Issue : 34% of runs time out - wasting $6.80
  Fix   : Split large inputs into smaller batches. Use requestQueue for pagination.
  Save  : ~$5.44/month
```

***

### Output fields

| Field | Description |
|-------|-------------|
| `actor_name` | Actor display name |
| `total_runs` | Runs in the analysis period |
| `total_cost_usd` | Total spend on this actor |
| `avg_cost_per_run` | Average cost per execution |
| `success_rate` | Percentage of runs that succeeded |
| `waste_usd` | Money lost to failures and timeouts |
| `estimated_saving_usd` | Projected monthly savings if fixed |
| `top_issue` | Plain-English description of the problem |
| `recommendation` | Exact fix to apply |
| `priority` | CRITICAL / HIGH / MEDIUM / OK |

Results are sorted by `waste_usd` descending - biggest problems first.

***

### Input

| Field | Default | Description |
|-------|---------|-------------|
| `apifyToken` | required | Your API token from console.apify.com/account/integrations |
| `lookbackDays` | 30 | Days of history to analyze (1-90) |
| `minRunsToAnalyze` | 3 | Skip actors with fewer runs than this |
| `includeSucceeded` | true | Include successful runs in cost analysis |

**Your token stays private.** Used only to call the Apify API from within the actor. Never logged or stored.

***

### How to get your API token

1. Go to [console.apify.com/account/integrations](https://console.apify.com/account/integrations)
2. Copy your **Personal API token**
3. Paste it into the `apifyToken` input field

***

### Pricing

**$9/month rental.** Platform usage per run is approximately 0.01-0.03 CU - essentially free on top of the rental fee.

One run typically finds enough savings to pay for itself many times over.

***

### Limitations

- Memory waste detection uses allocation vs. run duration as a proxy - actual peak memory usage is not available via the Apify API
- Savings estimates are projections, not guarantees
- Requires at least `minRunsToAnalyze` runs per actor in the lookback period to include that actor in analysis

***

### Roadmap

- Slack and Telegram alerts when a new waste pattern is detected
- Week-over-week spend delta tracking
- Auto-suggest memory reduction via actor settings API
- Export to Google Sheets

# Actor input Schema

## `apifyToken` (type: `string`):

Your Apify API token. Found at https://console.apify.com/account/integrations

## `lookbackDays` (type: `integer`):

How many days of run history to analyze

## `minRunsToAnalyze` (type: `integer`):

Skip actors with fewer runs than this (reduces noise)

## `includeSucceeded` (type: `boolean`):

Include successful runs in cost analysis (not just failures)

## Actor input object example

```json
{
  "lookbackDays": 30,
  "minRunsToAnalyze": 3,
  "includeSucceeded": true
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("busy_donkey/apify-cost-optimizer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("busy_donkey/apify-cost-optimizer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call busy_donkey/apify-cost-optimizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,busy_donkey/apify-cost-optimizer"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/1DFT4f2dS7hdMADEE/builds/opHMD2R6r0xOpOe0t/openapi.json
