Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to limit request per second in apache benchmark tools

I'm trying to stress test my Spring Boot application, but when I run the following command, what ab is doing is that trying to give out a result the the maximum my application could holds. But what I need is to check whether my application could hold at a specific request per second.

ab -p req.json -T application/json -k -c 1000 -n 500000 http://myapp.com/customerTrack/v1/send

The request per second given from above command is 4000, but actually, a lot of records are buffered in my application which means it can't hold that much rps. Could anyone tell me how to set a specific request per second in ab tools? Thanks!

like image 729
KAs Avatar asked Apr 06 '17 13:04

KAs


People also ask

How do I use Apache benchmark tool?

Apache Bench (ab) is a load testing and benchmarking tool for Hypertext Transfer Protocol (HTTP) server. It can be run from command line and it is very simple to use. A quick load testing output can be obtained in just one minute.

What is Apache benchmark tool?

ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.

What is non 2xx response?

Non-2xx responses. The number of responses that were not in the 200 series of response codes. If all responses were 200, this field is not printed. Keep-Alive requests. The number of connections that resulted in Keep-Alive requests.

What is ab command Linux?

AB (Apache Benchmark) command line tool is usually installed by default in most Linux and UNIX systems (can be installed on Windows as well). It is a featured and simple command line tool to perform a load test against an HTTP/HTTPS API.

What is the maximum number of Apache requests per second?

By default, Apache Request limit is 160 requests per second, that is, Apache can handle up to 160 requests per second, without any modification. Here are the steps to increase Apache requests per second.

How do I use Apache bench to benchmark my server?

Here's how. Log in to your Ubuntu Server and issue the command: If you're on a Red Hat-based distribution, that command would be: Once the tool is installed, you're ready to benchmark. I'm going to demonstrate using Apache Bench on a Nextcloud site hosted within a data center.

How to limit the number of connections per IP in Apache?

Restart Apache web server to apply changes. That’s it. Now Apache will automatically limit requests per IP on your website to 50 connections/ip.

How many requests should be made for benchmarking?

Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results. File containing data to POST.


2 Answers

I don't think you can get what you want from ab. There are a lot of other tools out there.

Here's a simple one that might do exactly what you want.

https://github.com/rakyll/hey

For rate limiting to 100 requests per second the below command should work.

hey -D req.json -T application/json -c 1000 -q 100 -n 500000 http://myapp.com/customerTrack/v1/send

like image 165
Jazzepi Avatar answered Sep 28 '22 08:09

Jazzepi


Apache Bench is single threaded program that can only take advantage of one processor on your client’s machine. In extreme conditions, the tool could misrepresent results if the parameters of your test exceed the capabilities of the environment the tool is running in. Accorading to your description, the rps has already reach your hardware limitation.

A lot of records are buffered in my application which means it can't hold that much rps

It is very hard to control request per second in single machine. You can find better performacne testing tools from here HTTP(S) Benchmark Tools

If you have budget you can try goad, which is an AWS Lambda powered, highly distributed, load testing tool built in Go for the 2016 Gopher Gala. Goad allows you to load test your websites from all over the world whilst costing you the tiniest fractions of a penny by using AWS Lambda in multiple regions simultaneously.

like image 35
howie Avatar answered Sep 28 '22 07:09

howie