simplest way to benchmark a URL

Since I will forget this:

ab -c 10 -n 100

ab is a simple benchmarking tool from Apache. -c 10 means 10 concurrent connections, -n 100 means 100 requests. Note that it gave me Benchmarking localhost (be patient)...apr_socket_recv: Connection refused (61) when I tried it on http://localhost:3000/, but that seems to be an IPv6 thing and replacing that with seemed to work.

You can also do this with POST requests if you have HTTP Basic auth:

echo "observation[latitude]=38&observation[longitude]=-121" > post.txt && \
ab -c 10 -n 100 \
  -A username:password \
  -T application/x-www-form-urlencoded \
  -p post.txt \
  "" && \
rm post.txt

Haven’t found a way to just give it POST params without creating a file, but whatever, this works.

Comments are closed.