Manage multiple outbound TCP connections

My program should send data to several (about 50) "client" stations. Important data bits must be sent via TCP to ensure arrival. The compounds are mostly fixed and should not change during one period of program activity.

What do you think will be the best for this? I heard that creating a new thread for each connection is usually not recommended, but is this recommendation valid when connections should not change? Scalability would be nice to have, but this does not cause much concern, as the number of client stations is not expected.

The program is written in Java, if that matters.

Thank,

Alex

+3
source share
4

, , 50 . , - .

(N N ), NIO. , , , :

  • , ,
  • ( ),
  • -, ..
  • .
+2

50 , . . - 200 , ..

+1

I would use a thread pool. Depending on the configuration of the thread pool, it will create as many threads as you need, but this solution is more scalable. This will be normal not only for 50, but also for 5000 customers.

0
source

Why don't you limit the number of threads using matching as a connection pool?

0
source

Source: https://habr.com/ru/post/1793817/


All Articles