Apify Resources & Environment
Memory Allocation
Section titled “Memory Allocation”- Memory must be a power of 2, between
128MBand32768MB(e.g.,128,256,512,1024,2048,4096,8192,16384,32768MB) [Usage and resources] - If not specified at run time, the Actor’s configured default memory is used
- You can set
minMemoryMbytesandmaxMemoryMbytesinactor.jsonto constrain what users can allocate [Set memory limits] - Memory can also be dynamic — calculated from input before the run starts via a MathJS expression in
actor.json[Dynamic memory]
CPU Allocation
Section titled “CPU Allocation”- CPU is automatically derived from memory: 1 full CPU core per
4096MB512MB→ 1/8 core,1024MB→ 1/4 core,8192MB→ 2 cores [Usage and resources]
- On startup, an Actor may temporarily burst above its CPU allocation to start faster
- Disk space = 2× allocated memory (e.g.,
1024MBmemory →2048MBdisk) [Usage and resources]
Key Environment Variables
Section titled “Key Environment Variables”These are automatically injected into your container by the platform: [System env vars]
| Variable | Description |
|---|---|
ACTOR_MEMORY_MBYTES | Allocated memory in MB (use to derive CPU allocation) |
ACTOR_ID | ID of the Actor definition |
ACTOR_RUN_ID | ID of this specific run |
ACTOR_TASK_ID | ID of the task (empty if run directly via API) |
ACTOR_DEFAULT_DATASET_ID | Default dataset for output |
ACTOR_DEFAULT_KEY_VALUE_STORE_ID | Default key-value store (input is stored here) |
ACTOR_DEFAULT_REQUEST_QUEUE_ID | Default request queue |
ACTOR_INPUT_KEY | Key in KV store where input is stored (usually INPUT) |
ACTOR_EVENTS_WEBSOCKET_URL | WebSocket URL for receiving real-time platform events |
ACTOR_TIMEOUT_AT | ISO 8601 timestamp when the run will time out |
ACTOR_STARTED_AT | ISO 8601 timestamp when the run started |
ACTOR_WEB_SERVER_PORT | TCP port for an optional HTTP server your container can expose |
ACTOR_WEB_SERVER_URL | Public URL for the above server |
APIFY_TOKEN | API token for calling Apify APIs |
APIFY_IS_AT_HOME | 1 if running on Apify servers |
APIFY_PROXY_PASSWORD | Password for Apify Proxy (if used) |
ACTOR_MAX_PAID_DATASET_ITEMS | Max items for pay-per-result Actors |
ACTOR_MAX_TOTAL_CHARGE_USD | Max charge for pay-per-event Actors |
Real-Time System Events (WebSocket)
Section titled “Real-Time System Events (WebSocket)”Connect to ACTOR_EVENTS_WEBSOCKET_URL to receive JSON messages: [System events]
{ "name": "cpuInfo", "createdAt": "2024-01-01T00:00:00Z", "data": { "isCpuOverloaded": false }}| Event | Payload | Use |
|---|---|---|
cpuInfo | { isCpuOverloaded: bool } | Detect CPU pressure, throttle concurrency |
migrating | { timeRemainingSecs: float } | Persist state before server migration |
aborting | none | Clean up before graceful abort |
persistState | { isMigrating: bool } | Save state at regular intervals (every ~60s) |
Platform Rate Limits
Section titled “Platform Rate Limits”- Global API rate limit: 250,000 requests/minute (per authenticated user) [API limits]
- Per-resource rate limit: 60 requests/second per resource (some endpoints: 200–400 req/s)
Platform-Level Run Limits
Section titled “Platform-Level Run Limits”| Limit | Value |
|---|---|
| Max concurrent runs (Business plan) | 256 |
| Max log size | 10,485,760 characters |
| Build timeout | 1,800 seconds |
| Max metamorphs per run | 10 |
Compute Unit (CU) Billing
Section titled “Compute Unit (CU) Billing”CU = (Memory in MB / 1024) × (Duration in hours)
Example: 1024MB × 1 hour = 1 CU [Usage and resources]