Let's talk about the performance test of 2 yuan

foreword

As a test, I have more or less done or heard of performance tests. When it comes to performance testing, the first impression may be high, because it involves evaluating the performance, stability and reliability of the system. Indeed, the water of performance testing is very deep. If you play well, you can develop into a performance testing expert and architect level.

The requirements for junior and intermediate test students are probably to be able to perform interface stress testing, and to be able to analyze key indicators such as TPS, concurrency, throughput, and resource utilization based on the generated reports, which can assist developers in performance tuning.

In this article, let’s briefly talk about performance testing, including the concepts, indicators, tools, processes, and learning routes of performance testing. After reading this article, you probably have a preliminary grasp of the basics of performance testing.

What is software performance

Before talking about performance testing, let's talk about a concept, what is it 软件性能?

Software performance is a non-functional characteristic of software. It does not focus on whether the software can complete a specific function, but the timeliness displayed when the function is completed. For example: a login function can realize the login operation, but it takes 10 seconds to enter the main page during the login process, which means that the performance of the software is not good.

What is performance testing

Performance testing refers to various performance indicators of the system (such as response time, throughput, concurrency, resource utilization, error rate, etc.) for testing.

The functional test focuses on the operation of one person (that is, whether the function can be realized), and the performance test focuses on the operation of multiple people (the premise of the performance test is that there is no problem with the function).

performance test index

After knowing what is performance and what is performance testing, we need to understand some performance-related indicators. Only through the establishment and analysis of performance indicators can we judge whether the performance of the software meets the requirements.

  • 响应时间 RT(Response Time)

    The time from 用户发送一个请求to is the response time.用户接收到服务器返回的响应数据

    Usually measured using average response time, maximum response time, percentile response time, etc.

    Response time = rendering time + network transmission time + server response time + application delay time

  • 吞吐量(Throughput)

    The number of client requests processed by the system per unit time.

    Usually 请求数/秒(QPS) or 请求数/分钟(RPM) is used as the unit of throughput, and it can also be expressed, and it can also be used  or  as a unit 页面数/秒from a business point of view  .访问人数/天页面访问量/天

    throughput=(number of requests)/(total time)

  • 并发数(Concurrency)

    The number of users who use the system concurrently is usually measured by the maximum number of concurrent users, the number of online users, and the number of system users.

    • Number of concurrent users: The number of users who submit requests to the system at the same time at a certain physical moment. The submitted requests may be for the same scenario or function, or different scenarios or functions.

    • Number of online users: the number of users accessing the system within a certain period of time, and these users do not necessarily submit requests to the system at the same time. For example: 日活- indicates the number of daily active users

    • Number of system users: total user data registered in the system.

      The relationship between the three: the number of system users >= the number of online users >= the number of concurrent users

  • 资源利用率

    The usage of different system resources is usually measured as a percentage of the maximum value occupied.

    Server resources that typically require attention are:

    • CPU使用率

      The CPU is like the human brain, mainly responsible for the judgment of related things and the actual processing mechanism.

      CPU usage refers to the CPU usage when the system is running. It is usually measured by the average CPU usage and peak CPU usage (generally no more than 80%-90%).

    • 内存使用率

      The memory is the memory block area in the brain, where the information collected by the eyes, skin, etc. is recorded for the CPU to judge, but it is temporary and the access speed is fast. If the computer is turned off or the power is cut off, the data in the memory will be lost disappear.

      Memory usage refers to the memory usage when the system is running, and is usually measured by the average memory usage, peak memory usage, etc.

    • 磁盘I/O

      The memory block in the brain saves important data and saves them permanently. It will not be lost even if the computer is turned off or powered off. The speed is slow so that the data can be used again in the future (by reading and writing). It is usually measured by the disk read and write speed, the number of disk I/O requests, and so on.

    • 网络

      Bandwidth, usually measured in terms of send/receive rates.

performance testing tools

  • Apache JMeter: A powerful and widely used open source performance testing tool. It supports multiple protocols and technologies, including HTTP, HTTPS, Web Services, JDBC, FTP, etc. It can simulate a large number of concurrent users and generate complex test scenarios.

  • LoadRunner: A commercial performance testing tool for complex enterprise applications. It provides a wide range of protocol and technical support, has powerful load generation and monitoring capabilities, and can simulate large-scale user loads and complex business processes.

  • Locust: An open source load testing tool written in Python. With simple syntax and easy scripting, it can simulate a large number of concurrent users and execute complex test scenarios. It also provides real-time monitoring and visual reporting capabilities.

Different tools have their own characteristics, and you can choose the appropriate tool for different testing requirements and project environments. JMeter and Locust are recommended here.

Performance testing process

