Skip to main content

Performance test your ASP.NET Core application using NBomber

Yesterday I talked about Bombardier, an HTTP benchmarking tool written in Go and how you can use it to test the performance of your ASP.NET Core applications. While discussing the usage, a colleague mentioned another load testing tool, NBomber.

NBomber is a load-testing framework for Pull and Push scenarios, designed to test any system regardless of a protocol (HTTP/WebSockets/AMQP, etc) or a semantic model (Pull/Push).

It goes a lot further than what Bombardier has to offer. One of the things I find nice is that load test scenario’s can be written using C#. 😉

Remark: NBomber comes with a free personal license, if you want to use it inside your organization, you’ll have to buy a business license.

Let’s write a simple load test to test our API!

  • We start by creating a new Console application and adding the NBomber nuget package:
    • dotnet add package NBomber
  • As we want to test an HTTP endpoint, let’s also add the NBomber.Http plugin to simplify defining and handling of HTTP load tests:
    • dotnet add package NBomber.Http
  • Now we can start writing our test scenario. Here is a simple example scenario where we call our API endpoint simulating 100 users:

 

    • To run the scenario, we only have to run the console app:
    • After test completion results, results are written in multiple formats to a folder.
    • Here is how the HTML report looks like after the test run;

       

      Want to learn more? Check out this video introduction:

      Popular posts from this blog

      Podman– Command execution failed with exit code 125

      After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

      Azure DevOps/ GitHub emoji

      I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

      Cleaner switch expressions with pattern matching in C#

      Ever find yourself mapping multiple string values to the same result? Being a C# developer for a long time, I sometimes forget that the C# has evolved so I still dare to chain case labels or reach for a dictionary. Of course with pattern matching this is no longer necessary. With pattern matching, you can express things inline, declaratively, and with zero repetition. A small example I was working on a small script that should invoke different actions depending on the environment. As our developers were using different variations for the same environment e.g.  "tst" alongside "test" , "prd" alongside "prod" .  We asked to streamline this a long time ago, but as these things happen, we still see variations in the wild. This brought me to the following code that is a perfect example for pattern matching: The or keyword here is a logical pattern combinator , not a boolean operator. It matches if either of the specified pattern...