NodeJS SDK Websocket high CPU usage Problem (SOLVED)

Hi

I ended up with a problem in Fyers WebSocket API for Nodejs SDK.I think in the Nodejs implementation of WebSocket API, there is some iterator that is causing abnormal CPU usage. Even for 1 script subscribed, it's using 8 to 9 % of CPU.

I did the same thing with Shoonya's Websocket API , and even for 500 stocks + Index data subscribed full depth, the CPU usage is not more than 3-4 % of CPU. I am taking the example of Shoonya because their Official SDK for Node JS was incomplete, so I wrote the wrapper SDK for Shoonya using their endpoints, as they provide their REST API endpoints.So I know the code being used in there, but not in the case of Fyers, I'm using the official SDK of Fyers, and that's creating the problem.

Below, I have shown the CPU usage. I have used Fyers and Shoonya to compare, both are separate processes subscribed to a single script with full depth using the websocket. Both have the same logic. We can clearly see that Fyers is using around 8% and Shoonya is using 0.7 %, and most of the time, Shoonya's process is sleeping.

Thanks

2 replies