Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Agenda - Problems of LINE app’s network stack - What we did to revamp the network stack - What we achieved with this project

Slide 3

Slide 3 text

େੴ ক๜ Masakuni Oishi LINE Communication Platform Engineering

Slide 4

Slide 4 text

Background - SPDY protocol + our own push mechanism - It was introduced in the early days of LINE app for efficient API calls. - But, the successor protocols, HTTP/2 and HTTP/3, have been standardized. SPDY should be replaced by them. - The code had become difficult to maintain. - Because, we had made our own customizations to Netty library. The network stack of LINE Android app had several problems

Slide 5

Slide 5 text

Project Goals - Migrate SPDY to HTTP/2 - In addition, consider upgrading to HTTP/3 in the future. - Comply with standard specifications - Reduce our own customizations as much as possible. - Safely complete the migration of the network stack - A failure in the network stack may affect a huge number of LINE users.

Slide 6

Slide 6 text

Difficulties - Migrate all API calls in the app “at once”. - Implement bidirectional communication with the server over HTTP/2. - Release incrementally in a way that allows for rollback.

Slide 7

Slide 7 text

Why we need to migrate AT ONCE SPDY protocol stack has a connection pool. Server Features SPDY stack Connection pool API X API X over SPDY Client app

Slide 8

Slide 8 text

Why we need to migrate AT ONCE HTTP/2 protocol stack also has its own connection pool. Server Features HTTP/2 stack Connection pool API Y Client app API Y over HTTP/2

Slide 9

Slide 9 text

Why we need to migrate AT ONCE If both SPDY and HTTP/2 are used at the same time, the number of TCP connections to the server will be doubled. Server Features SPDY stack Connection pool API X API X over SPDY HTTP/2 stack Connection pool API Y API Y over HTTP/2 Client app

Slide 10

Slide 10 text

Solution Introduced a common network layer so that the protocol to be used can be switched by a feature flag. Features SPDY stack Connection pool API X,Y HTTP/2 stack Connection pool Common network layer Switch by a feature flag

Slide 11

Slide 11 text

Bidirectional communication with server - For real-time chatting and other purposes, LINE client app uses bidirectional communication with the server. - Previously, LINE app used a mechanism called “SPDY Push”, which utilizes server-initiated streams of the SPDY protocol.

Slide 12

Slide 12 text

SPDY Push When the server pushes a message to the client, it is sent as a server-initiated stream (SYN_STREAM + DATA frames) on the SPDY connection. Server Client SPDY stack SPDY connection SYN_STREAM + DATA

Slide 13

Slide 13 text

Problems of SPDY Push - Most network libraries do not support server-initiated streams. - For LINE Android app, we forked Netty library and made our own customizations. - These customizations were the main cause of making the code difficult to maintain. - Therefore, for HTTP/2, we have developed a new mechanism called “Streaming Push”.

Slide 14

Slide 14 text

Streaming Push Client makes a call of HTTP POST method, and uses its request body and response body as streams, respectively. Server Client HTTP/2 stack HTTP POST method Request body → ← Response body

Slide 15

Slide 15 text

Implementation of Streaming Push - The mechanism of Streaming Push is a proven one that is also used in gRPC. - It fully follows the semantics of HTTP/2. - In LINE Android app, Streaming Push is implemented on top of the bare, un-customized OkHttp library.

Slide 16

Slide 16 text

Prepare for rollout - SPDY and HTTP/2 protocol stack can be switched by a feature flag. - SPDY Push and Streaming Push are also switched by this flag. - We added a mechanism that allows this flag to be changed for each user by server-side settings.

Slide 17

Slide 17 text

Test and Rollout We spent more than a month conducting in-house tests of HTTP/2 protocol, gradually increasing the number of test targets. Finally, we rolled out the HTTP/2 protocol to all users and completed it successfully without any trouble. LINE client developers All LINE employees 5% of users 100% of users

Slide 18

Slide 18 text

What we achieved with this project - LINE Android app has completely migrated from SPDY to HTTP/2. - A new push mechanism that complies with HTTP/2 semantics has been introduced. - Successfully completed the rollout without any trouble. - Client-side code is now in a modern architecture using OkHttp and Kotlin Coroutines.

Slide 19

Slide 19 text

QUIC and HTTP/3… - The semantics of HTTP/3 have not changed from HTTP/2. - Streaming Push mechanism should also work on HTTP/3. - Currently, OkHttp does not support QUIC and HTTP/3. However, when OkHttp supports them, LINE Android app should only need to upgrade the version of the OkHttp library.

Slide 20

Slide 20 text

OSS library created for this project - We released an OSS library created for this project. - Lich OkHttp & Lich Thrift : https://github.com/line/lich - Coroutine-aware extensions for OkHttp & Apache Thrift - e.g. Perform a resumable download using Range requests.

Slide 21

Slide 21 text

Thank you