WO2019041499A1 - Selection method and device for data sending object, computer equipment and storage medium - Google Patents

Selection method and device for data sending object, computer equipment and storage medium Download PDF

Info

Publication number
WO2019041499A1
WO2019041499A1 PCT/CN2017/107978 CN2017107978W WO2019041499A1 WO 2019041499 A1 WO2019041499 A1 WO 2019041499A1 CN 2017107978 W CN2017107978 W CN 2017107978W WO 2019041499 A1 WO2019041499 A1 WO 2019041499A1
Authority
WO
WIPO (PCT)
Prior art keywords
request data
target
identity
data
status code
Prior art date
Application number
PCT/CN2017/107978
Other languages
French (fr)
Chinese (zh)
Inventor
包晓华
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019041499A1 publication Critical patent/WO2019041499A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system

Definitions

  • the present application relates to the field of computer technology, and in particular, to a method, an apparatus, a computer device, and a storage medium for selecting a data transmission object.
  • the application node and the service node generally judge the load of a certain network node through the feedback result of the heartbeat or the request data, and the two parties that need the communication transmit through the network data.
  • the load is balanced by rejecting the response.
  • the traditional method of balancing load requires effective data transmission between the two communicating parties, which increases unnecessary data transmission and creates additional pressure on the network.
  • the network pressure is too high, it will cause message blocking, packet loss, etc.
  • the requester needs more threads, memory, message queues and other resources to maintain the link state of the double-ended server in the link pool, occupying the server resources of the requester, and affecting the preparation efficiency of the data request.
  • a method, an apparatus, a computer device, and a storage medium for selecting a data transmission object are provided.
  • a method for selecting a data transmission object comprising:
  • the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data, and the status code is used to indicate whether the request data is successfully sent.
  • the corresponding identity identifier When the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is decremented by one count;
  • the target device corresponding to the identifier with the smallest count is determined as the transmission target of the target request data.
  • a device for selecting a data transmission object comprising:
  • the status code obtaining module is configured to obtain a status code returned by the local network layer after the request data is sent out through the network, and the status code is in one-to-one correspondence with the request data, where the status code is used to indicate whether the request data is successfully sent;
  • An identifier obtaining module configured to acquire an identity identifier of the target device that is sent by the status code corresponding to the request data
  • a counting module configured to: when the status code indicates that the request data is successfully sent, add a count to the corresponding identity identifier; otherwise, count the corresponding identity identifier by one count; and
  • the object determining module is configured to determine, as the sending target of the target request data, the target device corresponding to the identifier with the smallest count when receiving the sending instruction of the target request data.
  • a computer device comprising a memory and one or more processors, the memory storing computer readable instructions, the computer readable instructions being executed by the processor, causing the one or more processors to execute
  • the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data, where the status code is used to indicate whether the request data is successfully sent;
  • the identity identifier of the target device sent by the request data when the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is counted down; and the target request data is received.
  • the target device corresponding to the identifier with the smallest count is determined as the destination of the target request data.
  • One or more non-transitory readable storage mediums storing computer readable instructions, when executed by one or more processors, cause the one or more processors to execute
  • the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data.
  • the status code is used to indicate whether the request data is successfully sent.
  • the identity identifier of the target device sent by the request data when the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is counted down; and the target request data is received.
  • the target device corresponding to the identifier with the smallest count is determined as the destination of the target request data.
  • FIG. 1 is a flowchart of a method of selecting a data transmission object according to an embodiment of the present application
  • FIG. 2 is a flowchart of a method for selecting a data transmission object according to another embodiment of the present application.
  • FIG. 3 is a flowchart of a method for selecting a data transmission object according to still another embodiment of the present application.
  • FIG. 4 is a block diagram showing an exemplary structure of a device for selecting a data transmission object according to an embodiment of the present application
  • FIG. 5 is a schematic diagram showing the internal structure of a computer device according to an embodiment of the present application.
  • first, second and the like are used to describe various elements, but these elements are not limited by these terms. These terms are only used for the first element The piece is distinguished from another element.
  • the first quotient value can be referred to as a second quotient value without departing from the scope of the invention, and similarly, the second quotient value can be referred to as a first quotient value. Both the first quotient value and the second quotient value are quotient values, but they are not the same quotient value.
  • FIG. 1 is a flowchart of a method for selecting a data transmission object according to an embodiment of the present application.
  • a method for selecting a data transmission object according to an embodiment of the present application is described in detail with reference to FIG. 1, as shown in FIG.
  • the selection method of the data transmission object includes the following steps S101, S102, S103, and S104.
  • the returned status code is “00”, it indicates that the request data is successfully transmitted, and when the returned status code is another code, it indicates that the request data transmission fails, wherein.
  • the status code is a status code returned by the local network layer to the local end according to the TCP protocol.
  • the status codes returned by the TCP protocol layer are the same.
  • the user can map the status code returned by the network layer of the TCP protocol to the application layer according to the requirements and characteristics of the system. For example, the "Y" character of the application layer can be mapped to the status code "00", and the application will be applied.
  • the "N" of the layer maps other status codes returned by the network layer.
  • the network layer feeds back a status code corresponding to the requested data to determine whether the requested data is successfully transmitted.
  • the identifier of the target device may be a MAC (Media Access Control or Medium Access Control) physical address of the target device, and may also be an IP address of the target device, or may be the target. Other unique identifiers for the device.
  • MAC Media Access Control or Medium Access Control
  • the “receiving the status code returned by the local network layer” in the above step S102 is further “acquiring the status code returned by the local network layer in the preset first time period”.
  • the preset first time period is a time period for detecting which device is more suitable for the sending object of the target request data, and the determining of the first time period may be pre-written by the programmer.
  • the first time period of the preset period is used as the time period for load detection, and can be set according to actual service requirements. For example, it can be set within one day from the start time, or can be selected as the working time period, for example, 9:00 am ⁇ 6:00 pm, or one week or one month from the start time, where the start time can be the current time, or other time set by the programmer, when the application's usual data request is very large,
  • the first time period is set to be shorter to avoid occupying too much memory on the application end, and no limitation is imposed here.
  • the use of the preset first time period to define a valid status code can avoid consuming too many resources of the local end when the amount of historical request data is particularly large, and also avoiding only when the number of target devices or the identity identifier is changed. By determining the target device caused by the target device in the historical data exchange, the defect of the target device corresponding to the new identity cannot be selected.
  • the method for selecting the data sending object before the step of step S102, further includes:
  • the method for selecting the data sending object further includes: counting the counting result of the target device having the same service capability that is connected to the local end by the network.
  • the target devices having the same service processing capability for example, both process the automatic underwriting service server, so that the target request data is processed to be sent to the target device, and the corresponding target device has the capability of processing the requested data.
  • the redirection object of the request data of the same service may be different.
  • the service request quantity is large, it needs to be processed by multiple servers having corresponding service processing capabilities, and specifically, which server is sent to which server. Processing is what is done by the selection method of the data request transmission object according to one embodiment of the present application.
  • the counting result of the target device having the same service capability to be connected to the local end is counted as zero, so that the target device corresponding to the new identity can be counted by the start of the preset first time period.
  • the step of adding or subtracting the corresponding identity identifier in the step is used to determine the load of the target device corresponding to the identity identifier, and the more request data sent to the target device corresponding to the same identity identifier, the implied The smaller the load of the target device corresponding to the identity identifier, the smaller the number of request data sent to the target device corresponding to the same identity identifier, or the smaller the load of the target device corresponding to the identity identifier.
  • the target device corresponding to the identifier with the smallest count is determined as the sending target of the target request data.
  • step S104 of the embodiment the target device corresponding to the identifier with the lowest count is determined as the transmission target of the target request data, so that the target request data can be sent to the target device corresponding to the identifier with the smallest count when transmitting.
  • the target device with the least load is processed to process the target request data, thereby achieving load balancing.
  • the request data in the above step and the request data sent out through the network in the step S101 are any real valid request data that is currently existing, not to add one count or subtract one count.
  • the generated data is data that is not specifically generated for load detection of a target device. For example, when the user logs in to an application account, the user sends the history request data of the account login to the server. For example, when a server resource needs to be called, a resource request data sent to the server, and the like.
  • the target object data is determined by determining the status of the request data transmission.
  • the target request data is sent to the target device corresponding to the lowest-identified identity identifier to balance the devices. Load.
  • the existing request data is directly used to determine the load of the corresponding target device, and is not required.
  • the local end additionally generates request data for detecting the peer target device, which can greatly reduce the resource consumption of the load detection.
  • the selection method of the data transmission object is further The following steps (1) to (4) are included.
  • the target request data is sent to the determined target device through the network.
  • the "determined target device” may be the target device determined by the above step S104.
  • the "determined target device" in the step (1) is the target device determined by the above step S104.
  • the identity identifier of the target device of the target request data is counted according to the status code and the identity identifier, and the status code is a status code corresponding to the target request data, and the identity identifier is an identity identifier of the target device of the target request data.
  • the identity of the target of the target request data is incremented by one, when the above step (2) When the status code returned in the data is a status code indicating that the target request data has failed to be transmitted, the identity of the destination to which the target request data is transmitted is decremented by one.
  • the sending object of the target request data is included in the range of counting, so that the selecting method of the data sending object can be cyclically performed, and the target devices can be automatically updated according to the existing true and effective request data sending situation. Count the results.
  • FIG. 2 is a flowchart of a method for selecting a data transmission object according to another embodiment of the present application, and a method for selecting a data transmission object, as shown in FIG. 2, the method includes the foregoing steps S101, S102, and S103. The following steps S201 and S202 are also included.
  • the natural number whose weight is greater than zero is, for example, 1, 2, 3, 4, or 5, and the like.
  • the greater the weight of the preset target device indicates that the processing capability of the target device is stronger, and the user can preset the corresponding weight according to the service processing capability of each target device.
  • the user can preset a larger weight for the target device with stronger service processing capability and a smaller weight for the target device with weaker service processing capability.
  • step S104 is specifically the following step S203:
  • the result of the identification of the identity of the target device A is 100
  • the weight of the target device A is 4, and the technical result of the identity of the target device B is 80, and the weight of the target device B.
  • the value is 2, the target device A has a quotient of 25, and the target device B has a quotient of 40.
  • the target device A has a higher count result than the target device B, but the target device A has a lower quotient than the target device B,
  • the target request data is sent to the target device A.
  • the target device with strong processing capability can process more request data by presetting the corresponding weights of the target devices, so that no resource waste is caused.
  • the method for selecting the data transmission object further includes the following steps 1 to 4:
  • the status code corresponding to the target request data is determined as the status code.
  • the identity identifier of the target device of the target request data is counted, the status code is a status code corresponding to the target request data, and the identity identifier is the identity identifier of the target device of the target request data.
  • the "determined target device" in the above step 1 is the target device determined by the above step S203.
  • the status code returned in the above step 2 is a status code indicating that the target request data is successfully transmitted, The identity of the object to which the target request data is sent is incremented by one.
  • the status code returned in the above step 2 is a status code indicating that the target request data is failed to be transmitted, the identity of the object to which the target request data is transmitted is decremented by one. count.
  • the sending object of the target request data is included in the range of counting, so that the selecting method of the data sending object can be cyclically performed, and the target devices can be automatically updated according to the existing true and effective request data sending situation. Count the results.
  • FIG. 3 is a flowchart of a method for selecting a data transmission object according to still another embodiment of the present application, and a method for selecting a data transmission object, as shown in FIG. 3, the method including the steps S101 to S104 further includes the following steps. S301 and S302.
  • the programmer of the second time period can adjust the storage according to the actual requirements and the storage space of the local device.
  • the second device can be used.
  • the time period is set longer.
  • the second time period can be set shorter.
  • the start time of the second time period is the transmission time of the target request data.
  • the other target device in the step S302 represents the other target device of the target device determined by the step S104 or S203.
  • the step S302 further includes:
  • the target device corresponding to the calculated identity with the second smallest quotient is determined as the other target device.
  • the method further includes: sorting the identity identifiers of the respective target devices according to the counting result in a small to large order, and then determining the target device corresponding to the identity identifier with the smallest counting result as the sending object of the target request data, and counting As a result, the target device corresponding to the second smallest identity is determined as the other target device in step S302.
  • the method further includes: sorting the identity of each target device according to a quotient from small to large, and then determining the target device corresponding to the identity with the lowest quotient as the target.
  • the sending object of the request data determines the target device corresponding to the second smallest identities as the other target devices in step S302.
  • the maintenance of the target request data that has been sent is performed for a period of time, so that when the determined target request data sending object does not have the ability to process the target request data, the local end cannot be found in time, so that the system cannot be Responding to the request data, the embodiment sends the target request data to the other by saving the already sent request data for a period of time and ending the time period and not receiving the response data of the request data.
  • the target device is to let other target devices continue to process the request data.
  • the method before the step of saving the request data, the method further includes:
  • Determining whether the target request data carries an important identifier and if so, saving the target request data and starting a countdown within a preset time period, the important identifier indicating that the target request data is important request data.
  • the programmer can classify different task processes according to requirements, distinguish important task processing from less important task processing, so that the system can automatically add important identifiers to target request data of important tasks.
  • the important target request data is not Because the target device determined for the first time has no corresponding processing capability and is delayed or ignored, on the other hand, the maintenance of the target request data does not occupy excessive resources such as memory and threads.
  • the labels of the foregoing steps S101 to S302 are not used to limit the sequence of the steps in the embodiment, and the numbers of the steps are only for the convenience of referring to the labels of the steps when describing the steps.
  • the above step S201 may be determined after the step of S103, or before the step of step S103, as long as the order of execution of the respective steps does not affect the logical relationship of the embodiment, and is within the scope of the claimed application.
  • FIG. 4 is an exemplary diagram of a selection device of a data transmission object according to an embodiment of the present application. The method for selecting a data transmission object according to an embodiment of the present application is described in detail below with reference to FIG. 4. As shown in FIG. 4, the selection device 10 of the data transmission object includes:
  • the status code obtaining module 11 is configured to obtain a status code returned by the local network layer after the request data is sent out through the network, where the status code is in one-to-one correspondence with the request data, and the status code is used to indicate whether the request data is successfully sent.
  • the identifier obtaining module 12 is configured to acquire an identity identifier of the target device that is sent by the status code corresponding to the request data.
  • the counting module 13 is configured to: when the status code indicates that the request data is successfully sent, add a count to the corresponding identity identifier; otherwise, the corresponding identity identifier is decremented by one;
  • the object determining module 14 is configured to determine, as the sending target of the target request data, the target device corresponding to the identifier with the smallest count when receiving the sending instruction of the target request data.
  • the status code acquiring module is configured to obtain a status code returned by the local network layer in a preset first time period after the request data is sent out through the network.
  • the request data sent externally and the target request data are not data generated by adding one count or subtracting one count, but actual valid request data existing, instead of performing load detection on a target device.
  • the existing request data for example, when the user logs in an account of an application, sends the history request data of the account login to the server, and then, for example, when requesting the server resource, the resource request data sent to the server, etc. Wait.
  • the existing request data is directly used to determine the load of the corresponding target device, and is not required.
  • the local end additionally generates request data for detecting the peer target device, which can greatly reduce the resource consumption of the load detection.
  • the counting module 13 is further configured to count the counting result of the target device with the same service capability that is connected to the local end by zero.
  • the target devices having the same service processing capability for example, both process the automatic underwriting service server, so that the target request data is processed to be sent to the target device, and the corresponding target device has the capability of processing the requested data.
  • the redirection object of the request data of the same service may be different.
  • the service request quantity is large, it needs to be processed by multiple servers having corresponding service processing capabilities, and specifically, which server is sent to which server. Processing is what is done by the selection method of the data request transmission object according to one embodiment of the present application.
  • the counting result of the target device with the same service capability that is connected to the local end by the above-mentioned counting module is counted as zero, so that the target device corresponding to the new identity can be obtained at the beginning of the preset first time period.
  • the defect of the target device corresponding to the new identity cannot be selected only by determining the target device in the historical data exchange.
  • the selecting device of the data sending object further includes:
  • the weight obtaining module is configured to obtain a preset weight corresponding to each identity identifier, where the weight is a natural number greater than zero;
  • a calculation module configured to calculate a quotient of the count result of each identity and a corresponding weight
  • the object determining module is specifically configured to: determine, as the sending object of the target request data, the target device corresponding to the identifier with the smallest calculated quotient value.
  • the data sending module is specifically configured to determine the target device corresponding to the second-identity identifier as the other target device, or determine the target device corresponding to the calculated second-identity identifier as the other target device.
  • the selecting device of the data sending object further includes:
  • a data sending module configured to send the target request data to the determined target device through the network.
  • the status code obtaining module is further configured to obtain a status code corresponding to the target request data returned by the local network layer.
  • the identifier obtaining module is further configured to obtain a status code corresponding to the target request data returned by the local network layer.
  • the foregoing counting module is further configured to: when the status code indicates that the target request data is successfully sent, add an identifier to the identity identifier of the target device of the target request data; otherwise, the target request number is The identity of the target device is decremented by one.
  • the status code is a status code corresponding to the target request data, and the identity is the identity of the target device of the target request data.
  • the selecting device of the data sending object further includes:
  • a data saving module configured to save the target request data and start a countdown in a preset time period when the target request data is sent to the determined target device through the network;
  • a data deletion module configured to delete the corresponding target request data when the response data of the target request data is received before the counting down ends
  • the data sending module is further configured to send the target request data to other target devices when the countdown has ended but the response data of the target request data is not received.
  • the data saving module further includes:
  • the determining module is configured to determine whether the request data carries an important identifier, and if yes, save the target request data and start a countdown within a preset time period, where the important identifier indicates that the target request data is important request data.
  • the data storage module, the data deletion module, and the data sending module perform maintenance work on the sent target request data for a period of time, so as to avoid when the determined target request data sending object does not have the capability to process the target request data.
  • the local end cannot be discovered in time, so that the system cannot respond to the request data.
  • the request data that has been sent is saved for a period of time, and the time period is ended and the response data of the request data is not received.
  • the target request data is sent to other target devices, the other target devices continue to process the requested data.
  • the determining module determines whether the stored target request data is important request data, so that only the more important target request data is saved and counted, instead of saving and maintaining all the requested data, which makes the important The request data will not be delayed or ignored because the target device determined by the first time has no corresponding processing capability.
  • the maintenance of the target request data does not occupy excessive resources such as memory and threads.
  • the selecting device of the data sending object further includes:
  • a first sorting module configured to change the identity of each target device according to the counting result from small to large Sorting the order;
  • the object determining module is specifically configured to determine the target device corresponding to the identifier with the smallest counting result as the sending object of the target request data, and determine the target device corresponding to the second smallest identifier of the counting result as the other Target device.
  • a second sorting module configured to sort the identifiers of the respective target devices according to the quotient from small to large; the object determining module is specifically configured to determine the target device corresponding to the identifier with the smallest quotient as the target request data.
  • the sending object determines the target device corresponding to the second smallest identities as the other target devices.
  • each module included in the selection device of the data transmission object may be implemented in whole or in part by software, hardware or a combination thereof. Further, each module in the selection device of the data transmission object may be a program segment for implementing a corresponding function.
  • first and second in the above-mentioned first sorting module and second sorting module are only to distinguish two sorting modules, and are not used to define which sorting module has higher priority or Other limited meanings.
  • the embodiment provides a data transmission object selection device, and the status code can determine whether the corresponding request data is successfully sent.
  • the determination of the load condition of the target device is based on the status code fed back by the local end, and It is necessary to create additional data transmission for the network, so that the network pressure can be reduced, and the target device with the smallest object count is determined as the target object of the target request data, and the load balancing of the target device can be achieved, and the load balancing is not implemented.
  • the target device with large load sends the request data, instead of sending the request data to the target device with a large load in the conventional technology, and sending the request data to the target device with a smaller load after receiving the response message of the reject response, further
  • the unnecessary data transmission in the network is reduced, and the target device with a large load is not required to open an additional process to respond to the message of the rejection response, and the burden of the target device with a large load is also reduced.
  • the selection means of the above data transmission object can be implemented in the form of a computer readable instruction which can be run on a computer device as shown in FIG.
  • a computer device comprising a memory, a processor, and computer readable instructions stored on the memory and executable on the processor, the processor
  • the selection method of the above data transmission object is implemented when the computer readable instruction is executed.
  • a computer apparatus comprising a memory and one or more processors having stored therein computer readable instructions that, when executed by one or more processors, cause one or more The processor performs the following steps: after sending the request data through the network, obtaining the status code returned by the local network layer, the status code is in one-to-one correspondence with the request data, the status code is used to indicate whether the request data is successfully sent, and the status code corresponding request is obtained.
  • the target device corresponding to the identifier with the smallest count is determined as the transmission target of the target request data.
  • the one or more processors before the step of determining, by the one or more processors, the target device corresponding to the identity with the smallest count as the destination of the target request data, the one or more processors further perform the following steps: acquiring each The identity identifier corresponds to a preset weight, the weight is a natural number greater than zero; and the quotient of the count result of each identity and the corresponding weight is calculated; and the identity identifier that is executed by one or more processors to minimize the count And determining, by the target device, a sending object of the target request data, further comprising: determining, by the target device corresponding to the identifier with the smallest quotient value, the sending target of the target request data.
  • the one or more processors before performing the step of determining a transmission object of the target request data, the one or more processors further perform the steps of: transmitting the target request data to the determined target device over the network; The status code corresponding to the target request data returned by the local network layer; and when the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented, otherwise, the target of the target request data is The device's identity is decremented by one count.
  • the one or more processors when the computer readable instructions are executed by one or more processors, the one or more processors further cause the step of: requesting data when the target request data is transmitted over the network to the determined target device Save and start the countdown within the preset time period; and when counting down When the response data of the target request data is received before the end of the time, the corresponding target request data is deleted, and when the countdown has ended but the response data of the target request data is not received, the target request data is transmitted to the other target device.
  • the one or more processors before the step of saving the target request data by the one or more processors, further perform the steps of: saving and starting the target request data when the request data carries the important identifier Countdown within a preset time period.
  • the source of the request data when executed by one or more processors, does not include data for counting the separately generated.
  • the identity of the corresponding target device is counted by one or minus one by using the status code fed back by the local network layer, and the status code can be used to determine whether the corresponding request data is successfully sent. Add a count to the corresponding target device, otherwise perform a countdown. The more the target device counts, the larger the load of the target device is. The judgment of the load condition of the target device is based on the status code fed back by the local end. It is not necessary to create additional data transmission for the network, thereby reducing network pressure and transmitting the target request data to the target device with the smallest count, that is, by transmitting the target request data to the target device with the smallest load to achieve load balancing of the target device.
  • the request data is not sent to the target device with a large load, instead of sending the request data to the target device with a large load in the conventional technology, and sending the request data after receiving the response message for rejecting the response.
  • the request data is not sent to the target device with a large load, instead of sending the request data to the target device with a large load in the conventional technology, and sending the request data after receiving the response message for rejecting the response.
  • FIG. 5 is a schematic diagram of an internal structure of a computer device according to an embodiment of the present application, which may be a server.
  • the computer device includes a processor coupled through a system bus, a non-volatile storage medium, an internal memory, an input device, a display screen, and a network interface.
  • the non-volatile storage medium of the computer device can store an operating system and computer readable instructions, and when the computer readable instructions are executed, the processor can be caused to perform a method for selecting a data transmission object according to various embodiments of the present application.
  • the specific implementation process of the method may refer to the specific content of each embodiment in FIG. 1 to FIG. 3, and details are not described herein again.
  • the processor of the computer device is used to provide computing and control capabilities, Support the operation of the entire computer equipment.
  • the internal memory can store computer readable instructions that, when executed by the processor, cause the processor to perform a method of selecting a data transmission object.
  • the input device of the computer device is used for input of various parameters, the display screen of the computer device is used for display, and the network interface of the computer device is used for network communication.
  • FIG. 5 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device to which the solution of the present application is applied.
  • the specific computer device may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
  • Non-volatile memories can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • ROM read only memory
  • PROM programmable ROM
  • EPROM electrically programmable ROM
  • EEPROM electrically erasable programmable ROM
  • one or more non-transitory readable storage media having computer readable instructions that, when executed by one or more processors, cause one or more processors to execute The following steps: after sending the request data through the network, the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data, the status code is used to indicate whether the request data is successfully sent; and the status code is sent corresponding to the request data.
  • the identity of the target device when the status code indicates that the request data is successfully sent, the corresponding identity is incremented by one, otherwise the corresponding identity is decremented by one; and when the target request data is received, the number is counted.
  • the target device corresponding to the smallest identity is determined as the destination of the target request data.
  • the one or more processors before the step of determining, by the one or more processors, the target device corresponding to the identity with the smallest count as the destination of the target request data, the one or more processors further perform the following steps: acquiring each The identity identifier corresponds to a preset weight, the weight is a natural number greater than zero; and the quotient of the count result of each identity and the corresponding weight is calculated; and the identity identifier that is executed by one or more processors to minimize the count And determining, by the target device, a sending object of the target request data, further comprising: determining, by the target device corresponding to the identifier with the smallest quotient value, the sending target of the target request data.
  • the one or more processors before performing the step of determining a transmission object of the target request data, the one or more processors further perform the steps of: transmitting the target request data to the determined target device over the network; The status code corresponding to the target request data returned by the local network layer; and when the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented, otherwise, the target of the target request data is The device's identity is decremented by one count.
  • the one or more processors when the computer readable instructions are executed by one or more processors, the one or more processors further cause the step of: requesting data when the target request data is transmitted over the network to the determined target device Saving and starting the countdown in the preset time period; and when receiving the response data of the target request data before the countdown ends, deleting the corresponding target request data, when the countdown has ended but the response data of the target request data is not received , the target request data is sent to other target devices.
  • the one or more processors before the step of saving the target request data by the one or more processors, further perform the steps of: saving and starting the target request data when the request data carries the important identifier Countdown within a preset time period.
  • the source of the request data when executed by one or more processors, does not include data for counting the separately generated.
  • all or part of the processes in the foregoing embodiment may be completed by instructing related hardware by computer readable instructions, and the computer readable instructions may be stored in a computer readable storage medium, such as
  • the computer readable instructions may be stored in a storage medium of a computer system and executed by at least one processor in the computer system to implement a process including an embodiment of the methods described above.
  • the storage medium includes, but is not limited to, a magnetic disk, a USB flash drive, an optical disk, a read-only memory (ROM), and the like.
  • the identity of the corresponding target device is counted by one or minus one by using the status code fed back by the local network layer, and the status code can be used to determine whether the corresponding request data is successfully sent. Add a count to the corresponding target device, otherwise perform a countdown. The more the target device counts, the greater the load on the target device, and the load on the target device. The judgment of the situation is made according to the status code fed back by the local end, and no additional data transmission is needed for the network, so that the network pressure can be reduced, and the target request data is sent to the target device with the smallest count, that is, by sending the target request data.
  • the target device with the least load is implemented to achieve the load balancing of the target device, and when the load balancing is implemented, the request data is not sent to the target device with a large load, instead of sending the request data to the target device with a large load in the conventional technology.
  • the response message of rejecting the response is sent to the other target device with less load, the unnecessary data transmission in the network is further reduced, and the target device that does not need to be loaded is required to open an additional process to respond to the rejection response.
  • the message also reduces the burden on the target device with a large load.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

