0

I need to create a server which sends the incoming data to the client side. Data is as network packets and depending on the token in this packet I have to send it to all the clients who are subscribed to that token. I am using tornado server to do this. So my questions are

  1. Shall I have a single IO loop to handle incoming data and sending it to clients? What if I use multiple IO loops?
  2. What if I use multiprocess? One process send data to clients and one to handle incoming data.

What will be the performance issues with both?

aja
  • 129
  • 1
  • 11
  • 1. Yes, it's better to use single IO loop. There is plenty of info on the internet to understand multi-loop use cases. 2. Multiprocess is a inevitable if you plan to scale your app. Receiver/sender split (using message queue for example) is fine, common and easy to create. [Overall, this could be a good thing to read to solve your questions by yourself](http://www.aosabook.org/en/distsys.html) – Fine Feb 09 '18 at 10:23
  • With the single IO loop if there is a delay in processing data then is there a change that I may miss some incoming packets? – aja Feb 12 '18 at 05:59
  • There is always a chance of so (but it's so rare and unique that I don't think that you should even think about it) and multiple IO loops doesn't solve that, it may just mitigate it a little. The thing is: if one of a multiple IO loops blocks, other will block too. Incoming packets in Tornado are received by OS into a socket's buffer, IO loop just reads from it when it's ready. Possible way of losing packets is a [socket buffer overflow](https://stackoverflow.com/questions/3205953/how-does-a-linux-socket-buffer-overflow), but I know nothing on whether it's a thing or not and how to avoid it. – Fine Feb 12 '18 at 10:31
  • +1. So is there a special case when we should multiple IO loop and is multiple IO loop similar to multiple thread? – aja Feb 14 '18 at 05:26

0 Answers0