Skip to content

Commit

Permalink
Merge pull request #715 from PRX/router-scaling
Browse files Browse the repository at this point in the history
Router scaling
  • Loading branch information
farski authored Oct 12, 2023
2 parents 8fce858 + 60e8019 commit fcb22cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
20 changes: 7 additions & 13 deletions spire/templates/apps/dovetail-router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -922,34 +922,28 @@ Resources:
Properties:
Pattern:
detail:
bucket:
name:
- !Select [5, !Split [":", !Ref FeedsS3BucketArn]]
object:
key:
- 815/feed-rss.xml
- 284/feed-rss.xml
- 70/feed-rss.xml
- criminal/feed-rss.xml
- themoth/feed-rss.xml
detail-type:
- Object Created
source:
- aws.s3
Handler: index.handler
InlineCode: |
InlineCode: !Sub |
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
const ddb = new AWS.DynamoDB({ region: 'us-east-1' });
const ecs = new AWS.ECS({ region: 'us-east-1' });
const ddb = new AWS.DynamoDB({ region: '${AWS::Region}' });
const ecs = new AWS.ECS({ region: '${AWS::Region}' });
const TABLE_NAME = process.env.DYNAMODB_TABLE_NAME;
const CLUSTER_NAME = process.env.ECS_CLUSTER_NAME;
const SERVICE_NAME = process.env.ECS_SERVICE_NAME;
const SCALE_TO = {
'815/feed-rss.xml': 4,
'70/feed-rss.xml': 20,
'criminal/feed-rss.xml': 16,
'themoth/feed-rss.xml': 20,
};
Expand All @@ -967,7 +961,7 @@ Resources:
for (const match of matches) {
guids.push(match[1]);
}
console.info(`Read ${guids.length} guids from s3://${Bucket}/${Key}`);
console.info(`Read ${!guids.length} guids from s3://${!Bucket}/${!Key}`);
// break into chunks of 100
const allKeys = guids.map((g) => ({ guid: { S: g } }));
Expand All @@ -984,7 +978,7 @@ Resources:
data.Responses[TABLE_NAME].forEach((r) => (found[r.guid.S] = true));
}
const newGuids = guids.filter((g) => !found[g]);
console.info(`Found ${newGuids.length} new guids not in DDB`);
console.info(`Found ${!newGuids.length} new guids not in DDB`);
// scale ECS service
if (newGuids.length > 0) {
Expand All @@ -993,15 +987,15 @@ Resources:
const count = res.services[0].desiredCount;
const desiredCount = SCALE_TO[Key];
if (count < desiredCount) {
console.info(`Scaling from ${count} to ${desiredCount}`);
console.info(`Scaling from ${!count} to ${!desiredCount}`);
const updateParams = {
cluster: CLUSTER_NAME,
service: SERVICE_NAME,
desiredCount,
};
await ecs.updateService(updateParams).promise();
} else {
console.info(`Already at ${count}`);
console.info(`Already at ${!count}`);
}
}
Expand Down
3 changes: 3 additions & 0 deletions storage/multi-region-replication/feeds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ Resources:
Rules:
- NoncurrentVersionExpirationInDays: 1 # Permanently delete non-current versions
Status: Enabled
NotificationConfiguration:
EventBridgeConfiguration:
EventBridgeEnabled: true
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
Expand Down

0 comments on commit fcb22cc

Please sign in to comment.