Snapchat is an instant photo-sharing app created by two Stanford University students. With the app, users can take photos, record videos, add text and drawings, called “Snaps, “and send them to their friends on the app. This article, from Snapchat Client Network Team, mainly introduces that Snapchat’s user experience has been greatly improved after using QUIC protocol.

Translation/Alex

Technology Review/Lian-xiang Liu

At Snapchat, our goal is to make Snapchat Camera the fastest way to share great moments. We don’t want users to have any delay in sharing with their friends.

Web requests are especially important when using Snapchat. While UI updates and disk writes can take milliseconds, network latency can be as high as seconds, with high error rates and device limitations. To reduce latency and errors, we keep requests and responses as small as possible, reduce unnecessary synchronization, bring media messages closer to users through global content distribution partners, and use a more efficient, next-generation network protocol called QUIC (Quick UDP Internet Connections).

01

How does the QUIC agreement help Snapchat?

Let’s take a look at the network stack before QUIC. Take Snap as an example. At the application layer, we first put Snap media into the HTTP2 Request payload, then use TLS to secure the connection at the security layer, and then use TCP to block the request and upload Snap to the server. However, for a mobile network environment, the TCP+TLS+HTTP2 protocol stack is suboptimal. For example, when Snap users switch between Wifi and WWAN, TCP requests fail. When Snap users are chatting with friends, being unable to send a message due to a broken connection can lead to a bad experience.

QUIC is an Internet transport protocol developed by Google engineers. QUIC is based on UDP and is the basis for replacing TCP+TLS+HTTP2 with HTTP3. It solves many transport and application layer problems without requiring any or only minor changes by application developers. As shown in the figure above, QUIC does not change the underlying operating system network protocol, nor does it change HTTP.

QUIC has the following advantages over TCP+TLS+HTTP2 stack:

** Faster connection setup: ** TCP+TLS requires 1 to 3 RTT (round-trip delay) before sending the payload, QUIC supports 0RTT.

** Improved congestion control: **QUIC has pluggable congestion control that provides richer information to congestion control algorithms than TCP, such as QUIC BBR V1 and QUIC BBR V2.

** Avoid header blocking multiplexing: ** For HTTP2 connections, when a TCP packet is lost, the connected stream cannot proceed until the packet is transmitted again or received by the receiver. This leads to increased latency, which in turn degrades the user experience (in a mobile network connection). QUIC eliminates this delay by overmultiplexing other streams.

** Connection migration: ** TCP requests will fail if the IP address changes. QUIC connections are identified with a 64 bit random number as an ID, allowing the client to continue requests without interference even if the IP address changes, allowing the user experience to continue as usual.

** Find lost connections: **QUIC can quickly find lost connections and avoid long requests hanging.

These advantages of QUIC apply well to the Snapchat use case:

** Faster Connection setup: ** Before Using QUIC, Snapchat P90 took 300 ms to establish a connection. This latency on the connection translates into user wait latency and prevents users from receiving and viewing Snap messages. The faster connection on QUIC directly reduces wait times and improves the user experience.

** Improved congestion control: ** On Snap, users can upload media files up to 10MB. Better congestion control algorithms can increase traffic and reduce latency and error rates (especially for large files).

** Multiplexing to avoid queue blocking: **Snapchat has a wealth of short content use cases like Snaps and stories, discover content, etc. Typically, multiple download streams will use the same connection. QUIC eliminates HTTP2 header blocking issues such as sending message requests blocking Spotlight short video requests.

** Connection migration: ** If the wifi connection is broken and messages cannot be sent, the Snap user experience will be significantly reduced, and QUIC addresses this pain point.

** Found missing connections: ** The constant loading of rotating ICONS when missing connections occurs is annoying (especially if the user is watching content in full screen mode). With QUIC, when a request failure due to a lost connection occurs, we immediately recognize it and try to connect again while providing a user-friendly interface.

02

QUIC’s app on Snapchat

Snapchat’s client network stack is built on Cronet, an open source mobile network library. Snap uses Cronet because it not only supports QUIC, but also improves visibility with rich metrics and logging. This enables us to observe client and server network performance more comprehensively.

Example shows

We choose different protocols based on the network performance of different countries and platforms. Overall, we observed that enabling QUIC improved p90/P99 network latency by 6-20% and reduced network errors by 3-8%. QUIC has further improvements for users with low Internet connections. Here we show three examples.

First example: In October 2019, we enabled QUIC on our advertising service. We observed improvements in latency and error rates for P90/P99.

We observed an improvement in error rates for all error codes, including connection timeout, connection loss, request timeout. When we break it down further by country and region, we find that countries and regions with relatively poor network quality and geographic distance from where we serve show higher improvement in latency.

** Second example: ** On top of QUIC, enabling BBR congestion control on the client-to-server path also brings significant latency improvements. Larger request payloads improve even more.

** Final example: ** Network request success rate when wifi connection is disconnected increases by 20% when connection migration is enabled on Android.

03

The future work

The successful integration of QUIC keeps us moving forward, and we will continue to make more efforts on QUIC in the future:

Improve coverage of QUIC

Further leverage the benefits of QUIC, including testing on BBR V2, support for connection migration on iOS, etc.

Original link:

Eng.snap.com/quic-at-sna…


For details, please scan the __ QR code __ or click __ to read the original text __ for more information about the conference.

This article uses the article synchronization assistant to synchronize