NBomber Documentation

repository·dev·Indexed 24 days ago

https://github.com/pragmaticflow/nbomber

A distributed, protocol-agnostic load-testing framework for .NET that allows developers to write high-performance tests in C# or F#. It supports testing HTTP, WebSockets, SQL, and gRPC, and integrates with xUnit and NUnit for CI/CD pipelines. Key features include native debugging, HTML reporting, real-time monitoring via NBomber Studio, data injection via Data Feed, and distributed workload simulation using a cluster mode with NATS.

Tokens
778
Snippets
2
Records
6
Agent score
31%

What's inside NBomber

  1. Overview of NBomber features and capabilities

    dev

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

    Key features include:

    • Native Debugging: Debug tests directly in Visual Studio, VS Code, or Rider.
    • Reporting: Generates informative HTML reports and supports real-time monitoring via NBomber Studio or Reporting Sinks (InfluxDB, TimescaleDB, Grafana).
    • Data Injection: Use Data Feed to inject real or fake data into tests.
    • Workload Simulation: Supports realistic, dynamic, and distributed workloads via a Distributed Cluster.
  2. Run the AutoCluster Demo

    dev

    The AutoCluster example demonstrates running multiple NBomber instances (nodes) in cluster mode. In this specific setup, the http_scenario is distributed such that it is executed on both the Coordinator and the Agent nodes.

    To run this demo, you must first start a NATS message broker using the provided docker-compose.yaml file via the Docker Compose CLI.

    docker compose up
  3. Create a basic load test scenario

    dev

    To create a load test, use Scenario.Create to define your logic and NBomberRunner to execute it. The logic inside the scenario is executed by NBomber, which measures the duration. You must return a Response.Ok() (or another response type) to signal the result of the operation. Use .WithLoadSimulations to define how the load is applied (e.g., injecting a specific rate of requests over a duration).

    var scenario = Scenario.Create("hello_world_scenario", async context =>
    {
        // you can define and execute any logic here, 
        // for example: send http request, SQL query etc
        // NBomber will measure how much time it takes to execute your logic
        await Task.Delay(1_000);
    
        return Response.Ok();
    })
    .WithLoadSimulations(
        Simulation.Inject(rate: 10,
                          interval: TimeSpan.FromSeconds(1),
                          during: TimeSpan.FromSeconds(30))
    );
    
    NBomberRunner
        .RegisterScenarios(scenario)
        .Run();