当前位置:网站首页>User login function: simple but difficult
User login function: simple but difficult
2022-07-02 07:00: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 ~
边栏推荐
- 浏览器滚动加载更多实现
- js把一个数组分割成每三个一组
- DeprecationWarning: . ix is deprecated. Please use. loc for label based indexing or. iloc for positi
- SQLI-LABS通关(less15-less17)
- Solve the problem of bindchange event jitter of swiper component of wechat applet
- PHP Session原理简析
- Latex error: the font size command \normalsize is not defined problem solved
- In depth study of JVM bottom layer (IV): class file structure
- [literature reading and thought notes 13] unprocessing images for learned raw denoising
- Solution to the black screen of win computer screenshot
猜你喜欢

Flex Jiugongge layout

table 组件指定列合并行方法

sqli-labs通关汇总-page3

Solve the problem of bindchange event jitter of swiper component of wechat applet

在php的开发环境中如何调取WebService?

VSCODE 安装LATEX环境,参数配置,常见问题解决

Latex warning: citation "*****" on page y undefined on input line*

Basic knowledge of software testing

Latex compilation error I found no \bibstyle &\bibdata &\citation command

Vscode installation, latex environment, parameter configuration, common problem solving
随机推荐
Date time API details
VSCODE 安装LATEX环境,参数配置,常见问题解决
[daily question] - Huawei machine test 01
Explanation and application of annotation and reflection
Fe - eggjs combined with typeorm cannot connect to the database
In depth study of JVM bottom layer (3): garbage collector and memory allocation strategy
UEditor .Net版本任意文件上传漏洞复现
JS divides an array into groups of three
Atcoder beginer contest 253 F - operations on a matrix / / tree array
JS delete the last bit of the string
Differences between ts and JS
CSRF攻击
CVE-2015-1635(MS15-034 )遠程代碼執行漏洞複現
Huawei mindspire open source internship machine test questions
CTF three count
图解Kubernetes中的etcd的访问
Self study table Au
Linux MySQL 5.6.51 community generic installation tutorial
IDEA2020中PySpark的两表关联(字段名相同)
ModuleNotFoundError: No module named ‘jieba. analyse‘; ‘ jieba‘ is not a package