title: why does this "hello world" golang http example slow down on osx
body: <p>I was benchmarking my little web application and noticed some significant slowdown when I was running apache bench against it after a couple of thousand requests.</p>
  
  <p><code>ab -n 20000 http://localhost:8080</code></p>
  
  <p>The first few thousand requests are fast, then it gets slower and slower. Dramatically slower. While the first thousand take maybe a second, requests 18000-20000 take up to 10 seconds.</p>
  
  <p>So I was trying to find the slow parts and at some point didn't have anything to exclude anymore until I ended up with benchmarking a "hello world" style http server example. To my surprise, the same slowdown occurred.</p>
  
  <pre><code>package main
  
  import "net/http"
  
  func main() {
      mux := http.NewServeMux()
  
      mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
          w.WriteHeader(200)
      })
      http.ListenAndServe(":8080", mux)
  }
  </code></pre>
  
  <p>The same little example runs consistently fast on a linux box. It's not really a big thing because I don't plan to run the app on osx in production ;) But I'm curious what's causing the terrible slowdown on osx anyways</p>