2
votes

I'm using Locust for load testing a site of mine and I'm curious about the difference between it and Apache Bench in terms of terminology.

With Apache Bench, you specify the number of requests (-n) and the number of multiple requests, or concurrency (-c).

Locust uses slightly different terminology. It has "Users to simulate" and "Hatch rate (users spawned/second)".

It is my understanding that "Users to simulate" would be the equivalent of number of requests in Apache Bench. Is that also true of -c and "Hatch rate" where "Hatch rate" is essentially how many concurrent requests will be made?

For example, are these two essentially or close to equivalent?

ab -n 1000 -c 100 url and Locust with 1000 users at a hatch rate of 100/second?

Note: I realize these two tools have very different capabilities and that Locust is a lot more flexible than Apache Bench. I'm really trying to understand the terminology difference.

4

4 Answers

3
votes

It's not exactly the same, because with locust you can specify multiple requests per user, to play out a whole scenario.

So while the whole scenario for a user might take 10 seconds to complete, if you hatch at 100/second you will end up with around 1000 concurrent requests, because the users hatched in the first second will not make their final request until 10 seconds in, when 900 more users have been hatched and are also making requests.

If on the other hand you only do one request per user, then it's comparable to Apache Benchmark

2
votes

The Apache Bench parameters and Locust parameters are not really comparable. How the Locust number of simulated Locust users affects the effective requests/second is very much dependent on the python code of your Locust and TaskSet class.

With Locust the aim is to define user behaviour with code, and then you can simulate a large number of these users.

You could have a Locust class that don't make any requests (though that would be kind of pointless), and that would result in getting an effective RPS of 0, no matter the number of users you choose to simulate. Likewise you could write a Locust class which just had a loop in which it constantly made HTTP requests and no wait time, and in that case the number of users simulated would correspond to the -c parameter of Apache Bench.

1
votes

Looking into Locust issue #646 - Allow a fixed RPS rate currently Locust doesn't support defining the desired throughput in terms of requests per unit of time.

You can consider Apache JMeter which has Constant Throughput Timer out of the box and Throughput Shaping Timer plugin if you need more flexibility.

0
votes

To compare Apache Benchmark with Locust, just simply test only 1 request,set the same time(-t 5), same users(-c 50), and hatch as quickly as possible in locust(-r 50 ).

-n means the whole request numbers , but there is no such parameter in locust. So we need a large number(100000) that can not been done in time limitation(-t 5):

ab -n 100000 -c 50 -t 5 url

locust -c 50 -r 50 -t 5 url xxx

In my case I find that ab is quicker up to 50% than locust which wrote in pure python.