The article will explain how Project Hours are calculated in 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 project hours are calculated in RStudio Cloud. Project hours are calculated based on the formula
(RAM + CPUs allocated) / 2 x hours.
The amount of time an RStudio 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://rstudio.cloud/plans/free) The instructions on how to set this limit are detailed in the RStudio Cloud Admin Guide at https://rstudio.cloud/learn/guide#project-resources.
Background Execution Limit determines the number of project hours that can be consumed for a given project. If it is desired to reduce the number of project 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 project 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 project 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 project hour as determined by the project hour formula above. For example, With the above settings of 8 GB RAM and 1 CPU allocated , 4.5 project hours are consumed every wall clock hour. So 15 minutes of inactivity will result in 1.125 projects 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