title: Scaling webscocket connections using golang
body: <pre><code>   func handleConn(w http.ResponseWriter, r *http.Request) {
          ws, err := upgrader.Upgrade(w, r, nil)
          if err != nil {
              if _, ok := err.(websocket.HandshakeError); !ok {
                  log.Println(err)
              }
              return
         }
  
          go writer(ws)
          reader(r, ws)
      }
  
      func main() {
         http.HandleFunc("/", handleConn)
      }
  </code></pre>
  
  <p>I am trying to build a high scaling websocket server using golang. Since there is lack of support in native go websocket package, i am using <a href="https://github.com/gorilla/websocket" rel="nofollow noreferrer">https://github.com/gorilla/websocket</a>. </p>
  
  <p>For every connection, a goroutine will be spawned to take care of writes to it. For scaling huge number of connections. Let's say if I have 1M concurrent connections then there should be 1M goroutines will be running on the server.</p>
  
  <p><strong>Hardware Specification:</strong></p>
  
  <p>16 GB Ram</p>
  
  <p>4 Core CPU</p>
  
  <p>2.5 GHz Intel Core i5</p>
  
  <p>will it work for large number of connections without affecting the performance?</p>