CN109491895A - Server stress test method and device - Google Patents

Server stress test method and device Download PDF

Info

Publication number
CN109491895A
CN109491895A CN201811256647.5A CN201811256647A CN109491895A CN 109491895 A CN109491895 A CN 109491895A CN 201811256647 A CN201811256647 A CN 201811256647A CN 109491895 A CN109491895 A CN 109491895A
Authority
CN
China
Prior art keywords
connection
message
client
thread
mapping table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811256647.5A
Other languages
Chinese (zh)
Inventor
马东辉
李永浩
张永新
满志远
邢云天
朱磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing CHJ Information Technology Co Ltd
Original Assignee
Beijing CHJ Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing CHJ Information Technology Co Ltd filed Critical Beijing CHJ Information Technology Co Ltd
Priority to CN201811256647.5A priority Critical patent/CN109491895A/en
Publication of CN109491895A publication Critical patent/CN109491895A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a kind of server stress test method and devices, this method comprises: the test request of at least two clients is sent to first thread pond;The first thread pond is provided at least two threads in advance;By the thread in the first thread pond, the test request of at least two client is handled, to test tested server.The server stress test method provided through the invention, it is possible to reduce number of threads, and then reduce system resource overhead.

Description

Server stress test method and device
Technical field
The present invention relates to computer field more particularly to a kind of server stress test method and devices.
Background technique
With the fast development of Internet technology, the requirement to the performance and stability of server is higher and higher, therefore needs Pressure test is carried out to server, to obtain the performance indicator of server.
Currently, each pressure test client generally requires 20 or so threads under the premise of keeping normal function, For pressure test, if establishing 100,000 connections, more than ten higher pressure test equipments of performance are generally required to dispose Pressure test client, more consuming system resource.
As it can be seen that server stress test, which exists in the prior art, needs the problem of expending compared with multi-system resource.
Summary of the invention
The embodiment of the present invention provides a kind of server stress test method and device, with settlement server pressure test needs The problem of expending compared with multi-system resource.
In a first aspect, being applied to pressure test equipment, this method the present invention provides a kind of server stress test method Include:
The test request of at least two clients is sent to first thread pond;The first thread pond be provided in advance to Few two threads;
By the thread in the first thread pond, the test request of at least two client is handled, to tested Examination server is tested.
Optionally, the test request includes that request is established in connection;
The thread by the first thread pond handles the test request of at least two client, comprising:
By the thread in the first thread pond, at least two client is sent to the tested server Request is established in connection;
By the thread in the first thread pond, receives the tested server and be based at least two client Connection establish request return connection establish result.
Optionally, the thread by the first thread pond, receive the tested server be based on it is described extremely The connection of few two clients is established the connection that request returns and is established after result, the method also includes:
The first information for each connection currently established is stored in connection management mapping table, wherein first letter Breath includes at least connection identifier;
According to the connection identifier stored in the connection management mapping table, Message Processing is carried out to the tested server Test.
Optionally, described according to the connection identifier stored in the connection management mapping table, to the tested server Carry out Message Processing test, comprising:
The news release request of first client is sent to the second thread pool, wherein first client is described Client at least two clients, second thread pool are provided at least two threads in advance;
By the thread in the second thread pool, select first client corresponding from the connection management mapping table Connection identifier, and using connection corresponding to selected connection identifier, first message is issued to the tested server, In, the first message is the message carried during the news release of first client is requested.
Optionally, described using connection corresponding to selected connection identifier, to the tested server publication the Before one message, the method also includes:
By the second information of the first message, it is stored in message management mapping table;Wherein, second information is at least wrapped Include message identifier;
It is described using connection corresponding to selected connection identifier, to the tested server publication first message it Afterwards, the method also includes:
In the case where issuing first message failure to the tested server, mapped according to the message management The message identifier of the first message stored in table issues the first message to the tested server again.
Optionally, described according to the connection identifier stored in the connection management mapping table, to the tested server Carry out Message Processing test, comprising:
In the case where the second client receives the message of the tested server publication, by third thread pool Thread determine described first according to corresponding first connection identifier of second client and the connection management mapping table The corresponding connection of connection identifier, and using the corresponding connection of first connection identifier, disappear to the tested server feedback Cease reception result;
Wherein, second client is the client at least two client, and the third thread pool is preparatory Configured at least two threads.
Optionally, described after being stored in connection management mapping table by the first information for each connection currently established Method further include:
The second connection identifier to be deleted is selected from the connection management mapping table;
The corresponding connection of second connection identifier is disconnected, and deletes described second from the connection management mapping table and connects Connect mark.
Optionally, the pressure test equipment is the pressure test equipment based on Netty.
Second aspect, the present invention also provides a kind of server stress test devices, are set to pressure test equipment, the device Include:
Sending module, for the test request of at least two clients to be sent to first thread pond;The first thread Pond is provided at least two threads in advance;
Processing module, for handling the test of at least two client by the thread in the first thread pond Request, to test tested server.
Optionally, the test request includes that request is established in connection;
The processing module, comprising:
First transmission unit, for sending institute to the tested server by the thread in the first thread pond Request is established in the connection for stating at least two clients;
First receiving unit, for receiving the tested server and being based on by the thread in the first thread pond The connection of at least two client establishes the connection that request returns and establishes result.
Optionally, described device further include:
First memory module receives the tested server for the thread by the first thread pond Connection based at least two client is established after the connection that request returns establishes result, each company that will currently establish The first information connect is stored in connection management mapping table, wherein the first information includes at least connection identifier;
Message Processing test module, for according to the connection identifier stored in the connection management mapping table, to the quilt Testing service device carries out Message Processing test.
Optionally, the Message Processing test module, comprising:
Second transmission unit, for the news release request of the first client to be sent to the second thread pool, wherein described First client is the client at least two client, and second thread pool is provided at least two lines in advance Journey;
News release unit, for selecting institute from the connection management mapping table by the thread in the second thread pool The corresponding connection identifier of the first client is stated, and using connection corresponding to selected connection identifier, to the tested clothes Business device issues first message, wherein the first message is the message carried during the news release of first client is requested.
Optionally, described device further include:
Second memory module, for described using connection corresponding to selected connection identifier, to the tested clothes It is engaged in front of device publication first message, by the second information of the first message, is stored in message management mapping table;Wherein, described Second information includes at least message identifier;
Module is retransmitted, is used in the case where issuing first message failure to the tested server, according to institute The message identifier of the first message stored in message management mapping table is stated, again to described in the tested server publication First message.
Optionally, the Message Processing test module, comprising:
Third transmission unit, for the case where the second client receives the message that the tested server is issued Under, by the thread in third thread pool, according to corresponding first connection identifier of second client and the connection management Mapping table determines the corresponding connection of first connection identifier, and utilizes the corresponding connection of first connection identifier, Xiang Suoshu Tested server feedback message sink result;
Wherein, second client is the client at least two client, and the third thread pool is preparatory Configured at least two threads.
Optionally, described device further include:
Selecting module, for being stored in it in connection management mapping table for the first information for each connection currently established Afterwards, the second connection identifier to be deleted is selected from the connection management mapping table;
Module is disconnected, for disconnecting the corresponding connection of second connection identifier, and from the connection management mapping table Delete second connection identifier.
Optionally, the pressure test equipment is the pressure test equipment based on Netty.
The third aspect, the embodiment of the present invention also provide a kind of server stress test device, including processor, memory and It is stored in the computer program that can be run on the memory and on the processor, the computer program is by the processing The step of device realizes above-mentioned server stress test method when executing.
Fourth aspect, the embodiment of the present invention also provide a kind of computer readable storage medium, the computer-readable storage Computer program is stored on medium, the computer program realizes above-mentioned server stress test side when being executed by processor The step of method.
Server stress test method provided in an embodiment of the present invention, the test request of at least two clients is sent to First thread pond;The first thread pond is provided at least two threads in advance;Pass through the thread in the first thread pond, place The test request of at least two client is managed, to test tested server.Since at least two clients are total Thread pool is enjoyed, thus under same test capacity, it is possible to reduce number of threads, and then reduce system resource overhead.
Detailed description of the invention
In order to illustrate the technical solution of the embodiments of the present invention more clearly, needed in being described below to the embodiment of the present invention Attached drawing to be used is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, For those of ordinary skill in the art, without any creative labor, it can also obtain according to these attached drawings Obtain other attached drawings.
Fig. 1 is the flow chart of server stress test method provided in an embodiment of the present invention;
Fig. 2 is the schematic diagram of pressure test equipment provided in an embodiment of the present invention;
Fig. 3 is the structure chart of server stress test device provided in an embodiment of the present invention;
Fig. 4 is the structure chart for the server stress test device that further embodiment of this invention provides.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based on this hair Embodiment in bright, every other implementation obtained by those of ordinary skill in the art without making creative efforts Example, shall fall within the protection scope of the present invention.
The embodiment of the present invention provides a kind of server stress test method.It is that the embodiment of the present invention provides referring to Fig. 1, Fig. 1 Server stress test method flow chart, as shown in Figure 1, comprising the following steps:
The test request of at least two clients is sent to first thread pond by step 101;The first thread pond is preparatory Configured at least two threads.
In the embodiment of the present invention, above-mentioned at least two client can be the client disposed on pressure test equipment, In, above-mentioned pressure test equipment can be server or server cluster.Optionally, the pressure test equipment can be base In the pressure test equipment of Netty, so as to improve the concurrency of test request processing.
Optionally, each client in above-mentioned at least two client can create multiple test requests, more to simulate A client sends test request to tested server.Above-mentioned test request may include that request, news release are established in connection Request, message subscribing request etc..
It should be noted that the test request of above-mentioned at least two client can be independent triggers, it is also possible to simultaneously Hair.In addition, each client can trigger one or a plurality of test request.
Above-mentioned first thread pond is provided at least two threads in advance.Specifically, above-mentioned at least two client can be total to The thread for enjoying first thread pond is tested, for example, above-mentioned at least two client can share the thread in first thread pond, it is right Tested server, which is attached foundation test or above-mentioned at least two client, can share the thread in first thread pond, Message Processing test is carried out to tested server.
In practical application, it can be pre-configured with the client that can share first thread pond, so that the test of the client is asked First thread pond can be sent to by, which asking, is handled.
It should be noted that in the case where the quantity of test request is greater than the quantity of thread in first thread pond, it can be with Test request is deposited in test request queue in advance, so that the thread in first thread pond can be successively from test request team Read test request is handled in column.
Step 102, by the thread in the first thread pond, handle the test request of at least two client, To test tested server.
In the embodiment of the present invention, above-mentioned tested server refers to the server for being performed pressure test, for example, MQTT (Message Queuing Telemetry Transport, message queue telemetering transport protocol) server.
In the step, by the thread in first thread pond, the test request of at least two client is handled.Example Such as, if first thread pond includes 10 threads, the test request of above-mentioned at least two client includes 500 test requests, then Above-mentioned 500 test requests of above-mentioned 10 thread process can be multiplexed.In compared with the prior art, each client is required to pair Answer multiple threads (for example, 20 threads), it is possible to reduce number of threads.
Server stress test method provided in an embodiment of the present invention, the test request of at least two clients is sent to First thread pond;The first thread pond is provided at least two threads in advance;Pass through the thread in the first thread pond, place The test request of at least two client is managed, to test tested server.Since at least two clients are total Thread pool is enjoyed, thus under same test capacity, it is possible to reduce number of threads, and then reduce system resource overhead.
Optionally, the test request includes that request is established in connection;
Above-mentioned steps 102 namely the thread by the first thread pond handle at least two client Test request, comprising:
By the thread in the first thread pond, at least two client is sent to the tested server Request is established in connection;
By the thread in the first thread pond, receives the tested server and be based at least two client Connection establish request return connection establish result.
In the embodiment of the present invention, by the thread in first thread pond, above-mentioned at least two are sent to tested server Request is established in the connection of client, be can be the synchronous connection for sending above-mentioned at least two client to tested server and is established Request;It is also possible to the asynchronous connection for sending above-mentioned at least two client to tested server and establishes request.
For example, request is established in the connection that the number of threads in first thread pond is greater than or equal to above-mentioned at least two client Quantity in the case where, can be sent by the thread synchronization in first thread pond above-mentioned at least two client connection foundation asks It asks;In the case where the quantity of request is established in the connection that the number of threads in first thread pond is less than above-mentioned at least two client, Then the sequencing of request can be established according to the connection of above-mentioned at least two client by the thread in first thread pond, point Request is established in the connection for not sending above-mentioned at least two client.
For example, including thread A in first thread pond, it includes connecting to establish to ask that request is established in the connection of at least two clients Request A1 can be established to the transmission connection of tested server by asking A1 and connection to establish request A2, thread A, and can receive tested After what examination server returned establishes result for the connection for connecting foundation request A1, connection foundation is sent to tested server and is asked A2 is sought, and receives the connection for establishing request A1 for connection that tested server returns and establishes result.
In practical application, result is established in above-mentioned connection can indicate that connection is successfully established, and can also indicate that connection is established and lose It loses.Optionally, when failure is established in connection, tested server can not also feed back any information, at this point, when a certain default The feedback information for not receiving tested server in long can determine that failure is established in connection.Specifically, can be by counting each A connection is established the corresponding connection of request and is established as a result, performance is established in the connection for analyzing tested server.
The embodiment of the present invention shares the thread in first thread pond by multiple client, sends and connects to tested server Foundation request is connect, to be attached foundation test to tested server, thus under same test capacity, it is possible to reduce line Number of passes amount, and then reduce the system resource overhead that connection is established in test process.
Optionally, the thread by the first thread pond, receive the tested server be based on it is described extremely The connection of few two clients is established the connection that request returns and is established after result, the method also includes:
The first information for each connection currently established is stored in connection management mapping table, wherein first letter Breath includes at least connection identifier;
According to the connection identifier stored in the connection management mapping table, Message Processing is carried out to the tested server Test.
In the embodiment of the present invention, the above-mentioned first information may include connection identifier, wherein connection identifier is referred to as connecting Connect handle.Optionally, the above-mentioned first information can also include the contextual business information of connection, for example, title, description etc..It can Choosing, connection identifier and the contextual business information of connection can be stored in connection management mapping table according to the form of key-value pair In, wherein connection identifier can be used as key, and the contextual business information of connection can be used as value.Upstream message processing test can To include news release test, message subscribing test etc..
The first information of the above-mentioned each connection that will currently establish, is stored in connection management mapping table, for example, being based on Connection is established the connection that request A1 is returned and is established in the case that result instruction connection is successfully established, will connection to establish request A corresponding The first information of connection be stored in connection management mapping table;Result is established establishing the connection that request A1 is returned based on connection In the case that instruction connection is successfully established, the first information that the corresponding connection of request A1 is established in connection is stored in connection management and is reflected In firing table.
It is above-mentioned according to the connection identifier stored in connection management mapping table, Message Processing is carried out to the tested server Test for example, determining the connection for being used for news release according to the connection identifier stored in connection management mapping table, and passes through the company It connects to tested server and gives out information, or determined according to the connection identifier stored in connection management mapping table and disappeared for feeding back Breath subscribes to the connection of result, and passes through the connection to tested server feedback message subscribing result.
The embodiment of the present invention is connected by the management of connection management mapping table, and based on connection management mapping table to described tested It tries server and carries out Message Processing test, so that connection management is more convenient and efficient, and then Message Processing test can be improved Efficiency.
Optionally, described according to the connection identifier stored in the connection management mapping table, to the tested server Carry out Message Processing test, comprising:
The news release request of first client is sent to the second thread pool, wherein first client is described Client at least two clients, second thread pool are provided at least two threads in advance;
By the thread in the second thread pool, select first client corresponding from the connection management mapping table Connection identifier, and using connection corresponding to selected connection identifier, first message is issued to the tested server, In, the first message is the message carried during the news release of first client is requested.
In the embodiment of the present invention, the first client can be any one in above-mentioned at least two client or multiple visitors Family end.
For example, in the case that the customer end A 1 and A2 needs in above-mentioned at least two client give out information, by client The news release request of end A1 is sent to the second thread pool, and the thread A1 in the second thread pool can be from connection management mapping table The corresponding connection identifier of customer end A 1 is selected, and using connection corresponding to the corresponding connection identifier of customer end A 1, to tested Server issues the message that carries in the news release request of the first client, and the thread A2 in the second thread pool can be from connection It manages and selects the corresponding connection identifier of customer end A 2 in mapping table, and utilize company corresponding to the corresponding connection identifier of customer end A 2 It connects, the message carried in the news release request for issuing the first client to tested server.
It should be noted that it is above-mentioned using connection corresponding to selected connection identifier, to the tested server First message is issued, can be through Netty interface, using connection corresponding to selected connection identifier, be tested to described It tries server and issues first message.Wherein, Netty be by JBOSS provide a Java Open Framework, it provide it is asynchronous, Event driven web application frame and tool.
In the embodiment of the present invention, multiple client shares the thread in the second thread pool, disappears to tested server Breath publication test, thus under same test capacity, it is possible to reduce number of threads, and then reduce system resource overhead.
Optionally, described using connection corresponding to selected connection identifier, to the tested server publication the Before one message, the method also includes:
By the second information of the first message, it is stored in message management mapping table;Wherein, second information is at least wrapped Include message identifier;
It is described using connection corresponding to selected connection identifier, to the tested server publication first message it Afterwards, the method also includes:
In the case where issuing first message failure to the tested server, mapped according to the message management The message identifier of the first message stored in table issues the first message to the tested server again.
In the embodiment of the present invention, above-mentioned second information includes at least message identifier, is used for the unique identification message.It is optional , above-mentioned second information can also include the information such as the call back function of message content, monitoring information.It optionally, can be by message The other information (such as call back function of message content, monitoring information) of mark and message is stored according to the form of key-value pair to disappear In breath management mapping table, wherein connection identifier can be used as key, and the other information of message can be used as value.
In the embodiment of the present invention, it can start at the time of issuing the first message to the tested server pre- If in duration, in the case where the feedback information for not being connected to the tested server, determining first message publication failure, wherein Above-mentioned preset duration can be rationally arranged according to actual needs, and it is not limited in the embodiment of the present invention.
It, can be by the news release of the client in the case where a certain client needs give out information in practical application The relevant information of the message carried in request is stored in message management mapping table, using as backup, in the feelings of news release failure Under condition, it can be given out information again to tested server based on the relevant information for storing the message in message management mapping table, So as to reduce the probability of news release failure.
Optionally, the case where first message that the tested server is sent issues successful feedback information is being received Under, the second information of the first message can be deleted, from the message management mapping table to save memory space.
Optionally, described according to the connection identifier stored in the connection management mapping table, to the tested server Carry out Message Processing test, comprising:
In the case where the second client receives the message of the tested server publication, by third thread pool Thread determine described first according to corresponding first connection identifier of second client and the connection management mapping table The corresponding connection of connection identifier, and using the corresponding connection of first connection identifier, disappear to the tested server feedback Cease reception result;
Wherein, second client is the client at least two client, and the third thread pool is preparatory Configured at least two threads.
In the embodiment of the present invention, above-mentioned second client can be in above-mentioned at least two client any one or it is more A client.Above-mentioned third thread pool can be same thread pond with above-mentioned second thread pool, be also possible to different thread pools, It is not limited in the embodiment of the present invention.Above-mentioned first connection identifier is that the second client receives disappearing for tested server publication Connection identifier corresponding to the connection of breath.
It should be noted that the embodiment of the present invention can be in advance by the context of each connection identifier connection corresponding with its Business information associated storage, for example, by the contextual business information of each connection identifier connection corresponding with its according to key-value pair Form be stored in connection management mapping table, be also possible to the contextual business of each connection identifier connection corresponding with its Information is stored respectively in different tables of data, and the contextual business information of each connection identifier connection corresponding with its exists Incidence relation, to find the contextual business information of its corresponding connection by connection identifier.
The company of being stored in the form of the contextual business information of each connection identifier connection corresponding with its is according to key-value pair Adapter tube reason mapping table in for, the embodiment of the present invention can according to the corresponding connection identifier of the second client (namely first connection Mark), the contextual business information of the corresponding connection of the connection identifier is searched from connection management mapping table, and can be based on being looked into The contextual business information for the connection found determines the corresponding connection of the second client.
In practical application, when client receives a message of tested server publication, third thread can be passed through Thread in pond determines the corresponding connection of the client according to connection identifier and connection management mapping table, by the connection to quilt Testing service device feedback message reception result, alternatively referred to as message subscribing result.
It should be noted that it is above-mentioned using the corresponding connection of first connection identifier, it is anti-to the tested server Message sink is presented as a result, can be through Netty interface, using the corresponding connection of first connection identifier, is tested to described Try server feedback message sink result.
In the embodiment of the present invention, multiple client shares the thread in third thread pool, disappears to tested server Breath subscribes to test, thus under same test capacity, it is possible to reduce number of threads, and then reduce system resource overhead.
Optionally, described after being stored in connection management mapping table by the first information for each connection currently established Method further include:
The second connection identifier to be deleted is selected from the connection management mapping table;
The corresponding connection of second connection identifier is disconnected, and deletes described second from the connection management mapping table and connects Connect mark.
In the embodiment of the present invention, above-mentioned second connection identifier can be any one stored in connection management mapping table or Multiple connection identifier.
Optionally, the corresponding connection of above-mentioned disconnection second connection identifier can be by described in the disconnection of Netty interface The corresponding connection of second connection identifier.
The disconnection that the embodiment of the present invention is connected based on connection management mapping table management, so that connection management is highly efficient, this Outside, after disconnecting a certain connection, the connection identifier is deleted from connection management mapping table, avoids disappearing using the connection transmission of disconnection Breath causes message to send failure.
The embodiment of the present invention is illustrated below in conjunction with Fig. 2, wherein can portion on pressure test equipment shown in Fig. 2 Affix one's name to multiple client:
Step a1, it initializes.
In the step, it can be based on Netty, initialization internal affairs processing thread pool, connection management thread pool are (on namely State first thread pond), Message Processing thread pool (namely above-mentioned second thread pool) and connection management mapping table, message storage Manage mapping table.
Step a2, connection is established.
In the step, external independent or concurrent connection request can be received, request is initiated the connection and store connection handle, When connection is received by MQTT server (namely above-mentioned tested server, alternatively referred to as Broker) and returns to successful connection event Afterwards, it will currently connect to connect handle as key, and be value with the contextual task information of connection, connection management mapping table is arrived in storage.
Step a3, it gives out information.
By taking QoS1 as an example, some connection is selected from connection management mapping table, the logical of the connection is used by Netty interface Road gives out information, and by message with unique message number MID (namely above-mentioned message identifier) be key, with message content, monitor disappear Call back function of breath etc. is that message management mapping table is arrived in value storage.
Deleted in message management mapping table if client receives the publication feedback of MQTT server this message and to Message issuer sends success notification, retries and gives out information if the feedback for not receiving MQTT server within a certain period of time Process, until success.
Step a4, message (QoS1) is subscribed to.
By taking QoS1 as an example, when client end receive MQTT server publication a message, then by connection handle find The connection of the client is fed back using the channel of this connection to one subscription of MQTT server by Netty interface.
Step a5, it disconnects.
In the step, some connection is selected from connection management mapping table, connection is closed by Netty interface and from connection This connection is removed in management mapping table.
The embodiment of the present invention shares one group of connection management thread on the basis of Netty, through a large amount of MQTT client Pond, Message Processing thread pool and connection management mapping table, message management mapping table, effectively reduce system resource overhead, can To accommodate greater number of client connection, reduces the consumption of the various resources of system, significantly reduce pressure test Cost overhead reduces MQTT server stress test execution difficulty.
It is the structure chart of server stress test device provided in an embodiment of the present invention, the server pressure referring to Fig. 3, Fig. 3 Force test device is set to pressure test equipment.As shown in figure 3, server stress test device 300 includes:
Sending module 301, for the test request of at least two clients to be sent to first thread pond;The First Line Cheng Chi is provided at least two threads in advance;
Processing module 302, for handling the survey of at least two client by the thread in the first thread pond Examination request, to test tested server.
Optionally, the test request includes that request is established in connection;
The processing module, comprising:
First transmission unit, for sending institute to the tested server by the thread in the first thread pond Request is established in the connection for stating at least two clients;
First receiving unit, for receiving the tested server and being based on by the thread in the first thread pond The connection of at least two client establishes the connection that request returns and establishes result.
Optionally, described device further include:
First memory module receives the tested server for the thread by the first thread pond Connection based at least two client is established after the connection that request returns establishes result, each company that will currently establish The first information connect is stored in connection management mapping table, wherein the first information includes at least connection identifier;
Message Processing test module, for according to the connection identifier stored in the connection management mapping table, to the quilt Testing service device carries out Message Processing test.
Optionally, the Message Processing test module, comprising:
Second transmission unit, for the news release request of the first client to be sent to the second thread pool, wherein described First client is the client at least two client, and second thread pool is provided at least two lines in advance Journey;
News release unit, for selecting institute from the connection management mapping table by the thread in the second thread pool The corresponding connection identifier of the first client is stated, and using connection corresponding to selected connection identifier, to the tested clothes Business device issues first message, wherein the first message is the message carried during the news release of first client is requested.
Optionally, described device further include:
Second memory module, for described using connection corresponding to selected connection identifier, to the tested clothes It is engaged in front of device publication first message, by the second information of the first message, is stored in message management mapping table;Wherein, described Second information includes at least message identifier;
Module is retransmitted, is used in the case where issuing first message failure to the tested server, according to institute The message identifier of the first message stored in message management mapping table is stated, again to described in the tested server publication First message.
Optionally, the Message Processing test module, comprising:
Third transmission unit, for the case where the second client receives the message that the tested server is issued Under, by the thread in third thread pool, according to corresponding first connection identifier of second client and the connection management Mapping table determines the corresponding connection of first connection identifier, and utilizes the corresponding connection of first connection identifier, Xiang Suoshu Tested server feedback message sink result;
Wherein, second client is the client at least two client, and the third thread pool is preparatory Configured at least two threads.
Optionally, described device further include:
Selecting module, for being stored in it in connection management mapping table for the first information for each connection currently established Afterwards, the second connection identifier to be deleted is selected from the connection management mapping table;
Module is disconnected, for disconnecting the corresponding connection of second connection identifier, and from the connection management mapping table Delete second connection identifier.
Optionally, the pressure test equipment is the pressure test equipment based on Netty.
Server stress test device 300 can be realized each of the server stress test method of above method embodiment Process, and reaching identical effect is to avoid repeating, which is not described herein again.
The server stress test device 300 of the embodiment of the present invention, sending module 301 are used at least two clients Test request be sent to first thread pond;The first thread pond is provided at least two threads in advance;Processing module 302, For the test request of at least two client being handled, to tested clothes by the thread in the first thread pond Business device is tested.Since at least two clients share thread pool, thus under same test capacity, it is possible to reduce thread Quantity, and then reduce system resource overhead.
The embodiment of the present invention also provides a kind of server stress test device, including processor, memory and is stored in institute The computer program that can be run on memory and on the processor is stated, when the computer program is executed by the processor It realizes each process of the server stress test method of any of the above-described embodiment of the method, and identical technical effect can be reached, To avoid repeating, which is not described herein again.
The embodiment of the present invention also provides a kind of computer readable storage medium, stores on the computer readable storage medium There is computer program, the computer program realizes each mistake of above-mentioned server stress test method when being executed by processor Journey, and identical technical effect can be reached, to avoid repeating, which is not described herein again.Wherein, the computer-readable storage medium Matter, such as read-only memory (Read-Only Memory, abbreviation ROM), random access memory (Random Access Memory, abbreviation RAM), magnetic or disk etc..
Referring to fig. 4, Fig. 4 is the structure chart of the another server stress test device for implementing to provide of the present invention, the server Pressure test device is set to pressure test equipment.As shown in figure 4, server stress test device 400 include: processor 401, Memory 402 and it is stored in the computer program that can be run on the memory 402 and on the processor, server stress Various components in test device 400 are coupled by bus interface 403, and the computer program is by the processor 401 realize following steps when executing:
The test request of at least two clients is sent to first thread pond;The first thread pond be provided in advance to Few two threads;
By the thread in the first thread pond, the test request of at least two client is handled, to tested Examination server is tested.
Optionally, the test request includes that request is established in connection;
The computer program is also used to when being executed by the processor 401:
By the thread in the first thread pond, at least two client is sent to the tested server Request is established in connection;
By the thread in the first thread pond, receives the tested server and be based at least two client Connection establish request return connection establish result.
Optionally, it is also used to when the computer program is executed by the processor 401:
The thread by the first thread pond receives the tested server and is based at least two visitor The connection at family end is established the connection that request returns and is established after result, by the first information for each connection currently established, storage In connection management mapping table, wherein the first information includes at least connection identifier;
According to the connection identifier stored in the connection management mapping table, Message Processing is carried out to the tested server Test.
Optionally, it is also used to when the computer program is executed by the processor 401:
The news release request of first client is sent to the second thread pool, wherein first client is described Client at least two clients, second thread pool are provided at least two threads in advance;
By the thread in the second thread pool, select first client corresponding from the connection management mapping table Connection identifier, and using connection corresponding to selected connection identifier, first message is issued to the tested server, In, the first message is the message carried during the news release of first client is requested.
Optionally, it is also used to when the computer program is executed by the processor 401:
It is described using connection corresponding to selected connection identifier, to the tested server publication first message it Before, by the second information of the first message, it is stored in message management mapping table;Wherein, second information includes at least and disappears Breath mark;
Correspondingly, the computer program is also used to when being executed by the processor 401: described to utilize selected connection The corresponding connection of mark is issued to after the tested server publication first message to the tested server In the case where the first message failure, according to the message mark of the first message stored in the message management mapping table Know, issues the first message to the tested server again.
Optionally, it is also used to when the computer program is executed by the processor 401:
In the case where the second client receives the message of the tested server publication, by third thread pool Thread determine described first according to corresponding first connection identifier of second client and the connection management mapping table The corresponding connection of connection identifier, and using the corresponding connection of first connection identifier, disappear to the tested server feedback Cease reception result;
Wherein, second client is the client at least two client, and the third thread pool is preparatory Configured at least two threads.
Optionally, it is also used to when the computer program is executed by the processor 401:
By the first information for each connection currently established, after being stored in connection management mapping table, from the connection The second connection identifier to be deleted is selected in management mapping table;
The corresponding connection of second connection identifier is disconnected, and deletes described second from the connection management mapping table and connects Connect mark.
Optionally, the pressure test equipment is the pressure test equipment based on Netty.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed The scope of the present invention.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description, The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In embodiment provided herein, it should be understood that disclosed device and method can pass through others Mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the unit, only A kind of logical function partition, there may be another division manner in actual implementation, for example, multiple units or components can combine or Person is desirably integrated into another system, or some features can be ignored or not executed.Another point, shown or discussed is mutual Between coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING or communication link of device or unit It connects, can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple In network unit.Some or all of unit therein can be selected to realize the embodiment of the present invention according to the actual needs Purpose.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.
It, can be with if the function is realized in the form of SFU software functional unit and when sold or used as an independent product It is stored in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially in other words The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention. And storage medium above-mentioned includes: that USB flash disk, mobile hard disk, ROM, RAM, magnetic or disk etc. are various can store program code Medium.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be subject to the protection scope in claims.

