Skip to content

Effective concurrent SshClient connections bumps into a limit #409

Description

@cankut

I am trying to make SSH connections to multiple clients concurrently to check their availability.

I noticed that, after a specific limit, increasing thread count doesn't have an effect on total process time.

For testing purposes,
I choose a fake IP address that connection will never happen and set the connection timeout to 5 seconds.

private static void MakeConnection()
{
using (var client = new SshClient("1.2.3.4", 22, "test", "test"))
{
client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(5);
try
{
client.Connect();
}
catch { }
}
}

Executed test runs for different thread & connection counts.

Here are the results:

Thread CountConnection CountTotal Process Time
115 sec
225 sec
335 sec
4410 sec
5510 sec
6610 sec
7715 sec
8815 sec

I expect to see 5 sec for each row but somehow effective active thread counts seems like 3. Even though I spawn 8 threads, it has been processed as 3+3+2.

What might be causing this behaviour?

Simple console application to reproduce the issue:
https://gist.github.com/cankut/4efb95d2da8fdf63fb14cf762b1f953d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions