当前位置:网站首页>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万奖金池!大规模电商图上的风险商品检测赛火热报名中!...
- Standing on the shoulders of giants to learn, jd.com's popular architect growth manual was launched
- C language POW function (how to play exponential function in C language)
- Understand │ what is cross domain? How to solve cross domain problems?
- 为什么需要第三方支付?
- 用户和权限创建普通用户
- MLX90640 红外热成像仪测温传感器模块开发笔记(七)
- [Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration
- greedy
- ES6--解构赋值
猜你喜欢

Graphic leetcode - Sword finger offer II 115. reconstruction sequence (difficulty: medium)

Oracle +JDBC

Standing on the shoulders of giants to learn, jd.com's popular architect growth manual was launched

Redis-基本了解,五大基本数据类型

【深度学习】视频分类技术整理

How bad can a programmer be?

Two years after its release, the price increased by $100, and the reverse growth of meta Quest 2

leetcode:1498. 满足条件的子序列数目【排序 + 二分 + 幂次哈希表】

Idea: solve the problem of code without prompt

分享Redshift渲染器的去噪方法技巧,一定要看看
随机推荐
To share the denoising methods and skills of redshift renderer, you must have a look
Clickhouse implements materializedpostgresql
In 2019, the global semiconductor revenue fell by 12% year-on-year, and China's market share ranked first
ZJNU 22-07-26 比赛心得
C language POW function (how to play exponential function in C language)
[Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration
Codeforces Round #810 (Div. 2)B.party(思维题)超详细题解
【毕设教程】YOLOv7 目标检测网络解读
JD: get the raw data API of commodity details
JS realizes video recording - Take cesium as an example
Express: search product API by keyword
JS jump to the page and refresh (jump to this page)
PyQt5快速开发与实战 4.5 按钮类控件 and 4.6 QComboBox(下拉列表框)
ES6--解构赋值
Redis 事物学习
What are the apps of regular futures trading platforms in 2022, and are they safe?
Standing on the shoulders of giants to learn, jd.com's popular architect growth manual was launched
Konka semiconductor's first storage master chip was mass produced and shipped, with the first batch of 100000 chips
【分层强化学习】HAC论文及代码
盘点下互联网大厂的实习薪资:有了它,你也可以进厂