Skip to content

Azure/JMeter-SignalR

Repository files navigation

SignalR JMeter Plugin

This plugin allows you to test your SignalR app server, including those using Azure SignalR service.

Table of Contents

Quick startup

Local bench

Dependencies

  1. JDK 17
  2. JMeter

Java 8 supported

Both the SignalR plugin and JMeter are compatible with JDK 8. But JDK 17 is recommended.

Steps

  1. Download Jmeter SignalR plugin (JmeterSignalR.jar). Place the jar in JMeter's lib/ext folder.
  2. Clone this repo and start the SignalR server in the examples/SignalRServer folder.
  3. Launch JMeter and load the SignalR.jmx script in the examples folder.
  4. Click start to begin . SignalR Plugin Local Test

Distributed bench on Azure Load Testing

Dependencies

  1. Azure Load Testing

Steps

  1. In Azure Load Testing, create a test and select "Upload a JMeter Script".

    Azure Load Test Creation
  2. Upload the JMeter script and SignalR plugin.

    Upload Script and Plugin
  3. Override parameters as needed: webAppUrl, connectionCountTotal, groupSize, sendDelayInMilliSeconds, payloadSizeInBytes

    Parameter Override
  4. Start the test and view the metrics.

    Start Test

Customize

Option 1: Modify in JMeter GUI

JMeter GUI Customization

Option 2: Build the plugin jar

  1. Clone the repo and modify the code as needed.
  2. Build the jar using:
    • Windows: .\gradlew.bat jar
    • Linux/MacOS: ./gradle jar
  3. Find the built JmeterSignalR.jar in build/libs.
  4. Enable the disabled SendToGroup Java + GUI.
Enable SendToGroup

Under the hood

JMeter, JMeter plugin, and Azure Load Testing

  • JMeter: An open-source benchmark tool, available in GUI and command-line modes. The GUI mode is useful for local debugging and modifying JMeter scripts but is less efficient than the command-line mode, which is more suitable for intense benchmark.
  • JMeter plugin: Extends JMeter's capabilities by loading jars in the lib/ext folder. These jars usually include samplers, controllers, GUI components, helper functions, and other dependencies.
  • Azure Load Testing: A service supporting JMeter engine, designed for easy execution of benchmarks across multiple JMeter instances. It integrates with Azure Monitor, providing a dashboard for nice metrics of JMeter results.

SignalR JMeter plugin

  • SignalR client integration: This plugin overcomes JMeter's lack of native support for the SignalR client. It simplifies the testing against SignalR or Azure SignalR services by adding SignalR dependencies into the plugin jar, avoiding the need for workarounds like using a websocket plugin.
  • Asynchronous metrics collection: Adapts to the bi-directional nature of the SignalR protocol, which is different from the traditional HTTP request-response model. It buffers SampleResult in a memory queue before batching them to JMeter listeners.
  • Connection aggregation: To optimize performance, the plugin aggregates multiple connections into a single JMeter thread using a ConnectionBundle class. This approach significantly reduces CPU overhead from thread context switching, especially valuable when connection counts reach several hundred. In Azure Load Testing, it allows the testing of up to 4000 connections per instance with just 1 virtual user.
  • Customization through JSR223 sampler: Offers flexibility in customizing the SignalR client using the JSR223 sampler, where groovy is the preferred scripting language. This feature enables users to alter client configurations and callbacks in the JMeter GUI.

The repo directory

  • The examples folder: Contains a compatible SignalR server and a JMeter script for immediate use and testing.
  • Under src/main/java/azure/signalr/groovy: Houses groovy scripts identical to those in the JMeter script.
  • Under src/main/java/azure/signalr/java: Java version for the JSR223 sampler. Those who prefer Java over groovy can modify these Java files and rebuild the plugin, then assemble the flow ( e.g., connect -> JoinGroup -> Send Message -> collect metrics) using GUI.
  • Under src/main/java/azure/signalr, ConnectionBundle class wraps a bundle of classes and SignalRUtil class offers some common help methods.