mtg is much slower than official MTProxy implement
EkkoG opened this issue · 12 comments
I run both mtg and official MTProxy implement on a same server, mtg is much slower
For ping, mtg always 50-100ms slower
And for speed, mtg up to 1000Kb/s, MTProxy can reach 5M/s
here is my config
secret = "eec3xxx36f6d"
bind-to = "0.0.0.0:443"
Here is MTProxy's run parameters, and its run with Docker https://hub.docker.com/r/telegrammessenger/proxy/
/usr/local/bin/mtproto-proxy -p 2398 -H 443 -M 2 -C 60000 --aes-pwd /etc/telegram/hello-explorers-how-are-you-doing -u root /etc/telegram/backend.conf --allow-skip-dh --nat-info 172.18.0.6 103.xx.xxx.180 -S cxxxbf --domain my.vultr.com
Same here, some regions which client connected is more slower than official MTProxy.
Or you can use mtg v1, and increase read and write buffer to 128KB or 256KB.
If mtg v1 works here, then the reason of this performance difference is a set of clusters it connects to. v1 with adtag uses so-called middle proxies, a set of special proxies that are able to terminate certain RPC calls. v2 relies on the same servers that are used by Telegram with no proxies at all. These servers could be overloaded, or routing to them from your location is slower :/
There is a good way how to measure that. Telegram clients support 2 types of proxies: MTPROTO and SOCKS5. From IP connectivity point of view, both SOCKS5 and MTPROTO with mtg v2 should ask for a connection to a certain types of proxies. Performance of SOCKS5 proxies should be similar to mtg v2.
Yes, as @hshh has advised, you can try to increase a buffer size. This is not a solution but rather a mitigation.
set buffer to 128KB makes speed reach 2.5M/s, still can't reach the speed of official MTProxy.
In my case the media loading speed is much better when set --tcp-buffer="256KB"
If mtg v1 works here, then the reason of this performance difference is a set of clusters it connects to. v1 with adtag uses so-called middle proxies, a set of special proxies that are able to terminate certain RPC calls. v2 relies on the same servers that are used by Telegram with no proxies at all. These servers could be overloaded, or routing to them from your location is slower :/
There is a good way how to measure that. Telegram clients support 2 types of proxies: MTPROTO and SOCKS5. From IP connectivity point of view, both SOCKS5 and MTPROTO with mtg v2 should ask for a connection to a certain types of proxies. Performance of SOCKS5 proxies should be similar to mtg v2.
Yes, as @hshh has advised, you can try to increase a buffer size. This is not a solution but rather a mitigation.
If mtg and official MTProxy use the same key, eg, with the same version, do they connect to the same server?
If mtg v1 works here, then the reason of this performance difference is a set of clusters it connects to. v1 with adtag uses so-called middle proxies, a set of special proxies that are able to terminate certain RPC calls. v2 relies on the same servers that are used by Telegram with no proxies at all. These servers could be overloaded, or routing to them from your location is slower :/
There is a good way how to measure that. Telegram clients support 2 types of proxies: MTPROTO and SOCKS5. From IP connectivity point of view, both SOCKS5 and MTPROTO with mtg v2 should ask for a connection to a certain types of proxies. Performance of SOCKS5 proxies should be similar to mtg v2.
Yes, as @hshh has advised, you can try to increase a buffer size. This is not a solution but rather a mitigation.If mtg and official MTProxy use the same key, eg, with the same version, do they connect to the same server?
Sorry, I have misunderstood the v1 means, it is an mtg version, not an MTProxy protocol version.
What kind of servers does official MTProxy use? middle proxies or same as Telegram?
I test again
mtg v1, default config, 500KB/s
mtg v1, read and write buffer increase to 256KB, 1.3M/s
mtg v2, default config, 900KB/s
mtg v2, increase tcp-buffer to 256kb, 2.7 M/s
official MTProxy, 6M/s
What kind of servers does official MTProxy use? middle proxies or same as Telegram?
Yes. This mode was abandoned in v2 due to its insane overcomplexity. But it works in mtg v1 if you use adtag. Adtag usage switches to middle proxies.
Unfortunately, I do not have enough of time to examine this performance issue. This is a research activity that will occupy a couple of days. I do not have them now :(
I hope to come back to this issue during US christmas time when everyone works in sloth mode.
Oh...it's really busy work, Thanks for your hard work again.
It seems that master branch has a couple of performance tunings that changed situation. If issue is still with us, feel free to reopen.