I'm trying to use ktor for many simultaneous of TCP connections on JVM. Each connection is tcp client to different ip/port, and amount of data would be quite low. Any suggestions of should there be single thread or multiple, pools, etc?
Question is about how to use coroutines correctly to implement multiple tcp clients.
By "many simultaneous of TCP" I mean number of connections will be bigger than number of cpu cores/threads. I'm quite sure that OS could handle that number of concurrent threads without problem. But what is best practices for similar cases?
02/10/2020, 8:58 AM
Are connections long lived?
Try to ask this question in #ktor
I might be wrong but I think you can create as many client sockets as you need backed by dedicated dispatcher. Dispatcher can contain only one single thread.
Then you may communicate with socket channels in some async coroutine builder.
02/10/2020, 12:44 PM
Why do you need own pool of connections? It's managed by configuration of Ktor connection driver, different drivers has different implementation details (non-blocking or blocking with thread pool) and you can configure them
02/11/2020, 7:56 AM
Where I could read more about "Ktor connection driver"? First pages of google only refer to databases. I don't use databases for this case.