Claims (18)

1. a kind of server stress test method, which is characterized in that be applied to pressure test equipment, comprising:
The test request of at least two clients is sent to first thread pond;The first thread pond is provided at least two in advance A thread;
By the thread in the first thread pond, the test request of at least two client is handled, to tested clothes Business device is tested.
2. the method according to claim 1, wherein the test request includes that request is established in connection;
The thread by the first thread pond handles the test request of at least two client, comprising:
By the thread in the first thread pond, the connection of at least two client is sent to the tested server Establish request;
By the thread in the first thread pond, the company of the tested server based at least two client is received Connecing to establish requests the connection returned to establish result.
3. according to the method described in claim 2, it is characterized in that, the thread by the first thread pond, receives After the tested server establishes result based on the connection that request return is established in the connection of at least two client, institute State method further include:
The first information for each connection currently established is stored in connection management mapping table, wherein the first information is extremely It less include connection identifier;
According to the connection identifier stored in the connection management mapping table, Message Processing survey is carried out to the tested server Examination.
4. according to the method described in claim 3, it is characterized in that, described according to the company stored in the connection management mapping table Mark is connect, Message Processing test is carried out to the tested server, comprising:
The request of the news release of first client is sent to the second thread pool, wherein first client be it is described at least Client in two clients, second thread pool are provided at least two threads in advance;
By the thread in the second thread pool, the corresponding connection of first client is selected from the connection management mapping table Mark, and using connection corresponding to selected connection identifier, first message is issued to the tested server, wherein The first message is the message carried during the news release of first client is requested.
5. according to the method described in claim 4, it is characterized in that, described utilize company corresponding to selected connection identifier It connects, to before the tested server publication first message, the method also includes:
By the second information of the first message, it is stored in message management mapping table;Wherein, second information includes at least and disappears Breath mark;
It is described using connection corresponding to selected connection identifier, to after the tested server publication first message, The method also includes:
In the case where issuing first message failure to the tested server, according in the message management mapping table The message identifier of the first message of storage issues the first message to the tested server again.
6. according to the method described in claim 3, it is characterized in that, described according to the company stored in the connection management mapping table Mark is connect, Message Processing test is carried out to the tested server, comprising:
In the case where the second client receives the message of the tested server publication, pass through the line in third thread pool Journey determines first connection according to corresponding first connection identifier of second client and the connection management mapping table Corresponding connection is identified, and using the corresponding connection of first connection identifier, is connect to the tested server feedback message Receive result;
Wherein, second client is the client at least two client, and the third thread pool is pre-configured with There are at least two threads.
7. according to the method described in claim 3, it is characterized in that, the first information for each connection currently established is stored After in connection management mapping table, the method also includes:
The second connection identifier to be deleted is selected from the connection management mapping table;
The corresponding connection of second connection identifier is disconnected, and deletes the second connection mark from the connection management mapping table Know.
8. the method according to claim 1, wherein the pressure test equipment is that the pressure based on Netty is surveyed Try equipment.
9. a kind of server stress test device, which is characterized in that be set to pressure test equipment, comprising:
Sending module, for the test request of at least two clients to be sent to first thread pond;The first thread pond is pre- First it is configured at least two threads;
Processing module, for handling the test request of at least two client by the thread in the first thread pond, To test tested server.
10. device according to claim 9, which is characterized in that the test request includes that request is established in connection;
The processing module, comprising:
First transmission unit, for by the thread in the first thread pond, to the tested server send it is described extremely Request is established in the connection of few two clients;
First receiving unit, for receiving the tested server based on described by the thread in the first thread pond The connection of at least two clients establishes the connection that request returns and establishes result.
11. device according to claim 10, which is characterized in that described device further include:
First memory module receives the tested server and is based on for the thread by the first thread pond The connection of at least two client is established the connection that request returns and is established after result, by each connection currently established The first information is stored in connection management mapping table, wherein the first information includes at least connection identifier;
Message Processing test module, for being tested to described according to the connection identifier stored in the connection management mapping table Server carries out Message Processing test.
12. device according to claim 11, which is characterized in that the Message Processing test module, comprising:
Second transmission unit, for the news release request of the first client to be sent to the second thread pool, wherein described first Client is the client at least two client, and second thread pool is provided at least two threads in advance;
News release unit, for by the thread in the second thread pool, selecting described the from the connection management mapping table The corresponding connection identifier of one client, and using connection corresponding to selected connection identifier, to the tested server Issue first message, wherein the first message is the message carried during the news release of first client is requested.
13. device according to claim 12, which is characterized in that described device further include:
Second memory module, for described using connection corresponding to selected connection identifier, to the tested server Before issuing first message, by the second information of the first message, it is stored in message management mapping table;Wherein, described second Information includes at least message identifier;
Module is retransmitted, for disappearing according to described in the case where issuing first message failure to the tested server The message identifier of the first message stored in breath management mapping table, again to the tested server publication described first Message.
14. device according to claim 11, which is characterized in that the Message Processing test module, comprising:
Third transmission unit leads in the case where for receiving the message of the tested server publication in the second client The thread in third thread pool is crossed, is mapped according to corresponding first connection identifier of second client and the connection management Table determines the corresponding connection of first connection identifier, and using the corresponding connection of first connection identifier, is tested to described Try server feedback message sink result;
Wherein, second client is the client at least two client, and the third thread pool is pre-configured with There are at least two threads.
15. device according to claim 11, which is characterized in that described device further include:
Selecting module, for by the first information for each connection currently established, after being stored in connection management mapping table, from The second connection identifier to be deleted is selected in the connection management mapping table;
Module is disconnected, is deleted for disconnecting the corresponding connection of second connection identifier, and from the connection management mapping table Second connection identifier.
16. device according to claim 9, which is characterized in that the pressure test equipment is that the pressure based on Netty is surveyed Try equipment.
17. a kind of server stress test device, which is characterized in that including processor, memory and be stored in the memory Computer program that is upper and can running on the processor, is realized when the computer program is executed by the processor as weighed Benefit require any one of 1 to 8 described in server stress test method the step of.
18. a kind of computer readable storage medium, which is characterized in that be stored with computer on the computer readable storage medium Program realizes that server stress described in any item of the claim 1 to 8 such as is surveyed when the computer program is executed by processor The step of method for testing.
CN201811256647.5A 2018-10-26 2018-10-26 Server stress test method and device Pending CN109491895A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811256647.5A CN109491895A (en) 2018-10-26 2018-10-26 Server stress test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811256647.5A CN109491895A (en) 2018-10-26 2018-10-26 Server stress test method and device

