Search code examples
websocketarchitecturesystem-design

Creating a fanout service using Websocket connection


im trying to build an application that serves real time data to the end users. i was thinking of using a websocket connection since the data is alot (10 events/sec). the trouble is this, the data is coming from a websocket connection from a third party. I am limited to only 1 websocket connection and in future i can ask for more but only a couple.

What im thinking is designing a websocket fanout service that works somewhat like this. enter image description here Proposed design. I'm confused about the reliability of such design and how i can scale it efficiently. This is an open ended question since Im really ironing out the design details but i would love any experienced input here.

PS: Im either going to use Node.js or Spring boot in the backend.


Solution

  • I have a few questions:

    • How are the end users accessing this data from the intermediary? is it through HTTP, Web Sockets, Polling, or PubSub?
    • How is the data going to be stored in the intermediate state (received from the socket but not accessed by the end users)?

    Since this resembles a system that ingests realtime market data, I will suggest a few things:

    • implement a POC of this system and check the time delta between when the event originally occurred and when it was received by the end users.
    • Use a high-compression packet format for sending data to clients (protobuf) since JSON is slow in serialization / de-serialization and also bulky
    • Assess the amount of data that needs to be processed, and make sure that the intermediary server has good computing power and enough memory to provide the necessary throughput/performance along with being able to store data in memory