The best modern alternatives to Apache Bench (ab)

Learn about the alternatives to Apache Bench. We are going to rate both bad and good alternatives.
Published 2023-03-21 8 min read
The best modern alternatives to Apache Bench (ab)

Apache Bench, also known as ab, sometimes called Apache Benchmark, is a widely used command-line tool for load-testing web servers. Common use cases include measuring server response time, requests per second, and identifying bottlenecks. Some users may find Apache Bench lacking in features or difficult to work with, as ab has some weird gotchas. Our goal today is to explore alternatives that are simple, but even easier to use.

What makes a good alternative to Apache Bench?

ab pros:

  • Apache Bench is as simple as it can get and it’s the best feature of this tool
  • you either already have ab on your system or you can install it with a single command
  • no further setup is necessary, plain command does the job

ab cons:

  • for me, it becomes unstable on longer tests, can’t quite figure out why, using keep alive (-k), helps in some scenarios, but not always
  • testing POST requests with a body requires an input file
  • output is really basic

So ideally we would preserve good parts, and get rid of the downsides. We’ll keep this in mind when rating each alternative solution.

Alternatives to Apache Bench

There is an important caveat - pros and cons are relative to ab, and as I mentioned simplicity and ease of use are the most important features. For starters let’s review some tools mentioned by other websites:

  • JMeter
  • Locust
  • Gatling
  • Siege
  • wkr
  • Hey

JMeter

JMeter is a widely used open-source performance testing tool designed to assess the load and performance of software applications. It simulates multiple users interacting with a system, helping to identify performance bottlenecks and optimize application performance. To do that you create a test plan. Test plans can be really complex and simulate real-life workloads, with variable request inputs, custom ramp-up, etc. It’s a really powerful tool, but it requires setup.

Pros:

  • Ability to simulate complex workloads
  • Deep insight into application performance
  • has UI and command line interface

Cons:

  • complicated setup - running anything requires creating a test plan
  • slow startup in GUI mode

Verdict: JMeter is a great tool, but it’s not a good alternative to Apache Bench , as it has a different philosophy. That’s why Apache Foundation maintains both AB and JMeter.

Locust

Locust is an open-source load-testing tool that allows developers to write Python code to define and simulate user behavior, making it easy to perform scalable load tests on web applications and APIs. Actually, it’s more like a JMeter counterpart written in Python.

Locust screenshot

Pros:

  • Ability to simulate complex workloads
  • Deep insight into application performance

Cons:

  • complicated setup - running anything requires writing Python code, that describes the “test plan”
  • requires a knowledge of Python (as you probably deduced from the previous line)

Verdict:
Locust is another great tool and another bad alternative to ab. The reasons are very similar to JMeter.

Gatling

Let me just quote gatling.io website:

Gatling is a powerful open-source load testing solution.

Gatling is designed for continuous load testing and integrates with your development pipeline. Gatling includes a web recorder and colorful reports.

Again - it’s just too much for quick performance testing.

Pros:

  • Great focus on analysis
  • Focus on integration of performance testing in the development pipeline
  • Has UI

Cons:

  • requires writing a scenario

Verdict: Gatling is yet another tool that can do everything ab does but requires much more effort. That’s why it’s not a great alternative.

Siege

Look at the name - Siege. It does just that, it “sieges” your application to see how it behaves. It’s much more concerned with load testing than pure application benchmarking. Although it’s the first Apache Bench alternative that is relatively simple, yet very powerful. You can totally run the test from a single command:

siege -c 1 -t 10S "http://localhost:3000/api/hello"

Pros:

  • Pretty powerful, especially when it comes to load testing
  • can run tests from a single command
  • can function similarly to curl (with -g option), which is nice, because you can double-check the response before the main test

Cons:

  • Other tools will get higher RPS when concurrency is set to 1 - it makes a difference only for very fast, less than 1ms endpoints
  • Has a pretty chatty output, which clogs up the terminal quickly, you can redirect the output to a file though

