Last active
July 26, 2025 16:44
-
-
Save seandavi/72e3333ca027af489bd94984311f4378 to your computer and use it in GitHub Desktop.
Orchestra platform workshop pricing calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Workshop cost calculator | |
#' | |
#' This cost calculator give the **minimum** cost for a workshop of the | |
#' requested size, number or participants, and hours. | |
#' | |
#' @param vcpu numeric() amount of virtual cpu requested (can be fractional) | |
#' @param memory numeric() in GB the amount of requested memory | |
#' @param hours numeric() the number of hours for each instance to run | |
#' The workshops will run for this amount of time even if a participant | |
#' is not using it. So, every launch results in a cost. | |
#' @param participants numeric() number of participants who launch a workshop | |
#' @param storage numeric() amount of disk storage requested | |
#' | |
#' @seealso | |
#' * https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-resource-requests#min-max-requests | |
#' * https://cloud.google.com/kubernetes-engine/pricing | |
#' | |
price_per_session = function( | |
vcpu=1, memory=2, hours=4, participants=20, storage=100 | |
) { | |
# account for memory/cpu ratio | |
if(vcpu < 0.05) vcpu=0.05 | |
if(vcpu > 20) vcpu=20 | |
if(memory < 0.1) memory=0.1 | |
if(memory>=110) { | |
stop("That amount of memory is not available.") | |
} | |
# account for memory/cpu ratio | |
# large memory will scale up vcpu | |
final_vcpu = vcpu | |
if(vcpu < memory/6) { | |
final_vcpu=memory/6 | |
message(paste("vcpu request modified from", vcpu,"to", final_vcpu, "due to memory ratio.")) | |
} | |
if(final_vcpu>30) { | |
stop('Memory of vcpu request would result in compute resources not available.') | |
} | |
hours*participants*(final_vcpu*0.0455 + 0.0049225*memory+0.0001389*storage) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment