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)
}
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 https://github.com/gorilla/websocket.
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.
Hardware Specification:
16 GB Ram
4 Core CPU
2.5 GHz Intel Core i5
will it work for large number of connections without affecting the performance?