antoniomika / sish

HTTP(S)/WS(S)/TCP Tunnels to localhost using only SSH.
https://ssi.sh
MIT License
3.84k stars 297 forks source link

How many max connections it can hold? #277

Closed adhikjoshi closed 9 months ago

adhikjoshi commented 10 months ago

I have 16GB Ram and 4 Core CPU virtual machine, how many connections it can hold at max?

Also is there any max limit?

antoniomika commented 9 months ago

sish is very much bound by CPU/network throughout moreso than anything else.

On a test VM I provisioned with 4 cores and 8gb of ram, here were the results I had. It's important to note that this wasn't exhaustive and is fairly anecdotal.

I ran sish with the configuration described in the readme. I then started a large number of ssh connections, each with a single tunnel forward. I did this by generating an ssh key for testing and then running this in a bash shell:

for i in {0..2000}; do ssh -i ./test -n -R 0:httpbin.org:80 ssi.sh & done

I ran this multiple times while watching the CPU/memory usage on the system with htop.

Doing this, I ran ~15000 connections before I started getting bored (first run of the command above was for 1000 to see if I'd crash my machine, then i ran it 7x over the next few minutes). I then spawned another shell that was randomly firing curl requests at the ports that were bound. The load avg on the system never passed 2. Memory was negligible, with max usage never peaking over 2gb.

Here's are some graphs I extracted from my monitoring instance:

Resource Usage: image

Connections (purple is sish instance, blue is my dev machine): image

From this, it's pretty safe to extrapolate the limits will be based on CPU and network. For this case, sish was listening on TCP ports, which could be a limitation depending on the number of ports available in your environment. If using sish for internal connections (aliases), this limit essentially disappears and instead you're left with number of concurrent ssh sessions and based on the throughput of the data you're transferring potentially being an I/O limit. Like I said, your mileage will vary.