Getting Started
This guide will help you get started with Fast Autoscaler.
Prerequisites
Before deploying the Fast Autoscaler, ensure you have:
- An AWS account with appropriate permissions
- An ECS cluster with at least one service to scale
- An SQS queue that the service processes
- An S3 bucket for state storage
Required IAM permissions:
sqs:GetQueueAttributes
- To read queue metricsecs:DescribeServices
- To get current service stateecs:UpdateService
- To update service desired counts3:GetObject
ands3:PutObject
- For state management
Quick Start
Lambda Deployment (Recommended)
-
Clone the repository:
git clone https://github.com/stepscale/fast-autoscaler.git
cd fast-autoscaler -
Install dependencies:
pip install -r requirements.txt -t package/
cp -r autoscaler package/
cp lambda_function.py package/
cd package && zip -r ../lambda_deployment.zip . -
Create a Lambda function using the AWS CLI:
aws lambda create-function \
--function-name ecs-fast-autoscaler \
--runtime python3.9 \
--handler lambda_function.handler \
--role arn:aws:iam::<account-id>:role/your-lambda-role \
--zip-file fileb://lambda_deployment.zip \
--timeout 60 \
--environment "Variables={ECS_CLUSTER=your-cluster,SERVICE_NAME=your-service,SQS_QUEUE_URL=your-queue-url}" -
Set up a CloudWatch Event Rule to trigger the Lambda function:
aws events put-rule \
--name ecs-autoscaling-trigger \
--schedule-expression "rate(1 minute)"
aws events put-targets \
--rule ecs-autoscaling-trigger \
--targets "Id"="1","Arn"="arn:aws:lambda:<region>:<account-id>:function:ecs-fast-autoscaler"