Web API Advanced Benchmark using NBomber Step-by-step guide to simulating load, concurrent users, and realistic scenarios in a .NET environment

Benchmark avanzati di una Web API con NBomber

Performing a comparative test of a Web API we developed is the first step toward consciously optimizing our source code. For this reason, a few days ago we published an article dedicated to the benchmarking of a Web API with Postman, a useful tool that can be used to obtain quick and helpful measurements in just a few steps.

However, when it comes to performance, simply measuring the response time of a single endpoint is not enough: in real-world scenarios, APIs must handle concurrent loads, traffic spikes, or respond to sequential calls with very tight timing constraints. In such cases, tools like Postman or simple manual scripts are not sufficient.

NBomber is a powerful open-source load testing tool written in .NET that allows you to simulate complex scenarios and collect detailed performance metrics for your Web APIs. It is particularly suited for developers and teams working in the .NET ecosystem, but it supports any kind of HTTP endpoint. In this article, we will focus on the main features of NBomber and see how it can be used to create more in-depth benchmarks for our Web API endpoints.

Requirements

  • Visual Studio or any compatible .NET editor (e.g., Rider, VS Code)
  • A .NET 6+ console project
  • NuGet package NBomber.Http
  • An API endpoint to test (e.g., https://localhost:5001/api/products)

#1. Creating a Console Project

Open the terminal and create a new console project:

#2. Adding NBomber via NuGet

Add the required packages:

#3. Test Scenario

Open the Program.cs file and insert the following base code:

In this example, NBomber will perform 10 simultaneous requests for 30 seconds, with a 5-second warm-up phase.

Customizable Parameters

  • copies: number of simulated users
  • duration: total duration of the test
  • WithWarmUpDuration: warm-up time to exclude unstable initial metrics

#4. Running the Benchmark

Launch the test with:

At the end of the execution, NBomber will display a detailed report in the console with:

  • Total number of requests executed
  • Percentiles (50th, 75th, 95th, 99th)
  • RPS (Requests per second)
  • Errors, timeouts, and more

NBomber can also automatically generate reports in HTML and JSON format.

#5. Exporting Results to HTML

To save the results into a readable HTML report, modify the runner configuration as follows:

You’ll find the report in the /reports folder, ready to be shared with the team or integrated into your CI/CD pipeline.

What You Can Test with NBomber

  • Performance under load (stress testing)
  • Scalability under concurrent users
  • Reliability of critical endpoints over time
  • Resilience in case of errors or timeouts

Conclusions

NBomber is a powerful, flexible tool designed for realistic and repeatable performance testing scenarios. It’s perfect for those working in .NET environments but also want to test any HTTP API, thanks to its simple syntax and the quality of its generated reports.

If you’ve already performed basic testing with Postman and want to go deeper, NBomber is the ideal next step. And if you haven’t yet, we recommend reading the introductory guide: Quick Benchmarking of a Web API with Postman.

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.