All files / src/lib stackit-pricing.ts

100% Statements 35/35
100% Branches 2/2
100% Functions 5/5
100% Lines 32/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177                                                                3x                                                                                             3x                   3x 3x 3x 3x 3x   3x 3x   3x 3x 3x       3x 3x 3x                           2004x             501x       501x   167x   167x         167x   167x   167x       167x   167x 334x   167x   167x   167x     167x     167x 167x                        
/**
 * Monthly cost model for a static STACKIT deployment (region EU01, Germany).
 *
 * Nothing runs on STACKIT yet; this is what the same stack would cost there.
 * "Static" means fixed servers running 24x7 with Docker Compose, rather
 * than Container Apps billed per second, and the database is the managed
 * PostgreSQL Flex, as on Azure (ADR-041).
 *
 * Prices are the public STACKIT price list, read from
 * https://pim.api.stackit.cloud/v1/skus on 2026-10-03 (hourly EUR, excl.
 * VAT). They are multiplied by 730 hours to match the Azure model; STACKIT's
 * own monthly figures use 720.
 */
 
import { HOURS_PER_MONTH } from "./azure-pricing";
 
export interface StackitServer {
  id: string;
  label: string;
  flavor: string; // STACKIT server flavor
  vcpu: number;
  ramGb: number;
  eurPerHour: number;
  components: string[];
  note: string;
}
 
// The Azure apps, grouped onto three general-purpose servers (g2i, Intel,
// CPU overprovisioned). The groups add up to more RAM than the Container
// Apps reserve today (14 GiB without Postgres since the EDC 0.18 apps left,
// #927), with room for the OS. The sizes are those chosen with the 0.18 apps
// and have not been revisited.
export const STACKIT_SERVERS: StackitServer[] = [
  {
    id: "graph",
    label: "Graph",
    flavor: "g2i.2",
    vcpu: 2,
    ramGb: 8,
    eurPerHour: 0.10229251676,
    components: ["Neo4j", "Neo4j Proxy", "Catalog Enricher"],
    note: "Neo4j reserves 2 GiB on Azure; 8 GB leaves page cache for the 5 300+ node graph",
  },
  {
    id: "edc",
    label: "EDC",
    flavor: "g2i.4",
    vcpu: 4,
    ramGb: 16,
    eurPerHour: 0.20458503352,
    components: [
      "Control plane + data plane (siglet)",
      "Identity Hub + Issuer",
      "NATS",
    ],
    note: "5 GiB reserved on Azure across 5 apps; the JVMs idle most of the day",
  },
  {
    id: "edge",
    label: "Identity + UI",
    flavor: "g2i.2",
    vcpu: 2,
    ramGb: 8,
    eurPerHour: 0.10229251676,
    components: ["Keycloak", "Vault + unseal", "UI", "Traefik"],
    note: "OIDC, secrets and TLS termination; the only server exposed to the internet",
  },
];
 
export interface StackitPgFlex {
  flavor: string; // vCPU.RAM
  eurPerHour: number;
  storageGb: number;
  performanceClass: string;
  performanceClassEurPerHour: number;
}
 
// The smallest PostgreSQL Flex flavor in EU01 is 2.4 (2 vCPU, 4 GB), single
// node. Azure runs the same databases on a B1ms (1 vCore, 2 GiB).
export const STACKIT_PG_FLEX: StackitPgFlex = {
  flavor: "2.4 Single",
  eurPerHour: 0.12598444444,
  storageGb: 32,
  performanceClass: "premium-perf2 (1 000 IOPS)",
  performanceClassEurPerHour: 0.02013888889,
};
 
// Block storage: every volume pays a performance class per disk plus
// capacity per GB.
const STACKIT_CAPACITY_EUR_PER_GB_HOUR = 0.0000907638;
const STACKIT_PG_BACKUP_EUR_PER_GB_HOUR = 0.00003697772;
const STACKIT_PERF1_DISK_EUR_PER_HOUR = 0.01016666667; // 500 IOPS
export const STACKIT_BOOT_DISK_GB = 50;
export const STACKIT_DATA_DISK_GB = 20; // Neo4j data and logs, Vault file backend
 
