This article by Baidu technical team “CAI Rui” original published in the “Baidu App technology” public number, the original title of “Baidu App network depth optimization series” DNS optimization “, thanks to the original author of selfless sharing.


One, foreword









The articles in this series are listed below:





  • Baidu APP Mobile Terminal Network In-depth Optimization Practice Sharing (I) : DNS Optimization (* article)
  • Baidu APP Mobile Terminal Network In-depth Optimization Practice Sharing (II) : Network Connection Optimization chapter
  • Baidu APP Mobile Terminal Network In-depth Optimization Practice Sharing (III) : Mobile Terminal Weak Network Optimization Chapter

















Ii. Related articles



TCP/IP Volume 1: protocol
Chapter 14 DNS: Domain name System



Comprehensive understanding of mobile DNS domain name hijacking and other miscellaneous problems: technical principles, root causes, solutions, etc



Mobile DNS optimization practice of Meitu App: THE HTTPS request time is reduced by nearly half



Summary of optimization means of modern mobile terminal network short connection: request speed, weak network adaptation, security guarantee



Mobile IM Developers must read (1) : Easy to understand the “weak” and “slow” mobile web



Mobile IM Developers must read (ii) : Summary of the most comprehensive mobile weak Network optimization methods ever


3. Technical background



The DNS optimization core needs to solve two problems:





  • 1) Service unavailability due to DNS hijacking or failure, thus affecting user experience and the company’s revenue;
  • 2) Performance degradation caused by inaccurate DNS scheduling, thus affecting user experience.



















Comprehensive understanding of mobile DNS domain name hijacking and other miscellaneous problems: technical principles, root causes, solutions, etc


Four, HTTPDNS


4.1 an overview of the































































Comprehensive understanding of mobile DNS domain name hijacking and other miscellaneous problems: technical principles, root causes, solutions, etc
Mobile DNS optimization practice of Meitu App: THE HTTPS request time is reduced by nearly half





4.2 DNS interface layer








4.3 the DNS strategy layer









[4.3.1 Dr Policy] :












(1)






(2)


















[4.3.2 Security Policy] :






(1)






(2)






[4.3.3 Task Scheduling Policy] :












(1)






(2)






[4.3.4 IP Selection Policy] :












[4.3.5 Cache Policy] :


















[4.3.6 Hit ratio strategy] :












(1)






(2)





4.4 Basic ability layer









[4.4.1 IPv4/IPv6 stack Detection] :











As we all know, TCP is connection-oriented. Before transmitting data, the client calls the connect method to establish a connection through a three-way handshake. UDP is connection-oriented and can send and receive data without establishing a connection. When we call UDP Connect method, the system will detect whether the port is available and the address is correct, and then record the IP address and port number of the peer end, and return it to the caller. Therefore, UDP Connect will not initiate three-way handshake like TCP Connect, resulting in real network loss. The UDP client can initiate real network loss only after calling send or sendto.



























The name happy EyeBall is derived from the fact that IPv4 or IPv6 glitches do not cause eyeballs to wait for loading or fail. The happy eyeball comes in RFC6555 v1 and RFC8305 v2, the former by Cisco and the latter by apple. The core problem of Happy EyeBall is the selection of V4 and V6 IP in complex environment. It is a set of overall solution, which provides provisions on the processing of domain name query, address sorting, connection attempts, etc. Interested students can refer to [5] and [6] in Resources.



[4.4.2 Data Transmission] :












(1)






(2)






[4.4.3 Cache implementation] :














Best practices for HTTPDNS









HTTPDNS in Android network architecture location and practice:






















Location and practice of HTTPDNS in iOS network architecture:






























6. Actual income



There are two main benefits of DNS optimization:





  • 1) Prevent DNS hijacking (especially important when things go wrong);
  • 2) Reduce network delay (in the case of inaccurate scheduling, network delay will be increased and user experience will be reduced).



These two benefits need to be combined with the business, taking Baidu App Feed business as an example:





  • 1) On the first point, we achieved a relatively large effect, iOS hijacking rate decreased from 0.12% to 0.0002%, Android hijacking rate decreased from 0.25% to 0.05%;
  • 2) The income of the second point is not obvious, because the main target group of Feed business is in China. Baidu’s node layout in China is relatively rich, and the overall quality of service is high. Even if the scheduling is inaccurate, the difference will not be too large, but the situation may be much worse in foreign countries.


Vii. Conclusion of this paper





Eight, personal experience









1) Basic knowledge should be learned and consolidated:






2) Learn to make invisible networks visible:






3)






4) Network optimization needs data support:






5)


Ix. Reference materials


  • [1] chromium.googlesource.com/chromium/sr…
  • [2] chromium.googlesource.com/chromium/sr…
  • [3] github.com/Tencent/mar…
  • [4] tools.ietf.org/html/rfc785…
  • [5] tools.ietf.org/html/rfc655…
  • [6] tools.ietf.org/html/rfc830…



Click here to enter


Appendix: more excellent articles on network communication



TCP/IP, rounding
Chapter 11 ·UDP: User datagram protocol



TCP/IP, rounding
Chapter 17: TCP: Transmission control Protocol



TCP/IP, rounding
Chapter 18: Establishment and termination of TCP connections



TCP/IP, rounding
Chapter 21. TCP Timeouts and retransmission



Once upon a time in technology: TCP/IP changed the world



Easy to Understand – In-depth understanding of TCP (part 1) : Theoretical basis



Easy to Understand – In-depth understanding of TCP (part 2) : RTT, sliding window, and congestion handling



Theory classic: TCP protocol three handshake and four wave process in detail



Connection between theory and practice: Wireshark captures packets to analyze TCP three-way handshake and four-way wave



