JMeter AWS API Load Testing Scenario

Purpose:

  • Perform load testing in the QA environment to find out service bottlenecks in AWS and optimize configuration selection.

1. Overall plan

insert image description here

1. Developers use VSCode to generate API Swagger, and use openapi-generator to import JMeter

2. According to the characteristics of the system, testers define the thick lines used by the system (covering key indicators), set the number of concurrency that meets the indicators, peak hours, etc. in JMeter, and run the test.

3. AWS monitoring personnel observe the system load and register it as a report to find out the weak points of the system.

4. Testers observe the running status of JMeter. When there are a large number of visits that do not meet the duration and connectivity, the registration report will be assisted by the developer to find out the reason.

5. Improve the resource allocation of AWS and optimize the architecture if necessary.

2. Environmental preparation

2.1 Nest generates Swagger in the local DEV environment

详见项目框架中的配置

2.2 Install JMeter

Download address: https://jmeter.apache.org/

详见:https://www.cnblogs.com/stulzq/p/8971531.html

2.3 Install OpenAPI Generator

Download address: https://pan.baidu.com/s/1tj5G99_aCbRc8FKRNrP8vg

Extraction code: 3ugu

详见:https://blog.csdn.net/leenhem/article/details/119816061

3. AWS service preparation

AWS services use Cloudformation for the first deployment and GitHub Action for automatic deployment. Before running the test, you only need to ensure that the environment is up to date.

4. Local configuration

4.1 Prepare Swagger JSON file

开发本地生成

4.2 Generating JMeter scripts

First put the Json file in the same directory as OpenAPI Generator

Enable the console or Powershell and run the following command:

java -jar openapi-generator-cli-5.1.0.jar generate -i swagger.json -g jmeter

4.3 Import script

Open the Jmeter program, select File–>Open, select the .jmx file, and import.

insert image description here

4.4 Edit variables

Click "User Defined Variables" to modify variables such as the system Host and Port.

Find the CSV file in the same directory as .jmx, modify the parameter variables required by each API and modify them to Mock values

4.5 Set the traffic

Select the API that needs to be authenticated, and modify the number of threads and other personalized values ​​for the business.

The purpose is to simulate the normal call frequency and concurrency in the API during a load test run cycle.

4.6 Running and Viewing

Click View Results Tree to view the results

Click Run (triangle symbol) above to start this round of load testing

4.7 Export Report

insert image description here

5. AWS Tracking

5.1 Cloudwatch indicator monitoring

Enter Cloudwatch, click the project monitoring interface in Dashboards, and view the database, container service, API, related memory, CPU, disk read and write and other indicators.

Find out when the entire system is under high load, an AWS service becomes a bottleneck and an indicator.

insert image description here

5.2 Cloudwatch log monitoring

Enter the log group to view the details of the log, the compliance of the log, the integrity of the log, and the audit log.

5.3 AWS optimization

According to the test results, optimize the configuration of service indicators and optimize the architecture if necessary.

possible reason:

1. The rationality of the structure

2. The configuration of AWS service (such as RDS CPU) indicators is low

3. The AWS auto-scaling function has not been effectively enabled

4. The coding logic and processing performance of some services are low

5, etc.

Guess you like

Origin blog.csdn.net/black0707/article/details/124971122