Spaghetti and Hammers

Load testing using k6

July 08, 2021 | 1 Minute Read

Last November I decided to join Onfido. Since I’ve joined, we have been focusing a lot on ensuring our systems scale and are able to hold the expected load for the foreseen future. And to ensure that we are creating a set of load tests for each system.

Today I just wanted to share a tool we’ve been using at Onfido that seems quite easy and nice: k6. I’m amazed by the simplicity in creating a load test from scratch, so I wanted to share it with you. I’m not going into many details as their documentation is fairly easy and complete, just have a look!

In case you are not familiar with the concept, a load test is a specific type of automated test where we add a given load (e.g., 100 requests per second) to our system under test. In the end, we see if the system is able to respect the defined SLOs.

Just a few hints if you are new to load tests:

  1. Different requests may produce different load in your system depending on your business logic. So try to create a representative sample of your production traffic

  2. Use a dummy client for load test. In normal code, we’d apply some retry strategy because network failures will happen. But in load testing, we shouldn’t do that (unless you really know what you are doing). Firstly because your system wouldn’t be under 100 requests per second (or whatever load you define), but if too many retries happen, you could be provoking an increased load (unless your retry strategy can prevent back-pressure efficiently).

  3. There’s a very interesting problem in load test / benchmarking tools: the coordinated omission problem. So make sure you understand it before starting your measurements, otherwise your metrics can be useless. Luckily for us, k6 has mechanisms to avoid this problem.

Newsletter

Did you enjoy this blog post? Sign up for my Newsletter to be notified of new posts. (Pretty low-volume, around once per month.)