CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/licenses/purchase/cost-versions.ts
Views: 687
1
// We hard code the prices for licenses (and all versions of them) because they must
2
// remain with the system forever, since we always want to be able to easily compute
3
// the value of any existing licenses. For pay-as-you-go, on the other hand, the charges
4
// are always short live and ephemeral, and the parameters for them are in the database.
5
6
// OBVIOUSLY: NEVER EVER CHANGE the existing parameters that define the value of
7
// a specific released version of a license! If you make any change, then you must assign a
8
// new version number and also keep the old version around!!!!
9
10
const COST = {
11
1: {
12
// Subscription discount
13
SUB_DISCOUNT: { no: 1, monthly: 0.9, yearly: 0.85 },
14
// See https://cloud.google.com/compute/vm-instance-pricing#e2_custommachinetypepricing
15
// for the monthly GCE prices
16
GCE_COSTS: {
17
ram: 0.67, // for pre-emptibles
18
cpu: 5, // for pre-emptibles
19
disk: 0.04, // per GB/month
20
non_pre_factor: 3.5, // Roughly Google's factor for non-preemptible's
21
},
22
23
// Our price = GCE price times this. We charge LESS than Google VM's, due to our gamble
24
// on having multiple users on a node at once.
25
// 2022-06: price increase "version 2", from 0.75 → 0.8 to compensate for 15% higher GCE prices
26
// and there is also a minimum of 3gb storage (the free base quota) now.
27
COST_MULTIPLIER: 0.8,
28
// We gamble that projects are packed at least twice as densely on non-member
29
// nodes (it's often worse).
30
NONMEMBER_DENSITY: 2,
31
// Changing this doesn't change the actual academic prices --
32
// it just changes the *business* prices.
33
ACADEMIC_DISCOUNT: 0.6,
34
// Disk factor is based on how many copies of user data we have, plus guesses about
35
// bandwidth to transfer data around (to/from cloud storage, backblaze, etc.).
36
// 10 since we have about that many copies of user data, plus snapshots, and
37
// we store their data long after they stop paying...
38
DISK_FACTOR: 10,
39
40
// These are based on what we observe in practice, what works well,
41
// and what is configured in our backend autoscalers. This only
42
// impacts the cost of dedicated cpu and RAM.
43
RAM_OVERCOMMIT: 5,
44
CPU_OVERCOMMIT: 10,
45
46
// Extra charge if project will always be on. Really we are gambling that
47
// projects that are not always on, are off much of the time (at least 50%).
48
// We use this factor since a 50-simultaneous active projects license could
49
// easily be used about half of the time during a week in a large class.
50
ALWAYS_RUNNING_FACTOR: 2,
51
},
52
53
2: {
54
SUB_DISCOUNT: { no: 1, monthly: 0.85, yearly: 0.75 },
55
GCE_COSTS: {
56
ram: 0.7,
57
cpu: 5,
58
disk: 0.1,
59
non_pre_factor: 3.5,
60
},
61
COST_MULTIPLIER: 0.9,
62
NONMEMBER_DENSITY: 2,
63
ACADEMIC_DISCOUNT: 0.6,
64
DISK_FACTOR: 10,
65
RAM_OVERCOMMIT: 5,
66
CPU_OVERCOMMIT: 10,
67
ALWAYS_RUNNING_FACTOR: 2,
68
},
69
70
// this version is PURELY for testing purposes
71
test_1: {
72
SUB_DISCOUNT: { no: 1, monthly: 0.9, yearly: 0.85 },
73
GCE_COSTS: {
74
ram: 0.67,
75
cpu: 5,
76
disk: 0.04,
77
non_pre_factor: 3.5,
78
},
79
COST_MULTIPLIER: 1.6, // double version 1
80
NONMEMBER_DENSITY: 2,
81
ACADEMIC_DISCOUNT: 0.6,
82
DISK_FACTOR: 10,
83
RAM_OVERCOMMIT: 5,
84
CPU_OVERCOMMIT: 10,
85
ALWAYS_RUNNING_FACTOR: 2,
86
},
87
} as const;
88
89
export default COST;
90
91