StrAPI: An Open Source Solution for Stress and Load Testing

Jennifer Liu
5 min readMar 30, 2023

--

By: Jack Moorman, Jennifer Liu, Mauricio Garza, Steven Min, Zachary Skobkariov

Why is HTTP Stress Testing Important?

HTTP stress testing is a process that involves simulating a high volume of traffic or requests to a web server to evaluate its performance and ability to handle heavy traffic loads. This type of testing is important for several reasons:

  • Identifying performance bottlenecks: By simulating a high volume of traffic, stress testing helps identify performance bottlenecks, such as slow response times, long load times, or server errors, which may impact the user experience.
  • Ensuring scalability: Stress testing helps determine whether the web server can scale to handle a higher volume of traffic or requests. This is particularly important for websites or applications that experience sudden surges in traffic, such as during sales events or product launches.
  • Validating application behavior: Stress testing can help validate the behavior of an application under high traffic loads, ensuring that it behaves as expected and doesn’t crash or display unexpected errors.
  • Improving reliability: By identifying and addressing performance issues before they become critical, stress testing helps improve the reliability of the web server and reduces the risk of downtime or service interruptions.

Overall, HTTP stress testing is important because it helps ensure that a web server or micro service can perform well under high traffic loads, which is critical for delivering a positive user experience and maintaining the reliability of the server.

What is StrAPI?

StrAPI is an open source, free, lightweight developer tool that will stress test your API routes and generate visuals to provide insight on what’s happening in order to optimize the performance of your application.

It can be challenging to create testing environments to stress test your routes. Let StrAPI do that for you!

How StrAPI Works

StrAPI utilizes Wrk2, a benchmarking tool, to facilitate the background process of creating and starting HTTP requests. StrAPI offers testing of multiple routes with configurable variables to simulate an accurate stress test in the client’s server. Before using StrAPI, you will need to have Wrk2 installed. Instructions to install Wrk2 can be found here. Once installed, clone the Github repo for StrAPI and run npm install in the root directory. Now you are ready to fire up StrAPI by running the command npm run dev in the terminal.

Once the server is running, fire up the server that you want to stress test and open up the StrAPI web app that is running on http://localhost:3100.

Running a Test

On the StrAPI app, head over to Dashboard and fill in the necessary info to run your test. Starting with the testing constants, enter in the root URL that you want to stress test, number of threads, test duration, number of connections, and throughput. Over to the right, specify the route, HTTP Method, body in JSON format (if applicable), and ratio and click “Add Method”. Once the method is added, you will see it rendered under the “Current Methods” container. Now, we are ready to begin the stress test. Go ahead and click the Start Test button and wait for the stress test to complete. Once the test is done, the data is plotted on a line plot in the plotter below.

Run Multiple Tests

You can compile multiple stress tests to compare the results of multiple tests. If the newly created trace is in a color that is not easily visible, or it has been accidentally deleted, simply click “Request Plot Data Manually” to retrieve the most recent test result data.

StrAPI also supports Grafana Metrics, our demo here is connected to a containerized Grafana on http://localhost:4000 (Grafana Board: 12486), connected to an instance of node exporter via prometheus. You can easily remove any panels you do not wish to use by clicking remove panel. And adding a panel is just as easy, merely paste the iframe src link (without the “ ”) of the desired panel and click the button! And, your settings will persist between application launches.

Ideas for improvement

Error handling

  • If the root url is incorrect or any of the get/post routes are responding with an error, there is no proper error handling of these potential problems

More Data

  • Wrk2 provides additional data that is not referenced such as the actual Requests/sec (throughput), and Transfers/sec

More Methods and Content Types

  • StrAPI only deals with GET and POST requests. Future goals for StrAPI would be to include stress testing for PUT, PATCH, and DELETE with different content types
  • Unique post body data so that there are not duplicates to POST requests that may result in errors on the server side

Connect to data metric exporters through Prometheus

  • Connecting StrAPI to support various HTTP exporters so that additional information can be retrieved such as individual HTTP request information to more accurately pinpoint system errors, bottlenecks, and weaknesses

TDD

  • Testing of StrAPI web application. For a stress testing application, you’d think we’d test our own application 😬
  • StrAPI is written in typescript by a large majority, reducing the use case of many of the simple tests. But, tests written to test api IO and proper lua file generation would bring additional reliability.

Data persistence and Authentication

  • StrAPI currently uses json files to store the data of test results and Grafana panels. As the current user is expected to use the application on a local machine.
  • In preparation of hosting StrAPI we recognize that users will want their routes and testing data private. So a database (SQL/NoSQL) should be implemented alongside authentication and encryption.
  • In addition more user preferences can be saved, such as test configuration profiles, allowing a user to load a previously saved stress test config.

Tech Stack

Next.js | React | TypeScript | Lua | Tailwind | Plotly | Wrk | Prometheus | Grafana | Docker | Webpack

Check us out:
StrAPI Github | Linkedin | Company Website

Meet the team:

Jack Moorman, Github | Linkedin

Jennifer Liu, Github | Linkedin

Mauricio Garza, Github | Linkedin

Steven Min, Github | Linkedin

Zachary Skobkariov, Github | Linkedin

So try StrAPI today, to stress your application to destress your occupation!

--

--