Redirection method, device, electronic device and computer-readable storage medium
By determining the target server with the smallest overhead and normal load on the server, the problem of increased data transmission delay and waste of network resources caused by the redirection method in the existing technology is solved, and the efficiency of data transmission and server availability are achieved.
Patent Information
- Application Number
- CN202210999319.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-19
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2042-08-19
AI Technical Summary
Existing redirection methods may increase data transmission delays and consume more network resources when selecting servers.
By determining the target server from other servers when receiving a client request message, the overhead between it and the client is minimal and the load is normal, and a redirect message is sent to the client, including the address of the target server. The method includes determining whether the load of its own device exceeds a preset threshold, and accurately selecting a target server based on the load conditions and path cost information of other servers.
It minimizes the data transmission delay, ensures the availability of the target server, prevents the client from receiving multiple redirect messages, and avoids failures caused by excessive server load.
Smart Images

Figure CN115361268B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computers, and in particular, to a redirection method, device, electronic device, and computer-readable storage medium. Background Art
[0002] In today's network environment, multiple servers are often deployed to reduce the pressure on a single server. When the load on one server is too large, the client will be redirected to the specified server using the redirection method, thereby reducing the pressure on the single server and avoiding single point failures that may cause business interruptions.
[0003] After the client establishes a transmission channel with the designated server selected by the existing redirection method, the data transmission delay may increase and more network resources may be consumed. Summary of the invention
[0004] The present application provides a redirection method, device, electronic device and computer-readable storage medium to solve the problem that after the existing redirection method selects a designated server to establish a transmission channel, the data transmission delay may increase and more network resources need to be consumed.
[0005] In a first aspect, the present application provides a redirection method, applied to a server, wherein the server is connected to other servers in a network, the method comprising: upon receiving a request message sent by a client, determining a target server from the other servers, wherein the overhead between the target server and the client is minimal and the load of the target server is normal; and sending a redirection message to the client, wherein the redirection message includes the address of the target server.
[0006] In the embodiment of the present application, since the overhead between the target server and the client is minimal, after the target server selected by the present solution establishes a connection with the client, the delay of data transmission can be minimized. In addition, if the load of the target server is normal, it can be ensured that the target server is an available server, preventing the client from receiving multiple redirection messages.
[0007] In combination with the technical solution provided in the first aspect above, in some possible implementations, before determining the target server from the other servers, the method further includes: determining that the load of the own device exceeds a preset threshold.
[0008] In the embodiment of the present application, after determining that the load of the own device exceeds the preset threshold, the target server is determined, which can ensure that the load of the server is not too large and prevent the server from malfunctioning.
[0009] In combination with the technical solution provided in the first aspect above, in some possible implementations, determining the target server from the other servers includes: determining the target server from the other servers in the network based on the load conditions of the other servers and path information characterizing the path overhead between the client and each server in the network.
[0010] In the embodiment of the present application, the path information representing the path cost between the client and each server in the network can be used to accurately determine the cost size of each server, and at the same time, the load conditions of other servers can be used to determine whether the load of each server is normal. Therefore, the target server can be accurately determined based on the load conditions of other servers and the path information.
[0011] In combination with the technical solution provided in the first aspect above, in some possible implementations, path information characterizing the path overhead between the client and each server in the network is obtained through the following steps: for each server in the network, determine the minimum overhead between the server and the client; based on the minimum overhead between each server and the client, sort according to the minimum overhead size to obtain the path information.
[0012] In an embodiment of the present application, the minimum overhead between each server and the client is sorted according to the minimum overhead size to obtain path information, so that the server with the minimum overhead between the client and the network can be accurately known based on the path information, making the final target server more accurate.
[0013] In combination with the technical solution provided in the first aspect above, in some possible implementations, the client is connected to each server through at least one intermediate node, and determining the minimum overhead between the server and the client includes: obtaining link information of each intermediate node and each server in the network, the link information including the overhead between the intermediate node or the server and each intermediate node or server directly connected to the intermediate node or the server; based on the link information of each intermediate node and each server, determining the minimum overhead between the server and the client.
[0014] In an embodiment of the present application, since the link information includes the overhead between the intermediate node or the server and each intermediate node or server directly connected to the intermediate node or the server, by obtaining the link information of each intermediate node and each server in the network, the minimum overhead between each server and the client can be accurately obtained.
[0015] In combination with the technical solution provided in the first aspect above, in some possible implementations, determining the target server from other servers in the network based on the load conditions of the other servers and the path information characterizing the path overhead between the client and each server in the network includes: determining the first server with the smallest overhead with the client from the path information; determining whether the load of the first server is normal, if the load of the first server is normal, the first server is the target server; if the load of the first server is abnormal, determining the second server with the smallest overhead with the client from the remaining servers from the path information, until the target server with normal load is found.
[0016] In an embodiment of the present application, the first server with the smallest overhead with the client in the path information is first determined. When the load of the first server is normal, the first server is the target server. If the load of the first server is abnormal, the second server with the smallest overhead with the client is determined from the remaining servers, and the above steps are repeated until a server with a normal load is found. This server is the target server with the smallest overhead with the client and a normal load.
[0017] In combination with the technical solution provided in the first aspect above, in some possible implementations, the method also includes: parsing the request message to obtain the request purpose corresponding to the request message; calling the function corresponding to the request purpose for processing, and generating a reply message based on the processing result; and sending the reply message to the client.
[0018] In the embodiment of the present application, by calling a function corresponding to the request purpose of the request message for processing, different functions can be achieved, thereby improving the scope of application of the present solution.
[0019] In a second aspect, the present application provides a redirection device, which is deployed on a server, and the server is connected to other servers in the network. The redirection device includes a determination module and a sending module. The determination module is used to determine a target server from the other servers when receiving a request message sent by a client, wherein the overhead between the target server and the client is minimal and the load of the target server is normal; the sending module is used to send a redirection message to the client, wherein the redirection message includes the address of the target server.
[0020] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are connected; the memory is used to store programs; and the processor is used to call the programs stored in the memory to execute a method provided in the above-mentioned first aspect embodiment and / or any possible implementation method in combination with the above-mentioned first aspect embodiment.
[0021] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a computer, the method provided in the embodiment of the first aspect above and / or in any possible implementation manner in combination with the embodiment of the first aspect above is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 A flowchart of a redirection method shown in an embodiment of the present application;
[0024] Figure 2 A schematic diagram of a network connection shown in an embodiment of the present application;
[0025] Figure 3 A flowchart of another redirection method according to an embodiment of the present application is shown;
[0026] Figure 4 This is a structural block diagram of a redirection device shown in an embodiment of the present application;
[0027] Figure 5 A structural block diagram of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0029] It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it is not necessary to further define and explain it in the subsequent drawings. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements that are not clearly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements limited by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements.
[0030] Furthermore, the term "and / or" in this application is merely a term used to describe the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone.
[0031] The technical solution of the present application will be described in detail below with reference to the accompanying drawings.
[0032] RTSP (Real Time Streaming Protocol) is a mature and widely used streaming media protocol, which can add more functions to the streaming process, such as pause, resume, play, fast forward, fast rewind, etc., and can control the sending process of streaming media data. It also has a message format similar to HTTP (Hyper Text Transfer Protocol) protocol and is well compatible with HTTP protocol.
[0033] The RTSP protocol has a redirection method, which can inform the client to establish a streaming media transmission channel with another specified server, thereby reducing the pressure on a single server and avoiding single point failures that may cause business interruptions. However, in the current redirection method, the RFC (Request For Comments; a series of numbered documents) document does not explain how to select this other server, so that after the client establishes a transmission channel with the specified server selected by the existing redirection method, it may cause an increase in data transmission delay and require more network resources.
[0034] Based on this, the inventor proposes a redirection method to solve the problem that after the existing redirection method selects a designated server to establish a transmission channel, it may cause an increase in data transmission delay and consume more network resources.
[0035] See also Figure 1 , Figure 1 This is a flowchart of a redirection method shown in an embodiment of the present application. Figure 1 Describe the steps it involves.
[0036] The redirection method is applied to a server, and the server is connected to other servers in the network. It is understandable that the server can be directly connected to other servers in the network, or the server can be connected to other servers in the network through intermediate nodes such as gateways and routers. Similarly, the client can also be directly connected to a server in the network, or the client can be connected to a server in the network through intermediate nodes such as gateways and routers.
[0037] S100: When receiving a request message sent by a client, a target server is determined from other servers.
[0038] Among them, the overhead between the target server and the client is minimal and the load of the target server is normal. Since the overhead between the target server and the client is minimal, after the target server selected by this solution establishes a connection with the client, the data transmission delay can be minimized. In addition, the load of the target server is normal, which can ensure that the target server is an available server and prevent the client from receiving multiple redirection messages.
[0039] In one implementation, the specific process of determining the target server from other servers may be: determining the target server from other servers in the network based on the load conditions of other servers and path information characterizing the path costs between the client and each server in the network.
[0040] The path information representing the path cost between the client and each server in the network may be pre-acquired and stored in a storage medium, and directly called when needed; or the path information may be acquired in real time when needed.
[0041] The load conditions of other servers may also be acquired in advance and stored in a storage medium, and may be directly called when needed; or the path information may also be acquired in real time when needed.
[0042] In order to make the obtained load status of the server more accurate, in one implementation mode, other servers may be periodically requested for their load status.
[0043] Alternatively, the servers in the network periodically send their own load conditions to other servers so that each server can obtain the accurate load conditions of other servers.
[0044] In one implementation, the load can be represented by the usage of the server's CPU (central processing unit), memory and other resources. When the usage of the server's CPU, memory and other resources exceeds a preset threshold, the server load is considered abnormal; when the usage of the server's CPU, memory and other resources is less than the preset threshold, the server load is considered normal. The preset threshold here should be greater than 0 and less than 1.
[0045] Alternatively, the server load can also be characterized by the amount of requests currently processed by the server in real time. In this case, when the amount of requests processed by the server in real time is greater than a preset threshold, the server load is considered abnormal; when the amount of requests processed by the server in real time is less than the preset threshold, the server load is considered normal. The preset threshold here can be set according to actual needs, and the specific value of the preset threshold is not limited here.
[0046] There are two implementations for obtaining the path information representing the path cost between the client and each server in the network.
[0047] In the first implementation, path information characterizing the path cost between the client and each server in the network can be obtained by the following steps: first, for each server in the network, the minimum cost between the server and the client is determined. Then, based on the minimum cost between each server and the client, the minimum cost is sorted according to the size of the minimum cost to obtain the path information.
[0048] The path information may only include the servers sorted according to the minimum cost size; or, the path information may also include the specific value of the minimum cost of each server.
[0049] When the path information includes the specific value of the minimum cost of each server, it is not necessary to sort according to the minimum cost size, that is, the process of obtaining the path information is: first, for each server in the network, determine the minimum cost between the server and the client. Then, based on the minimum cost between each server and the client, obtain the path information, and the path information includes the specific value of the minimum cost of each server.
[0050] When the client is connected to each server through at least one intermediate node. In order to accurately obtain the minimum cost between each server and the client, in one implementation, the specific process of determining the minimum cost between the server and the client can be: first obtain the link information of each intermediate node and each server in the network, and the link information includes the cost between the intermediate node or the server and each intermediate node or server directly connected to the intermediate node or the server. Then, based on the link information of each intermediate node and each server, determine the minimum cost between the server and the client.
[0051] Specifically, based on the link information of each intermediate node and each server, the process of determining the minimum overhead between the server and the client can be: first determine the respective overhead of each path connecting the server and the client, where the minimum overhead is the minimum overhead between the server and the client.
[0052] For easier understanding, see Figure 2 , Figure 2 This is a schematic diagram of a network connection shown in this application. The value of the connection line between any two devices in the network is the cost between the two devices, where the device here can be the above-mentioned intermediate node or server. Figure 2 Taking the network shown in FIG. 1 as an example, the specific process of obtaining path information in the first implementation manner is described.
[0053] When the client first accesses the second server and the second server needs to send a redirect message to the client, the minimum overhead between the first server, the third server and the client is first determined.
[0054] according to Figure 2 It can be seen that the path with the least cost between the first server and the client is: client-first intermediate node-third intermediate node-fourth intermediate node-second server-first server. The cost corresponding to this path is 1+2+3+3=9, so the minimum cost between the first server and the client is 9.
[0055] Similarly, according to Figure 2 It can be seen that the path with the least cost between the third server and the client is: client-first intermediate node-third intermediate node-fourth intermediate node-seventh intermediate node-third server. The cost corresponding to this path is 1+2+2+2=7, so the minimum cost between the third server and the client is 7.
[0056] It can be seen that the cost of the third server is less than that of the first server. The above examples are only for ease of understanding and should not be used as a limitation to the present application.
[0057] Under the second implementation mode, the specific process of obtaining the path information characterizing the path cost between the client and each server in the network may be to first determine the first node, which is an intermediate node directly connected to the client. Then, based on the link information of the first node, determine the second node with the smallest cost between the client and the intermediate node directly connected to the first node. After that, based on the link information of the first node and the link information of the second node, determine the third node with the smallest cost between the client and the intermediate node directly connected to the first node and / or the second node, and repeat the above steps until each intermediate node and each server in the network is traversed to obtain the path information. At this point, it is understood that the information includes all intermediate nodes and servers sorted by cost size.
[0058] For ease of understanding, Figure 2 Taking the network shown in FIG. 1 as an example, the specific process of obtaining path information in the second implementation manner is described.
[0059] When the client first accesses the second server and the second server needs to send a redirect message to the client, the first intermediate node directly connected to the client is first determined as the first node.
[0060] Among the second intermediate node and the third intermediate node directly connected to the first intermediate node, the cost from the third intermediate node to the first intermediate node is less than the cost from the second intermediate node to the first intermediate node. Therefore, the second node is the third intermediate node.
[0061] Among the remaining second intermediate nodes, fourth intermediate nodes, and fifth intermediate nodes directly connected to the first node and the second node in the network, the fourth intermediate node has the smallest overhead with the first node, so the third node is the fourth intermediate node. Repeat the above steps until each intermediate node and each server in the network is traversed to obtain the path information.
[0062] The method of calculating the cost between the intermediate node and the client is the same as the aforementioned method of determining the minimum cost between the server and the client, and is not repeated here for the sake of simplicity.
[0063] Figure 2 The path information corresponding to the network shown is [first intermediate node; third intermediate node; fourth intermediate node; fifth intermediate node; seventh intermediate node; second intermediate node; second server; third server; first server]. The path information here is sorted from small to large in terms of overhead, and the overhead between the first intermediate node and the client is the smallest. The above examples are only for ease of understanding and should not be used as a limitation to this application.
[0064] In order to enable each server to obtain accurate path information, in one implementation mode, the redirection method further includes: sending link information of its own device to each server in the network.
[0065] Based on the load conditions of other servers and path information representing the path costs between the client and each server in the network, there are two implementation methods for determining the target server from other servers in the network.
[0066] In the first implementation mode, based on the load conditions of other servers and the path information characterizing the path overhead between the client and each server in the network, the specific process of determining the target server from other servers in the network can be: first determine the first server with the smallest overhead with the client from the path information, and then determine whether the load of the first server is normal. If the load of the first server is normal, the first server is the target server. If the load of the first server is abnormal, determine the second server with the smallest overhead with the client from the remaining servers from the path information until the target server with normal load is found. At this time, the server that performs this step is not included in the path information.
[0067] For example, the path information includes server 1, server 2, server 3, and server 4, and the overhead between server 1 and the client is < the overhead between server 2 and the client < the overhead between server 3 and the client < the overhead between server 4 and the client, and the load situation of server 1 is abnormal, the load situation of server 2 is abnormal, the load situation of server 3 is normal, and the load situation of server 3 is abnormal, then the process of the above-mentioned first implementation method is as follows.
[0068] First, determine server 1 with the smallest cost to the client from the path information. Since the load of server 1 is abnormal, server 1 is excluded from the path information. Then determine server 2 with the smallest cost to the client from the remaining servers from the path information.
[0069] Since the load condition of server 2 is abnormal, server 2 is excluded from the path information, and then server 3 with the smallest overhead with the client among the remaining servers is determined from the path information.
[0070] Since the load of server 3 is normal, server 3 is the target server. The above examples are only for ease of understanding and should not be used as limitations on this application.
[0071] In the second implementation, based on the load conditions of other servers and the path information representing the path cost between the client and each server in the network, the specific process of determining the target server from other servers in the network can be: first, based on the load conditions of other servers, determine a server with normal load from other servers in the network except the server itself. Then, based on the path information, determine the server with the smallest cost between the client and the server with normal load, and the server with the smallest cost is the target server.
[0072] For example, the path information includes server 1, server 2, server 3, and server 4, and the overhead between server 1 and the client is < the overhead between server 2 and the client < the overhead between server 3 and the client < the overhead between server 4 and the client, and the load situation of server 1 is abnormal, the load situation of server 2 is normal, the load situation of server 3 is normal, and the load situation of server 3 is abnormal, then the process of the above-mentioned second implementation method is as follows.
[0073] First, based on the load conditions of other servers, it is possible to determine Server 2 and Server 3, which have normal load conditions. Then, based on the path information, it is known that the overhead between Server 2 and the client is less than the overhead between Server 3 and the client. Therefore, Server 2 is the target server. The above examples are only for ease of understanding and should not be used as a limitation to this application.
[0074] In order to ensure that the load of the server is not too large and to prevent the server from malfunctioning, in one implementation mode, before determining the target server from other servers, it is also possible to first determine whether the load of the own device exceeds a preset threshold.
[0075] The load and preset threshold here have the same meaning and determination method as those described above, and will not be repeated here for the sake of brevity.
[0076] S200: Send a redirect message to the client, where the redirect message includes the address of the target server.
[0077] In one implementation mode, when the server does not need to perform a redirection operation, upon receiving a request message sent by a client, the server can first parse the request message to obtain the request destination corresponding to the request message, then call the function corresponding to the request destination for processing, generate a reply message based on the processing result, and finally send the reply message to the client.
[0078] Among them, different request messages may correspond to different functions, and the request message may include a SETUP request message, a PLAY request message, a RECORD request message, etc.
[0079] Taking the SETUP request message as an example, if the received message is a SETUP request message, the server will add a session header field to the reply message when replying to the SETUP request message. The value of the session header field is a randomly generated string used to identify a session. Subsequent messages of this session will carry this session to distinguish different sessions. The reply message will also carry a transport header field. The value in the transport header field conforms to the format specified in the RFC document so that the client can accurately parse the reply message. This header field will carry transmission-related parameters, such as the transmission protocol and the transmission media type, the transport layer protocol, the network layer transmission form, the client RTP (Real-time Transport Protocol) / RTCP (Real-time Transport Control Protocol) port pair, the server RTP / RTCP port pair, and the SSRC (Synchronous Source) identifier. Finally, the reply message is sent.
[0080] The above examples are only for ease of understanding and should not be construed as limiting the present application.
[0081] In order to ensure that the request message can be accurately parsed, in one implementation, before parsing the request message, it is also possible to detect whether the message format of the request message is correct. If the format of the request message is correct, the subsequent steps are executed, and if the format of the request message is incorrect, the request message is discarded.
[0082] Since the request message has a fixed format, different fields of the request message have different meanings. Therefore, the purpose of the request message can be obtained by parsing the request message according to its format. At this point, a session ID (Identity document) can be created and associated with the client's address to identify a session. The session is maintained until the client stops getting data from the server.
[0083] Among them, it can be detected whether the format of the request message complies with the request message format specified in the RFC document.
[0084] It is understandable that after the complete content of the request message is obtained, the format of the request message is detected.
[0085] In order to prevent the sending of RTP (Real-time Transport Protocol) data during the processing of the request message or the sending of a response message to the client before the request message is processed, in one implementation, the process of processing the request message may be locked. Accordingly, after sending the reply message to the client, an unlocking operation is performed.
[0086] The specific implementation of the locking operation is well known to those skilled in the art and will not be described in detail here for the sake of brevity.
[0087] Since each request message corresponds to a timeout, the timeout is used to keep the server and client alive. If the server does not receive the client's request message within the specified timeout, the client will be considered inactive. If the request is received from the client within the specified timeout, the timeout will be refreshed to 0s and the timer will start again. Therefore, after locking the process of processing the request message, the timeout can be refreshed to 0s.
[0088] To further understand the above redirection method, please refer to Figure 3 It should be noted that Figure 3 The principle shown is only one of many embodiments of the redirection method of the present application, and therefore, it cannot be used as Figure 3 The manner shown is to be understood as limiting the present application.
[0089] like Figure 3 As shown, firstly, the link information of each intermediate node and each server in the network and the load of other servers are obtained. When a request message sent by the client is received, it is determined that the load of the own device exceeds a preset threshold.
[0090] If the load of the own device exceeds the preset threshold, the target server with the lowest overhead to the client and normal load is determined from other servers, and a redirect message including the address of the target server is sent to the client.
[0091] If the load of its own device does not exceed the preset threshold, the complete content of the request message is obtained; the message format of the request message is detected to see if it is correct; if the format of the request message is correct, the process of processing the request message is locked; then the timeout period corresponding to the request message is refreshed; then the request message is parsed to obtain the request purpose corresponding to the request message; finally, the function corresponding to the request purpose is called for processing, and a reply message is generated based on the processing result; the reply message is sent to the client, and the unlocking operation is performed.
[0092] in, Figure 3The specific implementation methods and principles of each step shown have been clearly described in the previous text and will not be repeated here for the sake of brevity.
[0093] See also Figure 4 , Figure 4 This is a structural block diagram of a redirection device 100 provided in an embodiment of the present application. The redirection device 100 is deployed in a server, and the server is connected to other servers in the network. The redirection device 100 includes a determination module 110 and a sending module 120.
[0094] The determination module 110 is used to determine a target server from the other servers when receiving a request message sent by the client, wherein the overhead between the target server and the client is minimal and the load of the target server is normal.
[0095] The sending module 120 is configured to send a redirect message to the client, wherein the redirect message includes the address of the target server.
[0096] The determination module 110 is further configured to determine whether the load of the own device exceeds a preset threshold before determining the target server from the other servers.
[0097] The determination module 110 is specifically configured to determine a target server from other servers in the network based on the load conditions of the other servers and path information representing the path costs between the client and each server in the network.
[0098] The determination module 110 is further used to determine the minimum cost between each server in the network and the client; based on the minimum cost between each server and the client, the paths are sorted according to the minimum cost size to obtain the path information.
[0099] Determination module 110 is specifically used to obtain the link information of each intermediate node and each server in the network, and the link information includes the cost between the intermediate node or the server and each intermediate node or server directly connected to the intermediate node or the server; based on the link information of each intermediate node and each server, determine the minimum cost between the server and the client.
[0100] Determination module 110 is specifically used to determine the first server with the smallest overhead with the client from the path information; determine whether the load of the first server is normal, if the load of the first server is normal, the first server is the target server; if the load of the first server is abnormal, determine the second server with the smallest overhead with the client from the remaining servers from the path information, until the target server with normal load is found.
[0101] The sending module 120 is also used to parse the request message to obtain the request purpose corresponding to the request message; call the function corresponding to the request purpose for processing, generate a reply message based on the processing result; and send the reply message to the client.
[0102] In one implementation, the sending module 120 may be an RTSP module in a server. The RTSP module is responsible for receiving, processing, and sending RTSP messages. The RTSP state machine describes the protocol behavior from RTSP session initialization to RTSP session termination.
[0103] The above-mentioned determination module 110 can be a redirection module, which is responsible for sending an RTSP redirection message to notify the client to establish communication with other servers. Before redirection, the redirection module will find a target server with the lowest overhead and normal load between the client and the target server, and fill the address of the target server in the RTSP redirection message.
[0104] The redirection device 100 provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned redirection method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned redirection method embodiment.
[0105] See also Figure 5 , which is an electronic device 200 provided in an embodiment of the present application. The electronic device 200 includes: a transceiver 210, a memory 220, a communication bus 230, and a processor 240.
[0106] The transceiver 210, the memory 220, and the processor 240 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses 230 or signal lines. The transceiver 210 is used to send and receive data. The memory 220 is used to store computer programs, such as storing Figure 4The software function module shown in is the redirection device 100. The redirection device 100 includes at least one software function module that can be stored in the memory 220 in the form of software or firmware or solidified in the operating system (OS) of the electronic device 200. The processor 240 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the redirection device 100. At this time, the processor 240 is used to determine the target server from the other servers when receiving the request message sent by the client, wherein the overhead between the target server and the client is the smallest and the load of the target server is normal; and send a redirection message to the client, wherein the redirection message includes the address of the target server.
[0107] Among them, the memory 220 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0108] The processor 240 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor 240 may also be any conventional processor, etc.
[0109] The electronic device 200 mentioned above includes but is not limited to a personal computer, a server, etc.
[0110] The embodiment of the present application also provides a non-volatile computer-readable storage medium (hereinafter referred to as storage medium), on which a computer program is stored, and when the computer program is run by a computer such as the above-mentioned electronic device 200, the redirection method shown above is executed. The computer-readable storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0111] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A redirection method, characterized in that: Applied to a server, the server being connected to other servers in a network, the method comprising: In the case of receiving a request message sent by the client, if it is determined that the load of the own device exceeds a preset threshold, determining a target server from the other servers, wherein the overhead between the target server and the client is minimal and the load of the target server is normal; and sending a redirect message to the client, wherein the redirect message includes the address of the target server; Wherein, determining the target server from the other servers includes: Determine the first server with the smallest cost to the client from the load conditions of the other servers and the path information representing the path costs between the client and each server in the network; determine whether the load of the first server is normal, if the load of the first server is normal, the first server is the target server; if the load of the first server is abnormal, determine the second server with the smallest cost to the client from the remaining servers from the path information, until the target server with a normal load is found; Alternatively, path information characterizing the path cost between the client and each server in the network is obtained by the following steps: For each server, the link information of each intermediate node and each server in the network is obtained, and the link information includes the cost between the intermediate node or the server and each intermediate node or server directly connected to the intermediate node or the server; based on the link information of each intermediate node and each server, the cost of each path connecting the server and the client is determined, where the minimum cost is the minimum cost between the server and the client, and based on the minimum cost between each server and the client, the paths are sorted according to the minimum cost size to obtain the path information.
2. The method according to claim 1, characterized in that: The method further comprises: Parsing the request message to obtain the request purpose corresponding to the request message; Calling a function corresponding to the request purpose to perform processing, and generating a reply message based on the processing result; The reply message is sent to the client.
3. A redirection device, characterized in that: Deployed on a server, the server is connected to other servers in the network, and the redirection device includes: A determination module, configured to, upon receiving a request message sent by a client, determine a target server from the other servers if it is determined that the load of the own device exceeds a preset threshold, wherein the overhead between the target server and the client is minimal and the load of the target server is normal; A sending module, configured to send a redirect message to the client, wherein the redirect message includes an address of the target server; The determination module is specifically used to determine the first server with the smallest cost with the client from the load conditions of the other servers and the path information representing the path costs between the client and each server in the network; determine whether the load of the first server is normal, if the load of the first server is normal, the first server is the target server; if the load of the first server is abnormal, determine the second server with the smallest cost with the client from the remaining servers from the path information, until the target server with a normal load is found; Alternatively, the determination module is specifically used to obtain, for each server, the link information of each intermediate node and each server in the network, wherein the link information includes the cost between the intermediate node or the server and each intermediate node or server directly connected to the intermediate node or the server; based on the link information of each intermediate node and each server, determine the cost of each path connecting the server and the client, wherein the minimum cost is the minimum cost between the server and the client, and based on the minimum cost between each server and the client, sort them according to the minimum cost size to obtain the path information.
4. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are connected; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1-2.
5. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a computer, the method according to any one of claims 1 to 2 is executed.
