DEV Community

Ivica Kolenkaš for AWS Community Builders

Posted on

1

Practical ECS scaling: an introduction

How effective is it to vertically scale an application that has a memory leak? Can a CPU-heavy application perform better with more CPU resources? Should you horizontally scale your application based on response times?

To show the answers to these questions in practice, I built and load tested a mock application in order to achieve results that are the same or very similar to those shown in Nathan Peck's great article on Amazon ECS Scalability Best Practices.

Meet the app

Application architecture

The application itself is built in Flask and its infrastructure is managed with AWS CDK for Python. The app has several REST API endpoints:

  • /cpu_intensive, simulating a CPU-intensive task. Calculates the square root of 64 * 64 * 64 * 64 * 64 * 64 ** 64 on each request.
  • /memory_leak, simulating a memory leak. Adds 1MB of memory on each request.
  • /long_response_time, simulating increasingly longer responses from a busy downstream system (e.g. a database). Sleeps for 2ms for each request received since the app was started.

All source code is available in this repository.

The performance envelope

Vertically scaling a container means giving the container more hardware resources.

When you vertically scale an application the first step is to identify what resources the application container actually needs in order to function.

There are different dimensions of resources that an application needs. For example: CPU, memory, storage, and network bandwidth. Some machine learning workloads may actually require GPU as well. Source

These resources form the performance envelope; a set of hardware constraints for the container.

Performance envelope


The first article in the series deals with an application that exceeds the "CPU" dimension of the performance envelope.

Have a look at how changing the performance envelope for a CPU-heavy application affects its performance.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Create a simple OTP system with AWS Serverless cover image

Create a simple OTP system with AWS Serverless

Implement a One Time Password (OTP) system with AWS Serverless services including Lambda, API Gateway, DynamoDB, Simple Email Service (SES), and Amplify Web Hosting using VueJS for the frontend.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay