title: Why isn't this go HTTP server spawning a goroutine per request in Chrome 47?
body: <p><em>Previously titled: <strong>How to spawn goroutine per HTTP request?</strong></em></p>
  
  <p>The code below is a simple HTTP server that echos the path back to the requester. I used it to test if the <code>ListenAndServe</code> method of the <code>net/http</code> package by default fires a goroutine to handle each request; which I discovered it doesn't. If I make three requests at the same time, the first takes 10 seconds to return, the second 20 (10 seconds after the first returns), and the third 30 seconds.</p>
  
  <pre><code>package main
  
  import (
    "fmt"
    "net/http"
    "time"
  )
  
  func handler(w http.ResponseWriter, r *http.Request) {
    time.Sleep(10000 * time.Millisecond)
    fmt.Fprint(w, r.URL.Path)
  }
  
  func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
  }
  </code></pre>
  
  <p>Basically what I want is the main goroutine to listen for an HTTP connection, then pass the reading of the request and the response to a handler spawned in another goroutine. </p>
  
  <p>Could someone point me in the right direction for accomplishing this? Preferably using the <code>net/http</code> package in go.</p>
  
  <p><strong>UPDATE 12/21/15 08:46 AM MST</strong></p>
  
  <p>I conducted the same exact test you did using my web browser (chrome 47), five requests at the root of localhost:8080, and the results were roughly:</p>
  
  <pre><code>1st: 10 seconds
  2nd: 20 seconds
  3rd: 30 seconds
  4th: 36 seconds     
  5th: 38 seconds
  </code></pre>
  
  <p>So, hopefully, the folks who would otherwise down-vote my question would understand my confusion and why I made the assumption I did. I have no idea why I got the results I did on the 4th and 5th request.</p>
  
  <p>I ran the same test using curl and had the same results as @tomasz.</p>
  
  <p>I'm using <code>go1.2.1</code>.</p>
  
  <p><strong>UPDATE 12/21/15 02:08 PM MST</strong></p>
  
  <p>Per @tomasz's suggestion below, I retitled this question from "How to spawn goroutine per HTTP request" to "Why isn't this go HTTP server spawning a goroutine per request in Chrome 47?"</p>