A selection method for a data sending object, comprising: after request data is sent to the outside via a network, obtaining a state code returned by a home terminal network layer, the state code having one-to-one correspondence to the request data, and the state code being used for indicating whether the request data is sent successfully (S101); obtaining an identity identification of target equipment sent by the state code corresponding to the request data (S102); when the state code indicates that the request data is sent successfully, adding one to the corresponding identity identification and counting, otherwise, subtracting one from the corresponding identity identification and counting (S103); and when a sending instruction of target request data is received, determining the target equipment corresponding to the identity identification with a least count to be a sending object of the target request data (S104).

Description

数据发送对象的选择方法、装置、计算机设备及存储介质Method, device, computer device and storage medium for selecting data transmission object
本申请要求于2017年08月28日提交中国专利局、申请号为2017107519978、发明名称为“数据发送对象的选择方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 2017107519978, entitled "Selection Method, Apparatus, Computer Equipment and Storage Medium for Data Transmission Objects", filed on August 28, 2017, the entire contents of which are hereby incorporated by reference. This is incorporated herein by reference.
技术领域Technical field
本申请涉及计算机技术领域,特别是涉及数据发送对象的选择方法、装置、计算机设备及存储介质。The present application relates to the field of computer technology, and in particular, to a method, an apparatus, a computer device, and a storage medium for selecting a data transmission object.
背景技术Background technique
目前对于网络传输中的应用节点和服务节点之间的通信,应用节点与服务节点之间一般是通过心跳或者请求数据的反馈结果来判断某个网络节点的负载,需要通信的双方通过网络数据传输来确定某个设备的负载,当某个设备的负载过大时,通过拒绝响应的方式来均衡负载。At present, for the communication between the application node and the service node in the network transmission, the application node and the service node generally judge the load of a certain network node through the feedback result of the heartbeat or the request data, and the two parties that need the communication transmit through the network data. To determine the load of a device, when a device's load is too large, the load is balanced by rejecting the response.
传统的这种均衡负载的方式需要通信双方进行有效的数据传输,增加了不必要的数据传输,给网络制造额外的压力,当网络压力过大时会导致消息阻塞、丢包等情况,也会使得请求方需要更多的线程、内存、消息队列等资源去维护链接池中双端服务器等的链接状态,占用请求方服务器资源,影响数据请求的准备效率。The traditional method of balancing load requires effective data transmission between the two communicating parties, which increases unnecessary data transmission and creates additional pressure on the network. When the network pressure is too high, it will cause message blocking, packet loss, etc. The requester needs more threads, memory, message queues and other resources to maintain the link state of the double-ended server in the link pool, occupying the server resources of the requester, and affecting the preparation efficiency of the data request.
发明内容Summary of the invention
根据本申请的各种实施例,提供了一种数据发送对象的选择方法、装置、计算机设备及存储介质。According to various embodiments of the present application, a method, an apparatus, a computer device, and a storage medium for selecting a data transmission object are provided.
一种数据发送对象的选择方法,该方法包括:A method for selecting a data transmission object, the method comprising:
通过网络对外发送请求数据后,获取本端网络层返回的状态码,该状态码与该请求数据一一对应,该状态码用于表示该请求数据是否发送成功; After the request data is sent out through the network, the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data, and the status code is used to indicate whether the request data is successfully sent.
获取该状态码对应请求数据所发送的目标设备的身份标识;Obtaining an identity identifier of the target device that is sent by the status code corresponding to the request data;
当该状态码表示该请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及When the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is decremented by one count; and
接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为该目标请求数据的发送对象。When receiving the transmission instruction of the target request data, the target device corresponding to the identifier with the smallest count is determined as the transmission target of the target request data.
一种数据发送对象的选择装置,该装置包括:A device for selecting a data transmission object, the device comprising:
状态码获取模块,用于通过网络对外发送请求数据后,获取本端网络层返回的状态码,该状态码与该请求数据一一对应,该状态码用于表示该请求数据是否发送成功;The status code obtaining module is configured to obtain a status code returned by the local network layer after the request data is sent out through the network, and the status code is in one-to-one correspondence with the request data, where the status code is used to indicate whether the request data is successfully sent;
标识获取模块,用于获取该状态码对应请求数据所发送的目标设备的身份标识;An identifier obtaining module, configured to acquire an identity identifier of the target device that is sent by the status code corresponding to the request data;
计数模块,用于当该状态码表示该请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及a counting module, configured to: when the status code indicates that the request data is successfully sent, add a count to the corresponding identity identifier; otherwise, count the corresponding identity identifier by one count; and
对象确定模块,用于接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象。The object determining module is configured to determine, as the sending target of the target request data, the target device corresponding to the identifier with the smallest count when receiving the sending instruction of the target request data.
一种计算机设备,包括存储器和一个或多个处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器执行以下步骤:通过网络对外发送请求数据后,获取本端网络层返回的状态码,该状态码与该请求数据一一对应,该状态码用于表示该请求数据是否发送成功;获取该状态码对应请求数据所发送的目标设备的身份标识;当该状态码表示该请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为该目标请求数据的发送对象。A computer device comprising a memory and one or more processors, the memory storing computer readable instructions, the computer readable instructions being executed by the processor, causing the one or more processors to execute After the request data is sent out through the network, the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data, where the status code is used to indicate whether the request data is successfully sent; The identity identifier of the target device sent by the request data; when the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is counted down; and the target request data is received. When the instruction is sent, the target device corresponding to the identifier with the smallest count is determined as the destination of the target request data.
一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行以 下步骤:通过网络对外发送请求数据后,获取本端网络层返回的状态码,该状态码与该请求数据一一对应,该状态码用于表示该请求数据是否发送成功;获取该状态码对应请求数据所发送的目标设备的身份标识;当该状态码表示该请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为该目标请求数据的发送对象。One or more non-transitory readable storage mediums storing computer readable instructions, when executed by one or more processors, cause the one or more processors to execute After the request data is sent out through the network, the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data. The status code is used to indicate whether the request data is successfully sent. The identity identifier of the target device sent by the request data; when the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is counted down; and the target request data is received. When the instruction is sent, the target device corresponding to the identifier with the smallest count is determined as the destination of the target request data.
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。Details of one or more embodiments of the present application are set forth in the accompanying drawings and description below. Other features, objects, and advantages of the invention will be apparent from the description and appended claims.
附图说明DRAWINGS
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings to be used in the embodiments will be briefly described below. Obviously, the drawings in the following description are only some embodiments of the present application, Those skilled in the art can also obtain other drawings based on these drawings without any creative work.
图1为根据本申请的一个实施例的数据发送对象的选择方法的流程图;1 is a flowchart of a method of selecting a data transmission object according to an embodiment of the present application;
图2为根据本申请的另一实施例的数据发送对象的选择方法的流程图;2 is a flowchart of a method for selecting a data transmission object according to another embodiment of the present application;
图3为根据本申请的又一实施例的数据发送对象的选择方法的流程图;FIG. 3 is a flowchart of a method for selecting a data transmission object according to still another embodiment of the present application; FIG.
图4为根据本申请的一个实施例的数据发送对象的选择装置的示范性结构框图;4 is a block diagram showing an exemplary structure of a device for selecting a data transmission object according to an embodiment of the present application;
图5为根据本申请的一个实施例的计算机设备的内部结构示意图。FIG. 5 is a schematic diagram showing the internal structure of a computer device according to an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the objects, technical solutions, and advantages of the present application more comprehensible, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
可以理解,本发明所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语的限制。这些术语仅用于将第一个元 件与另一个元件区分。举例来说,在不脱离本发明的范围的情况下,可以将第一商值称为第二商值,且类似地,可将第二商值称为第一商值。第一商值和第二商值两者都是商值,但其不是同一商值。It will be understood that the terms "first", "second" and the like, as used herein, are used to describe various elements, but these elements are not limited by these terms. These terms are only used for the first element The piece is distinguished from another element. For example, the first quotient value can be referred to as a second quotient value without departing from the scope of the invention, and similarly, the second quotient value can be referred to as a first quotient value. Both the first quotient value and the second quotient value are quotient values, but they are not the same quotient value.
图1为根据本申请的一个实施例的数据发送对象的选择方法的流程图,下面结合图1来详细描述根据本申请的一个实施例的数据发送对象的选择方法,如图1所示,该数据发送对象的选择方法包括以下步骤S 101、S102、S103及S104。FIG. 1 is a flowchart of a method for selecting a data transmission object according to an embodiment of the present application. Hereinafter, a method for selecting a data transmission object according to an embodiment of the present application is described in detail with reference to FIG. 1, as shown in FIG. The selection method of the data transmission object includes the following steps S101, S102, S103, and S104.
S101、通过网络对外发送请求数据后,获取本端网络层返回的状态码,该状态码与该请求数据一一对应,该状态码用于表示该请求数据是否发送成功。S101. After sending the request data to the network, obtain the status code returned by the local network layer, where the status code is in one-to-one correspondence with the request data, where the status code is used to indicate whether the request data is successfully sent.
根据本实施例的一个示例,返回的状态码为“00”时,表示该请求数据发送成功,当返回的状态码为其它码时,表示请求数据发送失败,其中。该状态码为本端网络层根据TCP协议向本端返回的状态码,在不同的系统中使用根据本实施例提供的数据发送对象的选择方法时,在TCP协议层返回的状态码是相同的,但是在应用层用户可以根据系统的需求与特色,将TCP协议的网络层返回的状态码映射到应用层,例如,可将应用层的“Y”字符映射该状态码“00”,将应用层的“N”映射网络层返回的其它状态码。According to an example of the embodiment, when the returned status code is “00”, it indicates that the request data is successfully transmitted, and when the returned status code is another code, it indicates that the request data transmission fails, wherein. The status code is a status code returned by the local network layer to the local end according to the TCP protocol. When the data transmission object selection method according to the embodiment is used in different systems, the status codes returned by the TCP protocol layer are the same. However, at the application layer, the user can map the status code returned by the network layer of the TCP protocol to the application layer according to the requirements and characteristics of the system. For example, the "Y" character of the application layer can be mapped to the status code "00", and the application will be applied. The "N" of the layer maps other status codes returned by the network layer.
在TCP协议的网络层应用中,每对外发送一个请求数据,网络层都会反馈一个与该请求数据对应的状态码,以确定该请求数据是否发送成功。In the network layer application of the TCP protocol, each time a request data is sent, the network layer feeds back a status code corresponding to the requested data to determine whether the requested data is successfully transmitted.
S102、获取该状态码对应请求数据所发送的目标设备的身份标识。S102. Acquire an identity identifier of the target device that is sent by the status code corresponding to the request data.
根据本实施例的一个示例,该目标设备的身份标识可以是该目标设备的MAC((Media Access Control或者Medium Access Control))物理地址,还可以是该目标设备的IP地址,还可以是该目标设备的其它唯一标识符。According to an example of the embodiment, the identifier of the target device may be a MAC (Media Access Control or Medium Access Control) physical address of the target device, and may also be an IP address of the target device, or may be the target. Other unique identifiers for the device.
在其中的一个实施例中,上述步骤S102中“获取本端网络层返回的状态码”进一步为“获取本端网络层在预设的第一时间段内返回的状态码”。In one of the embodiments, the “receiving the status code returned by the local network layer” in the above step S102 is further “acquiring the status code returned by the local network layer in the preset first time period”.
在该步骤中,上述的预设的第一时间段为检测哪个设备更为适合目标请求数据的发送对象的时间段,该第一时间段的确定可以由程序员预写入进行 设置,上述预设的第一时间段作为负载检测的时间段,可以根据实际的业务需求进行设置,例如可以设置自开始时间起一天之内,也可以选择为工作时间段,例如9:00am~6:00pm,或者是自开始时间起一周或一个月之内,其中,该开始时间可以是当前时间,也可以是程序员设置的其它时间,当应用端的平时的数据请求量非常大时,可以将该第一时间段设置的短一些,以避免占用应用端过多的内存,在此不做限制。In this step, the preset first time period is a time period for detecting which device is more suitable for the sending object of the target request data, and the determining of the first time period may be pre-written by the programmer. The first time period of the preset period is used as the time period for load detection, and can be set according to actual service requirements. For example, it can be set within one day from the start time, or can be selected as the working time period, for example, 9:00 am~ 6:00 pm, or one week or one month from the start time, where the start time can be the current time, or other time set by the programmer, when the application's usual data request is very large, The first time period is set to be shorter to avoid occupying too much memory on the application end, and no limitation is imposed here.
利用预设的第一时间段来限定有效的状态码可以避免历史请求数据的量特别大时,占用本端过多的资源,也使得在目标设备的数量或身份标识进行了变更时,避免只通过在历史数据往来中确定目标设备造成的无法选择新的身份标识对应的目标设备的缺陷。The use of the preset first time period to define a valid status code can avoid consuming too many resources of the local end when the amount of historical request data is particularly large, and also avoiding only when the number of target devices or the identity identifier is changed. By determining the target device caused by the target device in the historical data exchange, the defect of the target device corresponding to the new identity cannot be selected.
根据本实施例的一个示例,在该步骤S102的步骤之前,该数据发送对象的选择方法还包括:According to an example of the embodiment, before the step of step S102, the method for selecting the data sending object further includes:
S103、当该状态码表示该请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数。S103. When the status code indicates that the request data is successfully sent, add a count to the corresponding identity identifier, and otherwise count the corresponding identity identifier by one.
根据本实施例的一个示例,在该步骤S103的步骤之前,该数据发送对象的选择方法还包括:将与本端进行网络连接的具有相同业务能力的目标设备的计数结果计为零。According to an example of the embodiment, before the step of the step S103, the method for selecting the data sending object further includes: counting the counting result of the target device having the same service capability that is connected to the local end by the network.
其中,具有相同业务处理能力的目标设备例如均处理自动核保业务服务器,以使得该目标请求数据不论发送给那个目标设备进行处理,对应的目标设备都具有处理该请求数据的能力。The target devices having the same service processing capability, for example, both process the automatic underwriting service server, so that the target request data is processed to be sent to the target device, and the corresponding target device has the capability of processing the requested data.
一般而言,对于同一业务的请求数据的重定向对象可以不同,当业务请求量巨大时,需要通过多个具有对应业务处理能力的服务器来进行处理,具体需要将该请求数据发送给哪个服务器进行处理就是根据本申请的一个实施例的数据请求发送对象的选择方法所做的事情。Generally, the redirection object of the request data of the same service may be different. When the service request quantity is large, it needs to be processed by multiple servers having corresponding service processing capabilities, and specifically, which server is sent to which server. Processing is what is done by the selection method of the data request transmission object according to one embodiment of the present application.
通过在将与本端进行网络连接的具有相同业务能力的目标设备的计数结果计为零,使得可以在上述预设的第一时段开始时,可以通过将新的身份标识对应的目标设备纳入计数的对象之内,使得在目标设备的数量或身份标识 进行了变更时,避免只通过在历史数据往来中确定目标设备造成的无法选择新的身份标识对应的目标设备的缺陷。The counting result of the target device having the same service capability to be connected to the local end is counted as zero, so that the target device corresponding to the new identity can be counted by the start of the preset first time period. Within the object, making the number or identity of the target device When a change is made, it is avoided that the defect of the target device corresponding to the new identity cannot be selected only by determining the target device in the historical data exchange.
其中,在该步骤中对对应的身份标识进行加一或减一的计数用于确定该身份标识对应的目标设备的负载,向同一身份标识对应的目标设备发送的请求数据越多,隐含的可以表示该身份标识对应的目标设备的负载越大,对应的,向同一身份标识对应的目标设备发送的请求数据的数量越少,也可以隐含表示该身份标识对应的目标设备的负载越小。The step of adding or subtracting the corresponding identity identifier in the step is used to determine the load of the target device corresponding to the identity identifier, and the more request data sent to the target device corresponding to the same identity identifier, the implied The smaller the load of the target device corresponding to the identity identifier, the smaller the number of request data sent to the target device corresponding to the same identity identifier, or the smaller the load of the target device corresponding to the identity identifier. .
S104、接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象。S104. When receiving the sending instruction of the target request data, the target device corresponding to the identifier with the smallest count is determined as the sending target of the target request data.
在该实施例的步骤S104中,通过将计数最小的身份标识对应的目标设备确定为该目标请求数据的发送对象,使得该目标请求数据在发送时可以发送给计数最小的身份标识对应的目标设备,使得负载最小的目标设备处理该目标请求数据,从而实现负载均衡。In step S104 of the embodiment, the target device corresponding to the identifier with the lowest count is determined as the transmission target of the target request data, so that the target request data can be sent to the target device corresponding to the identifier with the smallest count when transmitting. The target device with the least load is processed to process the target request data, thereby achieving load balancing.
根据本实施例的一个示例,上述步骤中的请求数据以及该步骤S101中的通过网络对外发送的请求数据为当前已存在的任意真实有效的请求数据,不是为了加一计数或减一计数而另外生成的数据,即不是为了对某个目标设备进行负载检测而专门生成的数据,该已经存在的请求数据例如用户在登录某个应用的账号时,向服务器端发送账号登录的历史请求数据,再例如在需要调用服务器资源时,向服务器发送的资源请求数据等等。According to an example of the embodiment, the request data in the above step and the request data sent out through the network in the step S101 are any real valid request data that is currently existing, not to add one count or subtract one count. The generated data is data that is not specifically generated for load detection of a target device. For example, when the user logs in to an application account, the user sends the history request data of the account login to the server. For example, when a server resource needs to be called, a resource request data sent to the server, and the like.
在其中的一个实施例中,通过对上述请求数据发送状态的判断来决定目标请求数据的发送对象,本实施例将目标请求数据发送给计数最小的身份标识所对应的目标设备,以均衡各个设备的负载。In one of the embodiments, the target object data is determined by determining the status of the request data transmission. In this embodiment, the target request data is sent to the target device corresponding to the lowest-identified identity identifier to balance the devices. Load.
在传统技术的任务检测中,为了测试等需求,需要专门生成为了测试对应任务的数据,而在本申请的该实例中,将已经存在的请求数据直接用来判断对应目标设备的负载,不需要本端另外生成检测对端目标设备的请求数据,可以大大降低负载检测的资源消耗。In the task detection of the conventional technology, in order to test and other requirements, it is necessary to specifically generate data for testing the corresponding task, and in the example of the present application, the existing request data is directly used to determine the load of the corresponding target device, and is not required. The local end additionally generates request data for detecting the peer target device, which can greatly reduce the resource consumption of the load detection.
进一步地,在上述步骤S104的步骤之后,该数据发送对象的选择方法还 包括以下步骤(1)至(4)。Further, after the step of the above step S104, the selection method of the data transmission object is further The following steps (1) to (4) are included.
(1)、将该目标请求数据通过网络发送给确定的该目标设备,在该实施例中,该“确定的该目标设备”可以是通过上述步骤S104确定的目标设备。(1) The target request data is sent to the determined target device through the network. In this embodiment, the "determined target device" may be the target device determined by the above step S104.
在该实施例中,该步骤(1)中的“确定的目标设备”为通过上述步骤S104所确定的目标设备。In this embodiment, the "determined target device" in the step (1) is the target device determined by the above step S104.
(2)、获取本端网络层返回的与目标请求数据对应的状态码。(2) Obtaining a status code corresponding to the target request data returned by the local network layer.
(3)、当该状态码表示该目标请求数据发送成功时,对该目标请求数据的目标设备的身份标识进行加一计数,否则,对该目标请求数据的目标设备的身份标识进行减一计数。(3), when the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented, otherwise, the identity of the target device of the target request data is counted down by one. .
本实施例根据状态码及身份标识,对目标请求数据的目标设备的身份标识进行计数,状态码为与目标请求数据对应的状态码,身份标识为目标请求数据的目标设备的身份标识。In this embodiment, the identity identifier of the target device of the target request data is counted according to the status code and the identity identifier, and the status code is a status code corresponding to the target request data, and the identity identifier is an identity identifier of the target device of the target request data.
在该实施例中,当上述步骤(2)中返回的状态码为表示目标请求数据发送成功的状态码时,对该目标请求数据的发送对象的身份标识进行加一计数,当上述步骤(2)中返回的状态码为表示目标请求数据发送失败的状态码时,对该目标请求数据的发送对象的身份标识进行减一计数。In this embodiment, when the status code returned in the above step (2) is a status code indicating that the target request data is successfully transmitted, the identity of the target of the target request data is incremented by one, when the above step (2) When the status code returned in the data is a status code indicating that the target request data has failed to be transmitted, the identity of the destination to which the target request data is transmitted is decremented by one.
本实施例通过将该目标请求数据的发送对象纳入计数的范围之内,使得该数据发送对象的选择方法可以循环进行,可以根据已经存在的真实有效的请求数据的发送情况自动更新各个目标设备的计数结果。In this embodiment, the sending object of the target request data is included in the range of counting, so that the selecting method of the data sending object can be cyclically performed, and the target devices can be automatically updated according to the existing true and effective request data sending situation. Count the results.
图2为根据本申请的另一实施例的数据发送对象的选择方法的流程图,如图2所示的数据发送对象的选择方法,该方法在包括上述步骤S101、S102及S103的基础上,还包括以下步骤S201及S202。2 is a flowchart of a method for selecting a data transmission object according to another embodiment of the present application, and a method for selecting a data transmission object, as shown in FIG. 2, the method includes the foregoing steps S101, S102, and S103. The following steps S201 and S202 are also included.
S201、获取对每个身份标识对应预设的权值,该权值为大于零的自然数。S201. Acquire a preset weight corresponding to each identity identifier, where the weight is a natural number greater than zero.
根据本实施例的一个示例,该权值为大于零的自然数例如为1、2、3、4、或5等等。According to an example of the embodiment, the natural number whose weight is greater than zero is, for example, 1, 2, 3, 4, or 5, and the like.
在该实施例中,对一个目标设备预设的权值越大表示该目标设备的处理能力越强,用户可以根据各个目标设备的业务处理能力预设对应的权值,其 中,用户可以将业务处理能力较强的目标设备预设较大的权值,对业务处理能力较弱的目标设备预设较小的权值。In this embodiment, the greater the weight of the preset target device indicates that the processing capability of the target device is stronger, and the user can preset the corresponding weight according to the service processing capability of each target device. The user can preset a larger weight for the target device with stronger service processing capability and a smaller weight for the target device with weaker service processing capability.
S202、计算每个身份标识的计数结果与对应权值的商值。S202. Calculate a quotient of the result of each identity and a quotient of the corresponding weight.
其中,上述步骤S104具体为下述步骤S203:The above step S104 is specifically the following step S203:
S203、接收到目标请求数据的发送指令时,将计算的商值最小的身份标识对应的目标设备确定为目标请求数据的发送对象。S203. When receiving the sending instruction of the target request data, determine the target device corresponding to the identifier with the smallest quotient value as the target of the target request data.
根据本实施例的一个使用场景例如:对目标设备A的身份标识的计数结果为100,目标设备A的权值为4,对目标设备B的身份标识的技术结果为80,目标设备B的权值为2,则目标设备A的商值为25,目标设备B的商值为40,虽然目标设备A的计数结果高于目标设备B,但是目标设备A的商值小于目标设备B,故则将该目标请求数据发送给目标设备A。According to a usage scenario of the embodiment, for example, the result of the identification of the identity of the target device A is 100, the weight of the target device A is 4, and the technical result of the identity of the target device B is 80, and the weight of the target device B. The value is 2, the target device A has a quotient of 25, and the target device B has a quotient of 40. Although the target device A has a higher count result than the target device B, but the target device A has a lower quotient than the target device B, The target request data is sent to the target device A.
本实施例通过对各个目标设备预设其相应的权值,使得具有较强处理能力的目标设备可以处理更多的请求数据,以使得不会造成资源浪费。In this embodiment, the target device with strong processing capability can process more request data by presetting the corresponding weights of the target devices, so that no resource waste is caused.
根据本实施例的另一示例,在上述步骤S203的步骤之后,该数据发送对象的选择方法还包括以下步骤1至步骤4:According to another example of the embodiment, after the step of step S203, the method for selecting the data transmission object further includes the following steps 1 to 4:
1、将该目标请求数据通过网络发送给确定的该目标设备。1. Send the target request data to the determined target device through the network.
2、获取本端网络层返回的与目标请求数据对应的状态码。2. Obtain a status code corresponding to the target request data returned by the local network layer.
3、当目标请求数据的发送时间在预设的第一时间段内时,将与目标请求数据对应的状态码确定为状态码。3. When the sending time of the target request data is within the preset first time period, the status code corresponding to the target request data is determined as the status code.
4、根据状态码及身份标识,对目标请求数据的目标设备的身份标识进行计数,状态码为与目标请求数据对应的状态码,身份标识为目标请求数据的目标设备的身份标识。4. According to the status code and the identity identifier, the identity identifier of the target device of the target request data is counted, the status code is a status code corresponding to the target request data, and the identity identifier is the identity identifier of the target device of the target request data.
在该实施例中,上述步骤1中的“确定的该目标设备”为通过上述步骤S203确定的目标设备,当上述步骤2中返回的状态码为表示目标请求数据发送成功的状态码时,对该目标请求数据的发送对象的身份标识进行加一计数,当上述步骤2中返回的状态码为表示目标请求数据发送失败的状态码时,对该目标请求数据的发送对象的身份标识进行减一计数。 In this embodiment, the "determined target device" in the above step 1 is the target device determined by the above step S203. When the status code returned in the above step 2 is a status code indicating that the target request data is successfully transmitted, The identity of the object to which the target request data is sent is incremented by one. When the status code returned in the above step 2 is a status code indicating that the target request data is failed to be transmitted, the identity of the object to which the target request data is transmitted is decremented by one. count.
本实施例通过将该目标请求数据的发送对象纳入计数的范围之内,使得该数据发送对象的选择方法可以循环进行,可以根据已经存在的真实有效的请求数据的发送情况自动更新各个目标设备的计数结果。In this embodiment, the sending object of the target request data is included in the range of counting, so that the selecting method of the data sending object can be cyclically performed, and the target devices can be automatically updated according to the existing true and effective request data sending situation. Count the results.
图3为根据本申请的又一实施例的数据发送对象的选择方法的流程图,如图3所示的数据发送对象的选择方法,该方法包括上述步骤S101至S104的基础上还包括以下步骤S301及S302。FIG. 3 is a flowchart of a method for selecting a data transmission object according to still another embodiment of the present application, and a method for selecting a data transmission object, as shown in FIG. 3, the method including the steps S101 to S104 further includes the following steps. S301 and S302.
S301、将该目标请求数据通过网络发送给确定的该目标设备时,将该目标请求数据保存并启动预设时间段内的倒计时。S301. When the target request data is sent to the determined target device through the network, save the target request data and start a countdown within a preset time period.
根据本实施例的一个示例,该第二时间段的长短程序员可以根据实际的需求及本端设备的存储空间进行适应性调节,当本端设备的存储空间足够大时,可以将该第二时间段设置的长一些,当本端的存储空间容量有限时,可以将该第二时间段设置的短一些。在一个实施例中,该第二时间段的起始时间为该目标请求数据的发送时间。According to an example of the embodiment, the programmer of the second time period can adjust the storage according to the actual requirements and the storage space of the local device. When the storage space of the local device is sufficiently large, the second device can be used. The time period is set longer. When the storage capacity of the local end is limited, the second time period can be set shorter. In one embodiment, the start time of the second time period is the transmission time of the target request data.
S302、当在该倒计时结束之前接收到该目标请求数据的应答数据时,将对应的目标请求数据删除,当该倒计时已结束但未接收到该目标请求数据的应答数据,则将该目标请求数据发送给其它目标设备。S302. When the response data of the target request data is received before the countdown ends, the corresponding target request data is deleted. When the countdown has ended but the response data of the target request data is not received, the target request data is obtained. Send to other target devices.
根据本实施例的一个示例,该步骤S302中的其它目标设备表示除通过上述步骤S104或S203确定的目标设备的其它目标设备,在一个实施例中,该步骤S302还包括:According to an example of the embodiment, the other target device in the step S302 represents the other target device of the target device determined by the step S104 or S203. In an embodiment, the step S302 further includes:
将计数次小的身份标识对应的目标设备确定为其它目标设备,或;Determining the target device corresponding to the second-identification identity as another target device, or
将计算的商值次小的身份标识对应的目标设备确定为其它目标设备。The target device corresponding to the calculated identity with the second smallest quotient is determined as the other target device.
在该实施例中,还包括将各个目标设备的身份标识按照计数结果由小到大的顺序进行排序,然后将计数结果最小的身份标识对应的目标设备确定为目标请求数据的发送对象,将计数结果第二小的身份标识对应的目标设备确定为该步骤S302中的其它目标设备。In this embodiment, the method further includes: sorting the identity identifiers of the respective target devices according to the counting result in a small to large order, and then determining the target device corresponding to the identity identifier with the smallest counting result as the sending object of the target request data, and counting As a result, the target device corresponding to the second smallest identity is determined as the other target device in step S302.
在另一个实施例中,还包括将各个目标设备的身份标识按照商值由小到大的顺序进行排序,然后将商值最小的身份标识对应的目标设备确定为目标 请求数据的发送对象,将商值第二小的身份标识对应的目标设备确定为该步骤S302中的其它目标设备。In another embodiment, the method further includes: sorting the identity of each target device according to a quotient from small to large, and then determining the target device corresponding to the identity with the lowest quotient as the target. The sending object of the request data determines the target device corresponding to the second smallest identities as the other target devices in step S302.
本实施例通过对已发送的目标请求数据做一个一段时间内的维护工作,避免当确定的目标请求数据的发送对象没有处理该目标请求数据的能力时,本端无法及时发现,以致使系统无法对该请求数据做出应答,本实施例通过将已经发送的请求数据保存一段时间,并在该时间段计时结束且未收到该请求数据的应答数据时,通过将该目标请求数据发送给其它目标设备以让其它目标设备继续处理该请求数据。In this embodiment, the maintenance of the target request data that has been sent is performed for a period of time, so that when the determined target request data sending object does not have the ability to process the target request data, the local end cannot be found in time, so that the system cannot be Responding to the request data, the embodiment sends the target request data to the other by saving the already sent request data for a period of time and ending the time period and not receiving the response data of the request data. The target device is to let other target devices continue to process the request data.
根据本实施例的一个示例,在将该请求数据保存的步骤之前,该方法还包括:According to an example of the embodiment, before the step of saving the request data, the method further includes:
判断该目标请求数据是否携带重要标识,若是,则将该目标请求数据保存并启动预设时间段内的倒计时,该重要标识表示该目标请求数据为重要的请求数据。Determining whether the target request data carries an important identifier, and if so, saving the target request data and starting a countdown within a preset time period, the important identifier indicating that the target request data is important request data.
在该实施例中,程序员可以根据需求对不同的任务处理进行分类,将重要的任务处理与重要性不高的任务处理予以区分,使得系统可以对重要任务的目标请求数据自动添加重要标识。In this embodiment, the programmer can classify different task processes according to requirements, distinguish important task processing from less important task processing, so that the system can automatically add important identifiers to target request data of important tasks.
本实施例通过对存储的目标请求数据添加重要标识的限定,使得较为重要的目标请求数据才进行保存和倒计时,而不是对所有的请求数据均保存和维护,一方面使得重要的请求数据不会因为第一次确定的目标设备没有对应的处理能力而被延误或者忽略,另一方面,也是的对目标请求数据的维护不会占用过多的内存和线程等资源。In this embodiment, by adding the definition of the important identifier to the stored target request data, the more important target request data is saved and counted, instead of saving and maintaining all the requested data, on the one hand, the important request data is not Because the target device determined for the first time has no corresponding processing capability and is delayed or ignored, on the other hand, the maintenance of the target request data does not occupy excessive resources such as memory and threads.
根据本实施例的一个示例,上述步骤S101~S302的标号并不用于限定本实施例中各个步骤的先后顺序,各个步骤的编号只是为了使得描述各个步骤时可以通用引用该步骤的标号进行便捷的指代,例如上述步骤S201可以在S103的步骤之后,也可以在步骤S103的步骤之前,只要各个步骤执行的顺序不影响本实施例的逻辑关系即可确定在本申请请求保护的范围之内。According to an example of the embodiment, the labels of the foregoing steps S101 to S302 are not used to limit the sequence of the steps in the embodiment, and the numbers of the steps are only for the convenience of referring to the labels of the steps when describing the steps. For example, the above step S201 may be determined after the step of S103, or before the step of step S103, as long as the order of execution of the respective steps does not affect the logical relationship of the embodiment, and is within the scope of the claimed application.
图4为根据本申请的一个实施例的数据发送对象的选择装置的示范性结 构框图,下面结合图4来详细描述根据本申请的一个实施例的数据发送对象的选择方法,如图4所示,该数据发送对象的选择装置10包括:FIG. 4 is an exemplary diagram of a selection device of a data transmission object according to an embodiment of the present application. The method for selecting a data transmission object according to an embodiment of the present application is described in detail below with reference to FIG. 4. As shown in FIG. 4, the selection device 10 of the data transmission object includes:
状态码获取模块11,用于通过网络对外发送请求数据后,获取本端网络层返回的状态码,该状态码与该请求数据一一对应,该状态码用于表示该请求数据是否发送成功;The status code obtaining module 11 is configured to obtain a status code returned by the local network layer after the request data is sent out through the network, where the status code is in one-to-one correspondence with the request data, and the status code is used to indicate whether the request data is successfully sent.
标识获取模块12,用于获取该状态码对应请求数据所发送的目标设备的身份标识;The identifier obtaining module 12 is configured to acquire an identity identifier of the target device that is sent by the status code corresponding to the request data.
计数模块13,用于当该状态码表示该请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;The counting module 13 is configured to: when the status code indicates that the request data is successfully sent, add a count to the corresponding identity identifier; otherwise, the corresponding identity identifier is decremented by one;
对象确定模块14,用于接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象。The object determining module 14 is configured to determine, as the sending target of the target request data, the target device corresponding to the identifier with the smallest count when receiving the sending instruction of the target request data.
在其中的一个实施例中,上述状态码获取模块具体用于通过网络对外发送请求数据后,获取本端网络层在预设的第一时间段内返回的状态码。In one of the embodiments, the status code acquiring module is configured to obtain a status code returned by the local network layer in a preset first time period after the request data is sent out through the network.
其中,该对外发送的请求数据及该目标请求数据不是为了加一计数或减一计数而生成的数据,而是已存在的真实有效的请求数据,而不是为了对某个目标设备进行负载检测而专门生成的数据,该已经存在的请求数据例如用户在登录某个应用的账号时,向服务器端发送账号登录的历史请求数据,再例如在需要调用服务器资源时,向服务器发送的资源请求数据等等。The request data sent externally and the target request data are not data generated by adding one count or subtracting one count, but actual valid request data existing, instead of performing load detection on a target device. Specifically generated data, the existing request data, for example, when the user logs in an account of an application, sends the history request data of the account login to the server, and then, for example, when requesting the server resource, the resource request data sent to the server, etc. Wait.
在传统技术的任务检测中,为了测试等需求,需要专门生成为了测试对应任务的数据,而在本申请的该实例中,将已经存在的请求数据直接用来判断对应目标设备的负载,不需要本端另外生成检测对端目标设备的请求数据,可以大大降低负载检测的资源消耗。In the task detection of the conventional technology, in order to test and other requirements, it is necessary to specifically generate data for testing the corresponding task, and in the example of the present application, the existing request data is directly used to determine the load of the corresponding target device, and is not required. The local end additionally generates request data for detecting the peer target device, which can greatly reduce the resource consumption of the load detection.
作为可选地,该计数模块13还用于将与本端进行网络连接的具有相同业务能力的目标设备的计数结果计为零。Optionally, the counting module 13 is further configured to count the counting result of the target device with the same service capability that is connected to the local end by zero.
其中,具有相同业务处理能力的目标设备例如均处理自动核保业务服务器,以使得该目标请求数据不论发送给那个目标设备进行处理,对应的目标设备都具有处理该请求数据的能力。 The target devices having the same service processing capability, for example, both process the automatic underwriting service server, so that the target request data is processed to be sent to the target device, and the corresponding target device has the capability of processing the requested data.
一般而言,对于同一业务的请求数据的重定向对象可以不同,当业务请求量巨大时,需要通过多个具有对应业务处理能力的服务器来进行处理,具体需要将该请求数据发送给哪个服务器进行处理就是根据本申请的一个实施例的数据请求发送对象的选择方法所做的事情。Generally, the redirection object of the request data of the same service may be different. When the service request quantity is large, it needs to be processed by multiple servers having corresponding service processing capabilities, and specifically, which server is sent to which server. Processing is what is done by the selection method of the data request transmission object according to one embodiment of the present application.
通过上述计数模块将与本端进行网络连接的具有相同业务能力的目标设备的计数结果计为零,使得可以在上述预设的第一时段开始时,可以通过将新的身份标识对应的目标设备纳入计数的对象之内,使得在目标设备的数量或身份标识进行了变更时,避免只通过在历史数据往来中确定目标设备造成的无法选择新的身份标识对应的目标设备的缺陷。The counting result of the target device with the same service capability that is connected to the local end by the above-mentioned counting module is counted as zero, so that the target device corresponding to the new identity can be obtained at the beginning of the preset first time period. Within the object of the counting, when the number of the target device or the identity is changed, the defect of the target device corresponding to the new identity cannot be selected only by determining the target device in the historical data exchange.
进一步地,该数据发送对象的选择装置还包括:Further, the selecting device of the data sending object further includes:
权值获取模块,用于获取对每个身份标识对应预设的权值,该权值为大于零的自然数;The weight obtaining module is configured to obtain a preset weight corresponding to each identity identifier, where the weight is a natural number greater than zero;
计算模块,用于计算每个身份标识的计数结果与对应权值的商值;a calculation module, configured to calculate a quotient of the count result of each identity and a corresponding weight;
该对象确定模块具体用于:将计算的商值最小的身份标识对应的目标设备确定为目标请求数据的发送对象。The object determining module is specifically configured to: determine, as the sending object of the target request data, the target device corresponding to the identifier with the smallest calculated quotient value.
进一步地,该数据发送模块具体用于将计数次小的身份标识对应的目标设备确定为其它目标设备,或将计算的商值次小的身份标识对应的目标设备确定为其它目标设备。Further, the data sending module is specifically configured to determine the target device corresponding to the second-identity identifier as the other target device, or determine the target device corresponding to the calculated second-identity identifier as the other target device.
进一步地,该数据发送对象的选择装置还包括:Further, the selecting device of the data sending object further includes:
数据发送模块,用于将该目标请求数据通过网络发送给确定的该目标设备。And a data sending module, configured to send the target request data to the determined target device through the network.
上述状态码获取模块还用于获取本端网络层返回的与目标请求数据对应的状态码。The status code obtaining module is further configured to obtain a status code corresponding to the target request data returned by the local network layer.
上述标识获取模块还用于获取本端网络层返回的与该目标请求数据对应的状态码。The identifier obtaining module is further configured to obtain a status code corresponding to the target request data returned by the local network layer.
上述计数模块还用于当该状态码表示该目标请求数据发送成功时,对该目标请求数据的目标设备的身份标识进行加一计数,否则,对该目标请求数 据的目标设备的身份标识进行减一计数,状态码为与目标请求数据对应的状态码,身份标识为目标请求数据的目标设备的身份标识。The foregoing counting module is further configured to: when the status code indicates that the target request data is successfully sent, add an identifier to the identity identifier of the target device of the target request data; otherwise, the target request number is The identity of the target device is decremented by one. The status code is a status code corresponding to the target request data, and the identity is the identity of the target device of the target request data.
作为可选地,该数据发送对象的选择装置还包括:Optionally, the selecting device of the data sending object further includes:
数据保存模块,用于将该目标请求数据通过网络发送给确定的该目标设备时,将该目标请求数据保存并启动预设时间段内的倒计时;a data saving module, configured to save the target request data and start a countdown in a preset time period when the target request data is sent to the determined target device through the network;
数据删除模块,用于当在该倒计时结束之前接收到该目标请求数据的应答数据时,将对应的目标请求数据删除;a data deletion module, configured to delete the corresponding target request data when the response data of the target request data is received before the counting down ends;
上述数据发送模块还用于当该倒计时已结束但未接收到该目标请求数据的应答数据,则将该目标请求数据发送给其它目标设备。The data sending module is further configured to send the target request data to other target devices when the countdown has ended but the response data of the target request data is not received.
进一步作为可选地,该数据保存模块还包括:Further optionally, the data saving module further includes:
判断模块,用于判断该请求数据是否携带重要标识,若是,则将该目标请求数据保存并启动预设时间段内的倒计时,该重要标识表示该目标请求数据为重要的请求数据。The determining module is configured to determine whether the request data carries an important identifier, and if yes, save the target request data and start a countdown within a preset time period, where the important identifier indicates that the target request data is important request data.
本实施例通过数据保存模块、数据删除模块、数据发送模块对已发送的目标请求数据做一个一段时间内的维护工作,避免当确定的目标请求数据的发送对象没有处理该目标请求数据的能力时,本端无法及时发现,以致使系统无法对该请求数据做出应答,本实施例通过将已经发送的请求数据保存一段时间,并在该时间段计时结束且未收到该请求数据的应答数据时,通过将该目标请求数据发送给其它目标设备以让其它目标设备继续处理该请求数据。In this embodiment, the data storage module, the data deletion module, and the data sending module perform maintenance work on the sent target request data for a period of time, so as to avoid when the determined target request data sending object does not have the capability to process the target request data. The local end cannot be discovered in time, so that the system cannot respond to the request data. In this embodiment, the request data that has been sent is saved for a period of time, and the time period is ended and the response data of the request data is not received. When the target request data is sent to other target devices, the other target devices continue to process the requested data.
本实施例通过判断模块对存储的目标请求数据是否为重要请求数据予以判断,使得只有较为重要的目标请求数据才进行保存和倒计时,而不是对所有的请求数据均保存和维护,一方面使得重要的请求数据不会因为第一次确定的目标设备没有对应的处理能力而被延误或者忽略,另一方面,也是的对目标请求数据的维护不会占用过多的内存和线程等资源。In this embodiment, the determining module determines whether the stored target request data is important request data, so that only the more important target request data is saved and counted, instead of saving and maintaining all the requested data, which makes the important The request data will not be delayed or ignored because the target device determined by the first time has no corresponding processing capability. On the other hand, the maintenance of the target request data does not occupy excessive resources such as memory and threads.
进一步地,该数据发送对象的选择装置还包括:Further, the selecting device of the data sending object further includes:
第一排序模块,用于将各个目标设备的身份标识按照计数结果由小到大 的顺序进行排序;上述对象确定模块具体用于将计数结果最小的身份标识对应的目标设备确定为目标请求数据的发送对象,将计数结果第二小的身份标识对应的目标设备确定为上述的其它目标设备。a first sorting module, configured to change the identity of each target device according to the counting result from small to large Sorting the order; the object determining module is specifically configured to determine the target device corresponding to the identifier with the smallest counting result as the sending object of the target request data, and determine the target device corresponding to the second smallest identifier of the counting result as the other Target device.
第二排序模块,用于将各个目标设备的身份标识按照商值由小到大的顺序进行排序;上述对象确定模块具体用于将商值最小的身份标识对应的目标设备确定为目标请求数据的发送对象,将商值第二小的身份标识对应的目标设备确定为上述的其它目标设备。a second sorting module, configured to sort the identifiers of the respective target devices according to the quotient from small to large; the object determining module is specifically configured to determine the target device corresponding to the identifier with the smallest quotient as the target request data. The sending object determines the target device corresponding to the second smallest identities as the other target devices.
其中,该数据发送对象的选择装置中包括的各个模块可全部或部分通过软件、硬件或其组合来实现。进一步地,该数据发送对象的选择装置中的各个模块可以是用于实现对应功能的程序段。Wherein, each module included in the selection device of the data transmission object may be implemented in whole or in part by software, hardware or a combination thereof. Further, each module in the selection device of the data transmission object may be a program segment for implementing a corresponding function.
进一步地,上述的第一排序模块及第二排序模块中的“第一”和“第二”的意义仅在于将两个排序模块加以区分,并不用于限定哪个排序模块的优先级更高或者其它的限定意义。Further, the meanings of “first” and “second” in the above-mentioned first sorting module and second sorting module are only to distinguish two sorting modules, and are not used to define which sorting module has higher priority or Other limited meanings.
本实施例提供了一种数据发送对象的选择装置,通过该状态码即可判断对应的请求数据是否发送成功,对于目标设备的负载情况的判断是根据本端反馈的状态码做出的,不需要给网络制造额外的数据传输,从而可以减少网络压力,通过对象确定模块计数最小的目标设备确定为目标请求数据的发送对象,可以实现目标设备的负载均衡,且在实现负载均衡时是不向负载大的目标设备发送请求数据,而不是传统技术中的向负载大的目标设备发送请求数据、在收到拒绝响应的应答消息后再将该请求数据发给其它负载较小的目标设备,进一步减少了网络中不必要的数据传输,且无需负载较大的目标设备开启额外的进程去响应该拒绝应答的消息,也降低了负载较大的目标设备的负担。The embodiment provides a data transmission object selection device, and the status code can determine whether the corresponding request data is successfully sent. The determination of the load condition of the target device is based on the status code fed back by the local end, and It is necessary to create additional data transmission for the network, so that the network pressure can be reduced, and the target device with the smallest object count is determined as the target object of the target request data, and the load balancing of the target device can be achieved, and the load balancing is not implemented. The target device with large load sends the request data, instead of sending the request data to the target device with a large load in the conventional technology, and sending the request data to the target device with a smaller load after receiving the response message of the reject response, further The unnecessary data transmission in the network is reduced, and the target device with a large load is not required to open an additional process to respond to the message of the rejection response, and the burden of the target device with a large load is also reduced.
上述数据发送对象的选择装置可以实现为一种计算机可读指令的形式,计算机可读指令可以在如图5所示的计算机设备上运行。The selection means of the above data transmission object can be implemented in the form of a computer readable instruction which can be run on a computer device as shown in FIG.
根据本申请的一个实施例提供的计算机设备,该计算机设备包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,该处理器 执行该计算机可读指令时实现上述数据发送对象的选择方法。A computer device according to one embodiment of the present application, the computer device comprising a memory, a processor, and computer readable instructions stored on the memory and executable on the processor, the processor The selection method of the above data transmission object is implemented when the computer readable instruction is executed.
在一个实施例中,提供了一种计算机设备,包括存储器和一个或多个处理器,存储器中存储有计算机可读指令,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:通过网络对外发送请求数据后,获取本端网络层返回的状态码,状态码与请求数据一一对应,状态码用于表示请求数据是否发送成功;获取状态码对应请求数据所发送的目标设备的身份标识;当状态码表示请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象。In one embodiment, a computer apparatus is provided comprising a memory and one or more processors having stored therein computer readable instructions that, when executed by one or more processors, cause one or more The processor performs the following steps: after sending the request data through the network, obtaining the status code returned by the local network layer, the status code is in one-to-one correspondence with the request data, the status code is used to indicate whether the request data is successfully sent, and the status code corresponding request is obtained. The identity of the target device sent by the data; when the status code indicates that the request data is successfully sent, the corresponding identity is incremented, otherwise the corresponding identity is counted down; and the target request data is sent. When the target device corresponding to the identifier with the smallest count is determined as the transmission target of the target request data.
在一个实施例中,一个或多个处理器在执行将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象的步骤之前,一个或多个处理器还执行以下步骤:获取对每个身份标识对应预设的权值,权值为大于零的自然数;及计算每个身份标识的计数结果与对应权值的商值;一个或多个处理器所执行将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象的步骤,还包括:将计算的商值最小的身份标识对应的目标设备确定为目标请求数据的发送对象。In one embodiment, before the step of determining, by the one or more processors, the target device corresponding to the identity with the smallest count as the destination of the target request data, the one or more processors further perform the following steps: acquiring each The identity identifier corresponds to a preset weight, the weight is a natural number greater than zero; and the quotient of the count result of each identity and the corresponding weight is calculated; and the identity identifier that is executed by one or more processors to minimize the count And determining, by the target device, a sending object of the target request data, further comprising: determining, by the target device corresponding to the identifier with the smallest quotient value, the sending target of the target request data.
在一个实施例中,一个或多个处理器在执行确定目标请求数据的发送对象的步骤之前,一个或多个处理器还执行以下步骤:将目标请求数据通过网络发送给确定的目标设备;获取本端网络层返回的与目标请求数据对应的状态码;及当状态码表示目标请求数据发送成功时,对目标请求数据的目标设备的身份标识进行加一计数,否则,对目标请求数据的目标设备的身份标识进行减一计数。In one embodiment, the one or more processors, before performing the step of determining a transmission object of the target request data, the one or more processors further perform the steps of: transmitting the target request data to the determined target device over the network; The status code corresponding to the target request data returned by the local network layer; and when the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented, otherwise, the target of the target request data is The device's identity is decremented by one count.
在一个实施例中,计算机可读指令被一个或多个处理器执行时,还使得一个或多个处理器执行以下步骤:将目标请求数据通过网络发送给确定的目标设备时,将目标请求数据保存并启动预设时间段内的倒计时;及当在倒计 时结束之前接收到目标请求数据的应答数据时,将对应的目标请求数据删除,当倒计时已结束但未接收到目标请求数据的应答数据时,则将目标请求数据发送给其它目标设备。In one embodiment, when the computer readable instructions are executed by one or more processors, the one or more processors further cause the step of: requesting data when the target request data is transmitted over the network to the determined target device Save and start the countdown within the preset time period; and when counting down When the response data of the target request data is received before the end of the time, the corresponding target request data is deleted, and when the countdown has ended but the response data of the target request data is not received, the target request data is transmitted to the other target device.
在一个实施例中,一个或多个处理器在执行将目标请求数据保存的步骤之前,一个或多个处理器还执行以下步骤:当请求数据携带有重要标识时,将目标请求数据保存并启动预设时间段内的倒计时。In one embodiment, before the step of saving the target request data by the one or more processors, the one or more processors further perform the steps of: saving and starting the target request data when the request data carries the important identifier Countdown within a preset time period.
在一个实施例中,计算机可读指令被一个或多个处理器执行时,请求数据的来源不包括用于计数单独生成的数据。In one embodiment, when the computer readable instructions are executed by one or more processors, the source of the request data does not include data for counting the separately generated.
本实施例通过利用本端网络层回馈的状态码来对对应的目标设备的身份标识进行加一或减一的计数,通过该状态码即可判断对应的请求数据是否发送成功,当发送成功时对对应的目标设备进行加一计数,否则进行减一计数,目标设备的计数越多则表示该目标设备的负载越大,对于目标设备的负载情况的判断是根据本端反馈的状态码做出的,不需要给网络制造额外的数据传输,从而可以减少网络压力,将目标请求数据发送给计数最小的目标设备,即通过将目标请求数据发送给负载最小的目标设备从而实现目标设备的负载均衡,且在实现负载均衡时是不向负载大的目标设备发送请求数据,而不是传统技术中的向负载大的目标设备发送请求数据、在收到拒绝响应的应答消息后再将该请求数据发给其它负载较小的目标设备,进一步减少了网络中不必要的数据传输,且无需负载较大的目标设备开启额外的进程去响应该拒绝应答的消息,也降低了负载较大的目标设备的负担。In this embodiment, the identity of the corresponding target device is counted by one or minus one by using the status code fed back by the local network layer, and the status code can be used to determine whether the corresponding request data is successfully sent. Add a count to the corresponding target device, otherwise perform a countdown. The more the target device counts, the larger the load of the target device is. The judgment of the load condition of the target device is based on the status code fed back by the local end. It is not necessary to create additional data transmission for the network, thereby reducing network pressure and transmitting the target request data to the target device with the smallest count, that is, by transmitting the target request data to the target device with the smallest load to achieve load balancing of the target device. When the load balancing is implemented, the request data is not sent to the target device with a large load, instead of sending the request data to the target device with a large load in the conventional technology, and sending the request data after receiving the response message for rejecting the response. For other target devices with smaller loads, further reducing unnecessary numbers in the network Transmission, and no load larger target device is turned on an additional process to respond to the rejection reply message, but also reduces the burden of a large load of the target device.
图5为根据本申请的一个实施例的计算机设备的内部结构示意图,该计算机设备可以为服务器。参照图5,该计算机设备包括通过系统总线连接的处理器、非易失性存储介质、内存储器、输入装置、显示屏和网络接口。其中,该计算机设备的非易失性存储介质可存储操作系统和计算机可读指令,该计算机可读指令被执行时,可使得处理器执行本申请各实施例的一种数据发送对象的选择方法,该方法的具体实现过程可参考图1至3各实施例的具体内容,在此不再赘述。该计算机设备的处理器用于提供计算和控制能力, 支撑整个计算机设备的运行。该内存储器中可储存有计算机可读指令,该计算机可读指令被处理器执行时,可使得处理器执行一种数据发送对象的选择方法。计算机设备的输入装置用于各个参数的输入,计算机设备的显示屏用于进行显示,计算机设备的网络接口用于进行网络通信。FIG. 5 is a schematic diagram of an internal structure of a computer device according to an embodiment of the present application, which may be a server. Referring to Figure 5, the computer device includes a processor coupled through a system bus, a non-volatile storage medium, an internal memory, an input device, a display screen, and a network interface. The non-volatile storage medium of the computer device can store an operating system and computer readable instructions, and when the computer readable instructions are executed, the processor can be caused to perform a method for selecting a data transmission object according to various embodiments of the present application. The specific implementation process of the method may refer to the specific content of each embodiment in FIG. 1 to FIG. 3, and details are not described herein again. The processor of the computer device is used to provide computing and control capabilities, Support the operation of the entire computer equipment. The internal memory can store computer readable instructions that, when executed by the processor, cause the processor to perform a method of selecting a data transmission object. The input device of the computer device is used for input of various parameters, the display screen of the computer device is used for display, and the network interface of the computer device is used for network communication.
本领域技术人员可以理解,图5中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。It will be understood by those skilled in the art that the structure shown in FIG. 5 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device to which the solution of the present application is applied. The specific computer device may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
如此处所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性。合适的非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。Any reference to a memory, storage, database, or other medium as used herein may include non-volatile. Suitable non-volatile memories can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
在一个实施例中,提供了一个或多个存储有计算机可读指令的非易失性可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:通过网络对外发送请求数据后,获取本端网络层返回的状态码,状态码与请求数据一一对应,状态码用于表示请求数据是否发送成功;获取状态码对应请求数据所发送的目标设备的身份标识;当状态码表示请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象。In one embodiment, there is provided one or more non-transitory readable storage media having computer readable instructions that, when executed by one or more processors, cause one or more processors to execute The following steps: after sending the request data through the network, the status code returned by the local network layer is obtained, and the status code is in one-to-one correspondence with the request data, the status code is used to indicate whether the request data is successfully sent; and the status code is sent corresponding to the request data. The identity of the target device; when the status code indicates that the request data is successfully sent, the corresponding identity is incremented by one, otherwise the corresponding identity is decremented by one; and when the target request data is received, the number is counted. The target device corresponding to the smallest identity is determined as the destination of the target request data.
在一个实施例中,一个或多个处理器在执行将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象的步骤之前,一个或多个处理器还执行以下步骤:获取对每个身份标识对应预设的权值,权值为大于零的自然数;及计算每个身份标识的计数结果与对应权值的商值;一个或多个处理器所执行将计数最小的身份标识对应的目标设备确定为目标请求数据的发送对象的步骤,还包括:将计算的商值最小的身份标识对应的目标设备确定为目标请求数据的发送对象。 In one embodiment, before the step of determining, by the one or more processors, the target device corresponding to the identity with the smallest count as the destination of the target request data, the one or more processors further perform the following steps: acquiring each The identity identifier corresponds to a preset weight, the weight is a natural number greater than zero; and the quotient of the count result of each identity and the corresponding weight is calculated; and the identity identifier that is executed by one or more processors to minimize the count And determining, by the target device, a sending object of the target request data, further comprising: determining, by the target device corresponding to the identifier with the smallest quotient value, the sending target of the target request data.
在一个实施例中,一个或多个处理器在执行确定目标请求数据的发送对象的步骤之前,一个或多个处理器还执行以下步骤:将目标请求数据通过网络发送给确定的目标设备;获取本端网络层返回的与目标请求数据对应的状态码;及当状态码表示目标请求数据发送成功时,对目标请求数据的目标设备的身份标识进行加一计数,否则,对目标请求数据的目标设备的身份标识进行减一计数。In one embodiment, the one or more processors, before performing the step of determining a transmission object of the target request data, the one or more processors further perform the steps of: transmitting the target request data to the determined target device over the network; The status code corresponding to the target request data returned by the local network layer; and when the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented, otherwise, the target of the target request data is The device's identity is decremented by one count.
在一个实施例中,计算机可读指令被一个或多个处理器执行时,还使得一个或多个处理器执行以下步骤:将目标请求数据通过网络发送给确定的目标设备时,将目标请求数据保存并启动预设时间段内的倒计时;及当在倒计时结束之前接收到目标请求数据的应答数据时,将对应的目标请求数据删除,当倒计时已结束但未接收到目标请求数据的应答数据时,则将目标请求数据发送给其它目标设备。In one embodiment, when the computer readable instructions are executed by one or more processors, the one or more processors further cause the step of: requesting data when the target request data is transmitted over the network to the determined target device Saving and starting the countdown in the preset time period; and when receiving the response data of the target request data before the countdown ends, deleting the corresponding target request data, when the countdown has ended but the response data of the target request data is not received , the target request data is sent to other target devices.
在一个实施例中,一个或多个处理器在执行将目标请求数据保存的步骤之前,一个或多个处理器还执行以下步骤:当请求数据携带有重要标识时,将目标请求数据保存并启动预设时间段内的倒计时。在一个实施例中,计算机可读指令被一个或多个处理器执行时,请求数据的来源不包括用于计数单独生成的数据。In one embodiment, before the step of saving the target request data by the one or more processors, the one or more processors further perform the steps of: saving and starting the target request data when the request data carries the important identifier Countdown within a preset time period. In one embodiment, when the computer readable instructions are executed by one or more processors, the source of the request data does not include data for counting the separately generated.
根据本实施例的一个示例,上述实施例方法中的全部或部分流程,可以通过计算机可读指令来指令相关的硬件来完成,计算机可读指令可存储于一计算机可读取存储介质中,如本申请实施例中,该计算机可读指令可存储于计算机系统的存储介质中,并被该计算机系统中的至少一个处理器执行,以实现包括如上述各方法的实施例的流程。该存储介质包括但不限于磁碟、优盘、光盘、只读存储记忆体(Read-Only Memory,ROM)等。According to an example of the embodiment, all or part of the processes in the foregoing embodiment may be completed by instructing related hardware by computer readable instructions, and the computer readable instructions may be stored in a computer readable storage medium, such as In the embodiments of the present application, the computer readable instructions may be stored in a storage medium of a computer system and executed by at least one processor in the computer system to implement a process including an embodiment of the methods described above. The storage medium includes, but is not limited to, a magnetic disk, a USB flash drive, an optical disk, a read-only memory (ROM), and the like.
本实施例通过利用本端网络层回馈的状态码来对对应的目标设备的身份标识进行加一或减一的计数,通过该状态码即可判断对应的请求数据是否发送成功,当发送成功时对对应的目标设备进行加一计数,否则进行减一计数,目标设备的计数越多则表示该目标设备的负载越大,对于目标设备的负载情 况的判断是根据本端反馈的状态码做出的,不需要给网络制造额外的数据传输,从而可以减少网络压力,将目标请求数据发送给计数最小的目标设备,即通过将目标请求数据发送给负载最小的目标设备从而实现目标设备的负载均衡,且在实现负载均衡时是不向负载大的目标设备发送请求数据,而不是传统技术中的向负载大的目标设备发送请求数据、在收到拒绝响应的应答消息后再将该请求数据发给其它负载较小的目标设备,进一步减少了网络中不必要的数据传输,且无需负载较大的目标设备开启额外的进程去响应该拒绝应答的消息,也降低了负载较大的目标设备的负担。In this embodiment, the identity of the corresponding target device is counted by one or minus one by using the status code fed back by the local network layer, and the status code can be used to determine whether the corresponding request data is successfully sent. Add a count to the corresponding target device, otherwise perform a countdown. The more the target device counts, the greater the load on the target device, and the load on the target device. The judgment of the situation is made according to the status code fed back by the local end, and no additional data transmission is needed for the network, so that the network pressure can be reduced, and the target request data is sent to the target device with the smallest count, that is, by sending the target request data. The target device with the least load is implemented to achieve the load balancing of the target device, and when the load balancing is implemented, the request data is not sent to the target device with a large load, instead of sending the request data to the target device with a large load in the conventional technology. After the response message of rejecting the response is sent to the other target device with less load, the unnecessary data transmission in the network is further reduced, and the target device that does not need to be loaded is required to open an additional process to respond to the rejection response. The message also reduces the burden on the target device with a large load.
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above-described embodiments may be arbitrarily combined. For the sake of brevity of description, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction between the combinations of these technical features, All should be considered as the scope of this manual.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。 The above-mentioned embodiments are merely illustrative of several embodiments of the present application, and the description thereof is more specific and detailed, but is not to be construed as limiting the scope of the invention. It should be noted that a number of variations and modifications may be made by those skilled in the art without departing from the spirit and scope of the present application. Therefore, the scope of the invention should be determined by the appended claims.

