@cloud-carbon-footprint/gcp
Version:
The core logic to get cloud usage data and estimate energy and carbon emissions from Google Cloud Platform.
204 lines • 10.9 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGCPEmissionsFactors = exports.GCP_CLOUD_CONSTANTS = void 0;
const core_1 = require("@cloud-carbon-footprint/core");
const GCPRegions_1 = require("../lib/GCPRegions");
const common_1 = require("@cloud-carbon-footprint/common");
exports.GCP_CLOUD_CONSTANTS = {
SSDCOEFFICIENT: 1.2,
HDDCOEFFICIENT: 0.65,
MIN_WATTS_MEDIAN: 0.68,
MIN_WATTS_BY_COMPUTE_PROCESSOR: {
[]: 0.64,
[]: 0.65,
[]: 0.71,
[]: 1,
[]: 1.14,
[]: 2.17,
[]: 3.04,
[]: 0.82,
[]: 0.47,
[]: 0.45,
[]: 26,
[]: 18,
[]: 8,
[]: 35,
[]: 35,
[]: 35,
[]: 46,
[]: 9,
[]: 36,
[]: 26,
},
getMinWatts: (computeProcessors) => {
const minWattsForProcessors = computeProcessors.map((processor) => {
return exports.GCP_CLOUD_CONSTANTS.MIN_WATTS_BY_COMPUTE_PROCESSOR[processor];
});
const wattsForProcessors = (0, core_1.getWattsByAverageOrMedian)(computeProcessors, minWattsForProcessors);
return wattsForProcessors
? wattsForProcessors
: exports.GCP_CLOUD_CONSTANTS.MIN_WATTS_MEDIAN;
},
MAX_WATTS_MEDIAN: 4.11,
MAX_WATTS_BY_COMPUTE_PROCESSOR: {
[]: 3.97,
[]: 4.26,
[]: 3.69,
[]: 4.74,
[]: 5.42,
[]: 8.58,
[]: 8.25,
[]: 2.55,
[]: 1.69,
[]: 2.02,
[]: 229,
[]: 153,
[]: 71,
[]: 306,
[]: 306,
[]: 306,
[]: 407,
[]: 76.5,
[]: 306,
[]: 229,
},
getMaxWatts: (computeProcessors) => {
const maxWattsForProcessors = computeProcessors.map((processor) => {
return exports.GCP_CLOUD_CONSTANTS.MAX_WATTS_BY_COMPUTE_PROCESSOR[processor];
});
const wattsForProcessors = (0, core_1.getWattsByAverageOrMedian)(computeProcessors, maxWattsForProcessors);
return wattsForProcessors
? wattsForProcessors
: exports.GCP_CLOUD_CONSTANTS.MAX_WATTS_MEDIAN;
},
NETWORKING_COEFFICIENT: 0.001,
MEMORY_COEFFICIENT: 0.000392,
PUE_AVG: 1.1,
PUE_TRAILING_TWELVE_MONTH: {
[]: 1.08,
[]: 1.11,
[]: 1.11,
[]: 1.09,
[]: 1.07,
[]: 1.09,
[]: 1.12,
[]: 1.13,
},
getPUE: (region) => {
return exports.GCP_CLOUD_CONSTANTS.PUE_TRAILING_TWELVE_MONTH[region]
? exports.GCP_CLOUD_CONSTANTS.PUE_TRAILING_TWELVE_MONTH[region]
: exports.GCP_CLOUD_CONSTANTS.PUE_AVG;
},
AVG_CPU_UTILIZATION_2020: 50,
REPLICATION_FACTORS: {
CLOUD_STORAGE_SINGLE_REGION: 2,
CLOUD_STORAGE_DUAL_REGION: 2,
CLOUD_STORAGE_MULTI_REGION: 2,
COMPUTE_ENGINE_REGIONAL_DISKS: 2,
CLOUD_FILESTORE: 2,
CLOUD_SQL_HIGH_AVAILABILITY: 2,
CLOUD_MEMORY_STORE_REDIS: 2,
CLOUD_SPANNER_SINGLE_REGION: 2,
CLOUD_SPANNER_MULTI_REGION: 2,
KUBERNETES_ENGINE: 3,
DEFAULT: 1,
},
KILOWATT_HOURS_BY_SERVICE_AND_USAGE_UNIT: {
total: {},
},
ESTIMATE_UNKNOWN_USAGE_BY: core_1.EstimateUnknownUsageBy.USAGE_AMOUNT,
SERVER_EXPECTED_LIFESPAN: 35040,
};
const getGCPEmissionsFactors = () => {
if ((0, common_1.configLoader)().GCP.USE_CARBON_FREE_ENERGY_PERCENTAGE)
return {
[]: 0.0002152373529,
[]: 0.0002152373529,
[]: 0.0003255,
[]: 0.00011124,
[]: 0.00011124,
[]: 0.0000072,
[]: 0.0000893,
[]: 0.00030912,
[]: 0.00028835,
[]: 0.0001776,
[]: 0.00037848,
[]: 0.0002592,
[]: 0.00038976,
[]: 0.00026496,
[]: 0.00029325,
[]: 0.000603,
[]: 0.00061732,
[]: 0.00035712,
[]: 0.0005046,
[]: 0.00047242,
[]: 0.00035949,
[]: 0.0004608,
[]: 0.00001143,
[]: 0.000121,
[]: 0.0000198,
[]: 0.00007396,
[]: 0.0001076,
[]: 0.00013301,
[]: 0.0000129,
[]: 0.000298,
[]: 0.000059,
[]: 0,
[]: 0.00000232,
[]: 0.00002838,
[]: 0.0000589,
[]: 0.00065472,
[]: 0.00014444,
[]: 0.00033732,
[]: 0.00139032,
[]: 0.00121064,
[]: 0.00143137,
[]: 0.0002152373529,
};
return {
[]: 0.000456,
[]: 0.000456,
[]: 0.000434,
[]: 0.000309,
[]: 0.000309,
[]: 0.00006,
[]: 0.00019,
[]: 0.000448,
[]: 0.000365,
[]: 0.000296,
[]: 0.000456,
[]: 0.00036,
[]: 0.000464,
[]: 0.000384,
[]: 0.000425,
[]: 0.00067,
[]: 0.000671,
[]: 0.000372,
[]: 0.00058,
[]: 0.000598,
[]: 0.000521,
[]: 0.000576,
[]: 0.000127,
[]: 0.000121,
[]: 0.00011,
[]: 0.000172,
[]: 0.000269,
[]: 0.000283,
[]: 0.000086,
[]: 0.000298,
[]: 0.000059,
[]: 0.000028,
[]: 0.000029,
[]: 0.000129,
[]: 0.00019,
[]: 0.000848,
[]: 0.00041,
[]: 0.000828,
[]: 0.001676,
[]: 0.001843,
[]: 0.002805,
[]: 0.0003171470588,
};
};
exports.getGCPEmissionsFactors = getGCPEmissionsFactors;
//# sourceMappingURL=GcpFootprintEstimationConstants.js.map