Skip to content

Commit

Permalink
change logic to determine max resource limits (#3708)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Oct 2, 2023
1 parent 92cd880 commit 3dfc881
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ServiceContainer: React.FC<ServiceProps> = ({
// round to 100
Math.round(
convert(AWS_INSTANCE_LIMITS["t3"]["medium"]["RAM"], "GiB").to("MB") *
UPPER_BOUND / 100
UPPER_BOUND / 100
) * 100
); //default is set to a t3 medium
const context = useContext(Context);
Expand Down Expand Up @@ -137,12 +137,24 @@ const ServiceContainer: React.FC<ServiceProps> = ({
}
});

setMaxCPU(Math.fround(largestInstanceType.vCPUs * UPPER_BOUND));
setMaxRAM(
Math.round(
convert(largestInstanceType.RAM, "GiB").to("MB") * UPPER_BOUND / 100
) * 100
);
// if the instance type has more than 4 GB ram, we use 90% of the ram/cpu
// otherwise, we use 75%
if (largestInstanceType.RAM > 4) {
// round down to nearest 0.5 cores
setMaxCPU(Math.floor(largestInstanceType.vCPUs * 0.9 * 2) / 2);
setMaxRAM(
Math.round(
convert(largestInstanceType.RAM, "GiB").to("MB") * 0.9 / 100
) * 100
);
} else {
setMaxCPU(Math.floor(largestInstanceType.vCPUs * UPPER_BOUND * 2) / 2);
setMaxRAM(
Math.round(
convert(largestInstanceType.RAM, "GiB").to("MB") * UPPER_BOUND / 100
) * 100
);
}
}
})
.catch((error) => { });
Expand Down

0 comments on commit 3dfc881

Please sign in to comment.