const STACKIT_NLB_EUR_PER_HOUR = 0.01304166667; // Essential NLB 10
const STACKIT_PUBLIC_IP_EUR_PER_HOUR = 0.00405555556;
 
export const STACKIT_LOGS_EUR_PER_GB = 1.2; // ingestion
const STACKIT_LOGS_RETENTION_EUR_PER_GB_DAY = 0.01;
const STACKIT_LOGS_RETENTION_DAYS = 30;
 
// Per participant, on top of the shared stack. Participants are contexts in
// one EDC-V deployment, so they add data and traffic, not servers.
export const PARTICIPANT_STORAGE_GB = 2;
export const DATA_HOLDER_EXTRA_STORAGE_GB = 10; // FHIR and OMOP data, average
const PARTICIPANT_LOG_GB = 150 / 1024; // EHDS Art. 50 audit trail
 
export interface StackitCost {
  servers: { id: string; eur: number }[];
  serversEur: number;
  pgFlexEur: number;
  disksEur: number;
  networkEur: number;
  logsEur: number;
  sharedEur: number;
  participantsEur: number;
  totalEur: number;
}
 
const month = (eurPerHour: number) => eurPerHour * HOURS_PER_MONTH;
 
export function stackitCost(
  participants: number,
  dataHolderShare = 0.6,
  baseLogGb = 18.3, // what the Azure stack ingests per month today
): StackitCost {
  const servers = STACKIT_SERVERS.map((s) => ({
    id: s.id,
    eur: month(s.eurPerHour),
  }));
  const serversEur = servers.reduce((t, s) => t + s.eur, 0);
 
  const pg = STACKIT_PG_FLEX;
  const pgFlexEur =
    month(pg.eurPerHour) +
    month(pg.performanceClassEurPerHour) +
    month(pg.storageGb * STACKIT_CAPACITY_EUR_PER_GB_HOUR) +
    month(pg.storageGb * STACKIT_PG_BACKUP_EUR_PER_GB_HOUR);
 
  const disks = STACKIT_SERVERS.length + 1; // a boot disk each + one data disk
  const diskGb =
    STACKIT_SERVERS.length * STACKIT_BOOT_DISK_GB + STACKIT_DATA_DISK_GB;
  const disksEur =
    month(disks * STACKIT_PERF1_DISK_EUR_PER_HOUR) +
    month(diskGb * STACKIT_CAPACITY_EUR_PER_GB_HOUR);
 
  const networkEur =
    month(STACKIT_NLB_EUR_PER_HOUR) + month(STACKIT_PUBLIC_IP_EUR_PER_HOUR);
 
  const logGb = (gb: number) =>
    gb * STACKIT_LOGS_EUR_PER_GB +
    gb * STACKIT_LOGS_RETENTION_DAYS * STACKIT_LOGS_RETENTION_EUR_PER_GB_DAY;
  const logsEur = logGb(baseLogGb);
 
  const holders = Math.round(participants * dataHolderShare);
  const participantGb =
    participants * PARTICIPANT_STORAGE_GB +
    holders * DATA_HOLDER_EXTRA_STORAGE_GB;
  const participantsEur =
    month(participantGb * STACKIT_CAPACITY_EUR_PER_GB_HOUR) +
    logGb(participants * PARTICIPANT_LOG_GB);
 
  const sharedEur = serversEur + pgFlexEur + disksEur + networkEur + logsEur;
  return {
    servers,
    serversEur,
    pgFlexEur,
    disksEur,
    networkEur,
    logsEur,
    sharedEur,
    participantsEur,
    totalEur: sharedEur + participantsEur,
  };
}