compute-disk-limits.ts 4.7 KB

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