I am looking for a bit of guidance here, as after spending lots of time browsing various tutorials and SO answers, I have failed to find something that would help me move forward, although what I want to do is probably a fairly common use case.
I have a GO server, and a WS powered by Gorilla. What I want to do is exchange multiple sources of unrelated data via that WS connection.
Let me try to elaborate :
Say, I have one stream of data that goes as follows : {type: "data_type", payload: "payload"}
. That data is processed by one of the Web Components (WC) on the front end. Now, I have many such Web Components on one page on the front end, that respectively need to be fed data of that type. The data as described is NOT common to all these Web Components. That means one of these WC rely on one source of data as typed above, another one of these WC rely on the same type of data, but with obviously different values. These WC "operate" separately.
I am not sure how to go about this.
- Should the data flow all be managed by one single WS connection ? It would mean in this case, the WS data would need an additional identifier as follows :
{web_component_id: "id", type: "data_type", payload: "payload"}
Wouldn't that have an effect on memory consumption on the UI ?
- Should the WS connection be handled the way it seems to be described here : https://stackoverflow.com/a/43760265/7461599 ?
In this case, that means the web server would open a new WS path associated with each one of the Web Components that consume its respective WS data ? Something as follows :
http.HandleFunc("/ws/web_component_id", func(w http.ResponseWriter, r *http.Request) {
serveWs(pool, w, r)
})
In this case here, it means there would be as many WS connections as there are WC fed with their respective data. That means up to a 1000 simultaneous WS connections potentially. What would be the effect on performance ? If I understood correctly, based on this guy's post about his 3 million WS connections, the effect on performance in my case with 1000 connections, would be negligible.
Should it be managed with some kind of map function on the back end, where every WC is mapped with one WS connection as described above ?
do I need a pool as described here ? https://tutorialedge.net/projects/chat-system-in-go-and-react/part-4-handling-multiple-clients/
Is it correct to think of my WC as the Clients the author of the above tutorial describes ?