Protocol Diagram of Computer Network Communication (Chinese Edition)



What is the maximum size of a packet in UDP?



P2P technology details (a) : NAT details – detailed principle, P2P introduction



(2) : P2P NAT traversal (hole) solution



P2P technology details (three) : P2P technology STUN, TURN, ICE details



Easy to Understand: Quickly understand the PRINCIPLE of NAT penetration in P2P technology



High performance network programming (a) : the number of concurrent TCP connections can be a single server



High performance Network programming (II) : The last 10 years, the famous C10K concurrent connection problem



High performance Network Programming (III) : In the next 10 years, it is time to consider C10M concurrency



High performance Network programming (IV) : Theoretical exploration of high performance network applications from C10K to C10M



High performance network programming (5) : read the I/O model of high performance network programming



High performance network programming (6) : understand the threading model of high performance network programming



Unknown Network Programming (I) : A Brief Analysis of the DIFFICULT Problems in TCP Protocol (Part I)



Unknown Network Programming (II) : A Brief Analysis of the DIFFICULT Problems in TCP Protocol (Part II)



Why TIME_WAIT and CLOSE_WAIT when closing TCP connections



Unknown network programming (iv) : In-depth analysis of TCP abnormal shutdown



Network programming unknown (5) : UDP connectivity and load balancing



Unknown network programming (6) : Understand UDP in depth and use it well



Unknown network programming (7) : How to make unreliable UDP reliable?



Hidden Network programming (8) : Deep decryption of HTTP from the data transport layer



Quick Understanding of Network Communication Protocols (Part 1)



A Quick Understanding of Network Protocols (Part 2)



Network programming lazy introduction (three) : a quick understanding of the TCP protocol is enough



Network programming lazy starter (4) : Quickly understand the difference between TCP and UDP



Why UDP sometimes has an advantage over TCP



Network programming lazy entry (six) : the history of the most popular hub, switch, router function principle entry



Network programming lazy introduction (7) : simple, comprehensive understanding of HTTP protocol



Network programming lazy entry (eight) : teach you to write based on TCP Socket long connection



Network programming lazy introduction (nine) : popular explanation, IP address, why use MAC address?



Technology Literacy: A new generation of UDP-based low latency Network Transport layer protocol – QUIC in detail



Making the Internet faster: A new generation of QUIC protocols shared in Tencent’s technology practices



Summary of optimization means of modern mobile terminal network short connection: request speed, weak network adaptation, security guarantee



Let’s talk about long connections in iOS network programming



Mobile IM Developers must read (1) : Easy to understand the “weak” and “slow” mobile web



Mobile IM Developers must read (ii) : Summary of the most comprehensive mobile weak Network optimization methods ever



IPv6 Technology details: Basic Concepts, Application Status, Technical Practice (Part I)



IPv6 Technology details: Basic Concepts, Application status, Technical Practice (Part 2)



From HTTP/0.9 to HTTP/2: Understand the history and design of the HTTP protocol



Brain-disabled network programming introduction (a) : follow the animation to learn TCP three handshakes and four waves



What are we reading and writing when we read and write sockets?



Brain-disabled network programming introduction (3) : HTTP protocol must know must know some knowledge



Quick Understanding of HTTP/2 Server Push



Introduction to brain-damaged Network programming (5) : Ping command used every day, what is it?



Introduction to Network Programming (6) : What are public IP and internal IP? What the hell is NAT?



Take the network access layer design of online game server as an example to understand the technical challenges of real-time communication



To the next level: The network basics that a good Android programmer must know



Comprehensive understanding of mobile DNS domain name hijacking and other miscellaneous problems: technical principles, root causes, solutions, etc



Mobile DNS optimization practice of Meitu App: THE HTTPS request time is reduced by nearly half



Android programmers must know the network communication transport layer protocols – UDP and TCP



Introduction to Zero-Base Communication Technology for IM Developers (PART I) : 100 Years of Development of Communication Switching Technology (Part I)



Introduction to Zero-Base Communication Technology for IM Developers (II) : 100 Years of Development of Communication Switching Technology (II)



Introduction to Zero-base Communication Technology for IM Developers (III) : The Century-old changes of Chinese communication mode



Introduction to Zero-Base Communication technology for IM Developers (iv) : The evolution of mobile phones, the most comprehensive history of mobile terminals in history



Introduction to Zero-base Communication Technology for IM Developers (5) : 1G to 5G, 30 years of mobile communication technology evolution



Introduction to Zero-base Communication technology for IM developers (6) : Mobile terminal connector – “base station” technology



Introduction to Zero-Base Communication Technology for IM Developers (7) : The Swift Horse of Mobile Terminal — “Electromagnetic Wave”



Introduction to Zero-based Communication technology for IM Developers (eight) : Zero-based, the strongest “antenna” principle in history literacy



Introduction to Zero-Base Communication Technology for IM Developers (9) : “Core Network” — the Backbone of Wireless Communication Network



Introduction to Zero-Base Communication Technology for IM Developers (10) : Zero-base, the strongest 5G technology literacy in history



Why is WiFi signal bad? A text is understood!



Introduction to Basic Communication technology for IM Developers (12) : Networking? Network down? A text is understood!



Introduction to Zero-Base Communication Technology for IM Developers (13) : Why cell phone Reception is Poor? A text is understood!



How Hard is wireless On high-speed Trains? A text is understood!



Introduction to Zero-base Communication technology for IM Developers (15) : Understanding location technology, one article is enough



Baidu APP mobile terminal network in-depth optimization practice sharing (I) : DNS optimization chapter



Baidu APP mobile terminal network in-depth optimization practice sharing (II) : Network connection optimization



More of the same…