DEV Community

João Martins Filho
João Martins Filho

Posted on

Stressify.jl Performance Testing

Introduction

For approximately two years, I have been working as a QA Specialist at Grupo Casas Bahia, exclusively focused on Performance Testing, in order to ensure that the performance of the company's applications is ready to receive a high flow of users and that the usability of the application is not compromised.

During my journey (since working as QA for other companies), I have worked with several performance testing tools, such as JMeter, Gatling, Locust and K6, always noticing the pros and cons of all these tools. As we know, in the software development area, there is no silver bullet, so each tool adapts better to the needs of that project or company.

Well, after some time working with the K6 tool, I started to participate more actively in the Grafana K6 community (I recommend that everyone who has mastered a certain tool do this), because, in addition to learning even more by asking interesting questions, you will be helping other professionals with your experience.

In this community, I began to realize that one of the main points that QA professionals and professionals from other areas were looking for were ways to generate data from test execution, going beyond the normal results such as throughput requests, response time, error requests and returning to statistical data such as mean, median, P(90), P(95), standard deviation, etc. So I came up with a certain idea: how can I create a performance testing tool that, in addition to being efficient in its execution, can bring more statistical insights to the professional, as well as giving freedom from the language to generate new metrics, thus Stressify.jl was born, which is the subject of today's text.

Julia Programming Language

After the introduction, I thought of explaining why the Julia programming language?

The Julia language came to me in 2016 during a scientific initiation at the Federal Technological University of Paraná, in which our goal was to mitigate the use of open source tools for numerical and scientific calculations. During the initiation, I realized how powerful the language is.

Julia was created by Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and Alan Edelman, and released publicly in 2012. Julia's main goal is to combine the ease of use of languages ​​such as Python and R with the performance of low-level languages ​​such as C and Fortran. It is especially popular in the scientific community due to its ability to handle large volumes of data and complex calculations efficiently.

Main Features:

  • Performance: Julia is compiled just-in-time (JIT), which means that the code is compiled at runtime, allowing performance close to that of statically compiled languages.

  • Ease of Use: Julia's syntax is clear and expressive, making it accessible to programmers of different experience levels.
    Parallelism and Concurrency: Julia has native support for parallel and concurrent programming, facilitating the use of multiple CPU cores or even GPUs.

  • Dynamic Type System: Despite being dynamic, Julia allows optional type declarations, which can increase performance when necessary.
    Package Ecosystem: Julia has a robust package manager called Pkg, with a wide variety of packages for various applications, especially in data science, statistics, and machine learning.

Now that I have introduced a little more about the Julia programming language and why it is used, I will show you how to use the Stressify.jl tool

How to use Stressify.jl?

The first point I bring to you is that the focus of the tool was to be simple to install, develop, execute and generate reports.

Installation

As mentioned in the Julia language section about the package ecosystem, Julia has an active and democratic community, making it easier to create and use packages. Therefore, for Stressify, what you need is:

  1. Installing the Julia language: The documentation is very clear and the language is available for all operating systems, from Linux to Windows. In the link above, I have included the section on how to download and install it.

  2. After installing the Julia language, create a folder where you will add your test scripts and in the terminal, type the command julia. This will allow you to access the interpretation part of the language. Your terminal will look like this:

