Load Testing with K6 along with redis event driven process

Liau Kah Soon
AIA Singapore Technology Blog
5 min readJan 12, 2023

I was once told that things in your life only begin when you are challenged; whether it be a pivotal moment in your teen years, a time where you must make a life-altering decision, or in this case, when it comes to starting off your career.

My challenge came to me during my eleventh month as a working adult, when my team lead came to me with a rather intriguing project that I was eager to dip my toes in.

The term DNC stands for Do Not Call, and it allows you to opt out of receiving any marketing messages addressed to you. The good thing about this is you have more control on what kind of messages and emails you would like to receive. The pressure begins with checking through every single recipient’s DNC before sending emails to our customers.

A single email can reach either a hundred or a thousand recipients. Thinking of such a scale, we would have to check every single one of them within an acceptable response time. Not only that, we’re expecting a blast email being requested to send through in a short period of time.

This was when my team lead, Arnil, came up with a brilliant idea of using an event driven process. The process helps reduce the response time and handles all of the fallen parts of the situation. The main idea is to use redistributable software to temporarily store all needed data in the software and process it in the background.

The question brings itself up at this very moment. What exactly is Load Testing? Well, it is a process of simulating real conditions on an application and at the same time measuring the performance of that application’s time metrics. To compare, it is equivalent to the capability of a person to perform under a certain amount of pressure. The same can be said for an application, the better the operating capacity, the better the performance.

But what happens when you don’t thoroughly test your product? The consequences could lead to the loss of customers, revenue, and even more ruinous outcomes such as losing integrity and trust in your brand. Having a website launch fail is critical and prejudicial to any business, since it acts as a branch to meet the demands of customers as well as a revenue-generating part of your system.

To avoid all the horrors mentioned from happening, we need to use specific tools. Just like a movie, every actor plays their part and the same can be said for the tools I’m about to introduce in creating a successful load testing experience.

K6
When going through with a task, don’t you wish you had a tool that would help ease the process? In the case of load testing, that is exactly what k6 is for.
K6 is designed to process load test scripts that are written in Javascript (ES5.1+) and turn them into requests to load test websites and API. The best part of it is its ability to test the reliability and performance of your systems, and they also act in detecting issues and performance regressions early on.

Grafana
Compartmentalising is always in trend. In this case, Grafana helps users view their data by bringing them together into one or multiple dashboards which makes it easier to be interpreted and understood.

Grafana is an open-source interactive data-visualisation platform, and it is tailored to connect with a plethora of sources such as AWS Cloud Watch, Prometheus, Elasticsearch, InfluxDB, Graphite, and the list goes on and on. With the existence of Grafana, it’s much easier on the eyes to view data sources once they’re deciphered into a much more visually appealing sight.

InfluxDB
If anything can store large volumes of time series data and analyse it quickly in real time, it would be InfluxDB. InfluxDB is written in the Go programming language and is used for storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet of Things sensor data, and real-time analytics. To put it simply, the data is being written in real time, and you can read your data in real time.

These are the main actors of our load testing show. InfluxDB will act as the middle man between k6 and Grafana. We will use k6 as the testing tool, while piping the results into InfluxDB, which will be a database for Grafana Dashboard to show the results in a much more engaging manner. All of these tools mentioned above will be installed via Docker; an open source platform that allows us developers to build, run, update, and manage containers. In short, it’s a developer’s wonderland.
The reason for a load testing is all for the ease of a company’s mind. It will help us to have a simulation on the actual scenario of what will happen to our application; with all the possible problems that might surface.

We expect 200 concurrent users to use our service at the same time, however, we can’t tell if we are able to handle the amount even with the event driven process; thus comes load testing to save the day.

With all the tools I’ve mentioned before, I can find out the best performance and the limit of my application, and at the same time, I can provide the user with the specifics such as the actual number of concurrent users I can handle at the same time without any breakage.

--

--