Claims (20)

  1. 一种数据发送对象的选择方法,包括:A method for selecting a data transmission object includes:
    通过网络对外发送请求数据后,获取本端网络层返回的状态码,所述状态码与所述请求数据一一对应,所述状态码用于表示所述请求数据是否发送成功;After the request data is sent out through the network, the status code returned by the local network layer is obtained, where the status code is in one-to-one correspondence with the request data, and the status code is used to indicate whether the request data is successfully sent.
    获取所述状态码对应请求数据所发送的目标设备的身份标识;Obtaining an identity identifier of the target device that is sent by the status code corresponding to the request data;
    当所述状态码表示所述请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及When the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is counted down by one; and
    接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。When receiving the transmission instruction of the target request data, the target device corresponding to the identifier with the smallest count is determined as the transmission target of the target request data.
  2. 根据权利要求1所述的方法,其特征在于,在所述将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象之前,所述方法还包括:The method according to claim 1, wherein the method further comprises: before the determining, by the target device, the identifier corresponding to the identifier having the smallest number is the object to be sent by the target request data, the method further comprising:
    获取对每个身份标识对应预设的权值,所述权值为大于零的自然数;及Obtaining a preset weight corresponding to each identity, the weight being a natural number greater than zero; and
    计算每个身份标识的计数结果与对应权值的商值;Calculating the quotient of the result of each identity and the quotient of the corresponding weight;
    所述将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象,还包括:Determining, by the target device, the target device corresponding to the identifier with the smallest number as the object to be sent by the target request data, further comprising:
    将计算的商值最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。The target device corresponding to the identity with the smallest calculated quotient value is determined as the transmission target of the target request data.
  3. 根据权利要求1或2所述的方法,其特征在于,在确定所述目标请求数据的发送对象之后,所述方法还包括:The method according to claim 1 or 2, wherein after determining the destination of the target request data, the method further comprises:
    将所述目标请求数据通过网络发送给确定的所述目标设备;Transmitting the target request data to the determined target device through a network;
    获取本端网络层返回的与所述目标请求数据对应的状态码;及Obtaining a status code corresponding to the target request data returned by the local network layer; and
    当所述状态码表示所述目标请求数据发送成功时,对所述目标请求数据的目标设备的身份标识进行加一计数,否则,对所述目标请求数据的目标设备的身份标识进行减一计数。When the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented; otherwise, the identity of the target device of the target request data is counted down. .
  4. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括: The method according to claim 1 or 2, wherein the method further comprises:
    将所述目标请求数据通过网络发送给确定的所述目标设备时,将所述目标请求数据保存并启动预设时间段内的倒计时;及When the target request data is sent to the determined target device through the network, save the target request data and start a countdown within a preset time period; and
    当在所述倒计时结束之前接收到所述目标请求数据的应答数据时,将对应的目标请求数据删除,当所述倒计时已结束但未接收到所述目标请求数据的应答数据时,则将所述目标请求数据发送给其它目标设备。When the response data of the target request data is received before the countdown ends, the corresponding target request data is deleted, and when the countdown has ended but the response data of the target request data is not received, The target request data is sent to other target devices.
  5. 根据权利要求4所述的方法,其特征在于,在将所述目标请求数据保存之前,所述方法还包括:The method according to claim 4, wherein before the saving of the target request data, the method further comprises:
    当所述请求数据携带有重要标识时,将所述目标请求数据保存并启动所述预设时间段内的倒计时。When the request data carries an important identifier, the target request data is saved and a countdown within the preset time period is initiated.
  6. 根据权利要求1或2所述的方法,其特征在于,所述请求数据的来源不包括用于计数单独生成的数据。The method according to claim 1 or 2, wherein the source of the request data does not include data for counting separately generated.
  7. 一种数据发送对象的选择装置,所述装置包括:A device for selecting a data transmission object, the device comprising:
    状态码获取模块,用于通过网络对外发送请求数据后,获取本端网络层返回的状态码,所述状态码与所述请求数据一一对应,所述状态码用于表示所述请求数据是否发送成功;The status code obtaining module is configured to obtain a status code returned by the local network layer after the request data is sent out through the network, where the status code is in one-to-one correspondence with the request data, where the status code is used to indicate whether the requested data is Sent successfully;
    标识获取模块,用于获取所述状态码对应请求数据所发送的目标设备的身份标识;An identifier obtaining module, configured to acquire an identity identifier of a target device that is sent by the status code corresponding to the request data;
    计数模块,用于当所述状态码表示所述请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及a counting module, configured to: when the status code indicates that the request data is successfully sent, add a count to the corresponding identity identifier; otherwise, count the corresponding identity identifier by one count; and
    对象确定模块,用于接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。The object determining module is configured to determine, as the sending target of the target request data, the target device corresponding to the identifier with the smallest count when receiving the sending instruction of the target request data.
  8. 根据权利要求7所述的装置,其特征在于,所述装置还包括:The device according to claim 7, wherein the device further comprises:
    权值获取模块,用于获取对每个身份标识对应预设的权值,所述权值为大于零的自然数;及a weight obtaining module, configured to acquire a preset weight corresponding to each identity, where the weight is a natural number greater than zero;
    计算模块,用于计算每个身份标识的计数结果与对应权值的商值;a calculation module, configured to calculate a quotient of the count result of each identity and a corresponding weight;
    所述对象确定模块具体用于:将计算的商值最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。 The object determining module is specifically configured to: determine, as the sending target of the target request data, a target device corresponding to the identity identifier with the smallest calculated quotient value.
  9. 根据权利要求7所述的装置,其特征在于,所述装置还包括:The device according to claim 7, wherein the device further comprises:
    数据发送模块,用于将所述目标请求数据通过网络发送给确定的所述目标设备;a data sending module, configured to send the target request data to the determined target device by using a network;
    所述状态码获取模块,还用于用于获取本端网络层返回的与所述目标请求数据对应的状态码;及The status code obtaining module is further configured to acquire a status code corresponding to the target request data returned by the local network layer; and
    所述计数模块,还用于当所述状态码表示所述目标请求数据发送成功时,对所述目标请求数据的目标设备的身份标识进行加一计数,否则,对所述目标请求数据的目标设备的身份标识进行减一计数。The counting module is further configured to: when the status code indicates that the target request data is successfully sent, add an identifier to the identity identifier of the target device of the target request data, otherwise, target the data requesting the target The device's identity is decremented by one count.
  10. 根据权利要求7所述的装置,其特征在于,所述装置还包括:The device according to claim 7, wherein the device further comprises:
    数据保存模块,用于将所述目标请求数据通过网络发送给确定的所述目标设备时,将所述目标请求数据保存并启动预设时间段内的倒计时;a data saving module, configured to save the target request data and start a countdown within a preset time period when the target request data is sent to the determined target device through a network;
    数据删除模块,用于当在所述倒计时结束之前接收到所述目标请求数据的应答数据时,将对应的目标请求数据删除;及a data deletion module, configured to delete the corresponding target request data when the response data of the target request data is received before the counting down ends; and
    所述数据发送模块,还用于当所述倒计时已结束但未接收到所述目标请求数据的应答数据时,则将所述目标请求数据发送给其它目标设备。The data sending module is further configured to send the target request data to other target devices when the countdown has ended but the response data of the target request data is not received.
  11. 一种计算机设备,包括存储器和一个或多个处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:A computer device comprising a memory and one or more processors having stored therein computer readable instructions, the computer readable instructions being executed by the one or more processors such that the one or more The processors perform the following steps:
    通过网络对外发送请求数据后,获取本端网络层返回的状态码,所述状态码与所述请求数据一一对应,所述状态码用于表示所述请求数据是否发送成功;After the request data is sent out through the network, the status code returned by the local network layer is obtained, where the status code is in one-to-one correspondence with the request data, and the status code is used to indicate whether the request data is successfully sent.
    获取所述状态码对应请求数据所发送的目标设备的身份标识;Obtaining an identity identifier of the target device that is sent by the status code corresponding to the request data;
    当所述状态码表示所述请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及When the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is counted down by one; and
    接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。 When receiving the transmission instruction of the target request data, the target device corresponding to the identifier with the smallest count is determined as the transmission target of the target request data.
  12. 根据权利要求11所述的计算机设备,其特征在于,所述一个或多个处理器在执行所述将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象的步骤之前,所述一个或多个处理器还执行以下步骤:The computer device according to claim 11, wherein the one or more processors before performing the step of determining that the target device corresponding to the identity with the smallest number is determined as the transmission target of the target request data, The one or more processors also perform the following steps:
    获取对每个身份标识对应预设的权值,所述权值为大于零的自然数;及Obtaining a preset weight corresponding to each identity, the weight being a natural number greater than zero; and
    计算每个身份标识的计数结果与对应权值的商值;Calculating the quotient of the result of each identity and the quotient of the corresponding weight;
    所述一个或多个处理器所执行所述将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象的步骤,还包括:The step of determining, by the one or more processors, the target device corresponding to the identifier with the lowest count as the sending target of the target request data, further includes:
    将计算的商值最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。The target device corresponding to the identity with the smallest calculated quotient value is determined as the transmission target of the target request data.
  13. 根据权利要求11或12所述的计算机设备,其特征在于,所述一个或多个处理器在执行确定所述目标请求数据的发送对象的步骤之前,所述一个或多个处理器还执行以下步骤:A computer apparatus according to claim 11 or 12, wherein said one or more processors perform a step of determining a transmission object of said target request data, said one or more processors further performing the following step:
    将所述目标请求数据通过网络发送给确定的所述目标设备;Transmitting the target request data to the determined target device through a network;
    获取本端网络层返回的与所述目标请求数据对应的状态码;及Obtaining a status code corresponding to the target request data returned by the local network layer; and
    当所述状态码表示所述目标请求数据发送成功时,对所述目标请求数据的目标设备的身份标识进行加一计数,否则,对所述目标请求数据的目标设备的身份标识进行减一计数。When the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented; otherwise, the identity of the target device of the target request data is counted down. .
  14. 根据权利要求11或12所述的计算机设备,其特征在于,所述计算机可读指令被所述一个或多个处理器执行时,还使得所述一个或多个处理器执行以下步骤:A computer apparatus according to claim 11 or 12, wherein said computer readable instructions, when executed by said one or more processors, further cause said one or more processors to perform the following steps:
    将所述目标请求数据通过网络发送给确定的所述目标设备时,将所述目标请求数据保存并启动预设时间段内的倒计时;及When the target request data is sent to the determined target device through the network, save the target request data and start a countdown within a preset time period; and
    当在所述倒计时结束之前接收到所述目标请求数据的应答数据时,将对应的目标请求数据删除,当所述倒计时已结束但未接收到所述目标请求数据的应答数据时,则将所述目标请求数据发送给其它目标设备。 When the response data of the target request data is received before the countdown ends, the corresponding target request data is deleted, and when the countdown has ended but the response data of the target request data is not received, The target request data is sent to other target devices.
  15. 根据权利要求14所述的计算机设备,其特征在于,所述一个或多个处理器在执行所述将所述目标请求数据保存的步骤之前,所述一个或多个处理器还执行以下步骤:The computer apparatus according to claim 14, wherein said one or more processors further perform the following steps before said step of saving said target request data:
    当所述请求数据携带有重要标识时,将所述目标请求数据保存并启动所述预设时间段内的倒计时。When the request data carries an important identifier, the target request data is saved and a countdown within the preset time period is initiated.
  16. 一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:One or more non-transitory readable storage mediums storing computer readable instructions, when executed by one or more processors, cause the one or more processors to perform the following steps:
    通过网络对外发送请求数据后,获取本端网络层返回的状态码,所述状态码与所述请求数据一一对应,所述状态码用于表示所述请求数据是否发送成功;After the request data is sent out through the network, the status code returned by the local network layer is obtained, where the status code is in one-to-one correspondence with the request data, and the status code is used to indicate whether the request data is successfully sent.
    获取所述状态码对应请求数据所发送的目标设备的身份标识;Obtaining an identity identifier of the target device that is sent by the status code corresponding to the request data;
    当所述状态码表示所述请求数据发送成功时,对对应的身份标识进行加一计数,否则对对应的身份标识进行减一计数;及When the status code indicates that the request data is successfully sent, the corresponding identity identifier is incremented by one, otherwise the corresponding identity identifier is counted down by one; and
    接收到目标请求数据的发送指令时,将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。When receiving the transmission instruction of the target request data, the target device corresponding to the identifier with the smallest count is determined as the transmission target of the target request data.
  17. 根据权利要求16所述的存储介质,其特征在于,所述一个或多个处理器在执行所述将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象的步骤之前,所述一个或多个处理器还执行以下步骤:The storage medium according to claim 16, wherein the one or more processors before performing the step of determining that the target device corresponding to the identity with the smallest count is the transmission target of the target request data, The one or more processors also perform the following steps:
    获取对每个身份标识对应预设的权值,所述权值为大于零的自然数;及Obtaining a preset weight corresponding to each identity, the weight being a natural number greater than zero; and
    计算每个身份标识的计数结果与对应权值的商值;Calculating the quotient of the result of each identity and the quotient of the corresponding weight;
    所述一个或多个处理器所执行所述将计数最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象的步骤,还包括:The step of determining, by the one or more processors, the target device corresponding to the identifier with the lowest count as the sending target of the target request data, further includes:
    将计算的商值最小的身份标识对应的目标设备确定为所述目标请求数据的发送对象。The target device corresponding to the identity with the smallest calculated quotient value is determined as the transmission target of the target request data.
  18. 根据权利要求16或17所述的存储介质,其特征在于,所述一个或 多个处理器在执行确定所述目标请求数据的发送对象的步骤之前,所述一个或多个处理器还执行以下步骤:A storage medium according to claim 16 or 17, wherein said one or The plurality of processors, before performing the step of determining a transmission object of the target request data, the one or more processors further perform the following steps:
    将所述目标请求数据通过网络发送给确定的所述目标设备;Transmitting the target request data to the determined target device through a network;
    获取本端网络层返回的与所述目标请求数据对应的状态码;及Obtaining a status code corresponding to the target request data returned by the local network layer; and
    当所述状态码表示所述目标请求数据发送成功时,对所述目标请求数据的目标设备的身份标识进行加一计数,否则,对所述目标请求数据的目标设备的身份标识进行减一计数。When the status code indicates that the target request data is successfully sent, the identity of the target device of the target request data is incremented; otherwise, the identity of the target device of the target request data is counted down. .
  19. 根据权利要求16或17所述的存储介质,其特征在于,所述计算机可读指令被所述一个或多个处理器执行时,还使得所述一个或多个处理器执行以下步骤:A storage medium according to claim 16 or 17, wherein said computer readable instructions, when executed by said one or more processors, further cause said one or more processors to perform the following steps:
    将所述目标请求数据通过网络发送给确定的所述目标设备时,将所述目标请求数据保存并启动预设时间段内的倒计时;及When the target request data is sent to the determined target device through the network, save the target request data and start a countdown within a preset time period; and
    当在所述倒计时结束之前接收到所述目标请求数据的应答数据时,将对应的目标请求数据删除,当所述倒计时已结束但未接收到所述目标请求数据的应答数据时,则将所述目标请求数据发送给其它目标设备。When the response data of the target request data is received before the countdown ends, the corresponding target request data is deleted, and when the countdown has ended but the response data of the target request data is not received, The target request data is sent to other target devices.
  20. 根据权利要求19所述的存储介质,其特征在于,所述一个或多个处理器在执行所述将所述目标请求数据保存的步骤之前,所述一个或多个处理器还执行以下步骤:The storage medium of claim 19, wherein the one or more processors further perform the following steps prior to performing the step of saving the target request data:
    当所述请求数据携带有重要标识时,将所述目标请求数据保存并启动所述预设时间段内的倒计时。 When the request data carries an important identifier, the target request data is saved and a countdown within the preset time period is initiated.
