I am trying to see how many requests the go HTTP server can handle on my machine so I try to do some test but the difference is so large that I am confused.
First I
Firstly: benchmarks are often pretty artificial. Sending back a handful of bytes is going to net you very different results once you start adding database calls, template rendering, session parsing, etc. (expect an order of magnitude difference)
Then tack on local issues - open file/socket limits on your dev machine vs. production, competition between your benchmarking tool (ab/wrk) and your Go server for those resources, the local loopback adapter or OS TCP stacks (and TCP stack tuning), etc. It goes on!
In addition:
ab
is not highly regardedab
test also runs for 12s
and not the 5s
your wrk test does.I have no idea what kind of machine you're on, but my iMac with a 3.5GHz i7-4771 can push upwards of 64k req/s on a single thread responding with a w.Write([]byte("Hello World\n"))
Short answer: use wrk
and keep in mind that benchmarking tools have a lot of variance.