Jetty Load Generator

Today I stumbled upon Jetty Load Generator which is a utility to load test the HTTP servers based on Jetty’s HTTP client and Java 11+. In this blog article we are going to see how to get started with Jetty Load Generator and run a load test against the web page.

What is Jetty?

Before we see about Jetty Load Generator, let us see about Jetty. Jetty is an Eclipse project, web server and servlet container. It supports HTTP/2, WebSocket, JMX and other integrations. The memory footprint is small and available for free for development and production purposes.

What is Jetty Load Generator?

Jetty Load Generator was released last month and it can be downloaded from GitHub. It is a simple utility to load test HTTP servers. You can inject the load asynchronously, and it supports HTTP/2.

Getting Started with Jetty Load Generator?

Head to Maven repository page to download the latest version of uber jar. If you want to embed load generator into your code, you can leverage Load Generator APIs.

Launch Powershell or Command prompt or Terminal to validate the jar file by issuing the below command. I have downloaded the 1.0.4 version (current release at this time of writing).

java -jar .\jetty-load-generator-starter-1.0.4-uber.jar --help

Output

2021-03-04 20:38:34.581:INFO::main: Logging initialized @8048ms to org.eclipse.jetty.util.log.StdErrLog
Usage: <main class> [options]
  Options:
    --channels-per-user, -cpu
      Number of concurrent connections/streams per user
      Default: 128
    --connect-blocking, -cb
      Whether TCP connect is blocking
      Default: true
...
...

Running a Load Test

Let us run a simple load test by hitting the localhost:8080. In this demo I am using Jetty’s sample app.

To run the test with 10 threads; each thread iterates 10 times, issue the below command.

java -jar .\jetty-load-generator-starter-1.0.4-uber.jar --host 127.0.0.1 --iterations 10 --threads 2 --display-stats

Output

Jetty Load Generator - Load Test Report
Jetty Load Generator – Load Test Report

To run the 10 threads where each thread iterates 10 times, it took around 18 seconds. Total requests were 20 which clocked maximum of 195 ms.

Before you inject the load, check out the help section to fine tune your runtime settings. Otherwise, you might end up in injecting invalid workload.

For ramp up period, use --rru; For warm-up iterations, use -wi; To save report, use -sf <filename>; this will save the output in JSON format; To configure the TCP connect timeout, use -ct.

{
	"report": {
		"beginInstant": "2021-03-05T02:08:21.948937500Z",
		"completeInstant": "2021-03-05T02:08:23.652125700Z",
		"recordingDuration": 779,
		"availableProcessors": 4,
		"averageCPUPercent": 176.3359015535257,
		"requestRate": 288.79640344511006,
		"responseRate": 128.2442920389278,
		"sentBytesRate": 15774.047920788118,
		"receivedBytesRate": 466026.9328402597,
		"failures": 0,
		"1xx": 0,
		"2xx": 100,
		"3xx": 0,
		"4xx": 0,
		"5xx": 0,
		"histogram": "1614910101.904,1.751,555.745,HISTFAAAALB42i2OMQrCQBRENy8bQpAQQghBYggiIiLBQiSIiIWFiIVYCB7IG9h5FQuP4DUsLS0dE3dh/9uZ2f+3d7kmxpi7aZf7Ly8d4Wd7Nut3qzxvDiUPB48jIQF7KKipyNiwwGcsqmRPYYirPdODgbIFnq1l/FSjWjaux4HE5nSI6RLaSKRwSmkTlgqmTDSmEsUK95vuPoh9cQpziYlsQ6RZGTtyRuriNt86UdmVbgFfzgQR0w==\n"
	},
	"config": {
		"threads": 10,
		"warmupIterationsPerThread": 0,
		"iterationsPerThread": 10,
		"runFor": 0,
		"usersPerThread": 1,
		"channelsPerUser": 128,
		"resourceRate": 0,
		"rateRampUpPeriod": 0,
		"scheme": "http",
		"host": "127.0.0.1",
		"port": 8080,
		"transport": {
			"type": "http/1.1",
			"selectors": 1
		},
		"resource": {
			"method": "GET",
			"path": "/",
			"requestLength": 0,
			"responseLength": 0,
			"requestHeaders": {},
			"resources": []
		},
		"maxRequestsQueued": 1024,
		"connectBlocking": true,
		"connectTimeout": 5000,
		"idleTimeout": 15000
	}
}

To send the path, create a json file as shown below.

{
"path": "/test/dump/info"
}

Add the json file in the command line as shown below.

java -jar .\jetty-load-generator-starter-1.0.4-uber.jar --host 127.0.0.1 --iterations 10 --threads 1 --resource-rate 0 -rjp .\resources.json --display-stats

Pros

  • apt tool for developers
  • simple and easy to get started
  • export results to JSON format
  • CI/CD integration
  • HTTP/2 support

Cons

  • Distributed testing is limited
  • Runtime stats is missing
  • Not possible to record transactions
  • Limited in terms of max threads

Conclusion

Jetty Load Generator is a simple and helpful utility for load testing. APIs and Command line tool covers developers and testers as end users. Integration with CI/CD, HTTP/2 support and many more features are helpful to get started with load testing quickly.

Jetty Load Generator

Leave a Comment

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

Try new privacy focused search engine Neeva for freeCHECK IT OUT
+ +
Share via
Copy link