Disclosure of Invention
The technical problem to be solved and the technical task to be solved by the invention are to improve the prior art and provide a method, a device and a system for realizing the pressure test of the performance of a server.
According to a first aspect of the embodiments of the present disclosure, there is provided a method for implementing a stress test on server performance, the method including the following steps:
s1, a client requests to execute a speed limiting function of a speed limiter preset at a server, so that at least one service function of the server is limited;
s2, performing pressure test on at least one service function of the server and generating a pressure test result file;
and S3, generating a pressure detection result report according to the obtained pressure detection result file.
In an alternative embodiment, the step S1 further includes the following steps:
s101, establishing communication connection between a client and a server;
s102, a client applies for registering a speed limiter to a server by remote calling aiming at least one server function, wherein the registration information of the speed limiter comprises a first identifier associated with the speed limiter and at least one preset unit time service processing amount threshold;
s103, the server side adds the received registration information of the new registered speed limiter of the client side into a speed limiter management queue, so that the management of the speed limiter is realized;
s104, the client side sends a first identification associated with the speed limiter to the server side to initiate an execution request of the speed limiter;
and S105, the server side calls the speed limiter in the speed limiter management queue according to the first identification associated with the speed limiter to limit the speed of the corresponding server function.
In an alternative embodiment, the first identifier may include a speed limiter name.
In an alternative embodiment, the at least one traffic handling per unit time threshold comprises a number of service requests handled per second.
In an optional embodiment, the step S105 further includes the following steps:
s1051, a first counter is arranged in a speed limiter and used for counting the execution times of service functions of a service request of a client;
s1052, judging whether the number of application execution times of the service function corresponding to the speed limiter in the unit time reaches at least one preset service processing amount threshold value in the unit time, if not, returning to the client to continue execution immediately, and adding 1 to the count of a first counter arranged in the speed limiter; and if at least one unit time service processing capacity threshold value is reached, blocking the execution of the service function corresponding to the speed limiter, adding the service function into a waiting queue until the count of a first counter arranged in the speed limiter returns to zero in the next unit time, and judging whether the blocking needs to be continued again.
In an alternative embodiment, the unit time may be one second.
In an alternative embodiment, the at least one service function of the server includes a chat function and a transaction function.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for implementing a stress test on server performance, the apparatus including:
a memory for storing an application program;
a processor for running the application to perform the above method.
According to a third aspect of the embodiments of the present invention, there is provided a system for implementing a stress test on server performance, the system including:
the service function speed limiting module is configured to execute a speed limiting function of a speed limiter preset at the server end through a client end request, so that at least one service function of the server is limited in speed;
the pressure testing module is configured to perform pressure testing on at least one service function of the server and generate a pressure testing result file;
and the pressure detection result generation module is configured to generate a pressure detection result report according to the acquired pressure detection result file.
In an alternative embodiment, the system further comprises:
a communication module configured to establish a communication connection between a client and a server;
the speed limiter registration module is configured to apply for registering the speed limiter to a server side through remote calling aiming at least one server function through a client side, and the registration information of the speed limiter comprises a first identifier associated with the speed limiter and at least one preset traffic processing threshold per unit time;
the speed limiter management module is configured to add the received registration information of the new registered speed limiter of the client into a speed limiter management queue so as to realize the management of the speed limiter;
the speed limiter execution request module is configured to send a first identification associated with the speed limiter to a server side through a client side so as to initiate an execution request of the speed limiter;
and the speed limiter calling module is configured to call the speed limiters in the speed limiter management queue through the server according to the first identifier associated with the speed limiters, so as to limit the speed of the corresponding server function.
In an alternative embodiment, the system further comprises:
a first counter arranged in the speed limiter and used for counting the execution times of the service function of the service request of the client;
the service function execution frequency judging module is configured to judge whether the application execution frequency of the service function corresponding to the speed limiter in the unit time reaches at least one preset service processing amount threshold value in the unit time, if the application execution frequency does not reach the preset service processing amount threshold value in the unit time, the service function is returned to the client to be continuously executed immediately, and meanwhile, the counting of a first counter arranged in the speed limiter is added with 1; and if at least one unit time service processing capacity threshold value is reached, blocking the execution of the service function corresponding to the speed limiter, adding the service function into a waiting queue until the count of a first counter arranged in the speed limiter returns to zero in the next unit time, and judging whether the blocking needs to be continued again.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
compared with the traditional methods of modifying codes or limiting routers and bandwidths and the like, the method, the device and the system for realizing the pressure test of the server performance can greatly reduce the cost of manually modifying codes, solve the problem of efficiency of supporting simultaneous and concurrent execution of multi-task support, and accurately control various frequencies of each function operation and protocol, for example, the access pressure limitation of the server is carried out by taking seconds as a unit, so that the method, the device and the system are more in line with the practical situation, the tested result has reference significance, and meanwhile, accurate pressure test data can be provided for the performance optimization of the server according to the laziness. The method aims at the defect that the traditional speed limit based on network packet sending and flow can only be uniformly controlled. The invention adopts a more flexible CS structure to realize multi-frequency control, can add different limiting frequencies at different processes, and more truly restores a simulated pressure test scene.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to fig. 1 to 6 in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein is meant to encompass any and all possible combinations of one or more of the associated listed items.
As shown in fig. 1, fig. 1 is a flowchart illustrating a method for implementing stress testing on server performance according to an exemplary embodiment, including the following steps:
in step S1, the client requests to execute a speed limit function of a speed limiter preset at the server, so as to limit at least one service function of the server; the at least one service function of the server comprises information forwarding transfer between the client and transaction functions of virtual currency or virtual goods realized in response to the request of the client. For example, in the game server, the at least one service function of the server may be a function of performing information communication between different players, and a service function of implementing buying, selling, giving away and the like of virtual money or virtual goods between the players.
In step S2, performing a stress test on at least one service function of the server and generating the stress test result file; in this step, a threshold may be set for the number of the pressure test result files, and when a preset threshold condition is satisfied, the pressure test result files are backed up to the remote server and the pressure test result files of the local server are deleted correspondingly, so that the pressure test result files are transferred from the local server to the remote server in the process of pressure testing for the server, thereby avoiding that the disk space of the pressure test server becomes a bottleneck due to the excessively large record files of the pressure test result files generated in the process of pressure testing for the local server, and thus, long-time pressure testing can be realized, so that the pressure test result more accurately reflects the service quality provided in the actual service function, for example, when a game server is tested, a long-time test is needed to ensure that an accurate pressure test data report can be obtained, thereby better refining and improving server performance as well as software performance. As a preferred embodiment, a threshold may be set for the total file size of the stress test result file, or a threshold may be set for the stress test time interval, and the local server stress test result file is backed up when the preset time interval is reached, which can be set by those skilled in the art completely according to the actual situation.
In step S3, a pressure detection result report is generated from the acquired pressure detection result file. In this step, specific data in the pressure test result file may be called according to actual conditions to perform analysis of the test result, for example, an interrupt record generated by the server during the pressure test may be selected, for example, when a certain service function is executed, function interrupt data caused by the server may be selected. And according to the called data, performing data analysis and summarization to generate a pressure test result report.
As shown in fig. 2, as a preferred embodiment of the present disclosure, in step S1, the step of implementing speed limit for a certain service function of the server includes the following steps:
in step S101, a communication connection is established between the client and the server; in the step, a communication connection foundation can be established between the client and the device server in a remote calling mode;
in step S102, a client applies for registering a speed limiter to a server by remote calling aiming at least one server function, wherein the registration information of the speed limiter comprises a first identifier associated with the speed limiter and at least one preset unit time service processing amount threshold; alternatively, the first indication may be a specific name of the governor as a unique identifier of the governor.
In step S103, the server adds the received registration information of the new registered speed limiter of the client to a speed limiter management queue, thereby implementing management of the speed limiter; in this step, the governor is managed in a unified manner.
In step S104, the client initiates an execution request of the speed limiter by sending a first identifier associated with the speed limiter to the server;
in step S105, the server calls the speed limiter in the speed limiter management queue according to the first identifier associated with the speed limiter, so as to limit the speed of the corresponding server function.
As shown in fig. 3, step S105 further includes the steps of:
s1051, a first counter is arranged in a speed limiter and used for counting the execution times of service functions of a service request of a client;
s1052, judging whether the number of application execution times of the service function corresponding to the speed limiter in the unit time reaches at least one preset service processing amount threshold value in the unit time, if not, returning to the client to continue execution immediately, and adding 1 to the count of a first counter arranged in the speed limiter; and if at least one unit time service processing capacity threshold value is reached, blocking the execution of the service function corresponding to the speed limiter, adding the service function into a waiting queue until the count of a first counter arranged in the speed limiter returns to zero in the next unit time, and judging whether the blocking needs to be continued again.
As a preferred embodiment, the above steps may be set as:
s101, a communication foundation is established between a client C and a server S through remote calling;
s102, the client C registers the information of the speed limiter with the server S through remote calling, wherein the registration information comprises the name (unique identification) of the speed limiter and a preset limit QPS (maximum frequency per second);
and S103, after receiving the registration information of the client C, the server S adds the newly registered speed limiter into a speed limiter management queue for management. The server S can simultaneously manage a plurality of registered speed limiters;
s104, in any place needing speed limitation, the client C initiates an execution request to the server S through remote calling according to the name of the speed limiter;
s105, after receiving an execution request of the client C, the server S judges whether the execution times of the speed governor application in the second reaches the registered upper limit of the speed limit according to the speed governor queue, if the execution times of the speed governor application in the second does not reach the registered upper limit of the speed limit, the server S returns to the client C to continue execution, and meanwhile, the execution times of the speed governor in the second is added with 1; if the upper limit is reached, blocking the client C, adding the client C into the waiting queue until the next second, and judging whether the client C needs to continue blocking again; thereby achieving the function of limiting speed;
it should be noted that the server S resets the number of times each governor is executed per second.
As another more detailed embodiment of the present disclosure, for example, a single pressure test requires a mixed pressure test for chat and transaction, and the step of setting the rate limiter in step S1 includes:
the first step is as follows: registering two speed limiters in test case
REG_SPEEDER(“Chat”,60)
REG_SPEEDER(“Trade”,30)
After the test case runs, the two speed limiter settings are uploaded to a control server
The second step is that: where the test case loops for Chat, add WAIT ("Chat")
The third step: where the test case of the transaction loops, add WAIT ("Trade")
The fourth step: when the test case runs to WAIT ("Chat"), the test case requests to be executed by the control server, the control server judges whether the second reaches the upper limit according to the QPS registered in the step 1, if so, the test case is allowed to be executed continuously, if so, the case is blocked and WAITs, the request is added into the queue, and the execution is recovered after the next second. So that up to 60 cases per second can be performed.
The fifth step: the same is true for the test case of the transaction. Each case is controlled by an independent controller without influencing each other, so that the frequency can be accurately controlled for different processes and transactions.
As shown in fig. 4, as another aspect of the embodiments of the present disclosure, there is provided an apparatus for implementing a stress test on server performance, the apparatus including:
a memory for storing an application program;
a processor for running the application to perform the method described in any of the above embodiments.
The Memory may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Correspondingly, the embodiment of the invention also provides a stress test server, which comprises a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method for implementing the stress test on the performance of the server according to the embodiment when executing the computer program.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor is the control center of the pressure measurement server, and various interfaces and lines are used to connect the various parts of the whole pressure measurement server.
Corresponding to the method embodiment, the invention also provides a system embodiment. For the system embodiment, since it basically corresponds to the method embodiment, reference may be made to the partial description of the method embodiment for relevant points. The system embodiments described below are merely illustrative, where elements described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over multiple network elements. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. One of ordinary skill in the art can understand and implement it without inventive effort.
As shown in fig. 5, as another aspect of the embodiment of the present disclosure, there is provided a system for implementing stress test on server performance, the system including:
a service function speed limit module 101 configured to request execution of a speed limit function of a speed limiter preset at a server side through a client side, so as to limit at least one service function of the server;
the pressure testing module 102 is configured to perform pressure testing on at least one service function of the server and generate a pressure testing result file;
a pressure detection result generation module 103 configured to generate a pressure detection result report according to the acquired pressure detection result file.
As shown in fig. 6, as a preferred implementation of the embodiment of the present disclosure, the system further includes:
a communication module 104 configured to establish a communication connection between the client and server sides;
a speed limiter registration module 105, configured to apply for registering a speed limiter to a server by a client terminal through remote call for at least one server function, wherein registration information of the speed limiter includes a first identifier associated with the speed limiter and at least one predetermined traffic processing threshold per unit time;
the speed limiter management module 106 is configured to add the received registration information of the newly registered speed limiter of the client to a speed limiter management queue, so as to realize the management of the speed limiter;
a speed limiter execution request module 107 configured to initiate an execution request of the speed limiter by the client sending a first identifier associated with the speed limiter to the server;
and the speed limiter calling module 108 is configured to call the speed limiters in the speed limiter management queue according to the first identifier associated with the speed limiters through the server side, so as to limit the speed of the corresponding server function.
It should be recognized that embodiments of the present invention can be realized and implemented by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer readable memory. The methods may be implemented in a computer program using standard programming techniques, including a non-transitory computer readable storage medium configured with the computer program, where the storage medium so configured causes a computer to operate in a specific and predefined manner, according to the methods and figures described in the detailed description. Each program may be implemented in a high level procedural or object oriented programming language to communicate with a computer system. However, the program(s) can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language. Furthermore, the program can be run on a programmed application specific integrated circuit for this purpose.
Further, the method may be implemented in any type of computing platform operatively connected to a suitable interface, including but not limited to a personal computer, mini computer, mainframe, workstation, networked or distributed computing environment, separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, and the like. Aspects of the invention may be embodied in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optically read and/or write storage medium, RAM, ROM, or the like, such that it may be read by a programmable computer, which when read by the storage medium or device, is operative to configure and operate the computer to perform the procedures described herein. Further, the machine-readable code, or portions thereof, may be transmitted over a wired or wireless network. The invention described herein includes these and other different types of non-transitory computer-readable storage media when such media include instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor. The invention also includes the computer itself when programmed according to the methods and techniques described herein.
A computer program can be applied to input data to perform the functions described herein to transform the input data to generate output data that is stored to non-volatile memory. The output information may also be applied to one or more output devices, such as a display. In a preferred embodiment of the invention, the transformed data represents physical and tangible objects, including particular visual depictions of physical and tangible objects produced on a display.