_
   __ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.2 (2024-12-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia>
Enter fullscreen mode Exit fullscreen mode

Inside the Julia language REPL, type using Pkg and then Pkg.add("Stressify"), wait a few minutes and the tool will be installed.

Using Docker

If you have mastered Docker and have it installed on your machine, it's even simpler. Just run the command docker pull jfilhogn/stressify:latest, which will download the official image of the Stressify tool. Once downloaded and in the directory where you developed the scripts that will be explained in the topic below, run the command docker run --rm jfilhogn/stressify:latest yourscript.jl , and you'll be running your test!

Creating the scripts.

For this text, I will present a basic script for understanding, presenting each part of the code by topics. Initially, we will import the library.

using Stressify
Enter fullscreen mode Exit fullscreen mode

Once the library has been imported, we will declare the options, that is, the configurations we want for the test, such as the number of VUs, how many iterations it will execute or whether it will be by duration. For this example, we will use iterations.

using Stressify

Stressify.options(
    vus = 5,
    iterations = 10,
    duration = nothing
)
Enter fullscreen mode Exit fullscreen mode

So, in the code above we declare for our test that we will run the test with 5 simultaneous users and each VU will iterate through the requests 10 times, so the endpoint that will be stressed will receive a total of 50 requests.

Once the options part is done, we will make the calls for this, we will make the following part of the code.

using Stressify

Stressify.options(
    vus = 5,
    iterations = 10,
    duration = nothing
)

results = Stressify.run_test(
    Stressify.http_get("https://httpbin.org/get"),
    Stressify.http_post("https://httpbin.org/post"; payload="{\"key\": \"value\"}", headers=Dict("Content-Type" => "application/json")),
)
Enter fullscreen mode Exit fullscreen mode

We declare a variable resultsthat will receive a dictionary with all the results and metrics that the test will bring and to receive this information we use the run_test function that receives within it the requests that will be made, being in the example a GET and POST request. Your first script is ready!

To run the test, simply write the command julia seuscript.jl in the terminal and the output will be very similar to this:

================== Stressify ==================
    VUs                    :          5
    Iterações Totais       :         50
    Taxa de Sucesso (%)    :      100.0
    Taxa de Erros (%)      :        0.0
    Requisições por Segundo:       8.79
    Transações por Segundo :       8.79
    Número de Erros        :          0

---------- Métricas de Tempo (s) ----------
    Tempo Mínimo           :     0.1744
    Tempo Máximo           :     1.5394
    Tempo Médio            :     0.4666
    Mediana                :      0.394
    P90                    :     0.8338
    P95                    :     0.9099
    P99                    :     1.5394
    Desvio Padrão          :     0.2872

---------- Detalhamento de Tempos ----------
    Todos os Tempos (s)    : 1.3297, 0.3898, 0.5772, 0.5987, 0.5519, 0.3595, 0.1788, 0.3945, 0.1823, 0.3955, 0.8338, 0.8836, 0.1757, 0.7192, 0.5078, 0.3386, 0.6884, 0.3439, 0.1789, 0.3843, 1.5394, 0.3353, 0.1744, 0.4752, 0.2206, 0.3373, 0.6098, 0.3367, 0.1763, 0.7549, 0.9099, 0.389, 0.1791, 0.3985, 0.4764, 0.3511, 0.1815, 0.5019, 0.1785, 0.3935, 0.9097, 0.3951, 0.1823, 0.3905, 0.5544, 0.6412, 0.3959, 0.354, 0.1812, 0.3958
==========================================================

---------- Resultados dos Checks ----------
Enter fullscreen mode Exit fullscreen mode

This is where the tool's key point comes in: the transparency of all the results we obtained during the execution, providing data on minimum, maximum, average, median, P90, P95, P99 and Standard Deviation times. Finally, it provides a breakdown of all the times generated and, if your code has response checks, you will also see the results!

You may be wondering, are these results very similar to other testing tools? However, Stressify's big difference is that it uses the Julia language and has native statistical tools. Suppose you want to know the variation of these requests, you would just need to add these three lines of code.

using Statistics
variancia = var(results["all_times"])
print("Variância: ", variancia)
Enter fullscreen mode Exit fullscreen mode

So the main focus of the tool is to use everything we have available in the Júlia language to generate performance metrics.

The idea of ​​today's text was to give you an initial idea of ​​how to use the Stressify tool. I am working daily to bring you more improvements, and I will detail those that are mapped for the next versions in the next topic.

For the future!

  • Request Funnel: One of the main points of performance testing is to ensure that the test follows what happens in real life, and the request funnel is extremely important, being necessary to ensure that an endpoint X receives the correct percentage of requests compared to request Y.

  • Live Dashboard: The Julia language has excellent tools focused on dashboards and graphical views. In the next versions, I will bring a format in which, from the execution, you can see a graphical view of the execution of the tests with a report.

  • Use of GPUs: The language has integration with GPUs, and in this sense, there is nothing more interesting than using GPU VUs for each request.

And more news on the way!

That's it, folks. This is my first article about this new feature and I await your comments on how you used it. Finally, if you liked the article, give it a Star on Github, it helps a lot in understanding the tool within the Julia packages. Below, I bring the most important links along with the tool's documentation.

Important Links

Top comments (0)