zonyitoo / shadowsocks-yamux-plugin

A shadowsocks SIP003 Plugin with connection multiplexor in YAMUX protocol
MIT License
29 stars 3 forks source link

Low performance at high latency between server and client #1

Closed freakinyy closed 1 year ago

freakinyy commented 1 year ago

I set shadowsocks-rust with yamux-plugin between my local pc and remote server, but the bandwidth (600-700KB/s) is much lower than without yamux-plugin. Follow is my plugin options and mode:

...
"plugin_opts":"udp_timeout=30&tcp_fast_open=true",  
"plugin_mode":"tcp_and_udp",
...

But if I set shadowsocks-rust with yamux-plugin between local PC and local router (low latency), it seems that the bandwidth is much higher. I searched and found this: https://github.com/fatedier/frp/issues/2987

“通过调大yamux.Config.MaxStreamWindowSize(默认大小为256*1024,不能低于此值)可以缓解限速问题。如果带宽比较大的情况下,使用yamux做多路复用,假设多路复用客户端和服务端的RTT t ms,则单个stream的带宽约为:
((1000/t) * (MaxStreamWindowSize/2) * 8)/(1024*1024) Mbps”

So I tied to change the Config::default() when calling Session::new_client and Session::new_server in yumux-plugin-local.rs and yumux-plugin-server.rsto

let custom_config : Config = Config { 
            max_stream_window_size: (4*1024*1024),
             ..Config::default() };

The bandwidth between my local PC and remote server is much higher now (2MB/s). I am new to Rust and not good at networking, so I'm not sure if my trying is correct. So could you please test this?

zonyitoo commented 1 year ago

@driftluo Did you encounter the same issue?

zonyitoo commented 1 year ago

Just read the comments in the https://github.com/fatedier/frp/issues/2987 , your solution should be correct.

Maybe you could try to make the stream window size much higher (to get 1000Mbps brandwidth) and make a PR.

freakinyy commented 1 year ago

OK, I'll have a try.

driftluo commented 1 year ago

@driftluo Did you encounter the same issue?

yes, the default configuration bandwidth of yamux is very low, it is recommended that users adjust it according to their own situation

raintean commented 1 year ago

According to past practice, yamux protocol has 70~80% performance loss than raw tcp when use default config(rtt 150ms). loss of GRPC(h2 mux) is 50% +-. I do lot of work on this, but it dosen't work very well. 😢

QUIC is the silver bullet

zonyitoo commented 1 year ago

https://github.com/shadowsocks/qtun

You may want this plugin.