Publications (1)

Publication Number Publication Date
CN109491895A true CN109491895A (en) 2019-03-19

Family

ID=65691587

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811256647.5A Pending CN109491895A (en) 2018-10-26 2018-10-26 Server stress test method and device

Country Status (1)

Country Link
CN (1) CN109491895A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110912786A (en) * 2019-12-27 2020-03-24 深圳市星砺达科技有限公司 Gateway pressure testing method and device, computer equipment and storage medium
CN112134754A (en) * 2020-09-18 2020-12-25 中移(杭州)信息技术有限公司 Pressure testing method and device, network equipment and storage medium
CN112615759A (en) * 2020-12-17 2021-04-06 上海哔哩哔哩科技有限公司 Full link voltage measurement assembly, full link voltage measurement method and device
CN115174433A (en) * 2022-07-07 2022-10-11 东软睿驰汽车技术(大连)有限公司 Simulation method, simulation device and simulation system for multi-terminal access gateway
CN116016092A (en) * 2022-12-13 2023-04-25 杭州领祺科技有限公司 MQTT synchronous message method based on multithreading

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060075406A1 (en) * 2004-10-04 2006-04-06 Research In Motion Limited System and method for adaptive allocation of threads to user objects in a computer system
CN1953401A (en) * 2005-10-20 2007-04-25 英业达股份有限公司 Multi-threading network pressure testing method
CN101681273A (en) * 2007-05-10 2010-03-24 国际商业机器公司 Server device operating in response to received request
CN102480392A (en) * 2010-11-23 2012-05-30 中兴通讯股份有限公司 Performance test device and working method thereof
CN102622426A (en) * 2012-02-27 2012-08-01 杭州闪亮科技有限公司 Database writing system and database writing method
CN102855173A (en) * 2011-06-27 2013-01-02 北京新媒传信科技有限公司 Method and device for testing software performance
CN105138685A (en) * 2015-09-17 2015-12-09 福建新大陆软件工程有限公司 HBase-oriented performance testing system
CN105446860A (en) * 2015-11-11 2016-03-30 上海欣方智能系统有限公司 Asynchronous concurrent mechanism based pressure test system and test method
CN107832146A (en) * 2017-10-27 2018-03-23 北京计算机技术及应用研究所 Thread pool task processing method in highly available cluster system
CN108234242A (en) * 2017-12-29 2018-06-29 北京奇虎科技有限公司 A kind of method for testing pressure and device based on stream
CN108512710A (en) * 2017-02-24 2018-09-07 腾讯科技(深圳)有限公司 Test method based on testing tool and testing tool
CN108574610A (en) * 2018-01-30 2018-09-25 北京金山云网络技术有限公司 A kind of method for testing pressure, device, electronic equipment and medium

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060075406A1 (en) * 2004-10-04 2006-04-06 Research In Motion Limited System and method for adaptive allocation of threads to user objects in a computer system
CN1953401A (en) * 2005-10-20 2007-04-25 英业达股份有限公司 Multi-threading network pressure testing method
CN101681273A (en) * 2007-05-10 2010-03-24 国际商业机器公司 Server device operating in response to received request
CN102480392A (en) * 2010-11-23 2012-05-30 中兴通讯股份有限公司 Performance test device and working method thereof
CN102855173A (en) * 2011-06-27 2013-01-02 北京新媒传信科技有限公司 Method and device for testing software performance
CN102622426A (en) * 2012-02-27 2012-08-01 杭州闪亮科技有限公司 Database writing system and database writing method
CN105138685A (en) * 2015-09-17 2015-12-09 福建新大陆软件工程有限公司 HBase-oriented performance testing system
CN105446860A (en) * 2015-11-11 2016-03-30 上海欣方智能系统有限公司 Asynchronous concurrent mechanism based pressure test system and test method
CN108512710A (en) * 2017-02-24 2018-09-07 腾讯科技(深圳)有限公司 Test method based on testing tool and testing tool
CN107832146A (en) * 2017-10-27 2018-03-23 北京计算机技术及应用研究所 Thread pool task processing method in highly available cluster system
CN108234242A (en) * 2017-12-29 2018-06-29 北京奇虎科技有限公司 A kind of method for testing pressure and device based on stream
CN108574610A (en) * 2018-01-30 2018-09-25 北京金山云网络技术有限公司 A kind of method for testing pressure, device, electronic equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
乔平安等: "基于Linux系统的构建高性能服务器的研究", 《计算机与数字工程》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110912786A (en) * 2019-12-27 2020-03-24 深圳市星砺达科技有限公司 Gateway pressure testing method and device, computer equipment and storage medium
CN110912786B (en) * 2019-12-27 2021-07-16 深圳市星砺达科技有限公司 Gateway pressure testing method and device, computer equipment and storage medium
CN112134754A (en) * 2020-09-18 2020-12-25 中移(杭州)信息技术有限公司 Pressure testing method and device, network equipment and storage medium
CN112615759A (en) * 2020-12-17 2021-04-06 上海哔哩哔哩科技有限公司 Full link voltage measurement assembly, full link voltage measurement method and device
CN112615759B (en) * 2020-12-17 2023-03-31 上海哔哩哔哩科技有限公司 Full link voltage measurement assembly, full link voltage measurement method and device
CN115174433A (en) * 2022-07-07 2022-10-11 东软睿驰汽车技术(大连)有限公司 Simulation method, simulation device and simulation system for multi-terminal access gateway
CN115174433B (en) * 2022-07-07 2024-06-11 东软睿驰汽车技术(大连)有限公司 Simulation method, simulation device and simulation system for multi-terminal access gateway
CN116016092A (en) * 2022-12-13 2023-04-25 杭州领祺科技有限公司 MQTT synchronous message method based on multithreading

