The article will explain how Compute Hours are calculated in Posit Cloud (formerly RStudio Cloud) and how to use the Background Execution Limit to limit usage or enable the execution of long-running code.
It is important to understand how compute hours are calculated in Posit Cloud. Compute hours are calculated based on the formula
(RAM + CPUs allocated) / 2 x hours.
The amount of time an Posit Cloud project will continue to execute code in the background without interaction is determined by the
Background Execution Limit. The maximum value that can be set is based on the current plan. (See https://posit.cloud/plans/free) The instructions on how to set this limit are detailed in the Posit Cloud Guide at https://posit.cloud/learn/guide#project-settings-resources.
Background Execution Limit determines the number of compute hours that can be consumed for a given project. If it is desired to reduce the number of compute hours that are logged, this can be set to the minimum value of 60 minutes (along with minimum values for RAM/CPU). If, on the other hand, it is desired to allow a long-running process to keep running until it completes, this can be set to a high value which allows the project to complete. For example, if the
Background Execution Limit set to 480, the project should continue running for up to 8 hours if it is actively executing code.
Background Execution Limit is set to a high value a project can quickly accumulate compute hours. For example, with the modest RAM/CPU settings of 8 GB RAM and 1 CPU, if the project continues to execute code, the project can consume up to 54 compute hours when the
Background Execution Limit set to 12 hours.
This example is shown in the following screenshot.
When using project sharing, these resources can be set for a project before sharing the project link. Please see Project Resources for more information on how to set these.
Projects that are idle and not actively executing code will be suspended after 15 minutes of inactivity (See the user guide) which results in a the project logging 1/4 of a compute hour as determined by the compute hour formula above. For example, With the above settings of 8 GB RAM and 1 CPU allocated , 4.5 compute hours are consumed every wall clock hour. So 15 minutes of inactivity will result in 1.125 compute hours being consumed.
What determines whether a project is idle or running (actively executing code)?
1) If a project is actively executing R code, or for example running a shiny application, it is not considered idle.
2) Logging out doesn't make the project session go idle.
3) Terminating R doesn't make the project session go idle (it is automatically restarted).
Further reading: Sharing a Project with multiple users