Skip to content

Commit

Permalink
Merge pull request #70 from metriport/master
Browse files Browse the repository at this point in the history
Backmerge from master into develop
  • Loading branch information
leite08 authored Aug 9, 2024
2 parents b309310 + 586f8ba commit 67bb54b
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions infra/lib/fhir-server-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type Settings = {
taskCountMax: number;
minDBCap: number;
maxDBCap: number;
thresholdVolumeReadIops: number;
thresholdVolumeWriteIops: number;
/** Causes the duration of each completed statement to be logged if the statement ran for at least the specified amount of time. https://www.postgresql.org/docs/current/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT */
minSlowLogDurationInMs: number;
/** The load balancer idle timeout, in seconds. Can be between 1 and 4000 seconds */
Expand All @@ -55,10 +57,12 @@ export function settings(): Settings {
...defaults,
cpu: 4 * vCPU,
memoryLimitMiB: 8192,
taskCountMin: 6,
taskCountMax: 10,
minDBCap: 10,
maxDBCap: 48,
taskCountMin: 8,
taskCountMax: 20,
minDBCap: 15,
maxDBCap: 96,
thresholdVolumeReadIops: 2_500_000,
thresholdVolumeWriteIops: 2_500_000,
};
}
if (isSandbox(config)) {
Expand All @@ -70,6 +74,8 @@ export function settings(): Settings {
taskCountMax: 5,
minDBCap: 3,
maxDBCap: 12,
thresholdVolumeReadIops: 1_000_000,
thresholdVolumeWriteIops: 800_000,
};
}
return {
Expand All @@ -80,6 +86,8 @@ export function settings(): Settings {
taskCountMax: 5,
minDBCap: 1,
maxDBCap: 8,
thresholdVolumeReadIops: 1_000_000,
thresholdVolumeWriteIops: 800_000,
};
}

Expand Down Expand Up @@ -148,7 +156,8 @@ export class FHIRServerStack extends Stack {
dbCluster: rds.IDatabaseCluster;
dbCreds: { username: string; password: secret.Secret };
} {
const { minDBCap, maxDBCap, minSlowLogDurationInMs } = settings();
const theSettings = settings();
const { minDBCap, maxDBCap, minSlowLogDurationInMs } = theSettings;

// create database credentials
const dbClusterName = "fhir-server";
Expand Down Expand Up @@ -207,7 +216,12 @@ export class FHIRServerStack extends Stack {
});

// add performance alarms
this.addDBClusterPerformanceAlarms(dbCluster, dbClusterName, alarmAction);
this.addDBClusterPerformanceAlarms(
dbCluster,
dbClusterName,
theSettings,
alarmAction
);

return {
dbCluster,
Expand Down Expand Up @@ -369,10 +383,10 @@ export class FHIRServerStack extends Stack {
return fargateService.service;
}

// TODO REVIEW THESE THRESHOLDS
private addDBClusterPerformanceAlarms(
dbCluster: rds.DatabaseCluster,
dbClusterName: string,
{ thresholdVolumeReadIops, thresholdVolumeWriteIops }: Settings,
alarmAction?: SnsAction
) {
const createAlarm = ({
Expand Down Expand Up @@ -422,15 +436,15 @@ export class FHIRServerStack extends Stack {
createAlarm({
metric: dbCluster.metricVolumeReadIOPs(),
name: "VolumeReadIOPsAlarm",
threshold: 1_000_000, // IOPS
threshold: thresholdVolumeReadIops,
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
});

createAlarm({
metric: dbCluster.metricVolumeWriteIOPs(),
name: "VolumeWriteIOPsAlarm",
threshold: 800_000, // IOPS
threshold: thresholdVolumeWriteIops,
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
});
Expand Down

0 comments on commit 67bb54b

Please sign in to comment.