Skip to content
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

transport: native sockets on iOS/Android #13

Open
junr03 opened this issue Apr 11, 2019 · 11 comments
Open

transport: native sockets on iOS/Android #13

junr03 opened this issue Apr 11, 2019 · 11 comments

Comments

@junr03
Copy link
Member

junr03 commented Apr 11, 2019

Using native sockets on iOS/Android is the recommended approach for performing low-level networking. We should investigate:

  • What benefits we can get from using native sockets/APIs
  • The work required to use these APIs, both within Envoy Mobile and upstream Envoy
@junr03 junr03 transferred this issue from another repository May 2, 2019
@junr03 junr03 added design proposal platform/ios Issues related to iOS labels May 2, 2019
@junr03 junr03 added this to the v0.2 "Primo" milestone May 2, 2019
@stale
Copy link

stale bot commented Jun 2, 2019

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 2, 2019
@junr03 junr03 removed stale labels Jun 3, 2019
@rebello95 rebello95 assigned junr03 and unassigned rebello95 Jun 17, 2019
@junr03
Copy link
Member Author

junr03 commented Jun 17, 2019

Current proposal:

  • Envoy uses BSD sockets for sending/receiving data. On iOS, there are known issues that arise with this approach (such as these with gRPC). To work around these problems, Envoy will need to support using the native networking stack to send/receive data in place of the built-in mechanism
  • Note: We’ll need to take into account TLS support (we should likely use TLS from Envoy instead of native)
  • Implement a socket provider on iOS that will replace the existing BSD socket usage in Envoy. This will need further investigation, but can likely be accomplished through CFStream, Network.framework, etc.

@rebello95
Copy link
Contributor

Potentially related, here are some key announcements Apple made regarding networking at WWDC earlier this month: https://github.com/Blackjacx/WWDC#advances-in-networking-part-1 (parts 1 and 2)

@conradev
Copy link

You'll definitely want to use Network.framework as the socket provider on iOS – it works across all of Apple's platforms. BSD sockets do not work on Apple Watch, for example.

@sayrer
Copy link

sayrer commented Jun 20, 2019

an even simpler test: iirc, BSD sockets don't handle cellular/wifi transitions, but Open Transport and Network.framework do. Other areas to check might be multipath TCP support and VPNs.

@mattklein123
Copy link
Member

For watchers the main work items here are:

  1. Slightly refactor the TLS transport socket to allow for swapping out the actual read/write/connection APIs
  2. Create a new iOS transport socket that derives from the upstream TLS transport socket and uses appropriate iOS APIs for the underlying connections.

This should be pretty straightforward given existing Envoy extensibility mechanisms.

@rebello95
Copy link
Contributor

Detailed write-up of the current state of the transport layer issues on iOS in this comment: #128 (comment)

@junr03
Copy link
Member Author

junr03 commented Sep 6, 2019

Current proposal doc.

@junr03 junr03 modified the milestones: v0.2 "Primo", v0.3 "Secondi" Oct 22, 2019
@rebello95 rebello95 changed the title transport: proposal for iOS transport: native sockets on iOS/Android Oct 24, 2019
@rebello95
Copy link
Contributor

Related: #541

@junr03 junr03 modified the milestones: v0.3 "Secondi", Backlog Mar 18, 2020
@goaway
Copy link
Contributor

goaway commented Jul 29, 2020

https://docs.google.com/document/d/16jq5YO542BbAnBGwldgPfaJel9H3K6ufWD7Lqvrx0Bg/edit?usp=sharing

The above doc captures the current state of the world with copious linked references and examples. In brief, our current usage of POSIX sockets on both platforms, with our current workarounds, presents no serious general-case issues. There are some somewhat niche cases (e.g. on-demand VPN on iOS) which could be better addressed.

In the medium term, implementing socket providers using the newer platform APIs would yield some incremental benefit, but more importantly, help to future-proof the library.

@conradev
Copy link

conradev commented Aug 1, 2020

While there are no general issues, Multipath TCP could yield pretty significant gains:

Last year we announced that in addition to Siri, we'd also enabled Multipath TCP for Apple Music. Since then, we've seen a 13 percent reduction in music stalls and in the event that a stall occurs, there has been a 22 percent reduction in the stall duration. https://developer.apple.com/videos/play/wwdc2020/10111/

(It might even be more pronounced for Lyft because users are leaving/entering WiFi range all the time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants