midori icon indicating copy to clipboard operation
midori copied to clipboard

A strange issue run in multi thread tcp connect

Open MikoyChinese opened this issue 3 years ago • 4 comments

Hi,

I found a strange issue when I try to run demo in https://db.laomoe.com/ with midori. For me, I create a China mobile Nat in public and relay the tcp to US VPS. Here the config:

# China Mobile Nat
{
  "dns_mode": "ipv4_then_ipv6",
  "endpoints": [
    {
      "listen": "[::]:12345",
      "remote": {
        "addr": "[2603:xxxx:c003:xxxx:xxxx:5063:xxxx:xxxx]:3456",
        "net": "tcp",
        "trans": {
          "proto": "ws",
          "path": "/7bba04c83b1b2486736d9b2"
        }
      }
    }
  ]
}
# US VPS
{
  "dns_mode": "ipv4_then_ipv6",
  "endpoints": [
    {
      "remote": "127.0.0.1:443",
      "listen": {
        "addr": "[::]:3456",
        "net": "tcp",
        "trans": {
          "proto": "ws",
          "path": "/7bba04c83b1b2486736d9b2"
        }
      }
    }
  ]
}

And for iperf3, I can relay normally, but for multi thread connect in https://db.laomoe.com/, I can not use bandwidth fully and it just has a random range bandwith(about 5%~50% Normal Bandwidth). But for gost, it run no problem.

MikoyChinese avatar Dec 08 '21 08:12 MikoyChinese

I'm not sure if there is a performance issue when relaying multiple connections. Theoretically each connection is relayed separately, and there is no conflict between connections. With rust's concurrent model, there could seldom be a performance issue..

I made some tests with iperf3 on my vps just now (I am using a slow network, only 100Mbs). There seems merely any performance loss, no matter I spawned 1 thread, or 10 ~ 100 threads. According to some tests I made on my laptop (6 core, low voltage CPU) before, the relay could handle more than 10Gbs bandwith when using WS, with about 20% performance loss compared to TCP. The amount of connections does not affect the result.

At least, there should not be a bottleneck when transferred data at < 1Gbs. BTW, did you enable gost's multiplex feature?

zephyrchien avatar Dec 08 '21 10:12 zephyrchien

I install gost by script from https://github.com/KANIKIG/Multi-EasyGost. I am not sure if it enable the multiplex.

You maybe need to create a gost node in your vps, and run https://db.laomoe.com/ as same as me. You can compare midori with gost. But I don't know this problem if caused by midori or the https://db.laomoe.com/ website.

MikoyChinese avatar Dec 08 '21 10:12 MikoyChinese

I install gost by script from https://github.com/KANIKIG/Multi-EasyGost. I am not sure if it enable the multiplex.

Well, It is ws, not mws. So you are using plain websocket.

You maybe need to create a gost node in your vps, and run https://db.laomoe.com/ as same as me. You can compare midori with gost. But I don't know this problem if caused by midori or the https://db.laomoe.com/ website.

The site is interesting.. Have you tried other speed-test website like speedtest.net, fast.com, and got the same result?

Also, I think you should control variates to make sure if it is the relay's problem. Connect to the relay directly via speed-test tools like iperf3, instead of using a proxy over the relay and testing the proxy.

zephyrchien avatar Dec 08 '21 10:12 zephyrchien

Hi @MikoyChinese . I have written a websocket library recently, which does not buffer payload data and might be much more efficient than tungstenite(used by this repo). Would you like to have a look at it? link is here.

zephyrchien avatar Apr 09 '22 14:04 zephyrchien