@cloud-carbon-footprint/gcp
Version:
The core logic to get cloud usage data and estimate energy and carbon emissions from Google Cloud Platform.
232 lines • 12.6 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.71,
[]: 0.69,
[]: 0.46,
[]: 0.74,
[]: 0.27,
[]: 0.81,
[]: 0.58,
[]: 1.86,
[]: 0.77,
[]: 1.71,
[]: 2.21,
[]: 1.04,
[]: 0.61,
[]: 168,
[]: 120,
[]: 120,
[]: 84,
[]: 84,
[]: 48,
[]: 72,
[]: 8.64,
[]: 8.4,
[]: 30,
[]: 30,
[]: 9,
},
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.39,
[]: 3.75,
[]: 1.83,
[]: 2.2,
[]: 1.36,
[]: 4.38,
[]: 2.37,
[]: 5.56,
[]: 3.65,
[]: 5.51,
[]: 8.6,
[]: 4.06,
[]: 3.87,
[]: 1428,
[]: 1020,
[]: 1020,
[]: 714,
[]: 714,
[]: 408,
[]: 612,
[]: 73.44,
[]: 71.4,
[]: 255,
[]: 255,
[]: 76.5,
},
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.0000537,
[]: 0.0000446,
[]: 0.0003974,
[]: 0.0001227,
[]: 0.0001227,
[]: 0.0000103,
[]: 0.0000625,
[]: 0.0003719,
[]: 0.0001285,
[]: 0.0000182,
[]: 0.0003644,
[]: 0.0005,
[]: 0.000376,
[]: 0.0001598,
[]: 0.0002249,
[]: 0.0006179,
[]: 0.0003777,
[]: 0.0003523,
[]: 0.00046,
[]: 0.0003287,
[]: 0.0002769,
[]: 0.0003858,
[]: 0.0000008,
[]: 0.0000116,
[]: 0.0000165,
[]: 0.0000223,
[]: 0.0000883,
[]: 0.0000355,
[]: 0.0000003,
[]: 0.0000545,
[]: 0.0000006,
[]: 0.0000883,
[]: 0.0000545,
[]: 0.0000001,
[]: 0.0000094,
[]: 0.000008,
[]: 0.000019,
[]: 0.0005585,
[]: 0,
[]: 0.0003623,
[]: 0.0003782,
[]: 0.0004036,
[]: 0.0002471,
[]: 0.0001972,
[]: 0.0005358,
[]: 0.0000363,
[]: 0.0004511,
[]: 0.002473,
[]: 0.0007364,
[]: 0.0015297,
[]: 0.0001889431818,
};
return {
[]: 0.000413,
[]: 0.000372,
[]: 0.000576,
[]: 0.000323,
[]: 0.000323,
[]: 0.000079,
[]: 0.000169,
[]: 0.000555,
[]: 0.000357,
[]: 0.000303,
[]: 0.000439,
[]: 0.000505,
[]: 0.000453,
[]: 0.000296,
[]: 0.000357,
[]: 0.000679,
[]: 0.000532,
[]: 0.000367,
[]: 0.000561,
[]: 0.000498,
[]: 0.000454,
[]: 0.000643,
[]: 0.000039,
[]: 0.000089,
[]: 0.000103,
[]: 0.000106,
[]: 0.000276,
[]: 0.000209,
[]: 0.000015,
[]: 0.000202,
[]: 0.000016,
[]: 0.000276,
[]: 0.000202,
[]: 0.000005,
[]: 0.000059,
[]: 0.000067,
[]: 0.000238,
[]: 0.000657,
[]: 0.000003,
[]: 0.000366,
[]: 0.000382,
[]: 0.000434,
[]: 0.000305,
[]: 0.00034,
[]: 0.000749,
[]: 0.000248,
[]: 0.000989,
[]: 0.003123,
[]: 0.002058,
[]: 0.00381,
[]: 0.0003100681818,
};
};
exports.getGCPEmissionsFactors = getGCPEmissionsFactors;
//# sourceMappingURL=GcpFootprintEstimationConstants.js.map