当前位置:网站首页>How to select the data transmission format of instant messaging application
How to select the data transmission format of instant messaging application
2022-06-26 05:05:00 【JackJiang-】
Preface
Instant messaging applications ( Include IM Chat app 、 Real time message push application, etc ) In the early stage of development, when selecting technology , About the choice of data transmission format , In the eyes of instant messaging developers , It is a very controversial topic .
Analyze carefully , The probable reason is :
- There are a variety of protocols or encapsulation formats to choose from :
There is a wide range of options :XMPP、Protobuf、JSON、 private 2 Base number 、MQTT、 Freeze frame XML、Plain text wait ; - The same format is not applicable to most scenarios :
Different scenarios have the same consideration, and the choice of agreement goes to It is linked with this , such as : Mobile IM Or push technology XMPP Such an agreement , In most cases, it will be sprayed ; - Developers have their own preferences for the selected format :
Some people or teams have different experience and technical accumulation in one or several formats , It also contributes to their preference for one or more agreements .
In fact, to sum up the above reasons, we can know , The reason why there are different sounds for the data transmission format of instant messaging applications , The root cause lies in the concrete analysis of specific things , What protocol to choose depends on the scenario 、 Determined by the technical accumulation of the team 、 Even determined by the project cycle and cost , There is no unique solution here , Only the most suitable data transmission format , There is no such thing as the best format .
Of course , The selection of instant messaging transmission format in this article , It is the words of the original author , There may be a lot of controversy , But if you can bring some inspiration for the technology selection of your instant messaging application development , I believe this is what the author intended .( This article is published synchronously in :http://www.52im.net/thread-276-1-1.html)
Exchange of learning
- Instant messaging development communication group : 215891622 [ recommend ]
More information
Mobile IM Development , Recommended reading :《 Beginner level one is enough : Develop mobile from scratch IM》.
The selection of data format needs to consider
[1] Network data size : bandwidth , transmission efficiency
Although for a single user , The data transmission is very small , However, the server side has to bear many high concurrent data transmission ( In particular, the current high concurrency 、 Large number of users IM Chat application and real-time push server ), It must be taken into account that data takes up bandwidth , Try not to have redundant data , In this way, the bandwidth can be reduced , Use less resources , Less network IO, Improve transmission efficiency .
[2] Network data security : Network security of sensitive data
Some data transmission of related services are sensitive data , Therefore, we must consider encrypting part of the transmitted data . This usually occurs in application industries and scenarios with high data security requirements, such as banks , Of course, traditional instant messaging applications are based on user privacy considerations , Data encryption is also a problem that must be considered . Security is the basic condition of application , The requirements are the same , Just the encryption level 、 The security level requirements are different .
[3] Coding complexity
Encoding complexity includes serialization and deserialization complexity 、 efficiency 、 Scalability and maintainability of data structure .
For the code implementation of platform related services, the complexity of data processing and the scalability of data structure of the data sender and data receiver should also be considered , Maintainability , Labor costs and implementation complexity must also be taken into account . Usually , Instant messaging applications ( such as IM Chat app ) In the early stage of development , For the convenience of debugging , Many teams use simple text protocols 、JSON And so on , But after the post production deployment , For the sake of flow, etc , May switch to Protobuf And other agreements that save more traffic . But all in all , The definition of an agreement cannot remain unchanged forever , But if you have these foresight when you implement it , Consistency will greatly reduce future operational risks .
[4] The generality of the agreement 、 Public norms
The data type must be cross platform , The data format is universal , It is generally acceptable for people to get started . Of course , Now we have entered the era of mobile Internet , Multi terminal 、 Multi platform 、 Data communication on heterogeneous platforms is a prerequisite , And the choice of agreement , The commonality is only different from the application layer at most . Of course , in any case , Consistency of heterogeneous platforms , Is an indisputable prerequisite .
Different kinds of data transmission protocols ( Format ) Comparison
[1] Custom binary
advantage : Small volume of information , Corresponding to the above ”1“
shortcoming : High coding complexity ( Define the message format by yourself , Write your own serialization and deserialization methods , Handle fault tolerance by yourself , Poor scalability , For example, add a field , We must change the logical processing at both ends ), Corresponding to the above ”3“;
[2] An open source protocol that provides serialization and deserialization libraries
such as Google's protocol buffers, json, Thrift
advantage : Is a popular universal data format , Expansion is quite convenient , Serialization and deserialization are quite convenient ( There are corresponding libraries ), Error handling is convenient ( Library support ).
[3] Textual agreement
such as xml,json
advantage : serialize , Deserialization is easy ( Library support ), Debug is convenient , Strong visualization ;
shortcoming : Compared with binary storage, it occupies a large volume .
Which format would you choose ?
I will choose JSON(PS: In this paper, the “ I ” Refers to the original author ), Because he is “ The open source protocol that provides serialization and deserialization libraries is also a textual protocol ”, Here's why :
- The complexity of custom binary formats :
Customize the binary format for transmission , The whole process is defining the message ,write,read The process is too complicated , It's easy to make mistakes , For many data interaction programs , Will spend a lot of time on it ; - Extensibility of custom binary format :
Not easy to expand , but json It can solve this problem well ; - json Comparing the amount of binary data is not a problem :
json It takes up a little more space , But we can solve this problem through network data compression , Besides, json It is also lightweight , Transmission efficiency is also very high ; - Go and see 《unix Programming art 》 Well :
《 The first 5 Chapter -- Textualization , Good agreement leads to good practice 》、《 The first 6 Chapter -- transparency : A little light 》 Will tell you the benefits of using textual protocols .
Conclusion
After reading the text , The original author chooses JSON As a data transmission format for instant messaging applications ( agreement ), How to choose , I believe you have already found the answer .( I recommend reading another article 《 Mobile IM The technical problems that development needs to face 》)
Classification of relevant technical data
[1] Basic information of network programming :
《TCP/IP Detailed explanation - The first 11 Chapter ·UDP: User datagram protocol 》
《TCP/IP Detailed explanation - The first 17 Chapter ·TCP: Transmission control protocol 》
《TCP/IP Detailed explanation - The first 18 Chapter ·TCP Connection establishment and termination 》
《TCP/IP Detailed explanation - The first 21 Chapter ·TCP Over time and retransmission 》
《 Theoretical Classics :TCP Agreed 3 Shake hands with 4 Detailed explanation of the wave process 》
《 Combining theory with practice :Wireshark Caught analysis TCP 3 The second handshake 、4 The wave process 》
《 Computer network communication protocol diagram ( Chinese Collection Edition )》
《NAT Detailed explanation : The basic principle 、 Crossing technology (P2P Hole digging )、 Port aging, etc 》
《UDP What is the maximum size of a package in ?》
《Java New generation network programming model AIO Principle and Linux System AIO Introduce 》
《NIO Introduction to framework ( 3、 ... and ):iOS And MINA2、Netty4 cross-platform UDP Two way communication practice 》
《NIO Introduction to framework ( Four ):Android And MINA2、Netty4 cross-platform UDP Two way communication practice 》
>> More articles of the same kind ……
[2] of IM/ Push communication format 、 The choice of agreement :
《 Why? QQ It's using UDP Agreement, not TCP agreement ?》
《 Mobile instant messaging protocol selection :UDP still TCP?》
《 How to choose the data transmission format of instant messaging application 》
《 The strong proposal will Protobuf As your IM application data transfer format 》
《 Mobile IM The technical problems that development needs to face ( Including communication protocol options )》
《 Brief introduction of mobile terminal IM The pits developed : Architecture design 、 Communication protocol and client 》
《 Combining theory with practice : A typical set of IM Communication protocol design details 》
《58 Home real-time message system protocol design and other technical practice sharing 》
>> More articles of the same kind ……
[3] of IM/ Push the heartbeat to keep alive :
《Android Detailed explanation of process assurance : One article solves all your questions 》
《Android End message push summary : Realization principle 、 The heartbeat keeps alive 、 Problems encountered, etc 》
《 Why based on TCP The mobile end of the protocol IM We still need a heartbeat mechanism ?》
《 Wechat team original sharing :Android Version of wechat backstage to keep the real battle sharing ( Keep the process alive )》
《 Wechat team original sharing :Android Version of wechat backstage to keep the real battle sharing ( Network security chapter )》
《 Mobile IM practice : Realization Android Version of wechat's intelligent heartbeat mechanism 》
《 Mobile IM practice :WhatsApp、Line、 Heartbeat strategy analysis of wechat 》
>> More articles of the same kind ……
[4] of WEB End instant messaging development :
《 Novice entry post : In the history of the most complete Web Detailed explanation of the principle of end instant messaging technology 》
《Web End instant messaging technology inventory : Short polling 、Comet、Websocket、SSE》
《SSE Technical details : A brand new HTML5 Server push event technology 》
《Comet Technical details : be based on HTTP Long connection Web End real-time communication technology 》
《WebSocket Detailed explanation ( One ): A preliminary understanding WebSocket technology 》
《socket.io A little practice and thinking of message push 》
>> More articles of the same kind ……
[5] of IM Architecture design :
《 Talking about IM Architecture design of the system 》
《 Brief introduction of mobile terminal IM The pits developed : Architecture design 、 Communication protocol and client 》
《 A set of original distributed instant messaging (IM) System theoretical framework scheme 》
《 From zero to excellence : The evolution process of the technical framework of JD customer service instant messaging system 》
《 Mushroom Street im /IM Architecture selection of server development 》
《 tencent QQ1.4 Technology challenges and architecture evolution of 100 million online users PPT》
《 Wechat technical director talks about architecture : The way of WeChat —— The greatest truths are the simplest ( Speech full text )》
《 How to interpret 《 Wechat technical director talks about architecture : The way of WeChat —— The greatest truths are the simplest 》》
《 Fast fission : Witness the powerful background architecture of wechat 0 To 1 The evolution of ( One )》
《17 Year's practice : Technical methodology of Tencent's massive products 》
>> More articles of the same kind ……
[6] of IM Safe articles :
《 Instant messaging security ( One ): Understand and use... Correctly Android End encryption algorithm 》
《 Instant messaging security ( Two ): The combination encryption algorithm is discussed in IM Application in 》
《 Instant messaging security ( 3、 ... and ): Commonly used encryption and decryption algorithm and communication security 》
《 Instant messaging security ( Four ): The example analysis Android The risk of hard key coding in 》
《 Transport layer security protocol SSL/TLS Of Java Platform implementation and Demo demonstration 》
《 Combining theory with practice : A typical set of IM Communication protocol design details ( Including security layer design )》
《 Wechat new generation communication security solution : be based on TLS1.3 Of MMTLS Detailed explanation 》
《 From Ali OpenIM: Create a safe and reliable instant messaging service technology practice sharing 》
>> More articles of the same kind ……
[7] About real-time audio and video development :
《 Audio and video development of instant messaging ( One ): The theory of video codec 》
《 Audio and video development of instant messaging ( Two ): Digital video introduction of video coding and decoding 》
《 Audio and video development of instant messaging ( 3、 ... and ): Coding basis of video coding and decoding 》
《 Audio and video development of instant messaging ( Four ): Prediction technology of video codec 》
《 Audio and video development of instant messaging ( 5、 ... and ): Understanding the mainstream video coding technology H.264》
《 Audio and video development of instant messaging ( 6、 ... and ): How to start learning audio codec technology 》
《 Audio and video development of instant messaging ( 7、 ... and ): Introduction to audio fundamentals and coding principles 》
《 Audio and video development of instant messaging ( 8、 ... and ): Common real-time voice communication coding standards 》
《 Audio and video development of instant messaging ( Nine ): Echo and echo cancellation of real-time voice communication summary 》
《 Audio and video development of instant messaging ( Ten ): Echo cancellation in real-time voice communication Technical details 》
《 Audio and video development of instant messaging ( 11、 ... and ): Detailed explanation of packet loss compensation technology in real-time voice communication 》
《 Audio and video development of instant messaging ( Twelve ): Discussion on the framework of real-time audio and video chat for multiple people 》
《 Audio and video development of instant messaging ( 13、 ... and ): Real time video coding H.264 Characteristics and advantages of 》
《 Audio and video development of instant messaging ( fourteen ): Real time audio and video data transmission protocol 》
《 Audio and video development of instant messaging ( 15、 ... and ): Chat P2P And real-time audio and video applications 》
《 Audio and video development of instant messaging ( sixteen ): Some suggestions on the development of real-time audio and video in mobile terminal 》
《 Audio and video development of instant messaging ( seventeen ): Video coding H.264、V8 The past and this life 》
《 Open source real-time audio and video technology WebRTC Advantages and disadvantages 》
《 Conscience sharing :WebRTC Zero basic developer tutorial ( chinese )》
>> More articles of the same kind ……
[8] IM Develop comprehensive articles :
《 Mobile IM The technical problems that development needs to face 》
《 Development IM Is it better to use byte stream or character stream to design your own protocol ?》
《 Do you know the mainstream way of voice message chat ?》
《IM How to ensure the reliable delivery of messages in the system ( namely QoS Mechanism )》
《 Talk about mobile IM Optimization of login request in development 》
《 It's completely self-developed IM How to design “ Failure to retry ” Mechanism ?》
《 Technical test and analysis of the influence of wechat on the network ( Paper full text )》
《 The principle of instant messaging system 、 Technology and Application ( Technical papers )》
《 Open source IM engineering “ Mushroom street TeamTalk” The status quo of : An open source show with no end 》
>> More articles of the same kind ……
[9] Open source mobile IM Technical framework information :
《 Open source mobile IM Technical framework MobileIMSDK: Quick start 》
《 Open source mobile IM Technical framework MobileIMSDK: frequently asked questions 》
《 Open source mobile IM Technical framework MobileIMSDK: Stress test report 》
>> More articles of the same kind ……
[10] Articles on Push Technology :
《iOS The push service of APNs Detailed explanation : Design thinking 、 Technical principles and defects, etc 》
《Android End message push summary : Realization principle 、 The heartbeat keeps alive 、 Problems encountered, etc 》
《 Literacy stickers : know MQTT Communication protocol 》
《 One is based on MQTT Integrity of communication protocol Android push Demo》
《 Ask for advice android Message push :GCM、XMPP、MQTT The advantages and disadvantages of the three schemes 》
《 Mobile real-time message push technology analysis 》
《 Literacy stickers : Talking about iOS and Android The principle and difference of background real-time message push 》
《 Absolutely dry : be based on Netty Push service technology points to achieve massive access 》
《 Mobile IM practice : Google News push service (GCM) Research ( From wechat )》
《 Why wechat 、QQ In this way IM Tools not used GCM Service push message ?》
>> More articles of the same kind ……
[11] More instant messaging technology good article classification :
http://www.52im.net/forum.php?mod=collection&op=all
( This article is published synchronously in :http://www.52im.net/thread-276-1-1.html)
author :Jack Jiang ( Click the author name to enter Github)
Source :http://www.52im.net/space-uid-1.html
communication : Welcome to the instant messaging development exchange group 215891622
Discuss :http://www.52im.net/
Jack Jiang At the same time 【 original Java Swing Appearance engineering BeautyEye】 and 【 Lightweight mobile instant messaging framework MobileIMSDK】 The author of , You can go to download and exchange .
边栏推荐
- 2022.1.23
- [geek] product manager training camp
- DBeaver 安装及配置离线驱动
- 0622 horse palm fell 9%
- 【Unity3D】碰撞体组件Collider
- Codeforces Round #802 (Div. 2)(A-D)
- Codeforces Round #800 (Div. 2)
- Statsmodels Library -- linear regression model
- The first gift of the project, the flying oar contract!
- PSIM software learning ---08 call of C program block
猜你喜欢
UWB ultra high precision positioning system architecture
Why do many Shopify independent station sellers use chat robots? Read industry secrets in one minute!
超高精度定位系统中的UWB是什么
PowerShell runtime system IO exceptions
ModuleNotFoundError: No module named ‘numpy‘
Créateur de génie: cavalier solitaire, magnat de la technologie et ai | dix ans d'apprentissage profond
YOLOV5超参数设置与数据增强解析
文件上传与安全狗
2022.1.24
天才制造者:獨行俠、科技巨頭和AI|深度學習崛起十年
随机推荐
Final review of brain and cognitive science
Yolov5 super parameter setting and data enhancement analysis
Happy New Year!
Datetime data type ---now() gets the current time, datetime() creation date, performs mathematical operations, and to_ Datetime() converts to date type and extracts various parts of date
FastAdmin Apache下设置伪静态
Keras actual combat cifar10 in tensorflow
Second day of deep learning and tensorfow
Lstms in tensorflow_ Cell actual combat
A company crawling out of its grave
RESNET practice in tensorflow
ThreadPoolExecutor implements file uploading and batch inserting data
Genius makers: lone Rangers, technology giants and AI | ten years of the rise of in-depth learning
pycharm 导包错误没有警告
Mise en œuvre du routage dynamique par zuul
Rsync common error messages (common errors on the window)
Sklearn Library -- linear regression model
Zuul implements dynamic routing
Créateur de génie: cavalier solitaire, magnat de la technologie et ai | dix ans d'apprentissage profond
Is education important or ability important in software testing
Computer Vision Tools Chain