Skip to content

Commit

Permalink
Update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannakok committed Jan 2, 2024
1 parent c9f801a commit fe169f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ exports[`The DotcomRendering stack matches the snapshot 1`] = `
"EvaluationPeriods": 1,
"MetricName": "Latency",
"Namespace": "AWS/ELB",
"Period": 300,
"Period": 60,
"Statistic": "Average",
"Threshold": 200,
},
Expand All @@ -319,17 +319,18 @@ exports[`The DotcomRendering stack matches the snapshot 1`] = `
"AutoScalingGroupName": {
"Ref": "AutoscalingGroup",
},
"Cooldown": "120",
"MetricAggregationType": "Average",
"PolicyType": "StepScaling",
"StepAdjustments": [
{
"MetricIntervalLowerBound": -100,
"MetricIntervalUpperBound": 0,
"ScalingAdjustment": 12,
"ScalingAdjustment": 1,
},
{
"MetricIntervalUpperBound": -100,
"ScalingAdjustment": 12,
"ScalingAdjustment": 1,
},
],
},
Expand All @@ -347,7 +348,7 @@ exports[`The DotcomRendering stack matches the snapshot 1`] = `
"EvaluationPeriods": 1,
"MetricName": "Latency",
"Namespace": "AWS/ELB",
"Period": 300,
"Period": 60,
"Statistic": "Average",
"Threshold": 200,
},
Expand All @@ -359,22 +360,18 @@ exports[`The DotcomRendering stack matches the snapshot 1`] = `
"AutoScalingGroupName": {
"Ref": "AutoscalingGroup",
},
"Cooldown": "120",
"MetricAggregationType": "Average",
"PolicyType": "StepScaling",
"StepAdjustments": [
{
"MetricIntervalLowerBound": 0,
"MetricIntervalUpperBound": 100,
"ScalingAdjustment": 15,
"ScalingAdjustment": 4,
},
{
"MetricIntervalLowerBound": 100,
"MetricIntervalUpperBound": 200,
"ScalingAdjustment": 18,
},
{
"MetricIntervalLowerBound": 200,
"ScalingAdjustment": 21,
"ScalingAdjustment": 7,
},
],
},
Expand Down Expand Up @@ -841,14 +838,6 @@ exports[`The DotcomRendering stack matches the snapshot 1`] = `
"LatencyScalingAlarm": {
"Properties": {
"ActionsEnabled": true,
"AlarmActions": [
{
"Fn::GetAtt": [
"ScaleUpPolicy",
"Arn",
],
},
],
"AlarmDescription": "Scale up if latency is GreaterThanOrEqualToThreshold of 0.2 over 1 period(s) of 60 seconds",
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Dimensions": [
Expand All @@ -862,14 +851,6 @@ exports[`The DotcomRendering stack matches the snapshot 1`] = `
"EvaluationPeriods": 1,
"MetricName": "Latency",
"Namespace": "AWS/ELB",
"OKActions": [
{
"Fn::GetAtt": [
"ScaleDownPolicy",
"Arn",
],
},
],
"Period": 60,
"Statistic": "Average",
"Threshold": 0.2,
Expand Down Expand Up @@ -935,28 +916,6 @@ exports[`The DotcomRendering stack matches the snapshot 1`] = `
},
"Type": "AWS::IAM::Policy",
},
"ScaleDownPolicy": {
"Properties": {
"AdjustmentType": "ChangeInCapacity",
"AutoScalingGroupName": {
"Ref": "AutoscalingGroup",
},
"Cooldown": "120",
"ScalingAdjustment": -1,
},
"Type": "AWS::AutoScaling::ScalingPolicy",
},
"ScaleUpPolicy": {
"Properties": {
"AdjustmentType": "PercentChangeInCapacity",
"AutoScalingGroupName": {
"Ref": "AutoscalingGroup",
},
"Cooldown": "600",
"ScalingAdjustment": 100,
},
"Type": "AWS::AutoScaling::ScalingPolicy",
},
"WazuhSecurityGroup": {
"Properties": {
"GroupDescription": "Allow outbound traffic from wazuh agent to manager",
Expand Down
55 changes: 3 additions & 52 deletions dotcom-rendering/cdk/lib/dotcom-rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ import {
import { GuClassicLoadBalancer } from '@guardian/cdk/lib/constructs/loadbalancing';
import type { App } from 'aws-cdk-lib';
import { CfnOutput, Duration, Tags } from 'aws-cdk-lib';
import {
AdjustmentType,
HealthCheck,
MetricAggregationType,
StepScalingPolicy,
} from 'aws-cdk-lib/aws-autoscaling';
import { AdjustmentType, HealthCheck } from 'aws-cdk-lib/aws-autoscaling';
import { CfnAlarm, Metric } from 'aws-cdk-lib/aws-cloudwatch';
import { InstanceType, Peer } from 'aws-cdk-lib/aws-ec2';
import { LoadBalancingProtocol } from 'aws-cdk-lib/aws-elasticloadbalancing';
Expand Down Expand Up @@ -285,55 +280,11 @@ export class DotcomRendering extends GuStack {
// scalingAdjustment: -1,
// });

// @ts-ignore
const latencyStepScalingPolicy = new StepScalingPolicy(
this,
'LatencyStepScalingPolicy',
{
autoScalingGroup: asg,
metricAggregationType: MetricAggregationType.AVERAGE,
adjustmentType: AdjustmentType.EXACT_CAPACITY,
scalingSteps: [
{
lower: 0,
upper: 100,
change: props.minCapacity,
},
{
lower: 100,
upper: 200,
change: props.minCapacity,
},
{
change: props.minCapacity + 3,
lower: 200,
upper: 300,
},
{
change: props.minCapacity + 6,
lower: 300,
upper: undefined,
},
],
cooldown: Duration.seconds(60),
metric: new Metric({
namespace: 'AWS/ELB',
metricName: 'Latency',
period: Duration.minutes(1),
}),
},
);

// TODO: Link with CloudWatch alarms
// latencyStepScalingPolicy.lowerAlarm
// latencyStepScalingPolicy.upperAlarm
// latencyStepScalingPolicy.upperAction
// latencyStepScalingPolicy.lowerAction

asg.scaleOnMetric('LatencyStepScalingPolicy', {
metric: new Metric({
metricName: 'Latency',
namespace: 'AWS/ELB',
period: Duration.minutes(1),
}),
scalingSteps: [
{
Expand All @@ -358,7 +309,7 @@ export class DotcomRendering extends GuStack {
},
],
adjustmentType: AdjustmentType.EXACT_CAPACITY,
cooldown: Duration.minutes(1),
cooldown: Duration.minutes(2),
evaluationPeriods: 1,
});

Expand Down

0 comments on commit fe169f2

Please sign in to comment.