Similar Documents

Publication Publication Date Title
CN109491895A (en) Server stress test method and device
US10348809B2 (en) Naming of distributed business transactions
CN102143075B (en) Method and system for achieving load balance
US6912573B2 (en) Method for acquiring content information, and software product, collaboration system and collaboration server for acquiring content information
CN103139157B (en) A kind of based on the network communication method of socket, Apparatus and system
CN107947960A (en) The method for pushing and system of configuration information, the method for reseptance and system of configuration information
CN109743358A (en) Asynchronous message interface fusing control method, device, computer equipment and storage medium
WO2012132815A1 (en) Virtual server id management system, integrated monitoring system, virtual server id management program, and integrated monitoring program
CN107919971B (en) Method, apparatus and system for audio/video communication connection disaster tolerance
JP2005539298A (en) Method and system for remotely and dynamically configuring a server
NO318974B1 (en) Distributed MCU
CN108897854A (en) A kind of monitoring method and device of overtime task
CN108712501A (en) Sending method, device, computing device and the storage medium of information
CN107688512A (en) One kind optimization virtual-machine data backup method and system
CN101710893A (en) Device, system and method for correlating application software service systems
CN116319732A (en) Message queue centralized configuration management system and method based on RabbitMQ
CN105490849B (en) The automatic deployment method and system of application system
CN114490100B (en) Message queue telemetry transmission load balancing method, device and server
CN105871806A (en) Streaming media file slicing method, device and system
CN104754029B (en) Determine the methods, devices and systems of master management server
CN107741885B (en) Transaction and service association method and system based on CS framework
JP3515839B2 (en) Communication system between computer systems
CN103973485B (en) Operation management system and method based on fixed port
CN109889425B (en) Interaction method and device for client and storage medium
CN110443710A (en) A kind of the block catenary system and method for batch signature

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20190319

RJ01 Rejection of invention patent application after publication