A performance testing process typically consists of the following steps, which can be adjusted and adapted to specific projects and needs:

  • Analyze performance requirements and determine test objectives

    Performance indicators can be formulated by product managers or project managers, or performance test scenarios and indicators can be determined through log monitoring and analysis.

    For example: the transaction pass rate is 100%, TOP99% is within 5000ms, the maximum number of concurrent users is 1000, and the usage rate of CPU and memory is below 70%.

  • Develop a performance test plan

    Formulate performance test strategy, including test scope, test environment, test data and load configuration, etc.

    Determine the time of testing (usually after the function is stable, such as after the first round of testing) and resource constraints, and develop the timetable and milestones of the test plan.

  • Write a test plan

    Choose a suitable performance testing tool, such as JMeter, LoadRunner, etc. Select appropriate monitoring tools for monitoring system resource usage and performance metrics.

  • Build/confirm the test environment and prepare test data

    Build an environment that meets the testing requirements, including hardware, software, network and database, etc. Configure test servers, load generators, and monitoring tools to ensure readiness.

  • Write performance test scripts

    According to test scenarios and load types, write test scripts to define user operations and transaction processes. Set the parameters of the performance testing tool, such as the number of concurrent users, request frequency, etc.

  • Performance test script tuning (script enhancement)

    Set up checkpoints, parameterization, associations, rendezvous points, transactions, adjust think time, remove redundant scripts.

  • Analysis and Optimization

    Analyze the test results, identify performance bottlenecks and problems, and propose optimization suggestions and solutions based on the analysis results.

    Collect relevant data and log information bills to developers.

  • Regression Testing

    Perform performance tuning and optimization tests to verify the effectiveness of improvement measures. At the same time, business testing should also return to avoid affecting the normal use of functions after optimizing performance.

  • Write test report

    Write a performance test report summarizing test results and analysis, including performance metrics and a list of issues. Provide optimization suggestions and improvement measures for the development team's reference and implementation. Deliver the report to relevant teams and stakeholders for discussion and feedback.

  • Conduct continuous performance monitoring

    After the system goes online, regular performance monitoring and testing are carried out to ensure the stability and reliability of the system. Adjust and optimize system performance in a timely manner according to actual usage and changing requirements.

Performance testing learning path

  • Understand basic concepts and principles

    Learn fundamental concepts of performance testing such as performance metrics, load, throughput, response time, and more.

    Learn about the importance of performance testing and how to evaluate system performance and stability.

  • Master performance testing tools

    Choose a commonly used performance testing tool, recommend JMeter, and learn the basic principles and usage methods of performance testing tools, such as: commonly used components and components of JMeter, three methods of parameterization in JMeter, JMeter response result assertion and cookie manager, Synchronous timers implement concurrency scenarios, regular expressions and JSON expression extractors for interface associations, JMeter server resource monitoring and aggregation report analysis, etc.

  • tool enhancement

    Since graphical stress testing consumes resources, you can use the command line to perform stress testing without graphics. When the pressure provided by a single JMeter is not enough, you can learn distributed pressure measurement. JMeter can also learn to do secondary development based on third-party plug-ins such as Beanshell, and can also throw the written and debugged scripts into the Linux non-GUI environment for execution, solving the problem of too many sockets and excessive load of Jmeter in the Windows environment Pain points.

  • Hierarchical Supervision Learning

    Simply use commands (such as Linux commands df, du, free, netstat, etc.) to monitor server resources, including CPU, memory, disk, network, etc., and analyze indicators. If you feel that it is not intuitive enough, you can also learn how to build Prometheus+Exporter+Grafana to display indicators on a graphical interface, and you can also monitor hardware and databases. In addition, you can also learn SkyWalking to do distributed link monitoring, and combine DingTalk as an alarm mechanism.

  • Performance Bottleneck Analysis

    Learn to analyze common performance problems, such as: how to locate the soaring CPU to the code level, how to analyze the interface response time is too long, slow query SQL problems (for slow SQL, please refer to the previous article "Quickly Learn to Troubleshoot Slow Query SQL") , etc.

    To put it simply, if the performance test fails to meet the standard, it is necessary to judge whether it is a code problem or a server resource problem. For example, by monitoring the physical resources of the system, it is found that the CPU usage is 100%, or the memory is full, the bandwidth is full, etc., which is likely to be a server resource problem. , just mention the list to the operation and maintenance classmates. If the CPU, memory, bandwidth, etc. are all up to the standard, and the test finds that there are still performance problems, it is a development problem, and it must be assigned to the development to deal with.

    You can also use tools such as Arthas to locate code link problems. In short, the water is relatively deep at this level, and you often need to cooperate with developers to find and solve problems together.

  • Performance test platform development

    At this stage, you basically belong to the masters in performance testing. On the one hand, you need to understand the principles of performance testing, and on the other hand, you need to know the front-end and back-end development technology stacks, such as: front-end Vue, back-end SpringBoot, MyBatis, etc. Those who specialize in full-link stress testing platforms are generally large Internet companies, some of which are based on Jmeter for secondary development, and some even completely separate from Jmeter to develop their own platforms, depending on the company's needs and cost investment.

Well, let’s stop talking about the performance test for two dollars. Let’s talk about more knowledge about performance testing, the use of tools, and performance bottleneck analysis and optimization next time. It’s time to eat, bye bye~


Finally:  In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free 【保证100%免费】

加入我的软件测试交流群:110685036免费获取~(同行大佬一起学术交流,每晚都有大佬直播分享技术知识点)

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

method of obtaining:

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/131046489