-
Notifications
You must be signed in to change notification settings - Fork 965
Introduce MPTCP #1811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce MPTCP #1811
Conversation
Multipath TCP (MPTCP) is an extension of the standard TCP protocol that allows a single transport connection to use multiple network interfaces or paths. MPTCP is useful for applications like bandwidth aggregation, failover, and more resilient connections. Linux kernel starts to support MPTCP since v5.6, it's time to support it. The test report shows that MPTCP reduces latency by ~25% in a 1% networking packet drop environment. Proposed-by: Geliang Tang <[email protected]> Tested-by: Gang Yan <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Signed-off-by: zhenwei pi <[email protected]>
This PR could be tested by https://github.com/pizhenwei/valkey/tree/mptcp-with-hiredis |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #1811 +/- ##
============================================
+ Coverage 70.87% 70.98% +0.11%
============================================
Files 123 123
Lines 65651 65704 +53
============================================
+ Hits 46529 46642 +113
+ Misses 19122 19062 -60
🚀 New features to boost your workflow:
|
Not sure how useful MPTCP is for low-latency data center inner networks. It was built for mobile devices to switch between WiFi and cellular, handling packet loss. I do see the benefit of bandwidth aggregation though (which can be fixed externally, eg. openmptcprouter) |
MPTCP leads additional ~10% latency on Linux-6.11 from test over no packet drop stable network, so it is NOT suitable for any client/replication. If server listens on MPTCP, and the client side uses TCP, the connection will be TCP only. This means the client/replication side has a chance to decide TCP/MPTCP.. Hi @matttbe, is it possible to improve the performance of MPTCP as fast as TCP? |
Hello,
@xbasel: MPTCP can also be useful in data centre for fast recoveries when some links fail, to use the path with the lowest latency, or even to combine multiple paths. There were a few scientific papers on the subject (using MPTCP in data center). I guess with Valkey, there will be a higher focused on the latency aspect. Please note that on the server side, supporting MPTCP is "cheap": when clients don't request to use MPTCP, server applications will receive a "plain" TCP sockets from the kernel when connections are accepted, making the performance impact minimal.
To be able to use multiple paths for the same connection, a few bytes need to be added to the header of each TCP packet. More details here. It means that if only one path is used per connection, MPTCP cannot be as fast as TCP. But that's normal, that's the small cost to pay to leverage multiple network paths, potentially increasing throughput and reliability. Of course, if only one path is used per MPTCP connection, no need to use Multipath TCP ;) Still, we are working on reducing the gap between TCP and MPTCP single path, e.g. this recent modification here. |
Unrelated to this PR, any idea if its possible create subflows on the same interface ? |
Yes it is. This page should explain what is possible with the default path-manager: https://www.mptcp.dev/pm.html Some ideas:
Don't hesitate to share the use-case if something is not supported ;-) |
Some cloud providers and some internet routers enforce per-flow bandwidth limits. |
Signed-off-by: zhenwei pi <[email protected]>
No. LGTM now. |
Hi @PingXie @zuiderkwast Would you please take a look? |
I like this because it can be done without additional libraries. Currently we're busy with the 8.1 release and I will be away for the next week. This one will have to wait to the next release. I have some questions though:
|
We do recommend this, that's what GoLang is doing since v1.24 for example. But then, it is required to change the way the socket creation is handled in this PR: for the moment, there is an error if MPTCP is not supported by the kernel. Instead, if it is not possible to create an MPTCP socket, I suggest to simply retry with a plain TCP socket, then continue like before, e.g. #ifdef IPPROTO_MPTCP
if ((s = socket(p->ai_family, p->ai_socktype, IPPROTO_MPTCP)) == -1)
#endif
{
if ((s = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) continue;
} Note that I think it would still make sense to have an option to easily disable MPTCP support, just in case. Disabling MPTCP globally is not difficult, simply with |
@zuiderkwast : Oops, I forgot about the two other items
No need to change anything on the application side for that, the kernel will do that automatically once it has been configured, see here. There are tools that can automatically configure the MPTCP endpoints for the kernel, e.g. NetworkManager >=1.40. If these tools are not available, this can be easily done manually thanks to the
This should not change anything compared to before. If the If an MPTCP endpoint has been configured to accept connections to a different port, then this port will only be used for additional subflows (paths). Of course, there are ways for the application to get info about the connection and which subflows are being used, see here. |
Hi @matttbe If we change valkey as this style, valkey will listen on MPTCP by default on a higher Linux kernel implicitly, and client compiled by golang v1.24 (or higher) will get a few higher latency. Maybe lots of golang users need additional work for trouble shoot to find the root cause. So I prefer explicit
|
With GoLang 1.24, only the server side is using MPTCP by default, not the client side. That's good to have servers supporting MPTCP by default, so the clients, the ones who usually benefits the most from MPTCP, can use it if they want to. The latency is not supposed to increase with MPTCP, it should even decrease when it is possible to pick a path with a lower latency or less loaded. If the latency increases significantly with MPTCP single path compared to TCP, that's not normal. In this case, please report a new issue on our side. |
Based on the test results, if MPTCP connection is used by default, it may incur some performance loss.
The above test results were obtained from tests conducted in a virtual environment set up using a script.
valkey-server 、valkey-benchmark、valkey-cli is compiled in https://github.com/pizhenwei/valkey/tree/mptcp-with-hiredis This script has parameters: Usage example:
which simulates a scenario where only one network interface exists using MPTCP. By the way, there is a simpler testing method here: using Thanks the community for attention to MPTCP. Hope we can work together to make this happen. |
@Dwyane-Yan Thank you for the tests and sharing the results! Do you have more details about the benchmark tool? It looks like it will create many "small" requests (1KB), but will it create one connection per request, or one (or a few) connections doing many requests? Because you already contributed to MPTCP in the Linux kernel, maybe would like to analyse how the kernel is behaving with TCP and MPTCP? It would be really good to analyse the performances in this use-case -- e.g. with If that's OK, can we move this discussion to a new issue on MPTCP side? |
Signed-off-by: zhenwei pi <[email protected]>
Signed-off-by: zhenwei pi <[email protected]>
I create MPTCP support PR for libvalkey, please take a look. |
Yeah, I was wrong - I overlooked the protocol level overhead (and for some reason assumed MPTCP would magically disable itself if only one path/interface exists). I think it should be disabled by default. |
Signed-off-by: zhenwei pi <[email protected]>
Out of curiosity, what kind of test was it? Only small connections? With which kernel version? |
Yes, all my followup questions have so far been answered in this thread. The default of no does seem correct. |
The performance issue #1811 (comment) is solved? @Dwyane-Yan @matttbe I have a little bit worry about it or I missed some threads? |
Just to make sure we don't mix up things here:
|
I used sockperf (tcp). default size 65507. Summary:
Perf suggests these may contribute to higher latency:
Runs on kernel Do these numbers make sense ? Output:
|
@xbasel thank you for sharing this. I quickly tried in a VM using a kernel v6.15-rc0 with localhost and I don't see such differences when running the According to what perf told you, the improvement might be due to some recent improvements on MPTCP side trying to improve the performances with a single path. That's getting better :)
|
nice to see the single subflow optimization, @matttbe!
thoughts? |
Since commit 4a92db9("Introduce MPTCP (valkey-io#1811)"), valkey server starts to support MPTCP. Support MPTCP for replica as client side. Signed-off-by: zhenwei pi <[email protected]>
Multipath TCP (MPTCP) is an extension of the standard TCP protocol that allows a single transport connection to use multiple network interfaces or paths. MPTCP is useful for applications like bandwidth aggregation, failover, and more resilient connections. Linux kernel starts to support MPTCP since v5.6, it's time to support it. The test report shows that MPTCP reduces latency by ~25% in a 1% networking packet drop environment. Thanks to Matthieu Baerts <[email protected]> for lots of review suggestions. Proposed-by: Geliang Tang <[email protected]> Tested-by: Gang Yan <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Cc Linux kernel MPTCP maintainer @matttbe Signed-off-by: Nitai Caro <[email protected]>
Multipath TCP (MPTCP) is an extension of the standard TCP protocol that allows a single transport connection to use multiple network interfaces or paths. MPTCP is useful for applications like bandwidth aggregation, failover, and more resilient connections. Linux kernel starts to support MPTCP since v5.6, it's time to support it. The test report shows that MPTCP reduces latency by ~25% in a 1% networking packet drop environment. Thanks to Matthieu Baerts <[email protected]> for lots of review suggestions. Proposed-by: Geliang Tang <[email protected]> Tested-by: Gang Yan <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Cc Linux kernel MPTCP maintainer @matttbe
Multipath TCP (MPTCP) is an extension of the standard TCP protocol that allows a single transport connection to use multiple network interfaces or paths. MPTCP is useful for applications like bandwidth aggregation, failover, and more resilient connections. Linux kernel starts to support MPTCP since v5.6, it's time to support it. The test report shows that MPTCP reduces latency by ~25% in a 1% networking packet drop environment. Thanks to Matthieu Baerts <[email protected]> for lots of review suggestions. Proposed-by: Geliang Tang <[email protected]> Tested-by: Gang Yan <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Cc Linux kernel MPTCP maintainer @matttbe
Since commit 4a92db9("Introduce MPTCP (valkey-io#1811)"), valkey server starts to support MPTCP. Support MPTCP for replica as client side. Signed-off-by: zhenwei pi <[email protected]>
Multipath TCP (MPTCP) is an extension of the standard TCP protocol that allows a single transport connection to use multiple network interfaces or paths. MPTCP is useful for applications like bandwidth aggregation, failover, and more resilient connections. Linux kernel starts to support MPTCP since v5.6, it's time to support it. The test report shows that MPTCP reduces latency by ~25% in a 1% networking packet drop environment. Thanks to Matthieu Baerts <[email protected]> for lots of review suggestions. Proposed-by: Geliang Tang <[email protected]> Tested-by: Gang Yan <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Signed-off-by: zhenwei pi <[email protected]> Cc Linux kernel MPTCP maintainer @matttbe Signed-off-by: hwware <[email protected]>
Allow replicas to use MPTCP in the outgoing replication connection. A new yes/no config is introduced `repl-mptcp`, default `no`. For MPTCP to be used in replication, the primary needs to be configured with `mptcp yes` and the replica with `repl-mptcp yes`. Otherwise, the connection falls back to regular TCP. Follow-up of #1811. --------- Signed-off-by: zhenwei pi <[email protected]>
Allow replicas to use MPTCP in the outgoing replication connection. A new yes/no config is introduced `repl-mptcp`, default `no`. For MPTCP to be used in replication, the primary needs to be configured with `mptcp yes` and the replica with `repl-mptcp yes`. Otherwise, the connection falls back to regular TCP. Follow-up of valkey-io#1811. --------- Signed-off-by: zhenwei pi <[email protected]>
Multipath TCP (MPTCP) is an extension of the standard TCP protocol that allows a single transport connection to use multiple network interfaces or paths. MPTCP is useful for applications like bandwidth aggregation, failover, and more resilient connections.
Linux kernel starts to support MPTCP since v5.6, it's time to support it.
The test report shows that MPTCP reduces latency by ~25% in a 1% networking packet drop environment.
Thanks to Matthieu Baerts [email protected] for lots of review suggestions.
Proposed-by: Geliang Tang [email protected]
Tested-by: Gang Yan [email protected]
Signed-off-by: zhenwei pi [email protected]
Signed-off-by: zhenwei pi [email protected]
Cc Linux kernel MPTCP maintainer @matttbe