Mobile Development 15 min read

Connection Optimization Techniques in Baidu App: TLS and TCP Enhancements

The Baidu App reduces connection latency by cutting TLS and TCP round‑trips through session resumption, False Start, pre‑connect, backup and composite connections, and automatic rebuilds, achieving 12‑16 % faster text and image loads and modest success‑rate gains across Android and iOS.

Baidu App Technology
Baidu App Technology
Baidu App Technology
Connection Optimization Techniques in Baidu App: TLS and TCP Enhancements

In the Baidu App network optimization series, after covering DNS optimization, the focus shifts to HTTP connection optimization, which is crucial for reducing latency and improving success rates.

The main challenges are long connection establishment times and potential failures in variable network conditions, which affect user experience.

The connection establishment involves DNS query (1 RTT), TCP three‑way handshake (effectively 1 RTT), and TLS handshake (2 RTT), totaling about 4 RTTs before application data can be sent. Reducing TLS and TCP RTTs can significantly cut connection latency.

TLS Connection Optimization

Two primary methods are used:

Session Resumption

Session Resumption reuses previous TLS session information, either via Session Identifier or Session Ticket, saving roughly 1 RTT. Both methods are supported in Baidu App.

False Start

False Start allows the client to send application data immediately after the first TLS handshake messages, saving another RTT. It requires ALPN negotiation and forward‑secure ciphers, both of which Baidu App supports.

TCP Connection Optimization

Various connection pool types are employed, including low‑level TCP pools, WebSocket pools, and high‑level pools for HTTP proxies, SPDY/HTTP‑2, SOCKS, and SSL.

Key TCP optimization techniques include:

Pre‑connect

Pre‑establishes connections for critical domains, reducing perceived latency. Configurations are expressed as "domain|connectionCount" (e.g., https://a.baidu.com|2). Pre‑connects are created after a short delay during library initialization and refreshed periodically.

Connection Rebuild

When network conditions change (e.g., IP change), idle sockets are cleared and connections are rebuilt after a brief wait, with limits to avoid performance impact.

Backup Connection

If no idle connection is available, a backup connection is started after a 250 ms timer, competing with the primary connection to improve success rates.

Composite Connection

Multiple IP addresses are tried in parallel or sequentially, preferring IPv6 when available, to select the fastest path. This feature is currently disabled on iOS.

Best Practices and Architecture

On Android, Baidu App builds on OkHttp and HttpURLConnection, injecting Cronet via URL Stream Protocol to handle all optimizations. On iOS, Cronet is injected into URLSession using the URL Loading System.

The Cronet layer implements pre‑connect, connection rebuild, backup connection, composite connection (iOS disabled), Session Resumption, and False Start.

Benefits

In the Feed refresh scenario, these optimizations reduce text request latency by 16 % and image request latency by 12 %. Success rates improve by 0.29 % for text and 0.23 % for images.

Conclusion

Connection optimization is an ongoing effort; Baidu App will continue to refine these techniques and publish further series on weak‑network optimization.

References

1. https://chromium.googlesource.com/chromium/src/+/HEAD/docs/android_build_instructions.md

2. https://chromium.googlesource.com/chromium/src/+/HEAD/docs/ios/build_instructions.md

3. https://tools.ietf.org/html/rfc7918 (False Start)

4. https://tools.ietf.org/html/rfc5077 (Session Resumption)

5. https://tools.ietf.org/html/rfc7413 (TCP Fast Open)

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

iOSAndroidTCPTLSnetwork performanceConnection Optimization
Baidu App Technology
Written by

Baidu App Technology

Official Baidu App Tech Account

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.