当前位置:网站首页>Analysis on the optimization of login request in IM development of instant messaging mobile terminal
Analysis on the optimization of login request in IM development of instant messaging mobile terminal
2022-07-27 20:41:00 【wecloud1314】
What is the “ land ” still “ Sign in ”? This is a problem that many virgin developers struggle with , However, it is not the content of this text . This article will focus on the mobile terminal IM The login function of gives corresponding optimization suggestions .

Origin
In mobile IM Module , The core and most complex module is the login module . A login module that has not been well optimized often takes a long time and wastes traffic : A single login can take tens of seconds , For a few minutes , Synchronize hundreds of at the same time KB Even a few M The data of .
A simple login step can be divided into the following steps :
1) request lbs;
2) Connect link;
3) Send and receive login requests ;
4) Sync IM data .
And every step here has the possibility of optimization .( In fact, many of the following ideas are universal , It's not just IM APP To use ).
Optimize load balancing LBS request
stay PC Time , We will often ask lbs Make a series connection with the connection server , After all, we have to finish the request first lbs To get the real link Server address , So as to carry out the connection operation . In specific operation , commonly lbs A request is a request HTTP request , The time it takes here can be imagined . So a simple optimization idea is to remove this link from the login process .
However, direct rough removal lbs Requests are not desirable , If we directly built in the domain name or ip, The biggest problem is the inability to do load balancing . Therefore, it is more recommended to lbs Request asynchronization : Don't do it when you log in lbs request , When the network is idle and changes, it makes requests and caches , Each time you log in, you get it directly from the local cache link Address .

DNS Optimize
Use TCP It is inevitable to encounter DNS The problem of resolution , After all, we can't always use IP As the server address . stay PC Time ,DNS Parsing is almost painless . But in the wireless age ,DNS Related problems are becoming more and more serious . One side , Under mobile network ,DNS The parsing speed is incomparable , once DNS The parsing time can even catch up once TCP Connection time , Seconds , Ten seconds , Even three , Forty second request times are common . On the other hand , Due to the operator's inaction and act , Under the mobile network DNS It also shows that the resolution accuracy is low and it is often hijacked .
In these cases, consider using HTTP DNS,github There are also many open source implementations , such as HttpDNSLib. The most radical method is to optimize as before lbs equally , Avoid in each link DNS analysis .
1)lbs Back to the server ip Not a domain name
2) Local cache lbs ip Address standby , request lbs Priority is given to the use of ip Not a domain name
This way can not only avoid DNS The time taken to request , It can also be avoided to some extent DNS The question of being hijacked . The drawback is that in this case, a series of other problems need to be considered on the client side : How to go from ip list Select a valid address , Determine when to re request , Load balancing , Saving traffic, etc .
Login authentication request optimization
in fact , There is not much room for optimization in the login authentication request process . Once you connect to the server , The next thing to do is to encrypt the current connection and send and receive login feedback . These two steps are indispensable . Instant messaging chat software app Development can add Weike cloud consulting
And how to optimize is often related to the specific business : Suppose we use something like HTTPS General three-step negotiation encryption process , Security can indeed be guaranteed , But there are too many times , The whole login time will increase . The trick is naturally to combine encryption and login requests , This often involves the modification of login requests .
Data synchronization strategy optimization
After login , The client needs to synchronize from the server , A regular IM APP The following data needs to be synchronized :
1) The friends list ;
2) Friends' personal information ;
3) Group list ;
4) List of group members ;
5) Group member personal information ;
6) offline message .
Suppose a user has 1000 A good friend , 20 individual 50 The crowd , On average, each item is about 200 Bytes , Then a full synchronization will take about 0.2 * (1000 + 1000 + 20 + 1000 * 2) = 800 KB The data of , This is for a mobile IM It's unacceptable , What's more, this is the data volume of a relatively mild user .
Obviously full synchronization is not acceptable , The improved method is to synchronize by timestamp . The client will always only update data that is newer than the locally cached data . This is a general optimization direction .
There are also some optimizations that can be implemented according to business needs : Deferred and on-demand updates . Take the personal information of group members as an example , In fact, users don't care about real-time , After all, these group members are not necessarily friends of users , Their information changes can be completely updated when users view it ( Wechat strategy ). The same is true of friends' personal information , For most interfaces , They only care about users Id, Avatar and nickname are three basic information , And some icing on the cake Profile The information can be updated by time stamp when the user views the corresponding interface .
边栏推荐
- 【阿里安全 × ICDM 2022】20万奖金池!大规模电商图上的风险商品检测赛火热报名中!...
- ES6 -- Application of expansion operator
- Redis-基本了解,五大基本数据类型
- C语言--数组
- What is a multi-layer perceptron (what is a multi-layer perceptron)
- PyQt5快速开发与实战 4.3 QLabel and 4.4 文本框类控件
- 京东:按关键字搜索商品 API
- Following Huawei and MediaTek, the mobile phone chip manufacturer announced a donation of 7million yuan to Wuhan
- Can software testing be learned in 2022? Don't learn, software testing positions are saturated
- OA项目之我的审批(查询&会议签字)
猜你喜欢

access control

Pyqt5 rapid development and practice 4.3 qlabel and 4.4 text box controls
![Leetcode:1498. Number of subsequences that meet the conditions [sort + bisection + power hash table]](/img/a9/de68e8affcb6b84e82cf344e7254e3.png)
Leetcode:1498. Number of subsequences that meet the conditions [sort + bisection + power hash table]

Preprocessing and macro definition

How to optimize the open source community experience through developer metrics

2022.07.11

Redis thing learning

C language -- array

JS realizes video recording - Take cesium as an example

【数据集显示标注】VOC文件结构+数据集标注可视化+代码实现
随机推荐
[map set]
Pytorch multiplication and broadcasting mechanism
康佳半导体首款存储主控芯片量产出货,首批10万颗
[RCTF2015]EasySQL-1|SQL注入
图解LeetCode——592. 分数加减运算(难度:中等)
MySQL log error log
C language POW function (how to play exponential function in C language)
Set -- data deconstruction
京东:按关键字搜索商品 API
Clickhouse implements materializedpostgresql
DP (dynamic programming)
Slf4j introduction
Oracle Xe installation and user operation
Koin simple to use
Oracle +JDBC
Oracle simple advanced query
【分层强化学习】HAC论文及代码
用户和权限创建普通用户
Interviewer: what is the abstract factory model?
C language -- array