PCT/CN2017/107978 2017-08-28 2017-10-27 Selection method and device for data sending object, computer equipment and storage medium WO2019041499A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710751997.8 2017-08-28
CN201710751997.8A CN107682398B (en) 2017-08-28 2017-08-28 Selection method, device, computer equipment and the storage medium of data sending object

Publications (1)

Publication Number Publication Date
WO2019041499A1 true WO2019041499A1 (en) 2019-03-07

Family

ID=61135281

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/107978 WO2019041499A1 (en) 2017-08-28 2017-10-27 Selection method and device for data sending object, computer equipment and storage medium

Country Status (2)

Country Link
CN (1) CN107682398B (en)
WO (1) WO2019041499A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110912786B (en) * 2019-12-27 2021-07-16 深圳市星砺达科技有限公司 Gateway pressure testing method and device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9246819B1 (en) * 2011-06-20 2016-01-26 F5 Networks, Inc. System and method for performing message-based load balancing
CN105471760A (en) * 2014-09-12 2016-04-06 华为技术有限公司 Routing method, load balancing device and data communication system
CN105740083A (en) * 2016-01-28 2016-07-06 努比亚技术有限公司 Information processing method, device and system
CN105763473A (en) * 2016-04-14 2016-07-13 北京思特奇信息技术股份有限公司 Load-balanced route selection method and system
CN107026907A (en) * 2017-03-30 2017-08-08 上海斐讯数据通信技术有限公司 A kind of load-balancing method, load equalizer and SiteServer LBS

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9246819B1 (en) * 2011-06-20 2016-01-26 F5 Networks, Inc. System and method for performing message-based load balancing
CN105471760A (en) * 2014-09-12 2016-04-06 华为技术有限公司 Routing method, load balancing device and data communication system
CN105740083A (en) * 2016-01-28 2016-07-06 努比亚技术有限公司 Information processing method, device and system
CN105763473A (en) * 2016-04-14 2016-07-13 北京思特奇信息技术股份有限公司 Load-balanced route selection method and system
CN107026907A (en) * 2017-03-30 2017-08-08 上海斐讯数据通信技术有限公司 A kind of load-balancing method, load equalizer and SiteServer LBS

