Go HTTP server testing ab vs wrk so much difference in result

前端 未结 1 1585
一向
一向 2020-12-30 12:51

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

相关标签:
1条回答
  • 2020-12-30 13:35

    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 regarded
    • It is HTTP/1.0 only, and therefore doesn't do keepalives
    • Your other metrics vary wildly - e.g. look at the avg latency reported by each tool - ab has a much higher latency
    • Your ab test also runs for 12s and not the 5s your wrk test does.
    • Even 8k req/s is a huge amount of load - that's 28 million requests an hour. Even if—after making a DB call, marshalling a JSON struct, etc—that went down to 3k/req/s you'd still be able to handle significant amounts of load. Don't get too tied up in these kind of benchmarks this early.

    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.

    0 讨论(0)
提交回复
热议问题