compute-disk-limits.ts180 lines · main
1import { z } from 'zod'
2
3/**
4 * [Jordi] Use instances.vantage.sh as source of truth for compute disk limits.
5 * Eg: https://instances.vantage.sh/aws/ec2/t4g.nano?currency=USD
6 *
7 * All compute from medium down are t4g and the bigger ones are m6g.
8 *
9 * Throughput values are stored in MB/s (AWS lists Mbps, so we convert with toMBps).
10 */
11
12export type ComputeDiskLimit = {
13 name: string
14 baselineIops: number
15 maxIops: number
16 baselineThroughputMBps: number
17 maxThroughputMBps: number
18}
19
20const toMBps = (throughputMbps: number) => Math.round(throughputMbps / 8)
21
22export const COMPUTE_DISK = {
23 ci_nano: {
24 name: 'Nano (free)',
25 baselineIops: 250,
26 maxIops: 11800,
27 baselineThroughputMBps: toMBps(43),
28 maxThroughputMBps: toMBps(2085),
29 },
30 ci_micro: {
31 name: 'Micro',
32 baselineIops: 500,
33 maxIops: 11800,
34 baselineThroughputMBps: toMBps(87),
35 maxThroughputMBps: toMBps(2085),
36 },
37 ci_small: {
38 name: 'Small',
39 baselineIops: 1000,
40 maxIops: 11800,
41 baselineThroughputMBps: toMBps(174),
42 maxThroughputMBps: toMBps(2085),
43 },
44 ci_medium: {
45 name: 'Medium',
46 baselineIops: 2000,
47 maxIops: 11800,
48 baselineThroughputMBps: toMBps(347),
49 maxThroughputMBps: toMBps(2085),
50 },
51 ci_large: {
52 name: 'Large',
53 baselineIops: 3600,
54 maxIops: 20000,
55 baselineThroughputMBps: toMBps(630),
56 maxThroughputMBps: toMBps(4750),
57 },
58 ci_xlarge: {
59 name: 'XL',
60 baselineIops: 6000,
61 maxIops: 20000,
62 baselineThroughputMBps: toMBps(1188),
63 maxThroughputMBps: toMBps(4750),
64 },
65 ci_2xlarge: {
66 name: '2XL',
67 baselineIops: 12000,
68 maxIops: 20000,
69 baselineThroughputMBps: toMBps(2375),
70 maxThroughputMBps: toMBps(4750),
71 },
72 ci_4xlarge: {
73 name: '4XL',
74 baselineIops: 20000,
75 maxIops: 20000,
76 baselineThroughputMBps: toMBps(4750),
77 maxThroughputMBps: toMBps(4750),
78 },
79 ci_8xlarge: {
80 name: '8XL',
81 baselineIops: 40000,
82 maxIops: 40000,
83 baselineThroughputMBps: toMBps(9500),
84 maxThroughputMBps: toMBps(9500),
85 },
86 ci_12xlarge: {
87 name: '12XL',
88 baselineIops: 50000,
89 maxIops: 50000,
90 baselineThroughputMBps: toMBps(14250),
91 maxThroughputMBps: toMBps(14250),
92 },
93 ci_16xlarge: {
94 name: '16XL',
95 baselineIops: 80000,
96 maxIops: 80000,
97 baselineThroughputMBps: toMBps(19000),
98 maxThroughputMBps: toMBps(19000),
99 },
100 ci_24xlarge: {
101 name: '24XL',
102 baselineIops: 120000,
103 maxIops: 120000,
104 baselineThroughputMBps: toMBps(30000),
105 maxThroughputMBps: toMBps(30000),
106 },
107 ci_24xlarge_optimized_cpu: {
108 name: '24XL - Optimized CPU',
109 baselineIops: 120000,
110 maxIops: 120000,
111 baselineThroughputMBps: toMBps(30000),
112 maxThroughputMBps: toMBps(30000),
113 },
114 ci_24xlarge_optimized_memory: {
115 name: '24XL - Optimized Memory',
116 baselineIops: 120000,
117 maxIops: 120000,
118 baselineThroughputMBps: toMBps(30000),
119 maxThroughputMBps: toMBps(30000),
120 },
121 ci_24xlarge_high_memory: {
122 name: '24XL - High Memory',
123 baselineIops: 120000,
124 maxIops: 120000,
125 baselineThroughputMBps: toMBps(30000),
126 maxThroughputMBps: toMBps(30000),
127 },
128 ci_48xlarge: {
129 name: '48XL',
130 baselineIops: 240000,
131 maxIops: 240000,
132 baselineThroughputMBps: toMBps(40000),
133 maxThroughputMBps: toMBps(40000),
134 },
135 ci_48xlarge_optimized_cpu: {
136 name: '48XL - Optimized CPU',
137 baselineIops: 240000,
138 maxIops: 240000,
139 baselineThroughputMBps: toMBps(40000),
140 maxThroughputMBps: toMBps(40000),
141 },
142 ci_48xlarge_optimized_memory: {
143 name: '48XL - Optimized Memory',
144 baselineIops: 240000,
145 maxIops: 240000,
146 baselineThroughputMBps: toMBps(40000),
147 maxThroughputMBps: toMBps(40000),
148 },
149 ci_48xlarge_high_memory: {
150 name: '48XL - High Memory',
151 baselineIops: 240000,
152 maxIops: 240000,
153 baselineThroughputMBps: toMBps(40000),
154 maxThroughputMBps: toMBps(40000),
155 },
156} as const satisfies Record<string, ComputeDiskLimit>
157
158export type ComputeDiskKey = keyof typeof COMPUTE_DISK
159
160export const COMPUTE_BASELINE_IOPS = Object.fromEntries(
161 Object.entries(COMPUTE_DISK).map(([key, value]) => [key, value.baselineIops])
162)
163
164export const COMPUTE_MAX_IOPS = Object.fromEntries(
165 Object.entries(COMPUTE_DISK).map(([key, value]) => [key, value.maxIops])
166)
167
168export const COMPUTE_BASELINE_THROUGHPUT = Object.fromEntries(
169 Object.entries(COMPUTE_DISK).map(([key, value]) => [key, value.baselineThroughputMBps])
170)
171
172export const COMPUTE_MAX_THROUGHPUT = Object.fromEntries(
173 Object.entries(COMPUTE_DISK).map(([key, value]) => [key, value.maxThroughputMBps])
174)
175
176const computeInstanceAddonVariantIds = Object.keys(COMPUTE_DISK) as ComputeDiskKey[]
177
178export const computeInstanceAddonVariantIdSchema = z.enum(
179 computeInstanceAddonVariantIds as [ComputeDiskKey, ...ComputeDiskKey[]]
180)