Pressure testing method and device and related product
By preloading and real-time synchronizing the bill information of the resource server on the pressure-generating device, the problem of high bill expiration rate is solved, the effectiveness and accuracy of the pressure test are improved, and more efficient traffic simulation is achieved.
Patent Information
- Application Number
- CN202310217538.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-28
- Publication Date
- 2024-08-30
AI Technical Summary
In the existing stress testing technology, the pressure-generating equipment lacks the ability to sense whether the bill information has expired, resulting in a high bill expiration rate and affecting the stress testing effect.
Before the stress test starts, preload the account ticket information from the resource server and store it locally. During the period, the connection with the resource server is maintained, the refreshed ticket information is synchronized in real time, the latest local ticket information is used to initiate a stress test request, and the ticket is automatically expired when the ticket expires. Query and refresh.
It reduces the bill expiration rate, improves the effectiveness of traffic simulation and stress testing effect, ensures the use of the latest bill information, and improves the accuracy and efficiency of stress testing.
Smart Images

Figure CN118573580A
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a pressure testing method, device and related products. Background Art
[0002] Stress testing (abbreviated as stress testing) refers to actively generating traffic, thereby causing computing pressure on the service and testing the performance and robustness of the service. Based on the actual business scenarios and the deployment environment of the business system, stress testing devices (or stress testing nodes) are generally used to simulate massive users accessing the backend service to test the performance of the business link under business scenarios and massive data impacts. For example, full-link stress testing can discover problems that need to be optimized in the entire business link in complex business scenarios, and by solving these problems, improve the availability and reliability of the business system; distributed stress testing can simulate the access of massive users through multiple distributed stress testing devices, improving the efficiency and effect of stress testing.
[0003] In actual business scenarios, after an account logs in, a login state and various ticket information are formed. The ticket information of the account can be used for the corresponding verification when the account subsequently requests background services. During the stress test, the ticket information of the account needs to be carried to perform end-to-end traffic simulation. Therefore, the ticket information of the account is an indispensable part of the stress test. The ticket information of the account is time-sensitive. The ratio of the number of times when the expired account ticket information is used when the stress test request is initiated during the stress test to the total number of times the stress test request is initiated is defined as the ticket expiration rate. If the ticket expiration rate of the stress test is high, it will reduce the effectiveness of the traffic simulation and affect the stress test effect. For this reason, the resource server generally needs to refresh the ticket information to reduce the ticket expiration rate.
[0004] The refreshed ticket information is generally first obtained by the resource server and then synchronized to the stress-generating device, which acts as the initiator of the stress test request. In the existing technology, the stress-generating device preloads the latest ticket information of all accounts in the resource server before the stress test, and uses the preloaded result to simulate traffic during the stress test. In another technology, the stress-generating device pulls the latest ticket information of all accounts in the resource server during the stress test, and after the pull is completed, the traffic simulation is performed with the pulled account tickets. However, in the above two technical solutions, the stress-generating device only completes the traffic simulation based on the existing ticket information after its own preloading is completed or a one-time pull is completed. Since the stress-generating device itself lacks the ability to perceive whether the ticket information is expired, there is still a problem of a high ticket expiration rate, which affects the stress test effect. Summary of the invention
[0005] The embodiments of the present application provide a stress testing method, device and related products, which are intended to reduce the bill expiration rate and improve the effectiveness of traffic simulation.
[0006] The first aspect of the present application provides a pressure testing method, which is applied to a pressure generating device. The pressure testing method includes:
[0007] Before the stress test begins, the ticket information of the account to be tested is preloaded from the resource server and stored locally; wherein the account is the account corresponding to the business to be tested;
[0008] During the stress test, the ticket information of the account after being refreshed pushed by the resource server is synchronized to the local computer through the connection established with the resource server;
[0009] Using the latest ticket information of the local account, a stress test request is initiated to the backend server of the service to be tested.
[0010] Optionally, the stress testing method further includes:
[0011] When it is determined that the first ticket information of the target account stored locally during the stress test has expired, a query request for the latest ticket information of the target account is initiated to the resource server; wherein the target account is any account to be tested, the first ticket information is the latest version of the ticket information of the target account stored locally, and the query request carries version information of the first ticket information;
[0012] Receiving the latest ticket information provided by the resource server based on the query request, and synchronizing the latest ticket information provided by the resource server to the local;
[0013] Among them, if the version of the second ticket information in the resource server is later than the version of the first ticket information, the latest ticket information provided by the resource server is the second ticket information, and the second ticket information is the latest ticket information of the target account stored when the resource server receives the query request; or, if the version of the second ticket information in the resource server is earlier than or equal to the version of the first ticket information, the latest ticket information provided by the resource server is the third ticket information, and the third ticket information is the latest ticket information of the target account obtained after the resource server requests to refresh the ticket information of the target account.
[0014] Optionally, the stress-generating device includes a stress test script and a resource agent; the step of synchronizing the refreshed ticket information of the account pushed by the resource server to the local computer through the connection established with the resource server includes:
[0015] Synchronize the refreshed ticket information of the account pushed by the resource server to the local computer through the connection established between the resource proxy and the resource server;
[0016] The method of using the latest ticket information of the local account to initiate a stress test request to the backend server of the service to be tested includes:
[0017] Read the latest ticket information of the local account through the stress test script;
[0018] The stress test script initiates a stress test request to the backend server of the service to be tested according to the read ticket information.
[0019] Optionally, the stress-generating device locally uses a shared memory in a lock-free mode for the resource agent to perform write operations and for the stress test script to perform read operations; after reading the latest ticket information of the local account through the stress test script, the method further includes:
[0020] Performing a cyclic redundancy check on the information read from the shared memory through the stress test script;
[0021] If the verification passes, the stress test script is allowed to use the read information; if the verification fails, the stress test script is used to re-read the latest ticket information of the local account from the shared memory.
[0022] Optionally, the stress testing method further includes:
[0023] Constructing a hash map of account index information and accounts involved in the shared memory;
[0024] The step of reading the latest ticket information of the local account through the stress test script includes:
[0025] The stress test script obtains target index information, wherein the target index information is associated with the stress test requirement, and the target index information and the account index information are of the same type of information;
[0026] The stress test script reads the latest ticket information of the account corresponding to the target index information based on the hash map.
[0027] Optionally, the account index information is account type information, or the account index information is identification information of a memory block in a shared memory; the memory block corresponds one-to-one to the identification information, and the memory block corresponds one-to-one to the account.
[0028] Optionally, the stress testing method further includes:
[0029] When preloading ticket information of an account to be tested from the resource server fails, marking the state of a memory block in the shared memory corresponding to the account that failed to be preloaded as a first state; wherein the first state indicates that the preloading failed;
[0030] Retry at intervals to preload ticket information of the account corresponding to the memory block in the first state from the resource server until the state of the memory block is changed from the first state to a second state when the preloading is successful; wherein the second state indicates that the preloading is successful.
[0031] Optionally, the stress testing method further includes:
[0032] In the first preset time after the connection with the resource server fails, if the resource server cannot be reconnected successfully and the ticket information of the target account stored locally has expired, the ticket information prediction model is called; wherein the target account is any account to be tested;
[0033] Predicting the latest bill information of the target account by using the bill information prediction model;
[0034] The locally expired ticket information of the target account is replaced by the predicted latest ticket information.
[0035] Optionally, when the reconnection with the resource server cannot be successful within the first preset time after the connection with the resource server fails, and the ticket information of the target account stored locally has expired, calling the ticket information prediction model includes:
[0036] If reconnection with the resource server cannot be successful within a first preset time after the connection with the resource server fails, and the ticket information of the target account stored locally has expired, a ticket prediction request is generated according to a record of failure to reconnect with the resource server within the first preset time after the connection with the resource server fails, and version information of the ticket information of the target account stored locally;
[0037] calling the bill information prediction model through the bill prediction request;
[0038] The predicting the latest bill information of the target account by using the bill information prediction model includes:
[0039] Inputting the most recent N bill information of the target account into the bill information prediction model; N is a positive integer greater than 1;
[0040] The latest bill information of the target account predicted by the bill information prediction model based on the N input bill information is obtained.
[0041] The second aspect of the present application provides a stress testing method, which is applied to a resource server. The stress testing method includes:
[0042] Before the stress test begins, receive a preload request from the stress-generating device;
[0043] Providing the ticket information of the account to be tested to the pressure-generating device according to the preload request; wherein the account is the account corresponding to the service to be tested;
[0044] During the stress test, the refreshed ticket information of the account is pushed through the connection established with the stress-generating device, so that the stress-generating device uses the latest ticket information of the account to initiate a stress test request to the backend server of the service to be tested.
[0045] Optionally, the stress testing method further includes:
[0046] During the stress test, a query request for the latest ticket information of a target account is received from the stress-generating device; wherein the target account is any account to be tested; the query request is a request initiated by the stress-generating device when it determines that the first ticket information of the target account stored locally has expired, and the query request carries version information of the first ticket information; the first ticket information is the latest version of the ticket information of the target account stored locally by the stress-generating device;
[0047] Obtaining a version comparison result according to the version information of the first ticket information in the query request and the version information of the second ticket information stored in the resource server; the second ticket information is the latest ticket information of the target account stored when the resource server receives the query request;
[0048] The latest ticket information corresponding to the query request is provided to the pressure issuing device according to the version comparison result.
[0049] Optionally, providing the latest ticket information corresponding to the query request to the pressure-generating device according to the version comparison result includes:
[0050] If the version of the second ticket information is later than the version of the first ticket information, providing the second ticket information to the pressure-generating device;
[0051] If the version of the second ticket information is earlier than or equal to the version of the first ticket information, request to refresh the ticket information of the target account to obtain the third ticket information of the target account; provide the third ticket information to the pressure-generating device; wherein the version of the third ticket information is later than the version of the first ticket information.
[0052] Optionally, during the stress test, pushing the refreshed ticket information of the account through the connection established with the stress generating device includes:
[0053] After the ticket information of multiple accounts to be tested is centrally refreshed during the stress test, the refreshed multiple ticket information is pushed through the connection established with the stress-generating device;
[0054] Evenly distribute the next scheduled refresh time of the multiple bill information that are refreshed centrally to the validity period of the multiple bill information that are refreshed centrally;
[0055] Refresh the corresponding bill information according to the next scheduled refresh time of the multiple bill information that are refreshed centrally;
[0056] The refreshed ticket information is pushed through the connection established with the pressure-generating device.
[0057] Optionally, the stress testing method further includes:
[0058] After the connection with the pressure generating device fails, recording the connection failure information; the connection failure information includes the connection failure time;
[0059] After a preset time interval has passed since the connection failed, retry to establish a connection with the pressure generating device.
[0060] The third aspect of the present application provides a pressure testing device, which is applied to a pressure generating device. The pressure testing device comprises:
[0061] The bill preloading unit is used to preload the bill information of the account to be tested from the resource server and store it locally before the stress test starts; wherein the account is the account corresponding to the business to be tested;
[0062] A bill synchronization unit, used to synchronize the bill information of the account after being refreshed pushed by the resource server to the local computer through the connection established with the resource server during the stress test;
[0063] The stress testing unit is used to initiate a stress testing request to the backend server of the service to be tested by using the latest ticket information of the local account.
[0064] A fourth aspect of the present application provides a stress testing device, which is applied to a resource server. The stress testing device includes:
[0065] A receiving unit, used for receiving a preload request of a pressure generating device before the pressure test starts;
[0066] A first sending unit, configured to provide the pressure-generating device with ticket information of an account to be tested according to the preloading request; wherein the account is an account corresponding to the service to be tested;
[0067] The second sending unit is used to push the refreshed ticket information of the account through the connection established with the stress-generating device during the stress test, so that the stress-generating device can use the latest ticket information of the account to initiate a stress test request to the background server of the business to be tested.
[0068] A fifth aspect of the present application provides a pressure generating device, the pressure generating device comprising a processor and a memory:
[0069] The memory is used to store program codes and transmit the program codes to the processor;
[0070] The processor is used to execute the steps of the stress testing method of the first aspect according to the instructions in the program code.
[0071] A sixth aspect of the present application provides a resource server. The resource server includes a processor and a memory:
[0072] The memory is used to store program codes and transmit the program codes to the processor;
[0073] The processor is used to execute the steps of the stress testing method of the second aspect according to the instructions in the program code.
[0074] In a seventh aspect, the present application provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the steps of the stress testing method of the first aspect, or the program code is used to execute the steps of the stress testing method of the second aspect.
[0075] In an eighth aspect, the present application provides a computer program product, comprising a computer program or instructions, which, when executed, implement the steps of the stress testing method of the first aspect, or the program code is used to execute the steps of the stress testing method of the second aspect.
[0076] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0077] In the technical solution of the present application, before the stress test begins, the stress-generating device preloads the ticket information of the account to be tested from the resource server and stores it locally; during the stress test, the stress-generating device synchronizes the refreshed ticket information of the account pushed by the resource server to the local via the connection established with the resource server. As a result, the stress-generating device can timely synchronize the latest ticket of the account on the resource server side locally and apply it to the stress test. During the stress test, by timely synchronizing the refreshed account ticket information on the stress-generating device, the possibility of using expired tickets for stress-generating is reduced, thereby reducing the ticket expiration rate, improving the effectiveness of traffic simulation, and improving the stress test effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 A flow simulation implementation architecture diagram provided in an embodiment of the present application;
[0079] Figure 2 A schematic diagram of a stress test scenario provided in an embodiment of the present application;
[0080] Figure 3 A schematic diagram of another stress test scenario provided in an embodiment of the present application;
[0081] Figure 4 A schematic diagram of another stress test scenario provided in an embodiment of the present application;
[0082] Figure 5 A schematic diagram of the architecture of a pressure-generating node provided in an embodiment of the present application;
[0083] Figure 6 A schematic diagram of another stress test scenario provided in an embodiment of the present application;
[0084] Figure 7 A signaling interaction diagram of a stress testing method provided in an embodiment of the present application;
[0085] Figure 8 A signaling interaction diagram of a stress-generating device actively querying a resource server for the latest ticket information during a stress test provided in an embodiment of the present application;
[0086] Fig. 9 A schematic diagram of writing and reading according to a hash map provided in an embodiment of the present application;
[0087] Fig.10 A schematic diagram of a centralized expiration of bill information provided in an embodiment of the present application;
[0088] Fig.11 A schematic diagram of uniformly refreshing bill information within the validity period provided by an embodiment of the present application;
[0089] Fig. 12A A schematic diagram of a stress test verification result provided in an embodiment of the present application;
[0090] Fig. 12B The total time consumed for loading the account every day during the stress test for multiple consecutive days provided in the embodiment of the present application;
[0091] Fig.13 A schematic diagram of the structure of a pressure testing device provided in an embodiment of the present application;
[0092] Fig.14 A schematic diagram of the structure of another pressure testing device provided in an embodiment of the present application;
[0093] Fig.15 A structural diagram of a server in an embodiment of the present application. DETAILED DESCRIPTION
[0094] In terms of stress testing technology, for both resource servers and stress-generating devices, the resource server will first obtain the ticket information after the account is refreshed. During the stress testing phase, the account ticket information in the resource server needs to be synchronized to the stress-generating device so that the stress-generating device can generate stress based on it. The following introduces and explains two implementation schemes for synchronizing ticket information to the stress-generating device.
[0095] In an account ticket synchronization solution (1) based on preloading before stress testing, in the preparation stage before stress testing, the stress-generating device is first started to preload the full amount of account ticket information. After the preloading is completed, during the subsequent stress testing process, the resource server stops refreshing the account ticket, and the stress-generating device directly reads the locally preloaded account ticket information for stress testing. For solution (1), after the preloading before stress testing is completed, the account ticket is no longer updated. As the stress testing progresses, the expiration rate of the account ticket increases with the later stress testing rounds. In addition, the time consumed for preloading before stress testing will increase with factors such as the number of accounts and the size of the ticket, affecting the efficiency of normalized stress testing.
[0096] In another account ticket synchronization solution (2) based on real-time loading for stress testing, during stress testing, the stress-generating device pulls the latest account ticket information from the resource server. After the pull is completed, the latest account ticket information is used to simulate the traffic and start stress testing. During the stress test, the resource server stops refreshing the tickets for each account. As the number of accounts increases, the adoption of solution (2) will lengthen the lead time for starting the stress test, affecting the synchronization of stress startup of different stress-generating devices. For example, stress-generating device A completes the pulling of all account tickets and starts stress testing at time t1, and stress-generating device B is slightly later and completes the pulling of all account tickets and starts stress testing at time t2. The timing of starting stress testing between the two is not synchronized, which will affect the impact of the traffic simulated by the two stress-generating devices on the business, and thus affect the effectiveness and accuracy of the stress test.
[0097] In the above two solutions (1) and (2), the stress-generating device only completes the traffic simulation based on the existing ticket information after it has been preloaded or pulled once. Since the stress-generating device itself lacks the ability to perceive whether the ticket information is expired, the problem of a high ticket expiration rate cannot be well solved. In order to solve this problem, the embodiment of the present application provides a stress testing method, device, stress-generating device, resource server, computer-readable storage medium and computer program product. In the technical solution provided by the embodiment of the present application, the connection between the stress-generating device and the resource server is maintained during the stress test, and the resource server synchronizes the refreshed account ticket information to the stress-generating device in real time through the connection, so that the stress-generating device can locally retain the latest account ticket information that the resource server can provide. This avoids the problem that the stress-generating device only generates pressure based on the initially obtained account ticket information and cannot be updated in time, resulting in the use of expired ticket information for stress. Compared with solutions (1) and (2), it can reduce the ticket expiration rate and improve the effectiveness of traffic simulation and stress testing effect.
[0098] Several terms that may be involved in the embodiments of the present application are explained below.
[0099] 1) Account ticket: The login status and various ticket information formed after the account logs in are used for subsequent verification when the account requests background services. During the full-link stress test, account ticket information needs to be carried to perform end-to-end traffic simulation.
[0100] 2) Refresh conflict: Account tickets have a certain timeliness. To ensure the validity of account tickets during stress testing, it is necessary to refresh the expired or about to expire tickets in a timely manner. If the ticket is in use and a background request is initiated at the time of refresh, it is defined as a refresh conflict.
[0101] 3) Ticket expiration rate: During the stress test, the ratio of the number of times that expired account tickets were used when initiating stress test requests to the total number of stress test requests initiated.
[0102] Figure 1 This is a diagram of an implementation architecture of a traffic simulation provided in an embodiment of the present application. Figure 1 As shown, traffic simulation mainly involves two parts: data protocol and traffic amplification. Among them, the data protocol part needs to involve protocol construction, account tickets and business data; traffic amplification needs to involve stress testing engine, distributed stress and stress control. The expiration rate of account tickets in the data protocol directly affects the effectiveness of stress testing. The technical solution of this application mainly improves the synchronization method and refresh of account tickets after refresh.
[0103] Figure 2 A stress test scenario is shown. Figure 2The stress test scenario shown includes multiple stress-generating devices, resource servers, and backend servers of the business to be tested. Each stress-generating device serves as a stress-generating node for distributed stress testing. Different stress-generating devices can communicate with resource servers. The stress-generating devices generate stress to the backend servers based on the account ticket information provided by the resource servers. Figure 2 As shown in Figure 1, multiple pressure-generating devices can simultaneously generate pressure to the same backend server. Figure 2 In the stress test scenario shown, the stress generating device is used as an independent stress generating node; in other possible implementations, the stress generating device includes multiple stress generating nodes, each of which can be Figure 2 The pressure-generating device shown generally communicates with the resource server and generates pressure for the backend server, such as Figure 3 Stress test scenario shown.
[0104] Figure 2 and Figure 3 In the stress test scenario shown, the resource server can complete the account ticket refresh, storage, and provide the refreshed account ticket information to each stress node. In addition, in other possible implementations, the account ticket refresh is implemented by an independent server, and the storage of the refreshed ticket and the interaction with each stress node in terms of account ticket information are implemented by another server (resource server). Figure 4 Here is another stress test scenario. Figure 4 The scenario shown includes: multiple pressure-generating devices, a resource server, a refresh server, and a background server for the business to be tested.
[0105] exist Figure 4In the scenario shown, the refresh server provides an application program interface API for ticket refresh, and the resource server is deployed with multiple nodes, including a master node and multiple slave nodes. After the resource server starts the master node election, each node of the resource server grabs the token to compete for becoming the master node. In the resource server, the ticket information of all accounts is stored in CKV, the basic information of the account is loaded from mysql, and no account information is resident in the memory of each node of the resource server. The master node will continuously poll all accounts, and refresh the ticket information when it finds an account that is about to expire, and update the data to CKV, and synchronize it to the pressure device through the connection with the pressure device. The slave node and the master node both provide a query interface for the account, and the above-mentioned query interface can be provided in batches, or a single query interface can be provided at a time. In an embodiment of the present application, the master node and the slave node of the resource server can read the data information in CKV. For the pressure device, the master node of the resource server also provides an interface for actively refreshing the ticket information of a certain account, that is, a refresh interface. If the pressure device finds that the ticket information of a certain account is expired during the pressure test, it can actively request to refresh the ticket information through the refresh excuse. The resource server can refresh the ticket information through the API request provided by the refresh server, and the refreshed ticket information is stored in the CKV and provided to the pressure-generating device.
[0106] The embodiments of the present application provide a new architecture for a pressure-generating node. Figure 5 A schematic diagram of the architecture of a pressure node. Figure 5 As shown in , the stress test node includes a stress test script, shared memory, and a resource agent. The resource agent can write to the shared memory, and the stress test script can read from the shared memory. The resource agent is pre-deployed on each distributed stress test node. The interaction between the stress test node and the resource server is mainly realized through the resource agent deployed on it. The resource agent preloads all accounts from the resource server and stores them in the shared memory. At the beginning of the stress test, the stress test script directly reads the shared memory to obtain the account's ticket information. During the stress test, the resource server refreshes the ticket information of the account that is about to expire in advance, and notifies the resource agent through a connection (such as a long connection), and the resource agent then writes the refreshed ticket information to the shared memory. The stress test script can read and use the latest account ticket information through the shared memory.
[0107] Figure 6 A schematic diagram of another stress test scenario provided in an embodiment of the present application. Figure 6 As shown in Figure 2, the architecture of the pressure node is similar to Figure 5 same. Figure 6 The interaction between the resource proxy and the resource server is highlighted in the Figure 6In the stress test scenario shown, the stress test script of the stress-generating node can notify the resource agent of the need to refresh a single account, and the resource agent can request to refresh the ticket information of the account through the refresh interface provided by the master node in the resource server. In addition, the master node and slave node of the resource server both provide query interfaces. The resource agent deployed on the stress-generating device can query the master node or slave node for the ticket information of the account through the query interface, for example, to inquire whether the ticket has been refreshed. The master node and slave node can obtain the latest ticket information of the account through CKV. Figure 6 The Ticket Assistant API shown in supports refreshing ticket information after account login.
[0108] In the embodiments of the present application, the pressure-generating device may be a terminal device, such as a terminal in the form of a desktop computer; in addition, the pressure-generating device may also be a server, such as a distributed server that implements distributed multiple pressure-generating nodes for traffic simulation. The server involved in this article may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. In addition, the server may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. As an example, the terminal device may specifically include but is not limited to computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Therefore, the specific form of the pressure-generating device is not limited in the embodiments of the present application.
[0109] Figure 7 The signaling interaction diagram of a stress test method provided in the embodiment of the present application is shown in FIG. In introducing the stress test method, the implementation of the stress test method is described from two perspectives: the stress device and the resource server. Figure 7 As shown, the stress testing method includes:
[0110] S701: Before the stress test begins, the stress-generating device sends a pre-loading request for ticket information of an account to be tested to a resource server.
[0111] In the embodiment of the present application, the stress test is for the service of the business to be tested. As an example, the business to be tested is a payment business. In actual applications, the link of the business to be tested may be long, involving multiple terminals and multiple business nodes. The stress test can be for part of the link or all of the link of the business. The stress test for the whole link is called the whole link stress test. The service of the business to be tested is technically supported by its backend server. The service of the business to be tested is stress tested. Specifically, a stress test request can be initiated to the backend server of the business to be tested by simulating traffic to perform stress testing.
[0112] In the embodiments of the present application, the account number mentioned is the account number corresponding to the service to be tested. For example, the service to be tested is a payment service of a payment platform, and the account number is an account number that has been registered with the payment platform and has opened a payment service on the payment platform. It is understandable that in the specific implementation of the present application, the collection, use and processing of relevant data such as account ticket information need to comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0113] The stress device initiates a preload request for the account ticket information to be tested, with the purpose of preparing the necessary materials for traffic simulation before the formal stress test. In the example implementation, the stress device includes a stress test script and a resource agent, wherein the resource agent is pre-deployed on the stress device. In this step, the stress device can specifically communicate with the resource server through the resource agent to send a preload request for the ticket information of the account to be tested.
[0114] S702: After receiving the preloading request from the pressure-generating device, the resource server provides the pressure-generating device with ticket information of the account to be tested according to the preloading request.
[0115] In an optional implementation, the structure of the resource server is as follows Figure 4 and Figure 6 As shown in . The resource agent can preload the ticket information of the full amount of accounts to be tested from the master node and / or the slave node in batches through the query interface. The master node and the slave node of the resource server can respond to the preload request for the full amount of account ticket information to be tested, and the master node and the slave node can read the account ticket information in the CKV.
[0116] S703: The pressure-generating device stores the preloaded ticket information of the account to be tested locally.
[0117] In an optional implementation, the stress-generating device locally uses a lock-free shared memory for the resource agent to perform write operations. The resource agent preloads the account ticket information to be tested through the connection with the resource server and writes it into the local shared memory. The shared memory stores the latest synchronized account ticket information of the stress-generating device. Since the shared memory can also be used for read operations by the stress test script, the account ticket information stored in the shared memory can be read and used by the stress test script during the stress test.
[0118] S701-S703 describe the process of preloading account ticket information from the resource server by the stress device. S704-S705 describe the interaction between the stress device and the resource server due to the refresh of ticket information during the stress test after the preloading is completed.
[0119] S704. During the stress test, the resource server pushes the ticket information after the account is refreshed through the connection established with the stress-generating device.
[0120] That is to say, in the embodiment of the present application, the resource server does not stop refreshing the account ticket information during the stress test. Once the master node of the resource server polls and finds that the ticket information of one or some accounts to be tested is about to expire, the ticket will be refreshed, and the refreshed ticket information will be provided to the stress device through the connection (such as a long connection) established with the resource agent. For example, accounts K1~K1000 are all accounts to be tested. When the resource server polls and finds that the ticket information of account K99 is about to expire, the master node will request the ticket refresh API to refresh the ticket information of the account. After the refresh, the refreshed ticket information of account K99 is updated to CKV. The master node pushes the refreshed ticket information of account K99 to the resource agent through a long connection.
[0121] S705: The pressure-generating device synchronizes the refreshed ticket information of the account pushed by the resource server to the local device.
[0122] As described above, the ticket information of the account pushed by the resource server after the refresh arrives at the resource agent first, and the resource agent then writes it to the local stress device. For example, it is written to the shared memory for the stress test script to read and use. Using the above example, the ticket information of accounts K1 to K10000 (a total of 10,000 accounts) pre-loaded in the original storage in the shared memory, after the resource server refreshes the ticket of account K99 and pushes the long connection, the shared memory stores the latest ticket information of account K99 written by the resource agent, replacing the ticket information of account K99 stored in the past (including storage after pre-loading).
[0123] It should be noted that the above steps S704-S705 are continuously performed during the stress test of the stress-generating device. That is, due to the connection established between the stress-generating device and the resource server, once the ticket information of an account in the resource server is refreshed, it can be pushed to the stress-generating device so that the ticket information is refreshed synchronously.
[0124] S706: The stress-generating device uses the latest bill information of the account to initiate a stress test request to the backend server of the service to be tested.
[0125] The stress generation device generates stress through a stress test script. Specifically, the stress test script can read the latest ticket information of the local account; the stress test script initiates a stress test request to the background server of the service to be tested according to the read ticket information.
[0126] In actual applications, the stress device can initiate stress test requests in multiple rounds according to the stress test requirements for the backend server of the business to be tested in the specific business scenario. The time interval between multiple rounds of stress can be set according to the specific stress test requirements, and the value of the time interval between adjacent rounds is not limited here.
[0127] As an example, three rounds of stress test requests (the first round, the second round and the third round) are initiated. The accounts involved in the second round include accounts K3001 to K7000, among which the ticket information of accounts K6500 to K7000 is refreshed during the first round of stress testing. In the second round of stress testing, the ticket information of accounts K3001 to K6499 stored locally on the stress device and the ticket information of accounts K6500 to K7000 that are most recently refreshed and synchronized to the stress device can be used for stress testing. It can be seen that S706 in the embodiment of the present application is also a step that is continuously performed according to the setting of the stress round.
[0128] In the technical solution of the present application, before the stress test begins, the stress-generating device preloads the ticket information of the account to be tested from the resource server and stores it locally; during the stress test, the resource server does not stop refreshing the ticket information, and the stress-generating device synchronizes the refreshed ticket information of the account pushed by the resource server to the local via the connection established with the resource server. As a result, the stress-generating device can timely synchronize the latest ticket of the account on the resource server side locally and apply it to the stress test. During the stress test, by timely synchronizing the refreshed account ticket information on the stress-generating device, the possibility of using expired tickets for stress-generating is reduced, thereby reducing the ticket expiration rate, improving the effectiveness of traffic simulation, and improving the stress test effect.
[0129] The following describes the pulling and refreshing synchronization of ticket information in the stress test method in stages. 1. Cold start stage: In the cold start stage, the entry condition is: there is no data in the shared memory at startup, or the time difference from the last write time to the current time exceeds the configured threshold. The actions performed in the cold start stage are: the resource agent requests the full amount of account resources from the resource server in batches, and stores the account data in the corresponding area of the shared memory after pulling it. 2. Warm start stage: The entry condition in the warm start stage is: there is data in the shared memory at startup and the time difference from the last write time to the current time does not exceed the configured threshold. 3. Hot update stage: After the cold start or warm start, the resource agent shakes hands with the master node of the resource server to establish a long connection, sends a heartbeat packet every 5 seconds (the frequency can be set), and accepts the push of the refreshed ticket information from the master node in a timely manner, and then updates the corresponding account data in the shared memory.
[0130] The technical solution of the present application enables the stress test script to perceive the latest account ticket information in real time through shared memory, thereby solving the problems of long preparation time for accounts and account ticket expiration in stress testing. It has a low probability of refresh conflict in normalized full-link stress testing with a high concurrency performance impact base for stress testing.
[0131] In an embodiment of the present application, the stress test script of the stress-generating device has the ability to identify whether the account ticket information is expired. When the stress test script identifies that the account ticket information is expired, it notifies the resource agent deployed on the stress-generating device. The resource agent can proactively initiate a query request for the latest ticket information to the resource server when the account ticket information locally stored in the stress-generating device expires. The following describes the process of the stress-generating device proactively initiating a query request to the resource server in the stress test method provided in the embodiment of the present application.
[0132] Figure 8 A signaling interaction diagram of a stress test during which a stress-generating device actively queries a resource server for the latest ticket information is provided in an embodiment of the present application. Figure 8 As shown, during the stress test, the stress-generating device can actively query the resource server for the latest ticket information, and the resource server will perform subsequent actions based on the ticket information it holds. The following is an introduction in steps. In the stress test scenario illustrated in the signaling interaction diagram, the resource server refreshes the account ticket information through the ticket assistant.
[0133] S801. During a stress test, the stress-generating device determines that first ticket information of a target account stored locally during the stress test has expired, and initiates a query request for the latest ticket information of the target account to a resource server.
[0134] During the stress test, there is a possibility that the locally stored account ticket information expires. In the embodiment of the present application, the stress test script can sense this situation and notify the resource agent to query the resource server for the latest ticket of the account with expired ticket information. For the sake of clarity, in this embodiment, the target account is used as an example of an account with expired ticket information, and the target account is any account to be tested. The process of querying the latest ticket information of any account with expired ticket information can refer to the relevant details of the target account introduced in this embodiment.
[0135] In the embodiment of the present application, for the sake of distinction, the latest version of the ticket information of the target account stored locally in the pressure-generating device is named the first ticket information. In the embodiment of the present application, version information is introduced for the ticket information of the account, and the new and old conditions reflected by the version are used to avoid the problem of forced refresh causing the old version to overwrite the new version of the ticket. For example, for the ticket information of the same account with different new and old conditions, the new and old conditions can be distinguished based on the version information of the ticket information.
[0136] The purpose of the pressure-generating device initiating a query request to the resource server is to obtain the ticket information of the target account that is newer than the first ticket information version, so as to avoid using expired first ticket information for pressure generation. The query request initiated by the pressure-generating device to the resource server carries the version information of the first ticket information. This facilitates the resource server to compare the version of the ticket information based on the detailed version information of the first ticket after receiving the query request.
[0137] S802: After receiving a query request for the latest ticket information of a target account initiated by a pressure-generating device, the resource server obtains a version comparison result according to the version information of the first ticket information in the query request and the version information of the second ticket information stored in the resource server.
[0138] In an embodiment of the present application, the second ticket information is the latest ticket information of the target account stored locally when the resource server receives the query request. By comparing the version of the first ticket information and the version of the second ticket information, the resource server can determine whether the second ticket information is the ticket information refreshed after the first ticket information. After the resource server obtains the version comparison result, it can provide the latest ticket information corresponding to the query request to the pressure-generating device based on the version comparison result. Specifically, if the version of the second ticket information is later than the version of the first ticket information, S803 is executed; if the version of the second ticket information is earlier than or equal to the version of the first ticket information, S804-S806 are executed.
[0139] S803: The resource server provides the second ticket information to the pressure-generating device.
[0140] In this step, since the resource server itself holds the second ticket information which is updated later than the first ticket information, it can directly respond to the demand of the pressure-generating device and provide the second ticket information to the pressure-generating device.
[0141] S804: The resource server requests to refresh the ticket information of the target account.
[0142] Since the second ticket information held by the resource server itself cannot meet the needs of the pressure-generating device, the resource server can request the ticket assistant to refresh the ticket information of the target account. It is understandable that by refreshing with the ticket assistant, the resource server should be able to obtain valid ticket information of the target account that has not expired.
[0143] S805: The resource server obtains the third ticket information of the target account.
[0144] The version of the third ticket information is later than the version of the first ticket information, that is, the resource server obtains valid third ticket information by requesting the ticket assistant to refresh the ticket information of the target account. The third ticket information can meet the needs of the pressure-generating device, so S806 can be executed to provide the third ticket information to the pressure-generating device.
[0145] S806: The resource server provides the third ticket information to the pressure-generating device.
[0146] In actual applications, no matter the branch of S803 or the branch of S804-S806 is executed in the technical solution of the present application, S807 needs to be executed again.
[0147] S807: The pressure-generating device receives the latest ticket information provided by the resource server based on the query request, and synchronizes the latest ticket information provided by the resource server to the local device.
[0148] The synchronization method of this step is similar to that described in the previous embodiment, which can be that the resource proxy receives the latest ticket information of the target account provided by the resource server and stores it in the shared memory of the pressure-generating device. As described above, if the version of the second ticket information in the resource server is later than the version of the first ticket information, the latest ticket information provided by the resource server is the second ticket information, and the second ticket information is the latest ticket information of the target account stored when the resource server receives the query request; or, if the version of the second ticket information in the resource server is earlier than or equal to the version of the first ticket information, the latest ticket information provided by the resource server is the third ticket information, and the third ticket information is the latest ticket information of the target account obtained after the resource server requests to refresh the ticket information of the target account.
[0149] In an embodiment of the present application, the stress test script of the stress-generating device can determine whether the ticket information stored locally in the stress-generating device is expired, and query to obtain a new version of the ticket information that has not expired when it is expired, thereby compensating for the problem that the expiration of the ticket information affects the stress test effect when the resource server is not refreshed in time. The introduction of version information can distinguish the ticket information refreshed at different times, and avoid relatively old ticket information covering the new version of the ticket information of the same account. Through the compensation mechanism of the above-mentioned query method and the introduction of version information, the probability of the stress-generating device using a valid new version of the ticket information for stress generation can be increased, the ticket expiration rate can be reduced, and the effectiveness of the traffic simulation and the effect of the stress test can be guaranteed.
[0150] In an embodiment of the present application, the pressure-generating device locally stores the account ticket information received by the resource agent from the resource server. Shared memory allows write operations and read operations to be performed simultaneously, so the use of shared memory is suitable for realizing efficient synchronization of account ticket information in this solution. In the shared memory fixed-length storage, the reading and writing of different accounts in the shared memory will not affect each other. A memory block in the shared memory is configured for each account, so that the account and the memory block correspond one to one. The following statistics are combined with the example reading speed and writing speed to calculate the probability of conflict with the read operation when writing a certain account in the shared memory at a time.
[0151] In this example, assume that the account pool has 10 million accounts, the read operation speed is 1 million accounts / second, the write operation speed is 1000 accounts / second, and the write operation speed is 1000 accounts / second. The write operation of a single memory block in the shared memory can be completed within 1 microsecond. The probability P of a single write to an account conflicting with a read operation is 冲突 for:
[0152] P 冲突 =100w*10 -6 / 1000w=10 -7
[0153] 100w*10 -6 Indicates the number of accounts read within 1 microsecond, 1 million * 10 -6 =1, that is, 1 account is read in 1 microsecond; dividing this result by 1000w, it means that the probability of reading a specific account in the account pool in 1 microsecond is 10 -7 According to the writing speed of 1000 accounts / second, combined with the above probability, theoretically 10 4 A conflict occurs every second. The stress test time is usually 10 minutes. Given that the probability of conflict is very small, by comparing the cost and consumption of using multiple types of locks in shared memory, a lock-free mode can be used. The following Table 1 compares multiple lock solutions.
[0154] Table 1
[0155] Comparison plan Features Pthread mutex lock Read performance loss, maintaining 10 million locks, high cost semaphore Read performance loss and high cost RCU Occupies twice the storage No lock Small conflicts and low memory usage
[0156] In order to prevent the stress test script from reading dirty data from the shared memory when a read-write conflict occurs with a small probability, in the embodiment of the present application, a verification technology can be used on the stress-generating device to verify the data read by the stress test script. If the verification passes, the data can be used again. If the verification fails, the data will not be used and needs to be read again. Specifically, after the stress test script reads the latest ticket information of the local account, the stress test method in the embodiment of the present application also includes:
[0157] Performing a cyclic redundancy check on the information read from the shared memory through the stress test script;
[0158] If the verification passes, the stress test script is allowed to use the read information; if the verification fails, the stress test script is used to re-read the latest ticket information of the local account from the shared memory.
[0159] Cyclic Redundancy Check (CRC) is a fast algorithm that generates a short fixed-bit check code based on data such as network data packets or computer files. It is mainly used to detect or check errors that may occur after data transmission or storage. CRC uses the principle of division and remainder to realize the function of error detection, and has the advantages of clear principle and simple implementation. In the embodiment of the present application, through the shared memory lock-free mode + CRC check scheme, under the premise of low memory usage and low probability of conflict in reading and writing account ticket information, dirty reading of data can be further avoided, thereby improving the effect of stress testing.
[0160] In practical applications, for stress testing scripts, improving the reading speed is the key to achieving efficient stress testing. If the data in the memory block is read by polling, it is possible that the account ticket information read is not the account ticket information required for this round of stress testing. Based on this, the solution provided in the embodiment of the present application further proposes that a mapping relationship between account index information and the accounts involved in the shared memory can be pre-built. When it is necessary to read the data in the shared memory, it is only necessary to use the target index information associated with the stress testing requirements (where the target index information is of the same type as the account index information) to quickly index the account ticket information required for the stress testing requirements based on the pre-built mapping relationship and apply it to the stress test. Specifically, the stress testing method provided in the embodiment of the present application also includes:
[0161] Construct a hash map (Hash Map) of the account index information and the accounts involved in the shared memory.
[0162] As an example, the account index information is the account type information, or the account index information is the identification information of the memory block in the shared memory. The memory block has one-to-one corresponding identification information. As mentioned earlier, the memory block and the account are in a one-to-one correspondence, so the account can also be uniquely determined based on the identification information. The account type information can be an attribute assigned to the account after the account has activated certain business functions, or the account type information can also be determined in other ways, such as the account type information determined based on the account's activity and other characteristics. In an embodiment of the present application, the account index information can be used as an element in constructing a hash map to facilitate local reading of account ticket information as an index.
[0163] The reading the latest ticket information of the local account through the stress test script includes: the stress test script obtains target index information; the stress test script reads the latest ticket information of the account corresponding to the target index information based on the hash map.
[0164] Fig. 9 A schematic diagram of writing and reading based on a hash map is provided for an embodiment of the present application. As shown in the figure, when the resource agent writes account information to the shared memory, it writes based on the hash map. For example, according to the hash map, the corresponding account ticket information is written to the memory block; after the writing is completed, the stress test script completes the indexing of the information based on the target index information, that is, reads the latest ticket information from the shared memory.
[0165] In an optional implementation scheme, the stress test script is implemented through a software development kit SDK, which provides an input interface for account type information and identification information of memory blocks, so that the stress test script can determine the target index information based on the information obtained in the interface. It can be understood that after the hash mapping is pre-established, when a stress test is required, the target index information can be determined based on the actual stress test requirements, the type of business to be tested, etc. The stress test script then efficiently reads the required account ticket information in the shared memory based on the target index information for stress. It can be seen that in the embodiment of the present application, by establishing a hash mapping between the account index information and the account involved in the shared memory, accelerated access to the shared memory can be achieved, which is conducive to efficient stress in the stress test scenario.
[0166] During stress testing, it is very likely to encounter abnormal situations. For example, if the stress test finds that the bill information is expired, the above article introduces the compensation mechanism of active refresh. In addition, it is also possible to encounter batch preloading failures and disconnection between the stress device and the resource server. The embodiments of this application also provide solutions for the above two situations.
[0167] For the scenario of preloading failure, in an embodiment of the present application, when the pressure-generating device fails to preload the ticket information of the account to be tested from the resource server, the state of the memory block corresponding to the account that failed to preload in the shared memory is marked as the first state, wherein the first state indicates that the preloading failed; then, the ticket information of the account corresponding to the memory block in the first state is preloaded from the resource server at intervals, until the preloading is successful, the state of the memory block is changed from the first state to the second state, wherein the second state indicates that the preloading is successful. By specially marking the state in the memory block of the shared memory, the pressure-generating device can be assisted in identifying the memory blocks corresponding to the accounts that failed to be preloaded, thereby reloading the relevant information of the accounts for these memory blocks, and avoiding missing the acquisition of the ticket information of these accounts after the preloading fails.
[0168] In the case of disconnection (connection failure), in an embodiment of the present application, the resource server may record the connection failure information with the pressure-generating device, wherein the connection failure information includes the connection failure time. The resource server retries to establish a connection with the pressure-generating device after a preset time interval has passed since the connection failure time. The preset time interval can be set by itself, for example, it can be set to 30 seconds. In practical applications, each time the resource agent fails to connect to the resource server, the resource server will notify the resource agent of the fact of the connection failure, record the notification event as connection failure information, and maintain it through a list. The resource server can record the connection failure information through a temporary area of an information list. In order to avoid storage pressure caused by storing unnecessary or long-past connection failure information, the size of the list can be controlled. For example, the control list records a maximum of 50 pieces of information. By recording the connection failure information and retrying after a preset time interval, and notifying the resource agent of the connection failure, it is helpful to achieve timely retry after the connection is disconnected, and then achieve a stable connection again as soon as possible, reducing the impact on the synchronization effect of the latest bill information.
[0169] In addition, in other implementations, if the pressure-generating device fails to connect to the resource server, and the continuous long-term connection failure affects the synchronization of the ticket from the resource server to the pressure-generating device, so that the ticket information in the pressure-generating device has expired, the pressure-generating device can also independently predict the ticket information by calling the pre-trained ticket information prediction model, thereby completing the refresh. In specific implementation, if the pressure-generating device fails to connect to the resource server, the moment of the connection failure can be recorded, and an attempt can be made to reconnect to the resource server within the first preset time after the moment. If the reconnection fails once, the reconnection continues at a preset time interval. If the reconnection fails within the first preset time, and taking the target account as an example, the ticket information of the target account stored locally by the pressure-generating device has expired, it is necessary to call the ticket information prediction model to actively try to refresh the ticket information. The ticket information prediction model is independent of the resource server and can be called by the pressure-generating device. The ticket information prediction model can predict the next ticket information based on the N most recent ticket information of a certain account. Wherein, N is a positive integer greater than 1, as an example, N = 5. The ticket information prediction model is obtained through training with a large amount of account ticket information. It can grasp the rules of ticket refresh more accurately, so as to achieve prediction more accurately. It can be used temporarily when the pressure device fails to connect to the resource server to achieve ticket prediction.
[0170] When it is impossible to successfully reconnect to the resource server within the first preset time after the failure to connect to the resource server, and the ticket information of the target account stored locally has expired, the pressure-generating device can generate a ticket prediction request based on the record of the failure to reconnect to the resource server within the first preset time after the failure to connect to the resource server, and the version information of the ticket information of the target account stored locally. The ticket information prediction model is called through the ticket prediction request. In an optional implementation, the ticket prediction request serves as a "key" for calling the ticket information prediction model, which enables the ticket information prediction model to be in an available state. It should be noted that the model calling function of the ticket prediction request enables the ticket prediction model to predict ticket information only for accounts whose local ticket information has expired and cannot be updated through timely and successful reconnection, ensuring that only a small amount of ticket information is obtained through prediction when pressure is generated, and the interconnection with the resource server is still the most important update synchronization channel among the ticket information used.
[0171] In order to predict the latest ticket information of the target account when the connection with the resource server fails, the pressure-generating device inputs the target account's most recent N ticket information into the ticket information prediction model; and obtains the latest ticket information of the target account predicted by the ticket information prediction model based on the input N ticket information. Finally, the pressure-generating device replaces the locally expired ticket information of the target account with the predicted latest ticket information. Specifically, the predicted latest ticket information can be stored in the memory block corresponding to the target account in the shared memory.
[0172] In actual applications, the ticket information predicted by the ticket information prediction model in the shared memory can be specially marked. If the stress device and the resource server are successfully reconnected again, and the latest ticket information of the target account provided by the resource server is obtained through the connection with the resource server, the information can be replaced with the ticket information of the target account with special marks in the shared memory. In this way, the latest ticket information provided by the resource server is used as much as possible during the stress test process to ensure the effect of the stress test.
[0173] In one example, account ticket refresh requires calling the login service of the business platform, and concurrency needs to be controlled. Taking the example of refreshing the ticket information of 2,000 accounts per second, it takes 8.3 minutes to fully refresh 1 million accounts, and 83 minutes to refresh 10 million accounts. Assuming that the validity period of the ticket is 24 hours, these tickets will expire 24 hours after the first refresh, resulting in a large number of tickets having to be refreshed. If the stress test happens to be at this time, the ticket may frequently expire. In addition, when the resource server refreshes the ticket, the original ticket of the same account will also become invalid. Even if the trigger compensation logic described above is used at this time (see Figure 8), which will also create greater pressure on the background. Fig.10 A schematic diagram of centralized expiration of bill information provided in an embodiment of the present application.
[0174] In view of the above problems, the embodiment of the present application proposes that the ticket information can be refreshed in advance before expiration. For example, the ticket can be refreshed one hour before expiration. In addition, the next refresh time of the collectively refreshed ticket information can be scattered within the validity period after the centralized refresh. Specifically, during the stress test, the resource server pushes the refreshed ticket information of the account through the connection established with the stress-generating device, including:
[0175] After the resource server centrally refreshes the ticket information of multiple accounts to be tested during the stress test, it pushes the refreshed multiple ticket information through the connection established with the stress-generating device;
[0176] The resource server evenly distributes the next scheduled refresh time of the multiple ticket information refreshed in a centralized manner into the validity period of the multiple ticket information refreshed in a centralized manner;
[0177] The resource server refreshes the corresponding ticket information according to the next scheduled refresh time of the multiple ticket information that are refreshed centrally;
[0178] The resource server pushes the refreshed ticket information through the connection established with the pressure-generating device.
[0179] Fig.11 A schematic diagram of uniformly refreshing bill information within the validity period provided by an embodiment of the present application. Fig.11 As shown, in the embodiment of the present application, by arranging the next scheduled refresh time of the ticket information after the centralized refresh, the problem of concentrated expiration of the ticket information can be avoided, and the frequency of subsequent ticket refresh is close to uniform. In this way, the pressure on the background when facing refresh is reduced. Under the uniformly distributed scheduled refresh time, the ticket information of about 120 accounts is updated per second.
[0180] There are two scenarios in specific stress testing:
[0181] In the first scenario, the account ticket information updated every second is not used by the stress test script at this time. Then the resource server can directly refresh and subsequently synchronize the ticket information.
[0182] In the second scenario, the account ticket information updated every second happens to be used by the stress test script at this time, which is a refresh conflict. Taking 100,000 accounts per second as an example, the expected value of refresh conflicts per second is 1, that is, 1 out of 100,000 times per second will happen to use an expired account. Figure 8The compensation logic shown ensures that the ticket information of the account can obtain valid and latest updated ticket information when the pressure-generating device requests active refresh.
[0183] Based on the stress test scheme introduced in the embodiment of this application, an experimental verification was conducted to simulate a stress test of 3 million accounts per second, and the account ticket information was obtained and the validity was verified in each test process. At the same time, indicators such as time consumption and CRC check failure were monitored. Fig. 12A A schematic diagram of a stress test verification result provided in an embodiment of the present application. Fig. 12A As shown, there are 89,999,197 requests in total, with an average success rate of 2,747,308 requests per second, an average failure rate of 42 requests per second, and a total success rate of 100%. Fig. 12A The data pointed by the small and medium rectangular cursors are shown in the central rectangular box in the figure. Under the date and time, the number of successful transactions per second is 2994690, the number of failed transactions per second is 51, and the success rate is 100%. In addition, the various indicators are as follows:
[0184] The effective proportion of accounts is 99.998%; the average time to randomly obtain an account is 17 microseconds; the average time to directly query the ticket information is 76 milliseconds; and the average time to actively refresh is 414 milliseconds.
[0185] In addition, we also counted the number of times within 14 days that the CRC check failed when obtaining the account ticket information due to account read and write conflicts, which occurred a total of 4 times, which was in line with expectations.
[0186] This application also actually applies the stress testing method introduced above. The test results show that the average loading time during the stress test for 10 million accounts is 3.7 seconds. Fig. 12B The total time consumed for loading the account every day for the pressure test for consecutive days provided in the embodiment of the present application. Fig. 12B It can be seen that the daily loading time fluctuates between 0 and 4 seconds. Taking August 6, 2021 as an example, it takes more than 3.7 seconds. The average loading time is about 3.7 seconds. During the actual stress test, the expiration rate of account ticket information is close to 0, and the simulated traffic is 100%.
[0187] Based on the pressure testing method provided in the above embodiment, the present application also provides a pressure testing device. Fig.13 Provide explanation. Fig.13 This is a schematic diagram of the structure of the pressure testing device provided in the embodiment of the present application. Fig.13 The pressure test device shown is applied to pressure generating equipment, including:
[0188] The bill preloading unit 1301 is used to preload the bill information of the account to be tested from the resource server and store it locally before the stress test starts; wherein the account is the account corresponding to the service to be tested;
[0189] The ticket synchronization unit 1302 is used to synchronize the ticket information of the account after being refreshed pushed by the resource server to the local computer through the connection established with the resource server during the stress test;
[0190] The stress testing unit 1303 is used to initiate a stress testing request to the backend server of the service to be tested by using the latest ticket information of the local account.
[0191] Optionally, the pressure testing device further comprises:
[0192] A request unit, configured to initiate a query request for the latest ticket information of the target account to the resource server when it is determined that the first ticket information of the target account stored locally during the stress test has expired; wherein the target account is any account to be tested, the first ticket information is the latest version of the ticket information of the target account stored locally, and the query request carries version information of the first ticket information;
[0193] A receiving unit, configured to receive the latest ticket information provided by the resource server based on the query request, and synchronize the latest ticket information provided by the resource server to a local device;
[0194] Among them, if the version of the second ticket information in the resource server is later than the version of the first ticket information, the latest ticket information provided by the resource server is the second ticket information, and the second ticket information is the latest ticket information of the target account stored when the resource server receives the query request; or, if the version of the second ticket information in the resource server is earlier than or equal to the version of the first ticket information, the latest ticket information provided by the resource server is the third ticket information, and the third ticket information is the latest ticket information of the target account obtained after the resource server requests to refresh the ticket information of the target account.
[0195] Optionally, the stress generating device includes a stress test script and a resource agent; and the ticket synchronization unit is specifically used for:
[0196] Synchronize the refreshed ticket information of the account pushed by the resource server to the local computer through the connection established between the resource proxy and the resource server;
[0197] The pressure measurement unit is specifically used for:
[0198] Read the latest ticket information of the local account through the stress test script;
[0199] The stress test script initiates a stress test request to the backend server of the service to be tested according to the read ticket information.
[0200] Optionally, the stress-generating device locally uses a shared memory in a lock-free mode for the resource agent to perform write operations and for the stress test script to perform read operations; the stress test apparatus further includes: a verification unit, which is used to perform the following operations:
[0201] Performing a cyclic redundancy check on the information read from the shared memory through the stress test script;
[0202] If the verification passes, the stress test script is allowed to use the read information; if the verification fails, the stress test script is used to re-read the latest ticket information of the local account from the shared memory.
[0203] Optionally, the pressure testing device further comprises:
[0204] A mapping relationship building unit, used to build a hash map between the account index information and the account involved in the shared memory;
[0205] The pressure measurement unit is specifically used for:
[0206] The stress test script obtains target index information, wherein the target index information is associated with the stress test requirement, and the target index information and the account index information are of the same type of information;
[0207] The stress test script reads the latest ticket information of the account corresponding to the target index information based on the hash map.
[0208] Optionally, the account index information is account type information, or the account index information is identification information of a memory block in a shared memory; the memory block corresponds one-to-one to the identification information, and the memory block corresponds one-to-one to the account.
[0209] Optionally, the pressure testing device further comprises:
[0210] A status marking unit, configured to mark the status of a memory block in the shared memory corresponding to the account for which preloading failed as a first status when preloading ticket information of the account to be tested fails from the resource server; wherein the first status indicates preloading failure;
[0211] A reconnection unit, configured to retry at intervals to preload ticket information of an account corresponding to the memory block in the first state from the resource server;
[0212] The state marking unit is further used to change the state of the memory block from the first state to the second state until the preloading is successful; wherein the second state indicates that the preloading is successful.
[0213] Optionally, in the embodiment of the present application, the pressure generating device further includes:
[0214] A model calling unit, configured to call a ticket information prediction model when the client fails to reconnect to the resource server within a first preset time after the connection with the resource server fails and the ticket information of the target account stored locally has expired; wherein the target account is any account to be tested;
[0215] A prediction unit, configured to predict the latest bill information of the target account by using the bill information prediction model;
[0216] The information replacement unit is used to replace the locally expired ticket information of the target account with the predicted latest ticket information.
[0217] Optionally, the model calling unit is specifically used for:
[0218] If reconnection with the resource server cannot be successful within a first preset time after the connection with the resource server fails, and the ticket information of the target account stored locally has expired, a ticket prediction request is generated according to a record of failure to reconnect with the resource server within the first preset time after the connection with the resource server fails, and version information of the ticket information of the target account stored locally;
[0219] calling the bill information prediction model through the bill prediction request;
[0220] The prediction unit is specifically used for:
[0221] Inputting the most recent N bill information of the target account into the bill information prediction model; N is a positive integer greater than 1;
[0222] The latest bill information of the target account predicted by the bill information prediction model based on the N input bill information is obtained.
[0223] The present application also provides another stress testing device, which is applied to a resource server. The structure of the stress testing device is as follows: Fig.14 As shown, including:
[0224] A receiving unit, used for receiving a preload request of a pressure generating device before the pressure test starts;
[0225] A first sending unit, configured to provide the pressure-generating device with ticket information of an account to be tested according to the preloading request; wherein the account is an account corresponding to the service to be tested;
[0226] The second sending unit is used to push the refreshed ticket information of the account through the connection established with the stress-generating device during the stress test, so that the stress-generating device can use the latest ticket information of the account to initiate a stress test request to the background server of the business to be tested.
[0227] Optionally, the receiving unit of the stress testing device is further used to: during the stress test, receive a query request for the latest ticket information of the target account initiated by the stress-generating device; wherein the target account is any account to be tested; the query request is a request initiated by the stress-generating device when it determines that the first ticket information of the target account stored locally has expired, and the query request carries version information of the first ticket information; the first ticket information is the latest version of the ticket information of the target account stored locally by the stress-generating device;
[0228] The pressure testing device further includes: a version comparison unit and a third sending unit;
[0229] The version comparison unit is used to obtain a version comparison result according to the version information of the first ticket information in the query request and the version information of the second ticket information stored in the resource server; the second ticket information is the latest ticket information of the target account stored when the resource server receives the query request;
[0230] The third sending unit is used to provide the latest ticket information corresponding to the query request to the pressure issuing device according to the version comparison result.
[0231] Optionally, the third sending unit is specifically used to: if the version of the second ticket information is later than the version of the first ticket information, provide the second ticket information to the pressure-issuing device; if the version of the second ticket information is earlier than or equal to the version of the first ticket information, request to refresh the ticket information of the target account to obtain the third ticket information of the target account; provide the third ticket information to the pressure-issuing device; wherein the version of the third ticket information is later than the version of the first ticket information.
[0232] Optionally, the second sending unit in the pressure testing device is specifically used to:
[0233] After the ticket information of multiple accounts to be tested is centrally refreshed during the stress test, the refreshed multiple ticket information is pushed through the connection established with the stress-generating device;
[0234] Evenly distribute the next scheduled refresh time of the multiple bill information that are refreshed centrally to the validity period of the multiple bill information that are refreshed centrally;
[0235] Refresh the corresponding bill information according to the next scheduled refresh time of the multiple bill information that are refreshed centrally;
[0236] The refreshed ticket information is pushed through the connection established with the pressure-generating device.
[0237] Optionally, the pressure testing device further comprises:
[0238] A recording unit, configured to record connection failure information after the connection with the pressure generating device fails; the connection failure information includes the connection failure time;
[0239] The reconnection unit is used to retry to establish a connection with the pressure generating device after a preset time interval has passed since the connection failed.
[0240] The following introduces the structure of the pressure generating equipment in the form of a server.
[0241] Fig.15 : This is a schematic diagram of a server structure provided in an embodiment of the present application. The server 900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 922 (for example, one or more processors) and a memory 932, and one or more storage media 930 (for example, one or more mass storage devices) storing application programs 942 or data 944. Among them, the memory 932 and the storage medium 930 can be short-term storage or permanent storage. The program stored in the storage medium 930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 922 can be configured to communicate with the storage medium 930 and execute a series of instruction operations in the storage medium 930 on the server 900.
[0242] The server 900 may also include one or more power supplies 926, one or more wired or wireless network interfaces 950, one or more input and output interfaces 958, and / or one or more operating systems 941, such as Windows Server 2000. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM etc.
[0243] The CPU 922 is used to execute the following steps:
[0244] Before the stress test begins, the ticket information of the account to be tested is preloaded from the resource server and stored locally; wherein the account is the account corresponding to the business to be tested;
[0245] During the stress test, the ticket information of the account after being refreshed pushed by the resource server is synchronized to the local computer through the connection established with the resource server;
[0246] Using the latest ticket information of the local account, a stress test request is initiated to the backend server of the service to be tested.
[0247] The server of the above structure can also be used as an implementation form of a resource server. Therefore, when the resource server of the above form is applied to the embodiment of the present application, the CPU 922 can be used for:
[0248] Before the stress test begins, receive a preload request from the stress-generating device;
[0249] Providing the ticket information of the account to be tested to the pressure-generating device according to the preload request; wherein the account is the account corresponding to the service to be tested;
[0250] During the stress test, the refreshed ticket information of the account is pushed through the connection established with the stress-generating device, so that the stress-generating device uses the latest ticket information of the account to initiate a stress test request to the backend server of the service to be tested.
[0251] An embodiment of the present application also provides a computer-readable storage medium for storing program code, wherein the program code is used to execute any implementation of a stress testing method described in the aforementioned embodiments.
[0252] An embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute any one of the implementations of a stress testing method described in the aforementioned embodiments.
[0253] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0254] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the system is only a logical function division. There may be other division methods in actual implementation, such as multiple systems can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0255] The systems described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0256] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0257] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (full name in English: Read-Only Memory, English abbreviation: ROM), random access memory (full name in English: Random Access Memory, English abbreviation: RAM), disk or optical disk and other media that can store program codes.
[0258] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A stress testing method, characterized in that: Applied to pressure generating equipment, the method comprises: Before the stress test begins, the ticket information of the account to be tested is preloaded from the resource server and stored locally; wherein the account is the account corresponding to the business to be tested; During the stress test, the ticket information of the account after being refreshed pushed by the resource server is synchronized to the local computer through the connection established with the resource server; Using the latest ticket information of the local account, a stress test request is initiated to the backend server of the service to be tested.
2. The pressure testing method according to claim 1, characterized in that: Also includes: When it is determined that the first ticket information of the target account stored locally during the stress test has expired, a query request for the latest ticket information of the target account is initiated to the resource server; wherein the target account is any account to be tested, the first ticket information is the latest version of the ticket information of the target account stored locally, and the query request carries version information of the first ticket information; Receiving the latest ticket information provided by the resource server based on the query request, and synchronizing the latest ticket information provided by the resource server to the local; Among them, if the version of the second ticket information in the resource server is later than the version of the first ticket information, the latest ticket information provided by the resource server is the second ticket information, and the second ticket information is the latest ticket information of the target account stored when the resource server receives the query request; or, if the version of the second ticket information in the resource server is earlier than or equal to the version of the first ticket information, the latest ticket information provided by the resource server is the third ticket information, and the third ticket information is the latest ticket information of the target account obtained after the resource server requests to refresh the ticket information of the target account.
3. The pressure testing method according to claim 1, characterized in that: The stress-generating device includes a stress test script and a resource agent; the method of synchronizing the refreshed ticket information of the account pushed by the resource server to the local computer through the connection established with the resource server includes: Synchronize the refreshed ticket information of the account pushed by the resource server to the local computer through the connection established between the resource proxy and the resource server; The method of using the latest ticket information of the local account to initiate a stress test request to the backend server of the service to be tested includes: Read the latest ticket information of the local account through the stress test script; The stress test script initiates a stress test request to the backend server of the service to be tested according to the read ticket information.
4. The pressure testing method according to claim 3, characterized in that: The stress-generating device locally uses a shared memory in a lock-free mode for the resource agent to perform write operations and for the stress test script to perform read operations; After reading the latest ticket information of the local account through the stress test script, the method further includes: Performing a cyclic redundancy check on the information read from the shared memory through the stress test script; If the verification passes, the stress test script is allowed to use the read information; if the verification fails, the stress test script is used to re-read the latest ticket information of the local account from the shared memory.
5. The pressure testing method according to claim 4, characterized in that: Also includes: Constructing a hash map of account index information and accounts involved in the shared memory; The step of reading the latest ticket information of the local account through the stress test script includes: The stress test script obtains target index information, wherein the target index information is associated with the stress test requirement, and the target index information and the account index information are of the same type of information; The stress test script reads the latest ticket information of the account corresponding to the target index information based on the hash map.
6. The pressure testing method according to claim 4, characterized in that: Also includes: When preloading ticket information of an account to be tested from the resource server fails, marking the state of a memory block in the shared memory corresponding to the account that failed to be preloaded as a first state; wherein the first state indicates that the preloading failed; Retry at intervals to preload ticket information of the account corresponding to the memory block in the first state from the resource server until the state of the memory block is changed from the first state to a second state when the preloading is successful; wherein the second state indicates that the preloading is successful.
7. The pressure testing method according to claim 1, characterized in that: Also includes: In the first preset time after the connection with the resource server fails, if the resource server cannot be reconnected successfully and the ticket information of the target account stored locally has expired, the ticket information prediction model is called; wherein the target account is any account to be tested; Predicting the latest bill information of the target account by using the bill information prediction model; The locally expired ticket information of the target account is replaced by the predicted latest ticket information.
8. The pressure testing method according to claim 7, characterized in that: When the reconnection with the resource server cannot be successfully completed within the first preset time after the connection with the resource server fails and the ticket information of the target account stored locally has expired, calling the ticket information prediction model includes: If reconnection with the resource server cannot be successful within a first preset time after the connection with the resource server fails, and the ticket information of the target account stored locally has expired, a ticket prediction request is generated according to a record of failure to reconnect with the resource server within the first preset time after the connection with the resource server fails, and version information of the ticket information of the target account stored locally; calling the bill information prediction model through the bill prediction request; The predicting the latest bill information of the target account by using the bill information prediction model includes: Inputting the most recent N bill information of the target account into the bill information prediction model; N is a positive integer greater than 1; The latest bill information of the target account predicted by the bill information prediction model based on the N input bill information is obtained.
9. A stress testing method, characterized in that: Applied to a resource server, the method comprises: Before the stress test begins, receive a preload request from the stress-generating device; Providing the ticket information of the account to be tested to the pressure-generating device according to the preload request; wherein the account is the account corresponding to the service to be tested; During the stress test, the refreshed ticket information of the account is pushed through the connection established with the stress-generating device, so that the stress-generating device uses the latest ticket information of the account to initiate a stress test request to the backend server of the service to be tested.
10. The pressure testing method according to claim 9, characterized in that: The method further comprises: During the stress test, a query request for the latest ticket information of a target account is received from the stress-generating device; wherein the target account is any account to be tested; the query request is a request initiated by the stress-generating device when it determines that the first ticket information of the target account stored locally has expired, and the query request carries version information of the first ticket information; the first ticket information is the latest version of the ticket information of the target account stored locally by the stress-generating device; Obtaining a version comparison result according to the version information of the first ticket information in the query request and the version information of the second ticket information stored in the resource server; the second ticket information is the latest ticket information of the target account stored when the resource server receives the query request; The latest ticket information corresponding to the query request is provided to the pressure issuing device according to the version comparison result.
11. The pressure testing method according to claim 10, characterized in that: The providing the latest ticket information corresponding to the query request to the pressure issuing device according to the version comparison result includes: If the version of the second ticket information is later than the version of the first ticket information, providing the second ticket information to the pressure-generating device; If the version of the second ticket information is earlier than or equal to the version of the first ticket information, request to refresh the ticket information of the target account to obtain the third ticket information of the target account; provide the third ticket information to the pressure-generating device; wherein the version of the third ticket information is later than the version of the first ticket information.
12. The pressure testing method according to claim 9, characterized in that: During the stress test, the refreshed ticket information of the account is pushed through the connection established with the stress generating device, including: After the ticket information of multiple accounts to be tested is centrally refreshed during the stress test, the refreshed multiple ticket information is pushed through the connection established with the stress-generating device; Evenly distribute the next scheduled refresh time of the multiple bill information that are refreshed centrally to the validity period of the multiple bill information that are refreshed centrally; Refresh the corresponding bill information according to the next scheduled refresh time of the multiple bill information that are refreshed centrally; The refreshed ticket information is pushed through the connection established with the pressure-generating device.
13. A pressure testing device, characterized in that: Applied to pressure generating equipment, the device comprises: The bill preloading unit is used to preload the bill information of the account to be tested from the resource server and store it locally before the stress test starts; wherein the account is the account corresponding to the business to be tested; A bill synchronization unit, used to synchronize the bill information of the account after being refreshed pushed by the resource server to the local computer through the connection established with the resource server during the stress test; The stress testing unit is used to initiate a stress testing request to the backend server of the service to be tested by using the latest ticket information of the local account.
14. A pressure testing device, characterized in that: Applied to a resource server, the device comprises: A receiving unit, used for receiving a preload request of a pressure generating device before the pressure test starts; A first sending unit, configured to provide the pressure-generating device with ticket information of an account to be tested according to the preloading request; wherein the account is an account corresponding to the service to be tested; The second sending unit is used to push the refreshed ticket information of the account through the connection established with the stress-generating device during the stress test, so that the stress-generating device can use the latest ticket information of the account to initiate a stress test request to the background server of the business to be tested.
15. A pressure generating device, characterized in that: The device comprises a processor and a memory: The memory is used to store program codes and transmit the program codes to the processor; The processor is used to execute the steps of the stress testing method according to any one of claims 1 to 7 according to the instructions in the program code.
16. A resource server, characterized in that: The resource server includes a processor and a memory: The memory is used to store program codes and transmit the program codes to the processor; The processor is used to execute the steps of the stress testing method according to any one of claims 8 to 12 according to the instructions in the program code.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program code, and the program code is used to execute the steps of the stress testing method described in any one of claims 1 to 8, or the program code is used to execute the steps of the stress testing method described in any one of claims 9 to 12.
18. A computer program product, characterized in that It comprises a computer program or instructions, which, when executed, implement the steps of the stress testing method described in any one of claims 1 to 8, or the program code is used to execute the steps of the stress testing method described in any one of claims 9 to 12.
Citation Information
Cited By
Realization method and system for storing Radius account based on rcu-hash and storage medium
CN120639527A
