当前位置:网站首页>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 ~
边栏推荐
- 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)
- Compréhension de la technologie gslb (Global Server load balance)
- JS closure knowledge points essence
- Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
- The difference between SRAM and DRAM
- [Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)
- Mysql database - Advanced SQL statement (I)
- 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
- 1068. Consolidation of ring stones (ring, interval DP)
- Oil monkey plug-in
猜你喜欢

How to solve the problem of computer networking but showing no Internet connection

The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation

string

This time, thoroughly understand bidirectional data binding 01
![[SRS] build a specified version of SRS](/img/01/0d2d762e01b304220b8924d20277e3.jpg)
[SRS] build a specified version of SRS
![[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)](/img/1d/044e81258db86cf34eddd3b8f5cf90.jpg)
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)

Preliminary analysis of smart microwave radar module

3 environment construction -standalone

What indicators should be paid attention to in current limit monitoring?

Morning flowers and evening flowers
随机推荐
Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
On my first day at work, this API timeout optimization put me down!
Rest reference
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
[sg function] 2021 Niuke winter vacation training camp 6 h. winter messenger 2
Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
BUUCTF,Misc:LSB
Yyds dry goods inventory hands-on teach you to create a jigsaw puzzle using the canvasapi
JS demo calculate how many days are left in this year
How to solve the problem of requiring a password when accessing your network neighborhood on your computer
6.2 normalization 6.2.5 third normal form (3NF)
Morning flowers and evening flowers
How to solve the problem of computer networking but showing no Internet connection
DR-AP40X9-A-Qualcomm-IPQ-4019-IPQ-4029-5G-4G-LTE-aluminum-body-dual-band-wifi-router-2.4GHZ-5GHz-QSD
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)
Leetcode week 4: maximum sum of arrays (shape pressing DP bit operation)
IPhone development swift foundation 08 encryption and security
QGIS grid processing DEM data reclassification
Electronic tube: Literature Research on basic characteristics of 6j1
Asynchronous artifact: implementation principle and usage scenario of completable future