3

When designing a distributed system with 30 plus applications that each have 4 threads a piece for communication, so 120 threads total of 30 applications. We use ZeroMQ which uses Linux Sockets.

Is this number of threads going to be serious strain on the network?

Does multiprocessing/multiplexing have any benefit in taking strain off the network?

Link to resources would be great.

Thanks for your help,

Thank

Frank
  • 915
  • 1
  • 7
  • 22

1 Answers1

1

I can't say for ZeroMQ specifics, but generally network congestion have nothing to do with numbers of threads using the network. Networks are way slower than code executed in CPU, so if you want to saturate outbound bandwidth of a computer, you will usually need only one thread. I saw this for 100 Mbps Ethernet, this is probably true for 1 Gbps. Can't say for 10 Gbps+ solutions as I never worked with them.

Multithreading vs. multiplexing usually solves other issue. You should prefer in-thread multiplexing when the amount of threads you have depends on the amount of clients you serve. You say you already have a fixed number of threads per machine (4), so it's already pretty much perfect.

So, go with whatever fixed amount of threads you like. If it were to bring the network down, making less threads wouldn't help. If TCP isn't able to adapt, and your network has unacceptable quality of service, you'll need to limit your apps in some other way.

u354356007
  • 3,205
  • 15
  • 25
  • Hi. Thanks for the answer! It's actually 4 threads per application, not machine. With 30 or more applications per machine. But I agree with your statements in general. – Frank Aug 08 '18 at 17:30
  • A major concern brought up is context switching on the processor between threads as they wait for incoming messages. Does this information change your answer at all? – Frank Aug 08 '18 at 17:31
  • @Frank Unless you employ a spinlock mechanism, a thread waiting for IO is usually considered sleeping, so scheduler won't put it on CPU until said IO occurs. I wouldn't say a modern CPU will choke on 120 threads. The upper limit for a PC is probably around 2000 threads. – u354356007 Aug 09 '18 at 05:56