Skip to content

Commit

Permalink
feat(infra): lowering IAM server size, increaing keepalive timeout fo…
Browse files Browse the repository at this point in the history
…r better stability (#1821)
  • Loading branch information
lucianHymer authored Oct 27, 2023
1 parent 1ebca75 commit 5e853ca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion iam/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ const startServer = async (): Promise<void> => {
apiKey: process.env.MORALIS_API_KEY,
});

app.listen(port, () => {
const server = app.listen(port, () => {
// eslint-disable-next-line no-console
console.log(`server started at http://localhost:${port}`);
});

// This should be > the ELB idle timeout, which is 60 seconds
server.keepAliveTimeout = 61 * 1000;
};

startServer().catch((error) => {
Expand Down
6 changes: 3 additions & 3 deletions infra/production/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ const service = new awsx.ecs.FargateService("dpopp-iam", {
containers: {
iam: {
image: dockerGtcPassportIamImage,
memory: 8192,
cpu: 4096,
memory: 2048,
cpu: 1024,
portMappings: [httpsListener],
links: [],
environment: [
Expand Down Expand Up @@ -370,7 +370,7 @@ const ecsScorerServiceAutoscaling = new aws.appautoscaling.Policy("scorer-autosc
predefinedMetricSpecification: {
predefinedMetricType: "ECSServiceAverageCPUUtilization",
},
targetValue: 30,
targetValue: 50,
scaleInCooldown: 300,
scaleOutCooldown: 300,
},
Expand Down
20 changes: 18 additions & 2 deletions infra/staging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ const service = new awsx.ecs.FargateService("dpopp-iam", {
containers: {
iam: {
image: dockerGtcPassportIamImage,
memory: 1024,
memory: 512,
cpu: 256,
portMappings: [httpsListener],
links: [],
environment: [
Expand Down Expand Up @@ -355,10 +356,25 @@ const service = new awsx.ecs.FargateService("dpopp-iam", {
},
});

const ecsTarget = new aws.appautoscaling.Target("autoscaling_target", {
const ecsIamServiceAutoscalingTarget = new aws.appautoscaling.Target("autoscaling_target", {
maxCapacity: 10,
minCapacity: 1,
resourceId: pulumi.interpolate`service/${cluster.cluster.name}/${service.service.name}`,
scalableDimension: "ecs:service:DesiredCount",
serviceNamespace: "ecs",
});

const ecsIamServiceAutoscaling = new aws.appautoscaling.Policy("scorer-autoscaling-policy", {
policyType: "TargetTrackingScaling",
resourceId: ecsIamServiceAutoscalingTarget.resourceId,
scalableDimension: ecsIamServiceAutoscalingTarget.scalableDimension,
serviceNamespace: ecsIamServiceAutoscalingTarget.serviceNamespace,
targetTrackingScalingPolicyConfiguration: {
predefinedMetricSpecification: {
predefinedMetricType: "ECSServiceAverageCPUUtilization",
},
targetValue: 50,
scaleInCooldown: 300,
scaleOutCooldown: 300,
},
});

0 comments on commit 5e853ca

Please sign in to comment.