Verdict: Siege is a useful tool, but you can feel that its focus is on load testing.  Can be used as an Apache Bench alternative though.

wrk

wrk claims it’s a modern HTTP benchmarking tool. It’s really simple to use when we are talking about GET requests. Just run a command like this:

wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

Which will generate an output like this:

Running 30s test @ http://127.0.0.1:8080/index.html
  12 threads and 400 connections
  Thread Stats Avg Stdev Max +/- Stdev
    Latency 635.91us 0.89ms 12.92ms 93.69%
    Req/Sec 56.20k 8.07k 62.00k 86.54%
  22464657 requests in 30.00s, 17.76GB read
Requests/sec: 748868.53
Transfer/sec: 606.33MB

So it does a good job when it comes to that. It’s cool it prints Stdev for each metric. If you would like to test POST request performance it gets more complicated, as you have to create a script that informs wkr about the request details. There are additional options that can be unlocked via scripting.

Pros:

  • A one-line command for GET requests
  • More powerful customization unlocked via scripts

Cons:

  • POST request requires creating scripts understood by wrk
  • The last commit was in 2021

Verdict:
wrk is a decent Apache Bench alternative. Although testing POST requests is a bit over-complicated.

 

Hey

Hey is a really simple open-source program written in Go. After you install it you can test your endpoints with a single command:i

hey -n 100 -c 1 'http://localhost:3001'

as you can see option flags are similar to the ones of ab. There are some cool differences:

  • -d option passes the request body, same as in curl
  • -z limit total test time, after that, the test will switch off
  • -o will dump output to CSV format
  • -h2 enables HTTP/2

Additionally report that Hey prints out has more info. Here is an example from not so speedy web application:

> hey -n 100 -c 1 'http://localhost:3001'

Summary:
  Total:	10.6483 secs
  Slowest:	0.2728 secs
  Fastest:	0.0956 secs
  Average:	0.1065 secs
  Requests/sec:	9.3911


Response time histogram:
  0.096 [1]	|
  0.113 [85]	|■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.131 [11]	|■■■■■
  0.149 [1]	|
  0.166 [1]	|
  0.184 [0]	|
  0.202 [0]	|
  0.220 [0]	|
  0.237 [0]	|
  0.255 [0]	|
  0.273 [1]	|


Latency distribution:
  10% in 0.0979 secs
  25% in 0.0996 secs
  50% in 0.1016 secs
  75% in 0.1091 secs
  90% in 0.1151 secs
  95% in 0.1206 secs
  99% in 0.2728 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0000 secs, 0.0956 secs, 0.2728 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0017 secs
  req write:	0.0000 secs, 0.0000 secs, 0.0001 secs
  resp wait:	0.1061 secs, 0.0953 secs, 0.2725 secs
  resp read:	0.0003 secs, 0.0002 secs, 0.0011 secs

Status code distribution:
  [200]	100 responses

To be honest I quite like this output format, a it’s pretty detailed.

Pros:

  • Extensive command output
  • Simple command line interface, that covers most scenarios

Cons:

  • The last release was in 2020, with the last commit in 2021 - so it may become abandonware :(

Verdict:
Solid Apache Bench alternative. Offers simpler command line interface with more detailed output.

What is the best alternative to Apache Bench (ab)?

In my opinion, it’s Hey, as it presents the ideal balance between ease of use and enhanced capabilities , making it my go-to alternative to Apache Bench. wrk is a close second. Unfortunately, both are at risk of becoming abandonware. ab rather not have this problem.

Another good choice is Siege, which offers you much more than Apache Bench but still can be relatively simple to use.

Jmater, Locust, or Gattling are overkill in most cases, where ab would shine.

So maybe Apache Bench is the best tool on the market in this segment? For sure it’s the most stable and mature. Still, it’s really simple to use in day-to-day testing. That’s why it’s the most popular solution on the market. So my recommendation is that if you don’t have issues with ab just keep using it, if you have some issues try Hey or wrk.

#ab #performance