Releases 08 April 2022

Private load zones for load testing on the cloud

Nicole van der Hoeven

📖What you will learn

  • What private load zones are
  • How to run load tests in private load zones on k6 Cloud

Have you ever wanted to load test an application behind a corporate firewall?

If so, you probably ran into a few issues. Load testing on the cloud can be the most cost-effective way to run a load test, but not if the application isn't publicly accessible. Recently, we released a new feature for k6 Cloud that allows you to run load tests on your own private load zones.

But first, does it really matter where load is generated from?

Why the location of load generators matters

The location of your load generators affects your load testing results in several ways.

Latency

Firstly, the farther away your load generators are from your application servers, the higher the network latency that you can expect as requests are sent back and forth over a larger distance. This effect can also occur in reverse, where placing your load generators on the same network as your application servers could cause your load tests to report faster response times than you would actually expect to see in production.

Workload model

Secondly, the location of your load generators affects the workload model you're simulating. A workload model is a description of the load profile you want a test scenario to verify, and it includes an approximation of where the traffic from real users will come from. For example, if you choose load generators in the US, the response times in your test results won't accurately describe the user experience of Australian users.

Access to the application under test

And thirdly, you may find that your choice of location for load generators also dictates whether you can even access the application under test.

There are many use cases for testing an application that is not publicly accessible. Many companies erect firewalls around an application so that it is only accessible within the internal network for security reasons, especially if the application contains a databse of Personally Identifiable Information. Even if an application has already been released to the public, pre-production releases may be tested in a private test environment.

Applications that aren't exposed to the internet present a challenge for load testing. Testing on the cloud has become an industry standard due to the reduced maintenance costs and increased flexibility that it provides, but using load generators on the cloud also means that those load generators can't access private endpoints and services that need to be tested.

This problem is one we've been trying to solve for k6 Cloud as well. When you start a test on k6 Cloud, you choose a load zone, or location, that you'd like the load to come from. But how can you use k6 Cloud's AWS-provisioned load generators to test private applications?

How to test applications behind a firewall

One way to test an application behind a firewall is to use on-premise load generators. The load generators could be provisioned on the same network as the application servers, circumventing the firewall entirely.

However, this setup may yield faster reported response times due to the unrealistically low latency between the servers. The setup might also lead to increased costs in provisioning and maintaining on-premise machines. k6 Cloud does not currently support this approach, so that also means that test coordination and data collation may be an issue.

The other way is to use private load zones. Until recently, k6 Cloud did not support this. However, thanks to hard work by the k6 backend team, this is now possible.

Private load zones for k6 Cloud

What is a private load zone?

A private load zone is a special location that we set up for you on k6 Cloud. This location corresponds to availability zones you've selected on your own AWS account.

With private load zones, you can start tests on k6 Cloud but have them execute on your own cloud infrastructure, provisioned within AWS.

Benefits of using private load zones

Here are some reasons why you might want to use a private load zone on k6 Cloud:

  • Improved privacy or application security while doing load testing
  • Ability to leverage k6 Cloud's unified dashboards and visualization features
  • Reuse of existing cloud provider account to provision the infrastructure
  • Improved visibility into instance usage and provisioning activity on your team

How private load zones work

What happens under the hood when you start a test on a private load zone on k6 Cloud?

First, you set up your test to select the private load zone. You can do this one of two ways:

  • via the graphical Test Builder on k6 Cloud
  • via the k6 script, within the test options

Here's what the test options might look like for your k6 script:

export const options = {
ext: {
loadimpact: {
distribution: {
private: {
loadZone: 'amazon:eu:private load zone',
percent: 100,
},
},
},
},
};

Second, you start the test by:

  • clicking "Run" in k6 Cloud, or
  • running k6 cloud test.js from the k6 CLI.

Third, k6 checks whether your k6 Cloud account has permissions to start instances in your AWS account. These permissions need to be set up before tests can be executed.

Next, assuming k6 has the appropriate privileges, k6 instructs AWS to provision a number of instances according to your selections in the test script.

And finally, the test artifacts (the test script and any test data) are transferred to your AWS instances and k6 begins to execute the test.

In this clip from a recent k6 Office Hours livestream, one of the leads of our backend team, Samuel Regandell, demonstrates this process:

FAQs about private load zones

When will this be available?

It's available now! However, you will need to contact us to get the private load zone set up for your account before you can start using it.

Is running a test on a private load zone the same as running it on-premises?

No. In an on-premises load test, the test is executed on machines in your data center. You would have to physically provision and maintain these machines. We are working on a way to run distributed load tests entirely on-premise, but this feature is not yet available.

When you run a test on a private load zone, the test is executed on instances started in your AWS cloud account. These machines are physically located in geographical zones that you specify during setup.

Can you start private load zones in Azure, GCP, or other cloud providers?

No. At the moment, you can only start private load zones in AWS.

Can I use a mix of private and public load zones?

Yes, you can run tests on a combination of private and public load zones on k6 Cloud, and you can specify the percentage of load that you'd like to run on each zone within the script or within Test Builder.

How long does it take to start a test on a private load zone?

Once a private load zone has been set up, it will take only slightly more time to start a test on it than it would on a public load zone. This is because we reuse public load generators to improve startup time, but we can't use this strategy for private load zones at this point. However, the difference between the two shouldn't be more than a few seconds.

Is there a difference between how the metrics are aggregated?

No. Regardless of whether the load zones you've selected are private, public, or a mixture of the two, you'll continue to see the same metrics aggregated across all load zones.

How do you get started with private load zones?

If you'd like to try out this new feature, contact us at support@k6.io. We'll go over the details with you, take you through the steps for granting k6 Cloud the appropriate permissions, and set up your private load zone for you.

< Back to all posts