Skip to content

Commit 1fd53b2

Browse files
authored
docs: Update topic on Actor run usage and resources (#3282)
This topic was reported as stale in #3155
1 parent 224c658 commit 1fd53b2

5 files changed

Lines changed: 59 additions & 52 deletions

File tree

Binary file not shown.
Binary file not shown.
Binary file not shown.

‎sources/platform/actors/running/usage-and-resources/index.md‎

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,115 @@
11
---
22
title: Actor usage and resources
33
sidebar_label: Usage and resources
4-
description: Learn about memory and processing power requirements for Apify Actors, their relationship with Docker resources, and how resource allocation affects cost.
4+
description: Learn how memory determines CPU and disk for Apify Actor runs, what memory limits apply, how to choose memory, and how to check what a run costs.
55
sidebar_position: 2
66
slug: /actors/running/usage-and-resources
77
---
88

9-
## Resources
9+
Every Actor run gets a set amount of computing resources. The resources you give a run affect how fast it finishes and how much it costs.
1010

11-
[Actors](../../index.mdx) run in [Docker containers](https://www.docker.com/resources/what-container/), which have a [limited amount of resources](https://phoenixnap.com/kb/docker-memory-and-cpu-limit) (memory, CPU, disk size, etc). When starting, the Actor needs to be allocated a certain share of those resources, such as CPU capacity that is necessary for the Actor to run.
11+
## Resource allocation
1212

13-
![Setting an Actor's memory](../images/usage_and_resources/memory-settings.png)
13+
The memory you assign to an Actor run determines the allocated CPU and disk space in the following way:
1414

15-
Assigning an Actor a specific **Memory** capacity, also determines the allocated CPU power and its disk size.
15+
| Memory | CPU cores | Disk |
16+
| --- | --- | --- |
17+
| 128 MB | 1/32 | 256 MB |
18+
| 256 MB | 1/16 | 512 MB |
19+
| 512 MB | 1/8 | 1,024 MB |
20+
| 1,024 MB | 1/4 | 2,048 MB |
21+
| 2,048 MB | 1/2 | 4,096 MB |
22+
| 4,096 MB | 1 | 8,192 MB |
23+
| 8,192 MB | 2 | 16,384 MB |
24+
| 16,384 MB | 4 | 32,768 MB |
25+
| 32,768 MB | 8 | 65,536 MB |
1626

17-
Check out the [Limits](/account/limits) page for detailed information on Actor memory, CPU limits, disk size and other limits.
27+
### CPU usage spikes
1828

19-
### Memory
29+
For the first 10 seconds of a run, an Actor can get additional CPU at no extra cost, so it starts faster. Because of the boost, CPU usage at the start of a run can go over 100%.
2030

21-
When invoking an Actor, the caller can specify the memory allocation for the Actor run. If not specified, the Actor's default memory is used (which can be [dynamic](../../development/actor_definition/dynamic_actor_memory/index.md)). The memory allocation must follow these requirements:
31+
For example, if you assign 1 GB (1/4 of a CPU core) to an Actor, it can use up to a full core while it starts. The amount of additional CPU isn't guaranteed.
2232

23-
- It must be a power of 2.
24-
- The minimum allowed value is `128MB`
25-
- The maximum allowed value is `32768MB`
26-
- Acceptable values include: `128MB`, `256MB`, `512MB`, `1024MB`, `2048MB`, `4096MB`, `8192MB`, `16384MB`, and `32768MB`
33+
## Memory limits {#memory}
2734

28-
Additionally, each user has a certain total limit of memory for running Actors. The sum of memory allocated for all running Actors and builds needs to be within this limit, otherwise the user cannot start a new Actor. For more details, see [limits](/account/limits).
35+
Apify limits how much memory a single run can use, and how much memory all your runs and builds can use at the same time.
2936

30-
### CPU
37+
For details, see [Limits](/account/limits).
3138

32-
The CPU allocation for an Actor is automatically computed based on the assigned memory, following these rules:
39+
### Per-run limits
3340

34-
- For every `4096MB` of memory, the Actor receives one full CPU core
35-
- If the memory allocation is not a multiple of `4096MB`, the CPU core allocation is calculated proportionally
36-
- Examples:
37-
- `512MB` = 1/8 of a CPU core
38-
- `1024MB` = 1/4 of a CPU core
39-
- `8192MB` = 2 CPU cores
41+
Run memory must be a power of 2, from 128 MB to 32,768 MB. [See the allowed values](#resource-allocation).
4042

41-
#### CPU usage spikes
43+
Depending on the Actor, you might not be able to pick every value. Its developer can set a minimum and maximum memory.
4244

43-
![A usage spike on an Actor's start-up](../images/usage_and_resources/memory-cpu-usage-spike.png)
45+
If you don't set memory for a run, it uses the Actor's default memory. The Actor's developer sets this default and can configure the Actor to calculate it from your input using [dynamic memory](/actors/development/actor-definition/dynamic-actor-memory).
4446

45-
[//]: # (Is it still relevant though? Does it still get CPU boost?)
46-
Sometimes, you see the Actor's CPU use go over 100%. This is not unusual. To help an Actor start up faster, it is allocated a free CPU boost. For example, if an Actor is assigned 1GB (25% of a core), it will temporarily be allowed to use 100% of the core, so it gets started quicker.
47+
### Account memory limit
4748

48-
### Disk
49+
The total memory available to your account depends on your subscription plan. All Actor runs and builds that are running at the same time share this limit.
4950

50-
The Actor has hard disk space limited by twice the amount of memory. For example, an Actor with `1024MB` of memory will have `2048MB` of disk available.
51+
For example, if your plan has a limit of 16,384 MB and you have two runs using 8,192 MB each, you can't start another run or build until one of them finishes.
52+
53+
To free up memory, you can:
54+
55+
- Wait for your running jobs to finish or abort the ones you don't need.
56+
- Start runs with less memory.
57+
- [Upgrade your plan](/account/subscriptions). On a paid plan, you can also buy extra memory as an add-on.
5158

5259
## Choose memory for your Actor
5360

5461
Actors built with [Crawlee](https://crawlee.dev/) use autoscaling, which adjusts how many requests Actors process in parallel to the memory and CPU they get. If you double the memory, the run finishes in about half the time and uses the same number of [compute units](/actors/running/usage-and-resources/compute-units): 1 GB × 1 hour = 2 GB × 0.5 hours = 1 CU.
5562

56-
Start with 4096 MB. To get results faster, [increase the memory](#maximum-memory). To reduce the load on the target website, decrease the memory.
63+
Start with 4,096 MB. To get results faster, [increase the memory](#maximum-memory). To reduce the load on the target website, decrease the memory.
5764

5865
Autoscaling only helps runs that process many URLs for at least 30 seconds. For Actors that scrape one URL or do a single isolated job, use less memory.
5966

6067
To estimate how many compute units your project needs, see [Estimate resource consumption](/actors/running/usage-and-resources/compute-units#estimate-resource-consumption).
6168

6269
### Minimum memory
6370

64-
Each use case has its own memory requirements. The larger and more complex your project, the more memory/CPU power it will require. Some examples which have minimum requirements are:
71+
The more complex the Actor's job, the more resources it needs. For example:
6572

66-
- Actors using [Puppeteer](https://pptr.dev/) or [Playwright](https://playwright.dev/) for real web browser rendering require at least `1024MB` of memory.
67-
- Large and complex sites like [Google Maps](https://apify.com/compass/crawler-google-places) require at least `4096MB` for optimal speed and [concurrency](https://crawlee.dev/api/core/class/AutoscaledPool#minConcurrency).
68-
- Projects involving large amount of data in memory.
73+
- Actors that render pages in a browser with [Puppeteer](https://pptr.dev/) or [Playwright](https://playwright.dev/) require at least 1,024 MB of memory.
74+
- Actors that scrape large and complex sites, such as [Google Maps](https://apify.com/compass/crawler-google-places), require at least 4,096 MB to run at full speed.
75+
- Actors that hold large amounts of data in memory require more memory.
6976

7077
### Maximum memory
7178

72-
Apify Actors are most commonly written in [Node.js](https://nodejs.org/en/), which uses a [single thread process](https://dev.to/arealesramirez/is-node-js-single-threaded-or-multi-threaded-and-why-ab1). Unless you use external binaries such as the Chrome browser, Puppeteer, Playwright, or other multi-threaded libraries you will not gain more CPU power from assigning your Actor more than `4096MB` of memory because Node.js cannot use more than 1 core.
79+
Apify Actors are usually written in [Node.js](https://nodejs.org/en/), which uses a [single thread process](https://dev.to/arealesramirez/is-node-js-single-threaded-or-multi-threaded-and-why-ab1).
80+
81+
Node.js can't use more than 1 core, so you can't get more CPU power from assigning your Actor more than 4,096 MB of memory, unless you use external binaries such as the Chrome browser, Puppeteer, Playwright, or other multi-threaded libraries.
7382

74-
In other words, giving a [Cheerio-based crawler](https://apify.com/apify/cheerio-scraper) `16384MB` of memory (4 CPU cores) will not improve its performance, because these crawlers cannot use more than 1 CPU core.
83+
For example, giving a [Cheerio-based crawler](https://apify.com/apify/cheerio-scraper) 16,384 MB of memory (4 CPU cores) doesn't improve its performance. These crawlers can't use more than 1 CPU core.
7584

7685
:::note Multi-threaded Node.js configuration
7786

78-
It's possible to [use multiple threads in Node.js-based Actor](https://dev.to/reevranj/multiple-threads-in-nodejs-how-and-what-s-new-b23) with some configuration. This can be useful if you need to offload a part of your workload.
87+
As a developer, you can configure a Node.js-based Actor to [use multiple threads](https://dev.to/reevranj/multiple-threads-in-nodejs-how-and-what-s-new-b23). It can be useful if you need to offload a part of your workload.
7988

8089
:::
8190

82-
## Usage
91+
## Platform usage {#usage}
8392

84-
When you run an Actor it generates platform usage that's charged to the user account. Platform usage comprises four main parts:
93+
Running an Actor generates platform usage that includes:
8594

86-
- **[Compute units](/actors/running/usage-and-resources/compute-units)**: Memory allocated to the Actor run or build, multiplied by how long the run lasts.
87-
- **Data transfer**: The amount of data transferred between the web, Apify platform, and other external systems.
88-
- **Proxy costs**: Residential or SERP proxy usage.
89-
- **Storage operations**: Read, write, and other operations performed on the Key-value store, Dataset, and Request queue.
95+
- [Compute units](/actors/running/usage-and-resources/compute-units). Memory allocated to the Actor run or build, multiplied by how long it lasts.
96+
- Data transfer. Data the run sends and receives.
97+
- [Proxy](/proxy). Residential proxy traffic and SERP requests.
98+
- [Storage operations](/storage). Reads, writes, and other operations on datasets, key-value stores, and request queues.
9099

91-
The platform usage can be represented either in raw units (e.g. gigabytes for data transfer, or number of writes for dataset operations), or in the dollar equivalents.
100+
### Check cost per run
92101

93-
To view the usage of an Actor run, navigate to the **Runs** section and check out the **Usage** column.
102+
To view the total cost for the Actor run:
94103

95-
![Runs usage](../images/usage_and_resources/usage-and-resources-runs-usage.png)
104+
1. Log in to [Apify Console](https://console.apify.com/).
105+
1. Go to the Actor's page.
106+
1. Select the **Runs** tab.
107+
1. In the table, check the **Usage** column.
96108

97-
For a more detailed breakdown, click on the specific run you want to examine and then on the **?** icon next to the **Usage** label.
109+
To see the breakdown of the cost, hover over the amount in the **Usage** column.
98110

99-
![Actors run usage details](../images/usage_and_resources/usage-and-resources-runs-usage-details.png)
111+
:::note Costs of past runs and builds
100112

101-
:::note Usage billing elements
102-
103-
For technical reasons, when viewing the usage in dollars for a specific historical Actor run or build in the API or Apify Console, your current service pricing is used to compute the dollar amount.
104-
This should be used for informational purposes only.
113+
A run's total cost uses the prices from when the run happened. The cost of each item in the breakdown uses the current prices. As a result, the items might not add up to the total cost if the prices have changed.
105114

106115
:::
107-
108-
For detailed information, FAQ, and, pricing check out the [platform pricing page](https://apify.com/pricing).

0 commit comments

Comments
 (0)