当前位置:网站首页>User login function: simple but difficult
User login function: simple but difficult
2022-07-03 22:23:00 【Huawei cloud developer community】
Abstract : User login is just a common function , But its logic is not simple at all .
This article is shared from Huawei cloud community 《 User login of performance analysis TPS Low and CPU Filled with problem analysis 》, author :zuozewei .
User login is just a common function , But its logic is not simple at all . Because the login process needs to compare and verify personal information , During the verification process, the corresponding encryption algorithm must be called , Encryption algorithm is a function that requires high performance . The complex encryption algorithm has high security , But the performance is poor ; Uncomplicated encryption algorithm has good performance , But it's safe , This is a question of trade-offs .
Follow the design steps of the benchmark scenario of the test scheme , First, test the benchmark scenario of this interface .
● Problem phenomenon

As shown in the figure above , This phenomenon is becoming more and more obvious .
In the pressure measurement results TPS The average is 25 The average response time reached 993 ms.
● The analysis process
In terms of performance analysis logic , For the problem of long response time , The first thing to do is to split the time . Since this system has been deployed SkyWalking, Use it to see where time is mainly spent .

Look at the picture ,Tomcat Of SelfDuration The most. , In other words, time is almost consumed in the service itself .
● Global monitoring
First, check the resource level of the application server :

You can see 4C Of CPU Resources have been exhausted .
The container deployed here , Let's take a look at the resource usage of each container :

You can see that resources are mainly consumed by the service container .
● Service orientation analysis
First, enter the service container to view the resource consumption :

stay SkyWaking You can't see the complete call stack in , Consider connecting directly to the service Java The time consumption of the method in the process . Here we use Arthas Follow up .
Check out the busiest previous N Thread and print stack :

Here is the business code of the program .
therefore trace attemptAuthentication This method .

next trace authenticate This method .

Follow it layer by layer , Finally came here :

Since the crypt_raw The method takes a long time , Then decompile the source code to see what this paragraph is .

As you can see, here is an encryption algorithm BCrypt, So the conclusion is obvious BCrypt Although the encryption algorithm has high security , But the performance is poor .
● demo verification
Use here SpringBoot Realization MD5 Encryption and BCrypt Encrypted instance .

JMeter Concurrent 20 MD5 Encryption result :

JMeter Concurrent 20 BCrypt Encryption result :

● Suggested optimization direction
Here's an explanation ,Bcrypt When encrypting , every time HASH The values are different , So it's very slow !
What exactly is Bcrypt Algorithm , You can refer to this article :https://www.jianshu.com/p/2b131bfc2f10
So that's the analysis , The optimization scheme is actually clear , That is to use faster encryption , Or remove the encryption algorithm .
Click to follow , The first time to learn about Huawei's new cloud technology ~
边栏推荐
- Analysis report on the development prospect and investment strategy of global and Chinese modular automation systems Ⓟ 2022 ~ 2027
- How does sentinel, a traffic management artifact, make it easy for business parties to access?
- Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
- [sg function]split game (2020 Jiangxi university student programming competition)
- 6.0 kernel driver character driver
- 4. Data splitting of Flink real-time project
- [actual combat record] record the whole process of the server being attacked (redis vulnerability)
- Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
- Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
- China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
猜你喜欢

This time, thoroughly understand bidirectional data binding 01

gslb(global server load balance)技術的一點理解

2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units

How to switch between dual graphics cards of notebook computer

Farmersworld farmers world, no faith, how to talk about success?
![Intimacy communication -- [repair relationship] - use communication to heal injuries](/img/c2/f10405e3caf570dc6bd124d65b2e93.jpg)
Intimacy communication -- [repair relationship] - use communication to heal injuries

The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
![[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]](/img/55/309c9d52e503405b289bcfc4912be9.jpg)
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]

Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)

Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
随机推荐
How to obtain opensea data through opensea JS
2022 safety officer-a certificate registration examination and summary of safety officer-a certificate examination
Covariance
Leetcode problem solving - 230 The k-th smallest element in the binary search tree
How to solve the problem of requiring a password when accessing your network neighborhood on your computer
Rest参考
[automation operation and maintenance novice village] flask-2 certification
The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation
Are the top ten securities companies safe to open accounts and register? Is there any risk?
Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
[dynamic programming] Jisuan Ke: Jumping stake (variant of the longest increasing subsequence)
JS demo calculate how many days are left in this year
On my first day at work, this API timeout optimization put me down!
Leetcode problem solving - 235 Nearest common ancestor of binary search tree
Pooling idea: string constant pool, thread pool, database connection pool
Functions and differences between static and Const
Plug - in Oil Monkey
Is it safe and reliable to open an account and register for stock speculation? Is there any risk?
The overseas listing of Shangmei group received feedback, and brands such as Han Shu and Yiye have been notified for many times and received attention
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant