title: Go http server slow benchmark performance
body: <p>I was trying to find the maximum throughput of a go webserver. I ran simplewebserver on a 8 core machine(Intel Xeon 2.5 Mhz) and ran wrk tool on a different 8 core machine. Iperf command shows around 8-10Gbps between these machines . Initially, I made a mistake by using apache ab tool that gave only 16k requests/second. The problem was same as <a href="https://stackoverflow.com/questions/30352725/why-is-my-hello-world-go-server-getting-crushed-by-apachebench">link</a>. Now when I switched to wrk tool,  I am getting around 90k requests per second and ~ 11MB/sec. </p>
  
  <p>on the first 8 core machine, I ran simplewebserver.go</p>
  
  <pre><code>package main
  
  import (
     "io"
      "net/http"
      "runtime"
  )
  
  func hello(w http.ResponseWriter, r *http.Request) {
      io.WriteString(w, "Hello world!")
  }
  
   func main() {
      runtime.GOMAXPROCS(8)
      http.HandleFunc("/", hello)
      http.ListenAndServe(":8000", nil)
   }
  </code></pre>
  
  <p>On a different 8 core machine, i ran</p>
  
  <pre><code> ./wrk -t8 -c1000 -d10s http://10.0.0.6:8000/
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>Running 10s test @ http://10.0.0.6:8000/
  8 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
  Latency    42.65ms  114.89ms   1.96s    91.33%
  Req/Sec    11.54k     3.01k   25.10k    74.88%
  923158 requests in 10.10s, 113.57MB read
  Socket errors: connect 0, read 0, write 0, timeout 20
  Requests/sec:  91415.11
  Transfer/sec:     11.25MB
  </code></pre>
  
  <p>Can i say that I have reached maximum throughput of a golang web server?  I am getting 11 MB/sec which looks quite small for the basic program. If I run the wrk tool on www.google.com page, I am getting around 200 MB/sec. Even for larger complex computing systems like kafka(java server), the benchmark results get more than  70 MB/sec(<a href="https://engineering.linkedin.com/kafka/benchmarking-apache-kafka-2-million-writes-second-three-cheap-machines" rel="nofollow noreferrer">https://engineering.linkedin.com/kafka/benchmarking-apache-kafka-2-million-writes-second-three-cheap-machines</a>). How can a golang server handle extreme workloads of millions of requests per second(more than 100MB/sec minimum)? Am I wrong in any assumptions?</p>
  
  <p>UPDATE:</p>
  
  <p>I ran the same program on a 16 core machine with the same specs. I changed the maxprocs to 16 and results went higher to 120k requests/sec. I feel that I have the reached the maximum of golang http server and hence I am not finding any significant increment in the requests/sec. </p>