当前位置:网站首页>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 .
边栏推荐
- slf4j简介说明
- Redis hash structure command
- Huawei's 150 member team rushed to the rescue, and Wuhan "Xiaotangshan" 5g base station was quickly opened!
- You can understand it at a glance, eslint
- ES6 deleting attributes of objects_ ES6 delete an element "suggested collection" in the object
- Redis queue、rdb学习
- 多点双向重发布及路由策略的简单应用
- Jetpack Compose 性能优化指南——编译指标
- [RCTF2015]EasySQL-1|SQL注入
- In 2019, China's smart machine Market: Huawei won nearly 4 components, firmly ranking first in China
猜你喜欢

MLX90640 红外热成像仪测温传感器模块开发笔记(七)

【毕设教程】YOLOv7 目标检测网络解读

Mlx90640 infrared thermal imager temperature sensor module development notes (VII)

JVM overview and memory management (to be continued)

Ten year test old bird talk about mobile terminal compatibility test

A new UI testing method: visual perception test

How bad can a programmer be?

antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key

Injection attack

My approval of OA project (Query & meeting signature)
随机推荐
同源与跨域
Clickhouse implements materializedpostgresql
slf4j中如何进行log4j配置呢?
How to optimize the open source community experience through developer metrics
Codeforces Round #810 (Div. 2)B.party(思维题)超详细题解
Redis basic understanding, five basic data types
Users and permissions create ordinary users
华为150人团队驰援,武汉“小汤山”5G基站火速开通!
Knowledge dry goods: basic storage service novice Experience Camp
It is said that Intel will stop the nervana chip manufactured by TSMC at 16nm
Redis hash structure command
软件测试面试题:字符串 “axbyczdj“,如果得到结果“abcd
Some contents related to cmsis-rtos
Linked list~~~
速卖通:按关键字搜索商品 API
How bad can a programmer be?
JD: search product API by keyword
【阿里安全 × ICDM 2022】20万奖金池!大规模电商图上的风险商品检测赛火热报名中!...
Summary of simple topics
If you want to switch to software testing, you should pass these three tests first, including a 3000 word super full test learning guide