✅ Passing realtime data from Worker to ASP.NET Web API
I'm working on a stock broker company, currently working for the stock chart infrastructure. I need to connect to the realtime data feed server via a single TCP socket (the server's using C++), and fan out the stocks data in realtime via WebSocket to the frontend client (which is just static HTML/JS also statically served by ASP.NET Core).
One thing that bugs me and the team is: how do we properly transfer the data from the Worker instance to the Web API instance, so that it can be properly being fan out? At first I was thinking of using
I don't want to add another external infrastructure like using Kafka, Rabbit, or Redis pubsub, I want to avoid more latency.
So the questions would be:
One thing that bugs me and the team is: how do we properly transfer the data from the Worker instance to the Web API instance, so that it can be properly being fan out? At first I was thinking of using
System.Threading.Channels, but having it as a singleton that used by both the Web API and Worker doesn't makes sense to me, as I suppose the class will be created twice on the Web API and on Worker (or did I got it wrong?).I don't want to add another external infrastructure like using Kafka, Rabbit, or Redis pubsub, I want to avoid more latency.
So the questions would be:
- How do I properly transfer (and possibly fan out) the data being consumed by Worker instance to the ASP.NET Core instance?
- Is using
the best way to achieve this? On other language, I'd useSystem.Threading.Channels
in Go andchannel
in Rust.std::sync::mpsc