smartbe2021-02-18 21:43:23
smartbe, 2021-02-18 21:43:23

300 web sockets?

Hello! There is a question on a node.

I plan to write a server that will create 300 sockets. The socket can be updated about 10 times per second. For each socket update, mathematical operations of comparing numbers will be performed. That is, there can be about 3000 of them per second. Question. I'm new to this. Will the server do it? Do I need to fork processes? Can there be delays (that is, first one operation of 100 ms, then another only)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Dmitry Belyaev, 2021-02-18

If the calculation operations are blocking and they block the thread for a long time, then it is worth putting them into workers , it is better to choose the number of workers according to the number of logical cores (hardware threads), and you can distribute tasks with a simple round robin algorithm if the tasks themselves are approximately the same.
And as for sockets, 300 permanent connections per 1 process/thread is a mere trifle for a node, it will calmly digest several tens of thousands if the thread is not blocked for more than a few dozen operations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question