Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

Effectively running Java on Serverless Load Testing 2 min
Dhiraj Mahapatro
Dhiraj Mahapatro Principal Specialist Solutions Architect, Serverless

Load testing a serverless application is a key factor for building production grade applications. With load tests, you can easily synthesize a production environment by understanding and applying the same traffic patterns that you expect from your existing applications running in production.

This testing strategy helps you to adapt your serverless architecture, way in advance, to handle traffic spikes avoiding any surprises.

Understanding application at scale

Lambda functions scale at a faster rate; however, your application will have a database component which also has to scale accordingly to serve your end customers without any problems. Throttling can happen at the API Gateway, or Lambda function, or at the database level. Understanding those choke points and architecting around them becomes feasible when you provide and execute load tests.

Take this simple API as an example:

TestingSimpleApi

Writing a load test for this application will eventually execute an end-to-end tests at a higher scale.

Using Artillery

Artillery is a tool which can be easily used to run load tests. The configuration to run load test in Artillery would look like below:

## load-test.yml
config:
  phases:
    - duration: 60
      arrivalRate: 100
  processor: "./loadTestData.js"

scenarios:
  - name: "Create Products"
    flow:
      - post:
          url: "/ticket"
          beforeRequest: generateRandomTicketData
          json:
            userId: "{{ userId }}"
            description: "{{ description }}"

Assuming that you have installed Artillery in your local setup, now you can run the load test by calling:

artillery run load-test.yml --target $API_URL

Once tests are complete, you can assess and monitor metrics like:

  • Cold start durations in CloudWatch logs at P0 till P99
  • AWS X-Ray segment map for choke points
  • Number of concurrent Lambda function executions
  • and more

Other tools

You are not limited to using just Artillery. Here are some of the other load testing tools that can be used:

You can learn more about running load tests from serverless-test-samples.