Brief Introduction: The pressure test is to initiate a request to the service system through the simulation of user behavior, calculate the carrying capacity of the system, and perform a comprehensive physical examination of the system. After the pressure test, the system bottleneck can be optimized according to the performance of the pressure test to prevent online faults.
Author: Ling Ran
In actual business scenarios, pressure measurement is one of the essential, both to the server, database, network, etc. The evaluation of performance bottlenecks, still like to browse, order, payment and other important business continuity to ensure traffic node, or moving cloud on the stability of the overall business forecast, the performance pressure measurement are needed to help you build a complete recognition of system and business. According to Google, for every 500 milliseconds a site opens slowly, the number of visits drops by 20%. According to Amazon, for every 100-millisecond delay, transactions fall by 1%. These events and statistics are a wake-up call and an objective illustration of the importance of performance pressure measurement in enterprise applications.
The pressure test is to initiate a request to the service system through the simulation of user behavior, estimate the carrying capacity of the system, and perform a comprehensive physical examination of the system. After the pressure test, system bottlenecks can be optimized according to the performance of the pressure test to prevent online faults.
JMeter and PTS are common pressure measurement software in the industry
JMeter is the most widely used open source software in the field of performance pressure measurement.
For simple scenarios that require a small amount of concurrent testing, JMeter local testing can meet the requirements. However, with the increase of Internet users, the demand for the system to bear more concurrency is increasing day by day, and the pressure capacity of a single JMeter pressure machine has a certain limit, so it is necessary to use multiple pressure machines to improve the pressure capacity of JMeter, which requires the use of JMeter distributed pressure function.
However, JMeter has a lot of preparation ahead of the distributed pressure test. The following points need to be noted:
- The firewall of the press is closed or the correct port is open. SSL is set or disabled for RMI.
- All the presses are on the same subnet. If IP addresses 192. XXX or 10. XXX are used, the servers reside on the same subnet.
- All pressers use the same version of JMeter and Java.
- All pressers have copied sliced CSV data files, dependent JAR packages, etc.
- Monitoring data collection has been configured.
This shows that JMeter’s distributed pressure measurement requires the coordination of resources, which is difficult to prepare and inefficient for the personnel who perform the pressure measurement.
PTS is ali cloud development performance test tools, primarily in order to simulate the double tenth a flood peak flow, past ten years, now in the arrangement of the scene, pressure test execution, monitoring and analysis, report generation and so on various aspects ability is relatively perfect, can provide millions of concurrent, thousands of TPS flow ability, and can also fully compatible with JMeter, It naturally compensates for JMeter’s weakness in performance pressure measurement. It is a good choice for users who cannot bypass clustering problems with JMerer.
PTS’s JMeter manometry greatly simplifies the JMeter distributed manometry process while reducing the maintenance cost of the press during the manometry process. With THE JMeter pressure test of PTS, the user only needs to configure the number of machines to be used on the console. There is no need to prepare multiple presses with the same Java and JMeter versions installed in advance. At the same time, there is no need for users to split CSV parameter files according to the number of presses. After the manslaughter, PTS summarizes the monitoring data to produce a detailed manslaughter report for user review.
Compared to executing JMeter scripts directly from the command line, PTS is easier to use, provides a tremendous amount of pressure on demand, and provides concise and intuitive monitoring and reporting.
How do I initiate a PTS JMeter pressure test
Like the core steps of all compaction, the JMeter compaction using PTS focuses on creating the scenario, the compaction scenario, and viewing the report.
1. Create a scene: The PTS JMeter compaction is centered on a scenario where the compaction object is a scenario that includes JMeter (native) scripts, JMeter dependencies (a set of dependency JARS and a set of properties configurations), and some compaction configurations (PTS compaction configurations, For example, public network /VPC crimp, concurrency, number of engines, and crimp duration.
2. Pressure test scenario: The operation of the scene is divided into two aspects: one is to add, delete, modify and check the configuration of the scene; the other is to pressure test and debug the scene.
3. Report generation: each scene pressure test will generate a pressure test task and a report, including key indicators of pressure test, such as TPS, RT, success rate, etc., to assist users in troubleshooting system performance bottlenecks. In addition, PTS saves reports for 30 days by default, allows you to view historical reports at any time, and provides reports that can be exported in PDF format.
In the field of pressure measurement, as the pressure measurement requirements become increasingly diversified, more and more users want to inherit the pressure measurement capabilities on the cloud to their own systems, or according to their own business systems, customize the pressure measurement platform, so as to realize automatic customization of pressure measurement requirements.
Therefore, in order to facilitate the users’ ability to schedule millions of concurrent requests from PTS, PTS has opened The OpenAPI of JMeter, which provides the following core functions of pressure testing: editing scenario, debugging scenario, pressure testing scenario, viewing runtime data, and viewing reports.
Through the integration of OpenAPI, customers can more easily realize the multi-million level concurrent pressure test capability of PTS in their own business scenarios, realize the operation of adding, deleting, modifying, and searching scenarios, start the pressure test with one click, and stop the pressure test at any time during the pressure test. At the same time, in addition to JMeter native logs, the generated pressure test reports also include PTS aggregated data on the success rate, TPS and RT indicators of a certain sampler. Reports can also be viewed from a list of reports, JMeter native logs, and aggregated data from PTS on JMeter sampler pressure metrics.
So what are you waiting for? Come on, try writing your mega concurrent pressure platform using JMeter OpenAPI in PTS!
Appendix:
The specific steps are as follows:
Introduce POM dependencies
<! -- Create the entity classes required by the PTS scenario, --> <dependency> <groupId>com.aliyun</groupId> <artifactId>pts-api-entity</artifactId> The < version > < / version 1.0.1 > < / dependency > <! --PTS Java SDK dependencies. --> <dependency> <groupId>com.aliyun</groupId> <artifactId>pts20201020</artifactId> </dependency> <! -- Ali Cloud core library. --> <dependency> <groupId>com.aliyun</groupId> <artifactId> aliyun-java-sdK-core </artifactId> <version>4.5.2</version> </dependency>Copy the code
Copy the following code
import com.aliyun.pts20201020.Client; import com.aliyun.pts20201020.models.*; import com.aliyun.teaopenapi.models.Config; import java.util.ArrayList; import java.util.List; import java.util.Map; public class StartingDemo { public static void main(String[] args) throws Exception { Client client = getClient(); String sceneId = createScene(Client); String reportId = startTesting(client, sceneId); // Start scenario String reportId = startTesting(client, sceneId); Int count = 0; // Check if a report has been generated while (! HasReport (client, reportId) && count++ < 20) {// if the report is not generated, wait (30s) before query. // wait for thread. sleep(30 * 1000) according to the test time. } // Check the report getJMeterReport(client, reportId); } private static boolean hasReport(Client client, String reportId) throws Exception { ListJMeterReportsRequest request = new ListJMeterReportsRequest(); Request. SetPageNumber (1); request.setPageSize(1); Request. SetReportId (reportId); ListJMeterReportsResponse response = client.listJMeterReports(request); return response.getBody().getReports().size() > 0; } private static void getJMeterReport(Client client, String reportId) throws Exception {// Viewing machine logs GetJMeterLogsResponse GetJMeterLogsResponse = getJMeterLogs(Client, reportId); List<Map<String, ? >> logs = getJMeterLogsResponse.getBody().getLogs(); / / see the sampler aggregated data GetJMeterSampleMetricsResponse getJMeterSampleMetrics = getJMeterSampleMetrics (client, reportId); List<String> sampleMetricList = getJMeterSampleMetrics.getBody().getSampleMetricList(); / / check sample log GetJMeterSamplingLogsResponse getJMeterSamplingLogs = getJMeterSamplingLogs (client, reportId); List<String> sampleResults = getJMeterSamplingLogs.getBody().getSampleResults(); } private static GetJMeterSamplingLogsResponse getJMeterSamplingLogs(Client client, String reportId) throws Exception { GetJMeterSamplingLogsRequest request = new GetJMeterSamplingLogsRequest(); Request. SetPageNumber (1); request.setPageSize(10); // Conditional setting request.setReportId(reportId); GetJMeterSamplingLogsResponse response = client.getJMeterSamplingLogs(request); return response; } private static GetJMeterSampleMetricsResponse getJMeterSampleMetrics(Client client, String reportId) throws Exception { GetJMeterSampleMetricsRequest request = new GetJMeterSampleMetricsRequest(); // set the reportId request.setReportId(reportId); GetJMeterSampleMetricsResponse response = client.getJMeterSampleMetrics(request); return response; } private static GetJMeterLogsResponse getJMeterLogs(Client client, String reportId) throws Exception { GetJMeterLogsRequest request = new GetJMeterLogsRequest(); Request. SetPageNumber (1); request.setPageSize(10); // Queried pressure test engine index request.setReportId(reportId); GetJMeterLogsResponse response = client.getJMeterLogs(request); return response; } private static String startTesting(Client client, String sceneId) throws Exception { StartTestingJMeterSceneResponse startTestingSceneResponse = startTestingScene(client, sceneId); String reportId = startTestingSceneResponse.getBody().getReportId(); return reportId; } private static StartTestingJMeterSceneResponse startTestingScene(Client client, String sceneId) throws Exception { StartTestingJMeterSceneRequest request = new StartTestingJMeterSceneRequest(); request.setSceneId(sceneId); StartTestingJMeterSceneResponse response = client.startTestingJMeterScene(request); return response; } private static String createScene(Client client) throws Exception { SaveOpenJMeterSceneRequest request = new SaveOpenJMeterSceneRequest(); / / define scene SaveOpenJMeterSceneRequest. SaveOpenJMeterSceneRequestOpenJMeterScene scene = new SaveOpenJMeterSceneRequest.SaveOpenJMeterSceneRequestOpenJMeterScene(); SetSceneName ("test"); // Set the scene name scene.setscenename ("test"); // Set the file list, Including JMeter script lines, JMeter pressure dependent jar package, configuration data file List, such as < SaveOpenJMeterSceneRequest. SaveOpenJMeterSceneRequestOpenJMeterSceneFileList > fileList = new ArrayList<SaveOpenJMeterSceneRequest.SaveOpenJMeterSceneRequestOpenJMeterSceneFileList>(); / / Settings file attributes Need to set the file name and file public access to oss address SaveOpenJMeterSceneRequest. SaveOpenJMeterSceneRequestOpenJMeterSceneFileList testFile = new SaveOpenJMeterSceneRequest.SaveOpenJMeterSceneRequestOpenJMeterSceneFileList(); testFile.setFileName("baidu.jmx"); testFile.setFileOssAddress("https://pts-openapi-test.oss-cn-shanghai.aliyuncs.com/baidu.jmx"); fileList.add(testFile); scene.setFileList(fileList); SetConcurrency to 1 million scene.setconcurrency (1000000); SetAgentCount (2000); setAgentCount(2000); setAgentCount(2000); setAgentCount(2000); setAgentCount(2000); SetDuration (60 seconds scene.setduration (60); // Set the name of the test file, which must be included in the file list scene.settestfile (" bidu.jmx "); request.setOpenJMeterScene(scene); SaveOpenJMeterSceneResponse response = client.saveOpenJMeterScene(request); return response.getBody().getSceneId(); } private static Client getClient() throws Exception {// Enter your own AK/SK String accessKeyId = "AK "; String accessKeySecret = "sk"; Config config = new Config(); config.setAccessKeyId(accessKeyId); config.setAccessKeySecret(accessKeySecret); Client client = new Client(config); return client; }}Copy the code
Fill in your AK/SK
Fill in the correct AK/SK in the getClient of the above code
The original link
This article is the original content of Aliyun and shall not be reproduced without permission.