Also Published As

Publication number Publication date
CN107682398B (en) 2019-06-21
CN107682398A (en) 2018-02-09

Similar Documents

Publication Publication Date Title
US11411897B2 (en) Communication method and communication apparatus for message queue telemetry transport
US9729488B2 (en) On-demand mailbox synchronization and migration system
US11689606B2 (en) Communication method, system and apparatus
US11240745B2 (en) Network slice instance processing method and apparatus, and system
CN108200218B (en) Method and device for realizing load balance and electronic equipment
US10439901B2 (en) Messaging queue spinning engine
US10602381B2 (en) Load migration method, apparatus, and system
CN112261094B (en) Message processing method and proxy server
JP2022549055A (en) NODE RATE LIMITING METHOD, APPARATUS, ELECTRONIC DEVICE AND STORAGE MEDIUM
US20170078207A1 (en) Network prioritization based on node-level attributes
JP6273069B2 (en) Data processing system and data processing method
US20160344582A1 (en) Call home cluster
JP7037066B2 (en) Evaluation device, evaluation method and evaluation program
US11700189B2 (en) Method for performing task processing on common service entity, common service entity, apparatus and medium for task processing
CN114896025A (en) Architecture optimization method and device of service grid, computer equipment and storage medium
WO2019041499A1 (en) Selection method and device for data sending object, computer equipment and storage medium
CN114024968B (en) Message sending method and device based on intermediate equipment and electronic equipment
US10129147B2 (en) Network-on-chip flit transmission method and apparatus
CN111488222B (en) Stream aggregation method and device and electronic equipment
CN113641688A (en) Node updating method, related device and computer program product
CN109510864A (en) A kind of retransmission method of cache request, transmission method and relevant apparatus
US11985076B1 (en) Configuring cluster nodes for sharing network resources
CN112532450B (en) Dynamic updating method and system for data stream distribution process configuration
WO2024032011A1 (en) Cdn scheduling method, cdn scheduling system, and storage medium
US20230153159A1 (en) Hardware Accelerator Service Aggregation

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17923477

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 24.09.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 17923477

Country of ref document: EP

Kind code of ref document: A1