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

Hi Debjit Roy
Thank you for bringing this to our attention, kindly allow us some time, our team will analyse it and get back soon. We appreciate your patience and will keep you informed

Hi

Thanks to Fyers team for their quick assistance and initiative.

The problem is solved, and the fix to this issue is applied. I have tested the fix, it’s working fine.

Anybody who have the same issue can set the “webSocket queue processing interval” at a higher value, as explained in the Advanced Configuration section of the API docs.

https://myapi.fyers.in/docsv3#tag/Web-Socket/paths/~1WebSocket/delete

Problem fixed form version “fyers-api-v3”: “^1.4.2”