Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backmerge from master into develop #70

Merged
merged 5 commits into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading