Skip to content

Commit

Permalink
Address styling
Browse files Browse the repository at this point in the history
  • Loading branch information
piradeepk committed May 2, 2019
1 parent ed66e0b commit e34c553
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions design/aws-ecs-autoscaling-queue-worker.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# AWS ECS - L3 Construct for Autoscaling ECS/Fargate Service that Processes Items in a SQS Queue

To address issue [#2396](https://github.com/awslabs/aws-cdk/issues/2396), the AWS ECS CDK construct library should provide a way for customers to create a Queue Worker service (an AWS ECS/Fargate Service that processes items from an sqs queue). This construct will create an SQS Queue and enable autoscaling for the service based on cpu usage and the sqs approximateNumberOfMessagesVisible metric. This would mean adding new ECS CDK constructs `Ec2QueueWorkerService` and `FargateQueryWorkerService`, that would take in the necessary properties required to create a Task Definition, an SQS Queue as well as an ECS/Fargate Service with Auto Scaling rules.
To address issue [#2396](https://github.com/awslabs/aws-cdk/issues/2396), the AWS ECS CDK construct library should provide a way for customers to create a queue worker service (an AWS ECS/Fargate service that processes items from an sqs queue). This would mean adding new ECS CDK constructs `Ec2QueueWorkerService` and `FargateQueryWorkerService`, that would take in the necessary properties required to create a task definition, an SQS queue as well as an ECS/Fargate service and enable autoscaling for the service based on cpu usage and the SQS queue's approximateNumberOfMessagesVisible metric.

## General approach

The new [`ecs.QueueWorkerServiceBase`], [`ecs.Ec2QueueWorkerService`] and [`ecs.FargateQueueWorkerService`] classes will include L3 constructs for:
The new `ecs.QueueWorkerServiceBase`, `ecs.Ec2QueueWorkerService` and `ecs.FargateQueueWorkerService` classes will create L3 constructs for:

* Ec2QueueWorkerService
* FargateQueueWorkerService

A `QueueWorkerService` will create a task definition with the specified container (on both EC2 and Fargate). An `SQSQueue` will be created and autoscaling of the ECS Service will be dependent on both CPU as well as the SQS queue's `ApproximateNumberOfMessagesVisible` metric.
A `QueueWorkerService` will create a task definition with the specified container (on both EC2 and Fargate). An AWS SQS `Queue` will be created and autoscaling of the ECS Service will be dependent on both CPU as well as the SQS queue's `ApproximateNumberOfMessagesVisible` metric.

The `QueueWorkerService` constructs (for EC2 and Fargate) will use the following existing constructs:

* Ec2TaskDefinition/FargateTaskDefinition - To create a Task Definition for the container to start
* SQSQueue - The queue that the worker is processing from
* Ec2Service/FargateService - The Service running the container

## Code changes

Expand All @@ -18,7 +24,7 @@ Given the above, we should make the following changes to support queue workers o
2. Create `Ec2QueueWorkerServiceProps` interface and `Ec2QueueWorkerService` construct
3. Create `FargateQueueWorkerServiceProps` interface and `FargateQueueWorkerService` construct

# Part 1: Create `QueueWorkerServiceBaseProps` interface and `QueueWorkerServiceBase` construct
### Part 1: Create `QueueWorkerServiceBaseProps` interface and `QueueWorkerServiceBase` construct

The `QueueWorkerServiceBaseProps` interface will contain common properties used to construct both the Ec2QueueWorkerService and the FargateQueueWorkerService:

Expand Down Expand Up @@ -82,24 +88,18 @@ export interface QueueWorkerServiceBaseProps {
readonly maxScalingCapacity?: number

/**
* The intervals for scaling.
* The intervals for scaling based on the SQS queue's ApproximateNumberOfMessagesVisible metric.
*
* Maps a range of metric values to a particular scaling behavior.
* https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html
*
* @default [{ upper: 0, change: -1 },{ lower: 100, change: +1 },{ lower: 500, change: +5 }]
*/
readonly scalingSteps: autoScaling.ScalingInterval[];
}
```

The `QueueWorkerService` constructs (for EC2 and Fargate) will use the following existing constructs:

* Ec2TaskDefinition/FargateTaskDefinition - To create a Task Definition for the container to start
* SQSQueue - The queue that the worker is processing from
* Ec2Service/FargateService - The Service running the container


# Part 2: Create `Ec2QueueWorkerServiceProps` interface and `Ec2QueueWorkerService` construct
### Part 2: Create `Ec2QueueWorkerServiceProps` interface and `Ec2QueueWorkerService` construct

The `Ec2QueueWorkerServiceProps` interface will contain properties to construct the Ec2TaskDefinition, SQSQueue and Ec2Service:

Expand Down Expand Up @@ -160,7 +160,7 @@ new Ec2QueueWorkerService(stack, 'EcsQueueWorkerService', {
});
```

# Part 3: Create `FargateQueueWorkerServiceProps` interface and `FargateQueueWorkerService` construct
### Part 3: Create `FargateQueueWorkerServiceProps` interface and `FargateQueueWorkerService` construct

The `FargateQueueWorkerServiceProps` interface will contain properties to construct the FargateTaskDefinition, SQSQueue and FargateService:

Expand Down

0 comments on commit e34c553

Please sign in to comment.