Pooja
Pooja

Reputation: 209

Performance testing for serverless applications in AWS

In Traditional Performance Automation Testing: There is an application server where all the requests hits are received. So in this case; we have server configuration (CPU, RAM etc) with us to perform load testing (of lets say 5k concurrent users) using Jmeter or any load test tool and check server performance.

In case of AWS Serverless; there is no server - so to speak - all servers are managed by AWS. So code only resides in lambdas and it is decided by AWS on run time to perform load balancing in case there are high volumes on servers.

So now; we have a web app hosted on AWS using serverless framework and we want to measure performance of the same for 5K concurrent users. With no server backend information; only option here is to rely on the frontend or browser based response times - should this suffice? Is there a better way to check performance of serverless applications?

Upvotes: 3

Views: 1817

Answers (3)

Pradeep SJ
Pradeep SJ

Reputation: 2374

As you have mentioned, the serverless architecture (FAAS) don't have a physical or virtual server we cannot monitor the traditional metrics. Instead we can capture the below:

  1. Auto Scalability: Since the main advantage of this platform is Scalability, we need to check the auto scalability by increasing the load.

  2. More requests, less response time: When hitting huge amount of requests, traditional servers will increase the response time where as this approach will make it lesser. We need to monitor the response time.

  3. Lambda insights in Cloudwatch: There is an option to monitor the performance of multiple Lambda functions - Throttles, Invocations & Errors, Memory usage, CPU usage and network usage. We can configure the Lambdas we need and monitor in the 'Performance monitoring' column.

  4. Container CPU and Memory usage: In cloudwatch, we can create a dashboard with widgets to capture the CPU and memory usage of the containers, tasks count and LB response time (if any).

Upvotes: 0

Gareth McCumskey
Gareth McCumskey

Reputation: 1540

"Loadtesting" a serverless application is not the same as that of a traditional application. The reason for this is that when you write code that will run on a machine with a fixed amount CPU and RAM, many HTTP requests will be processed on that same machine at the same time. This means you can suffer from the noisy-neighbour effect where one request is consuming so much CPU and RAM that it is negatively affecting other requests. This could be for many reasons including sub-optimal code that is consuming a lot of resources. An attempted solution to this issue is to enable auto-scaling (automatically spin up additional servers if the load on the current ones reaches some threshold) and load balancing to spread requests across multiple servers.

This is why you need to load test a traditional application; you need to ensure that the code you wrote is performant enough to handle the influx of X number of visitors and that the underlying scaling systems can absorb the load as needed. It's also why, when you are expecting a sudden burst of traffic, you will pre-emptively spin up additional servers to help manage all that load ahead of time. The problem is you cannot always predict that; a famous person mentions your service on Facebook and suddenly your systems need to respond in seconds and usually can't.

In serverless applications, a lot of the issues around noisy neighbours in compute are removed for a number of reasons:

  • A lot of what you usually did in code is now done in a managed service; most web frameworks will route HTTP requests in code however API Gateway in AWS takes that over.
  • Lambda functions are isolated and each instance of a Lambda function has a certain quantity of memory and CPU allocated to it. It has little to no effect on other instances of Lambda functions executing at the same time (this also means if a developer makes a mistake and writes sub-optimal code, it won't bring down a server; serverless compute is far more forgiving to mistakes).

All of this is not to say its not impossible to do your homework to make sure your serverless application can handle the load. You just do it differently. Instead of trying to push fake users at your application to see if it can handle it, consult the documentation for the various services you use. AWS for example publishes the limits to these services and guarantees those numbers as a part of the service. For example, API Gateway has a limit of 10 000 requests per second. Do you expect traffic greater than 10 000 per second? If not, your good! If you do, contact AWS and they may be able to increase that limit for you. Similar limits apply to AWS Lambda, DynamoDB, S3 and all other services.

Upvotes: 1

ujlbu4
ujlbu4

Reputation: 1138

I didn't work with AWS, but in my opinion performance testing in case serverless applications should perform pretty the same way as in traditional way with own physical servers.

Despite the name serverless, physical servers are still used (though are managed by aws).

So I will approach to this task with next steps:

  • send backend metrics (response time, count requests and so on) to some metrics system (graphite, prometheus, etc)

  • build dashboard in this metric system (ideally you should see requests count and response time per every instance and count of instances)

  • take a load testing tool (jmeter, gatling or whatever) and start your load test scenario

During the test and after the test you will see how many requests your app processing, it response times and how change count of instances depending of concurrent requests.

So in such case you will agnostic from aws management tools (but probably aws have some management dashboard and afterwards it will good to compare their results).

Upvotes: 2

Related Questions