Use ab to benchmark endpoint on mac
I need to do perf test of an endpoint written by akka-http. On the advice of another dev, I tried to use ab command. ab is short for apache benchmark which is a tool to benchmark apache http server. It’s a builtin command on mac. But I frequently met strange apr_socket_recv: Connection reset by peer (54) on OSX issue. According to the answers, ab has some problem on mac, it’s better to run it on a linux machine. So I tried to use a simple docker image here to run ab command. It works like a magic. See below steps:
docker pull jordi/ab
# host.docker.internal is the host machine
docker run --rm jordi/ab -c 2000 -n 20000 -s 120s http://host.docker.internal:8081/endpoint