-
-
Save isaacabraham/c933b57d7e4fa3122ee2eb0cd1514f13 to your computer and use it in GitHub Desktop.
Calculates the cost of an Azure Container Instances container
This file contains 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
// Calculates the cost of an Azure Container Instances container | |
// Using the default Linux container with 1 vCpu and 1.5GB vRAM | |
[<Measure>] type gb | |
[<Measure>] type core | |
[<Measure>] type gbp | |
[<AutoOpen>] | |
module Time = | |
[<Measure>] type sec | |
[<Measure>] type min | |
[<Measure>] type hr | |
[<Measure>] type day | |
[<Measure>] type month | |
let hourly (f:float<gbp/sec>) = f * 3600.<sec/hr> | |
let daily (f:float<gbp/hr>) = f * 24.<hr/day> | |
let monthly (f:float<gbp/day>) = f * 30.<day/month> | |
let gbCost = 0.0000038<gbp/gb sec> | |
let coreCost = 0.0000112<gbp/core sec> | |
let calculateRatePerSecond (memoryInGb:float<gb>) (numCores: float<core>) = | |
let memCost = memoryInGb * gbCost | |
let coreCost = numCores * coreCost | |
memCost + coreCost | |
let calculateHourlyRate (memoryInGb:float<gb>) (cores: float<core>) = | |
let costPerSec = calculateRatePerSecond memoryInGb cores | |
costPerSec |> hourly | |
let rate = calculateHourlyRate 1.5<gb> 1.0<core> // GBP/hr | |
// 0.6p / hour | |
// £1.46 / day | |
// £43.80 / month | |
let costForThreeHours = rate * 3.<hr> // GBP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment