Load balancing method, load balancer and system of FreeSWITCH cluster

By establishing long connections in the FreeSWITCH cluster and selecting applicable load balancing strategies, poor compatibility and security risks caused by relying on third-party SIP proxy services in the existing technology are solved, and an efficient and secure load balancing solution is achieved, suitable for industries with high data security requirements.

CN119629176AActive Publication Date: 2025-03-14CHINA MERCHANTS BANK
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411531859.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-03-14
Estimated Expiration
2044-10-30

AI Technical Summary

Technical Problem

The existing FreeSWITCH cluster load balancing solution relies on third-party SIP proxy services, resulting in poor compatibility and security risks, making it difficult to meet industry needs with high data security requirements.

Method used

By obtaining the registration information of the FreeSWITCH cluster node from the registration center, establishing a long connection, selecting the applicable application scenarios based on the traffic characteristics of the signaling request, selecting the corresponding policy from the predefined load balancing policy, and forwarding the signaling request to the selected FreeSWITCH node to achieve load balancing.

Benefits of technology

No third-party SIP proxy services are required, and are technically controllable, reducing security risks. They are suitable for industries with high data security requirements and improve the load balancing capabilities and compatibility of FreeSWITCH clusters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119629176A_ABST
    Figure CN119629176A_ABST
Patent Text Reader

Abstract

The invention discloses a load balancing method, a load balancer and a system for a FreeSWITCH cluster, and relates to the technical field of digital communication. The load balancing method of the FreeSWITCH cluster comprises the following steps: acquiring registration information of all FreeSWITCH nodes in the FreeSWITCH cluster from a registration center; according to the registration information, establishing a long connection with the FreeSWITCH cluster; when it is monitored that the ESL client sends a signaling request, an application scene suitable for the signaling request is selected according to the flow characteristics of the signaling request; selecting a corresponding load balancing strategy from predefined load balancing strategies according to the application scene; and forwarding the signaling request to the FreeSWITCH node selected by the load balancing strategy by using the long connection. The technical problems that in the prior art, SIP proxy service of a third party is used, compatibility with the network is difficult, and safety risks exist can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of digital communication technology, and in particular to a load balancing method, a load balancer and a system for a FreeSWITCH cluster. Background Art

[0002] FreeSWITCH is an open source telephone soft switch platform that supports real-time audio and video communications and conferences, as well as multiple communication protocols such as SIP. Communication systems based on FreeSWITCH often need to support a large number of call requests at the same time, which places high demands on the concurrency of calls.

[0003] Normally, the FreeSWITCH server of such communication systems uses the SIP protocol to forward call requests. However, the SIP (Session initialization Protocol) protocol stack sofia can only perform single-thread processing and has a single-machine performance bottleneck. This results in an unbalanced load on the FreeSWITCH cluster of the communication system and limited concurrency capabilities of the communication system.

[0004] Currently, the traditional solution for FreeSWITCH cluster to achieve load balancing is usually to forward SIP requests to FreeSWITCH nodes through a server integrated with SIP proxy services such as openSIPS and Kamailio.

[0005] The above solution for implementing responsible balancing uses SIP proxy service, which has the following problems:

[0006] Because the SIP proxy service is only applicable to calls initiated by SIP clients, it can only proxy and distribute uplink SIP requests, which is difficult to be compatible with the network.

[0007] Traditional load balancing solutions require the deployment of third-party application services. The technology is uncontrollable and has certain security risks. It is not suitable for industries such as banks that have high requirements for data security.

[0008] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0009] The main purpose of this application is to provide a load balancing method, load balancer and system for a FreeSWITCH cluster, aiming to solve the technical problems in the existing technical solutions that the SIP proxy service provided by a third party is only applicable to calls initiated by SIP clients, has poor compatibility, and has certain security risks.

[0010] In view of the above technical shortcomings, the main purpose of the present invention is to provide a load balancing method for a FreeSWITCH cluster, comprising:

[0011] Get the registration information of all FreeSWITCH nodes in the FreeSWITCH cluster from the registration center;

[0012] Establish a long connection with the FreeSWITCH cluster through registration information;

[0013] When using an ESL client to send a signaling request, select an application scenario applicable to the signaling request based on the traffic characteristics of the signaling request;

[0014] According to the application scenario, select the corresponding load balancing strategy from the predefined load balancing strategies;

[0015] Use a persistent connection to forward signaling requests to the FreeSWITCH node selected by the load balancing strategy.

[0016] Preferably, in the above load balancing method, the step of establishing a long connection with the FreeSWITCH cluster through registration information includes:

[0017] Create a list of all service instances and a list of normal service instances;

[0018] Monitor the registration center in real time and add the newly registered FreeSWITCH nodes to the list of all service instances;

[0019] Establish a long connection with the newly registered FreeSWITCH node through the ESL protocol;

[0020] When a persistent connection with a newly registered FreeSWITCH node is successfully established, the newly registered FreeSWITCH node is added to the normal service instance list.

[0021] Preferably, in the above load balancing method, when monitoring the ESL client to send a signaling request, the step of selecting an application scenario applicable to the signaling request according to the traffic characteristics of the signaling request includes:

[0022] Use the ESL client to convert the HTTP request sent by the external Web client into a signaling request;

[0023] Extracting traffic characteristics corresponding to the signaling message from the signaling request;

[0024] Select the application scenario that corresponds to the traffic characteristics.

[0025] Preferably, in the above load balancing method, the step of selecting a corresponding load balancing strategy from predefined load balancing strategies according to the application scenario includes:

[0026] Determine whether the signaling request is applicable to a stateful scenario or a stateless scenario;

[0027] If it is determined to be applicable to the stateless scenario, a polling strategy or a random forwarding strategy is selected from the predefined load balancing strategies, and a signaling request is sent to the selected FreeSWITCH node;

[0028] If it is determined to be applicable to stateful scenarios, the consistent hashing strategy is selected from the predefined load balancing strategies and a signaling request is sent to the selected FreeSWITCH node.

[0029] Preferably, in the above load balancing method, the step of selecting a polling strategy or a random forwarding strategy from a predefined load balancing strategy, and sending a signaling request to the selected FreeSWITCH node includes:

[0030] Get the request count of the signaling request, take the modulus from the number of all FreeSWITCH nodes in the normal service instance list, and use the modulus result as the machine index corresponding to this signaling request;

[0031] Select the FreeSWITCH node corresponding to the machine index to forward this signaling request;

[0032] or,

[0033] Input the node numbers of all FreeSWITCH nodes in the normal service instance list into the random number generation algorithm, and use the obtained random number as the machine index corresponding to this signaling request;

[0034] Select the FreeSWITCH node corresponding to the machine index to forward this signaling request.

[0035] Preferably, in the above load balancing method, the step of selecting a consistent hashing strategy from a predefined load balancing strategy and sending a signaling request to a selected FreeSWITCH node includes:

[0036] Set the hash space and map the hash space into a virtual ring;

[0037] Calculate the node hash result of each FreeSWITCH node in the normal service instance list, and map the node hash results to virtual rings respectively;

[0038] Perform hash calculation on the signaling request and map the signaling hash result to the virtual ring;

[0039] Find the FreeSWITCH node corresponding to the hash result of the nearest neighbor node from the location of the signaling hash result and forward the signaling request.

[0040] Preferably, the load balancing method further comprises, before the step of forwarding the signaling request to the FreeSWITCH node selected by the load balancing strategy:

[0041] Monitor the heartbeat detection events of each FreeSWITCH node in the list of all service instances;

[0042] Based on the heartbeat detection event, determine whether the FreeSWITCH node is available;

[0043] If the FreeSWITCH node is determined to be unavailable, the FreeSWITCH node will be deleted from the normal service instance list;

[0044] Probe unavailable FreeSWITCH nodes within the scheduled monitoring time;

[0045] When the detection of an unavailable FreeSWITCH node fails, the persistent connection with the FreeSWITCH node is closed and the unavailable FreeSWITCH node is deleted from the list of all service instances.

[0046] Preferably, the load balancing method further comprises, after the step of establishing a persistent connection with the FreeSWITCH cluster through registration information:

[0047] Real-time monitoring of long connections with each FreeSWITCH node in the FreeSWITCH cluster;

[0048] When the persistent connection is detected to be disconnected, the timing thread is started and the persistent connection with the disconnected FreeSWITCH node is reestablished in the timing thread.

[0049] To achieve the above purpose, the present application also provides a load balancer for a FreeSWITCH cluster, including:

[0050] A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the load balancing method for a FreeSWITCH cluster as provided in any of the above technical solutions.

[0051] To achieve the above purpose, the present application also provides a FreeSWITCH cluster load balancing system, including:

[0052] Signaling server, registration center and FreeSWITCH cluster. Each FreeSWITCH node in the signaling server and FreeSWITCH cluster is connected to the registration center respectively.

[0053] The signaling server includes the ESL client and the above-mentioned load balancer;

[0054] The ESL client communicates with the external Web client and is used to convert the Http request sent by the Web client into a signaling request in the ESL format;

[0055] The load balancer is connected to the ESL client, and a computer program is built into the load balancer. The computer program is configured to implement the steps of the load balancing method of the FreeSWITCH cluster provided by any of the above technical solutions.

[0056] One or more technical solutions proposed in this application have at least the following technical effects:

[0057] The registration information of all FreeSWITCH nodes in the FreeSWITCH cluster is obtained from the registration center. The registration information contains the configuration of the FreeSWITCH node, and then a long connection with FreeSWITCH is established through the registration information. The long connection is based on the ESL protocol, and the connected ESL client implements the ESL protocol. The ESL protocol can be implemented by java. The java client that implements the ESL protocol can be integrated into the javaweb application, thereby realizing the conversion of the web application http protocol to the ESL protocol, thereby adapting to most web applications (Internet applications). When the ESL client is called to send a signaling request, the application scenario applicable to the signaling request is selected according to the traffic characteristics of the signaling request. The corresponding load balancing strategy can be selected from the predefined load balancing strategy according to the application scenario, and the FreeSWITCH node suitable for forwarding the signaling request is selected according to the long connection, and the signaling request is forwarded to the outside. In this way, a signaling control channel from the ESL client to the FreeSWITCH cluster is established, so there is no need to use the SIP proxy service of a third-party application. It is technically controllable and reduces security risks. It is suitable for industries with high requirements for data security. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0059] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0060] Figure 1 A schematic diagram of the structure of a load balancing system of a FreeSWITCH cluster provided in an embodiment of the present application;

[0061] Figure 2 A flow chart of a load balancing method for a FreeSWITCH cluster provided in an embodiment of the present application;

[0062] Figure 3 For this application Figure 2 A schematic diagram of a flow chart of a method for establishing a long connection provided in the illustrated embodiment;

[0063] Figure 4 For this application Figure 2 A schematic diagram of a flow chart of a method for selecting an application scenario provided by the illustrated embodiment;

[0064] Figure 5 For this application Figure 2 A flow chart of a method for selecting a load balancing strategy provided by the illustrated embodiment;

[0065] Figure 6 This application Figure 5 A schematic flow chart of a first method for sending a signaling request provided by the illustrated embodiment;

[0066] Figure 7 This application Figure 5 A schematic flow chart of a second method for sending a signaling request provided in the illustrated embodiment;

[0067] Figure 8 It is a flowchart of a FreeSWITCH node detection method provided in an embodiment of the present application;

[0068] Fig. 9 It is a flowchart of a breakpoint reconnection method of a FreeSWITCH node provided in an embodiment of the present application;

[0069] Fig.10 It is a flowchart of a registration method of a registration center provided in an embodiment of the present application;

[0070] Fig.11 It is a structural diagram of a load balancer of a FreeSWITCH cluster provided in an embodiment of the present application.

[0071] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0072] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0073] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0074] The technical problems existing in the prior art are as follows:

[0075] The existing FreeSWITCH cluster load balancing solution is usually to forward SIP requests to FreeSWITCH nodes through a server integrated with SIP proxy services such as openSIPS and Kamailio.

[0076] The above-mentioned solution for implementing the balancing function adopts the SIP proxy service method, which has the following problems:

[0077] Because the SIP proxy service is only applicable to calls initiated by SIP clients, it can only proxy and distribute uplink SIP requests, which is difficult to be compatible with the network;

[0078] Traditional load balancing solutions require the deployment of third-party application services. The technology is uncontrollable and has certain security risks. It is not suitable for industries such as banks that have high requirements for data security.

[0079] In order to solve the above technical problems, this application provides a solution, which integrates the ESL client in the signaling service, receives the Http signaling request sent from the external web client through the Http protocol through the signaling service, converts the signaling message through the ESL client, selects the applicable application scenario according to the traffic characteristics of the signaling, and then determines the applicable load balancing strategy, connects to the FreeSWITCH node selected by the load balancing strategy through a long connection with the FreeSWITCH cluster, and sends the signaling request to the FreeSWITCH node, which forwards the signaling. The above method is based on the ESL protocol, does not require an external SIP proxy, is compatible with the Internet, is technically controllable, has high security, and is suitable for fields with high data security requirements.

[0080] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device that can realize the above functions, a computer-readable storage medium, etc.

[0081] In order to better understand the above technical solution, the exemplary embodiments of the present application will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments shown here. On the contrary, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0082] To achieve the above technical objectives, see Figure 1 , Figure 1 A schematic diagram of the structure of a FreeSWITCH cluster load balancing system provided in an embodiment of the present application. The load balancing system includes:

[0083] Signaling server, registration center Zookeeper and FreeSWITCH cluster, where the FreeSWITCH cluster includes multiple FreeSWITCH nodes (i.e. Figure 1 The FreeSWITCH instance 1-3 in the signaling server includes an ESL client and a load balancer; wherein,

[0084] The ESL client can communicate with the external Web client through the message gateway. The Web client here can be a mobile client. The mobile client sends a greeting signal, which is sent to the ESL client of the signaling server through the message gateway in the form of an Http request. The ESL client converts the Http request into a signaling request of the ESL protocol. Then the load balancer connected to the ESL client can register with the registration center in advance, and pull the registration information of each FreeSWITCH node in the FreeSWITCH cluster from the registration center Zookeeper. In this way, a long connection with each FreeSWTICH node can be established through the registration information. The long connection is based on the ESL protocol. The load balancer will extract the traffic characteristics from the above signaling request, select the application scenario applicable to the traffic characteristics, and then select the corresponding load balancing strategy from the predefined load balancing strategy set. The load balancing strategy can select the FreeSWITCH node that executes the signaling request, so that the selected FreeSWITCH node can be used to forward the signaling request. Figure 1 As shown, in the embodiment of the present application, FreeSWITCH instance 3 is forwarded to the Huawei platform (a third-party service) through the sip / rtp protocol, and the Huawei platform distributes the signaling request to the corresponding seat.

[0085] Through the above method, the ESL channel can be directly opened, and the signaling request can be forwarded through the ESL client, load balancer and FreeSWITCH node without the need for a third-party SIP proxy, thereby improving the service capability of real-time audio and video calls and the signaling channel's ability to concurrently process uplink and downlink signaling. Externally, the real-time audio and video signaling channel of the FreeSWITCH node uses the SIP protocol as the carrier of signaling messages, and establishes a signaling exchange channel with the Huawei switch through FreeSWITCH, so there is no need to use the traditional F5 server-side load balancing solution to achieve balanced distribution of traffic.

[0086] Specifically, the following embodiments are Figure 1The load balancing method of the load balancing system provided in the illustrated embodiment is specifically divided into three steps: 1. Registration and discovery of the FreeSWITCH cluster; 2. The client load balancer uses a comprehensive load balancing algorithm to distribute the upstream traffic to the FreeSWITCH cluster; 3. Supports online expansion of FreeSWITCH nodes and automatic removal of faulty nodes.

[0087] See Figure 2 , Figure 2 A flow chart of a load balancing method for a FreeSWITCH cluster is provided for the present application embodiment. Figure 2 As shown, the load balancing method of the FreeSWITCH cluster includes:

[0088] S110: Get the registration information of all FreeSWITCH nodes in the FreeSWITCH cluster from the registration center.

[0089] First, the FreeSWITCH cluster needs to be registered in the registration center Zookeeper, and then discovered by the load balancer, so as to realize the ESL long connection between the load balancer and the FreeSWITCH node.

[0090] Specifically, the service registration part includes:

[0091] When FreeSWITCH starts, it will register the configuration information of the FreeSWITCH instance with the registration center Zookeeper, that is, the registration information mentioned above. The registration information includes information such as instance name, IP address and status; after the nodes in the FreeSWITCH cluster are updated, the node configuration information will be synchronized to the Zookeeper registration center.

[0092] S120: Establish a long connection with the FreeSWITCH cluster through registration information;

[0093] Combination Fig.10 As can be seen from the illustrated embodiment, the load balancer also needs to register with the Zookeeper registration center in advance and monitor the changes (such as creation, update and deletion) of the FreeSWITCH node in the registration center Zookeeper in real time. When the load balancer monitors the changes, it will maintain the load list in real time, thereby realizing the hot update of the FreeSWITCH node. There are three ways to maintain the load list in real time after monitoring the changes, as follows:

[0094] a) When a new load node (i.e., FreeSWITCH node) is detected to be created, i.e., when the FreeSWITCH node is registered to the Zookeeper registration center, the new node configuration information is added to the load list, and the FreeSWITCH ESL client is notified to connect to the newly added FreeSWITCH node; b) When a load node is detected to be updated, the original load node is removed from the load list, and the FreeSWITCH ESL client is notified to close the connection with the original FreeSWITCH node, and then the configuration information of the updated node (the node will restart after the update, and the configuration information will be registered to the Zookeeper registration center when it is started) is added to the load list, and the ESL client is notified to connect to the updated FreeSWITCH node; c) When a load node is detected to be deleted, the load node is removed from the load list, and the FreeSWITCH ESL client is notified to close the connection with the corresponding FreeSWITCH node.

[0095] Specifically, as a preferred embodiment, Figure 3 As shown, in the above load balancing method, step S120: the step of establishing a long connection with the FreeSWITCH cluster through registration information includes:

[0096] S121: Create a list of all service instances and a list of normal service instances. The list of all service instances here, i.e. the load list mentioned above, stores all FreeSWITCH instances registered with the Zookeeper registration center. The list of normal service instances stores FreeSWITCH instances that can normally establish ESL long connections.

[0097] S122: Monitor the registration center in real time and add the newly registered FreeSWITCH nodes monitored to the list of all service instances.

[0098] S123: Establish a long connection with the newly registered FreeSWITCH node through the ESL protocol.

[0099] S124: When a long connection with a newly registered FreeSWITCH node is successfully established, the newly registered FreeSWITCH node is added to the normal service instance list.

[0100] The technical solution provided by the embodiment of the present application is integrated in the signaling server in the form of a module through the client load balancer. When the application system of the signaling server itself is started, the registration information of all FreeSWITCH nodes in the current FreeSWITCH cluster will be obtained from the Zookeeper registration center, and the Zookeeper registration center will be monitored at the same time. The client load balancer maintains two lists, namely, a list of all service instances and a list of normal service instances. When a new FreeSWITCH node is added to the FreeSWITCH cluster, the necessary configuration information of the FreeSWITCH node will be registered on the Zookeeper registration center. After the load balancer monitors the changes in the Zookeeper registration center, the FreeSWITCH node will be added to the list of all service instances, and the client load balancer will try to connect to FreeSWITCH through the ESL protocol. When the connection state becomes CONNECTED, a long connection is successfully established with the node, and the node is added to the list of normal service instances.

[0101] Figure 2 The load balancing method of the FreeSWITCH cluster provided in the illustrated embodiment further includes the following steps after establishing a persistent connection with the FreeSWITCH cluster:

[0102] S130: When the ESL client is monitored to send a signaling request, an application scenario applicable to the signaling request is selected according to the traffic characteristics of the signaling request.

[0103] Combination Figure 1 From the structure shown, it can be seen that the mobile client contains a signaling http request, which is sent from the upstream message gateway to the signaling server that can provide real-time audio and video. The signaling server integrates the ESL client and the load balancer. The ESL client of the signaling server extracts the http message of the signaling message and passes it to the load balancer. The client load balancer determines the application scenario by analyzing the traffic characteristics (request header, response header, payload format in the request body, etc.) and selects the most appropriate load balancing strategy based on the application scenario.

[0104] Specifically, as a preferred embodiment, Figure 4 As shown, in the above load balancing method, step S130: when monitoring the ESL client to send a signaling request, the step of selecting an application scenario applicable to the signaling request according to the traffic characteristics of the signaling request includes:

[0105] S131: Use the ESL client to convert the HTTP request sent by the external Web client into a signaling request.

[0106] The ESL client can be connected to the external Web client through the Internet, so that the http request sent by the external Web client can be sent to the ESL client through the gateway, and then the ESL client can use the ESL protocol to convert the Http request into a signaling request. Because the ESL protocol is compatible with the Http protocol, it is compatible with most Internet applications, greatly improving the adaptability of the product.

[0107] S132: Extracting traffic characteristics corresponding to the signaling message from the signaling request.

[0108] S133: Select an application scenario corresponding to the traffic characteristics.

[0109] In the technical solution provided by the embodiment of the present application, the current traffic feature analysis only needs to identify the audio and video uplink and downlink signaling. The message structure of the audio and video signaling includes: conference number, called id, call id, call name, service number, call data, call type, device type and other field structures, which are not available in ordinary signaling messages. The signaling type is identified by analyzing the message. Audio and video signaling is a stateful scenario, and other signaling is a stateless scenario.

[0110] Figure 2 The technical solution provided by the illustrated embodiment, after the step of selecting an application scenario applicable to the signaling request according to the traffic characteristics of the signaling request, further includes:

[0111] S140: Select a corresponding load balancing strategy from predefined load balancing strategies according to the application scenario.

[0112] As mentioned above, audio and video signaling is applicable to stateful scenarios, and other signaling is applicable to stateless scenarios. Different load balancing strategies are applied to stateful scenarios and stateless scenarios, respectively, so as to achieve load balancing of different types of signaling requests.

[0113] Specifically, as a preferred embodiment, Figure 5 As shown, in the above load balancing method, step S140: according to the application scenario, the step of selecting a corresponding load balancing strategy from the predefined load balancing strategies includes:

[0114] S141: Determine whether the signaling request is applicable to a stateful scenario or a stateless scenario.

[0115] Generally, the message structure of audio and video signaling is complex, which is not found in ordinary signaling messages. The signaling type can be identified by analyzing the message. Audio and video signaling is a stateful scenario, while other signaling is a stateless scenario.

[0116] S142: If it is determined to be applicable to the stateless scenario, a polling strategy or a random forwarding strategy is selected from the predefined load balancing strategies, and a signaling request is sent to the selected FreeSWITCH node.

[0117] S143: If it is determined to be applicable to the stateful scenario, a consistent hashing strategy is selected from the predefined load balancing strategies, and a signaling request is sent to the selected FreeSWITCH node.

[0118] The technical solution provided in the embodiment of the present application is divided into two application scenarios: stateful scenarios and stateless scenarios. For stateful scenarios, a consistent load balancing strategy needs to be selected, and the use of a consistent hashing strategy can meet the needs; for stateless scenarios, a polling strategy or a random forwarding strategy is selected according to performance requirements. Specifically, the polling strategy is simple to implement, but it is inflexible and cannot be dynamically adapted; random forwarding can naturally disperse traffic, reduce the pressure on a single node, and enhance the fault tolerance of the cluster. Therefore, when the signaling request is applicable to a stateless scenario, select a polling strategy or a random forwarding strategy; when the signaling request is applicable to a stateful scenario, select a consistent hashing strategy.

[0119] The embodiment of the present application requires that the above-mentioned predefined load balancing strategy be pre-set in the load balancer, and the load balancing strategy includes: polling strategy, random forwarding strategy and consistent hashing strategy. The scheme for sending signaling requests using polling strategy or random forwarding strategy is as follows:

[0120] Specifically, as a preferred embodiment, Figure 6 As shown, in the above load balancing method, step S142: selecting a polling strategy or a random forwarding strategy from a predefined load balancing strategy, and sending a signaling request to the selected FreeSWITCH node includes:

[0121] S1421: Obtain the request count of the signaling request, perform a modulo operation on the number of all FreeSWITCH nodes in the normal service instance list, and use the modulo operation result as the machine index corresponding to this signaling request;

[0122] S1422: Select the FreeSWITCH node corresponding to the machine index to forward this signaling request;

[0123] The technical solution provided by the embodiment of the present application is to take the modulus of the number of requests and the number of all available FreeSWITCH nodes in the FreeSWITCH cluster, and the modulus result corresponds to the machine index. If the current number of requests is i and there are n machines in the cluster, then the corresponding machine index is

[0124] For example, if there are 10 FreeSWITCH nodes and the number of signaling requests is 100, then 100mod10=0, and the machine index is 0, corresponding to the first FreeSWITCH node in the normal service instance list. For the 101st signaling request, 101mod10=1, and the machine index is 1, corresponding to the second FreeSWITCH node in the normal service instance list.

[0125] or,

[0126] S1423: Input the node numbers of all FreeSWITCH nodes in the normal service instance list into the random number generation algorithm, and use the obtained random number as the machine index corresponding to this signaling request;

[0127] S1424: Select the FreeSWITCH node corresponding to the machine index to forward this signaling request.

[0128] The random forwarding strategy uses the incoming load balancer to obtain the list of available instances and the list of all instances, obtains a random number through the ThreadLocalRandom.current().nextInt(serverCount) method, and uses the random number as the set index value to return the specific instance. If the cluster has n machines, the corresponding machine index is used. In this way, the FreeSWITCH node corresponding to the successor index can forward this signaling request.

[0129] The above polling strategy and random forwarding strategy are applicable to stateless scenarios, are simple to implement, and can dynamically adapt to the forwarding requirements of multiple signaling requests.

[0130] In addition, for stateful scenarios, you need to select a consistent hashing strategy and send signaling requests to the selected FreeSWITCH node.

[0131] Specifically, as a preferred embodiment, Figure 7 As shown, in the above load balancing method, step S143: selecting a consistent hashing strategy from a predefined load balancing strategy, and sending a signaling request to the selected FreeSWITCH node includes:

[0132] S1431: Setting a hash space, mapping the hash space into a virtual ring;

[0133] S1432: Calculate the node hash result of each FreeSWITCH node in the normal service instance list, and map the node hash results to virtual rings respectively;

[0134] S1433: Perform hash calculation on the signaling request, and map the signaling hash result to a virtual ring;

[0135] S1434: Search for the FreeSWITCH node corresponding to the hash result of the nearest neighbor node from the location of the signaling hash result, and forward the signaling request.

[0136] In the technical solution provided in the embodiment of the present application, for the distributed FreeSWITCH cluster, all requests issued during the entire life cycle of a call should be sent to the machine of the same FreeSWITCH node, because FreeSWITCH maintains the connection and all status information of a call, and this information is not interoperable between various FreeSWITCHs. Traditional hash functions can establish a mapping relationship from data to servers, but when a server node is added or deleted, the data needs to be rehashed, which destroys the original mapping relationship, and in the real-time audio and video scenario, the service will be unavailable for a short period of time. Therefore, the embodiment of the present application adopts a consistent hashing strategy to solve the above problems. The consistent hashing strategy does not require the signaling request to be rehashed when a FreeSWITCH node is added or deleted.

[0137] The client load balancer will choose the most appropriate strategy in different scenarios.

[0138] Figure 2 The technical solution provided by the illustrated embodiment, after the step of selecting a corresponding load balancing strategy from predefined load balancing strategies according to the application scenario, further includes:

[0139] S150: Use a persistent connection to forward the signaling request to the FreeSWITCH node selected by the load balancing strategy.

[0140] like Figure 1 As shown in the figure, the long connection is a long connection established based on the ESL protocol. Therefore, the signaling channel between the ESL client and the FreeSWITCH node can be established by using the long connection. The FreeSWITCH node then establishes a connection with an external third-party operator through the sip / rtp protocol, thereby realizing signaling exchange and balanced distribution of traffic from the Web client to the third-party operator.

[0141] The technical solution provided by the embodiment of the present application obtains the registration information of all FreeSWITCH nodes in the FreeSWITCH cluster from the registration center, and the registration information includes the configuration of the FreeSWITCH node, and then establishes a long connection with FreeSWITCH through the registration information, the long connection is based on the ESL protocol, and the connected ESL client is also based on the ESL protocol, because the ESL protocol can support requests initiated based on the Http protocol, and is compatible with most Internet applications, so it has strong adaptability. When the ESL client sends a signaling request, the application scenario applicable to the signaling request is selected according to the traffic characteristics of the signaling request, and the corresponding load balancing strategy can be selected from the predefined load balancing strategy according to the application scenario, and the FreeSWITCH node suitable for forwarding the signaling request is selected according to the long connection, and the signaling request is forwarded to the outside, so that a signaling channel from the ESL client to the FreeSWITCH cluster is established, so that there is no need to use the SIP proxy service of a third-party application, which is technically controllable, reduces security risks, and is suitable for industries with high requirements for data security.

[0142] In addition, traditional FreeSWITCH clusters usually use a hot backup solution. When the main instance goes down, the communication service will be interrupted and it is necessary to switch to the backup node, which will result in high operation and maintenance costs.

[0143] To solve the problem of communication service interruption caused by FreeSWITCH cluster downtime, the present application embodiment designs and implements a FreeSWITCH cluster deployment solution, and achieves high availability of services through the detection mechanism and disconnection reconnection of FreeSWITCH nodes in the cluster.

[0144] Regarding the detection mechanism, specifically, as a preferred embodiment, as Figure 8 As shown, the load balancing method further includes, before step S150: forwarding the signaling request to the FreeSWITCH node selected by the load balancing strategy:

[0145] S201: Monitor the heartbeat detection events of each FreeSWITCH node in the list of all service instances.

[0146] S202: Determine whether the FreeSWITCH node is available based on the heartbeat detection event.

[0147] S203: If it is determined that the FreeSWITCH node is unavailable, the FreeSWITCH node is deleted from the normal service instance list.

[0148] S204: Detecting the unavailable FreeSWITCH node within the predetermined monitoring time.

[0149] S205: When the detection of an unavailable FreeSWITCH node fails, close the persistent connection with the FreeSWITCH node and delete the unavailable FreeSWITCH node from the list of all service instances.

[0150] The technical solution provided by the embodiment of the present application is to prevent the load balancer of the ESL client from selecting the FreeSWITCH node that has expired. It is necessary to detect whether the FreeSWITCH nodes in the load list are all available and whether the state is normal, which is also the live detection mechanism. Under normal circumstances, the FreeSWITCH node itself will generate a heartbeat event every 20 seconds, which can be used to detect whether FreeSWITCH is operating normally. The load balancer judges whether the FreeSWITCH node is normal by monitoring the heartbeat events of each FreeSWITCH node. When a FreeSWITCH node does not send a heartbeat event for more than 20 seconds, the client load balancer will remove the node from the normal service instance list, retain it in all service instance lists, and start a timer. If the heartbeat event of the FreeSWITCH node is received again within the default timeout period, the node will be re-added to the normal service instance list, otherwise it will be removed from all service instance lists, and the ESL connection to it will be closed. Through the above-mentioned live detection mechanism, the nodes that are temporarily unable to provide services in the cluster can be intelligently filtered out, thereby avoiding the impact on the business.

[0151] In addition, the FreeSWITCH node may be updated or disconnected, in which case the FreeSWITCH node needs to be disconnected and reconnected.

[0152] Specifically, as a preferred embodiment, Fig. 9 As shown, the load balancing method further includes the following steps after step S120: establishing a persistent connection with the FreeSWITCH cluster through registration information:

[0153] S301: Real-time monitoring of long connections with each FreeSWITCH node in the FreeSWITCH cluster;

[0154] S302: When it is detected that the long connection is disconnected, the timing thread is started, and the long connection with the disconnected FreeSWITCH node is re-established in the timing thread.

[0155] The technical solution provided by the embodiment of the present application connects the signaling server of the real-time audio and video signaling service to each FreeSWITCH node through a long connection. The signaling server communicates with FreeSWITCH through the FreeSWITCH ESL (Event Socket Library) protocol, which is a custom protocol on top of TCP, similar to the Http protocol or Sip protocol. The signaling service implements an ESL protocol-based client based on the Netty framework. In the Netty connection processing method, an asynchronous callback event is added through the ChannelFutureListener method. When the long connection is disconnected, a timed thread will be enabled to perform a reconnection operation until the connection is re-established. The above method can ensure the connection with the FreeSWITCH node and the smooth flow of the signaling service.

[0156] In summary, the technical solution provided by the above embodiments of the present application is the first load balancing method that supports FreeSWITCH ESL, supports clustered deployment of FreeSWITCH, and greatly improves the call concurrent processing capability. In addition, it supports FreeSWITCH cluster deployment, and realizes the registration and discovery of FreeSWITCH nodes by containerizing FreeSWITCH and scripting deployment. Finally, through the online expansion of FreeSWITCH cluster nodes and the automatic removal of faulty nodes, the problem of machine failure can be automatically handled, which greatly reduces the occurrence of production problems with low manpower input, greatly reduces the impact time of production failures, and reduces the impact scope.

[0157] To achieve the above purpose, Fig.11 As shown, the present application also provides a load balancer for a FreeSWITCH cluster, including:

[0158] A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the load balancing method for a FreeSWITCH cluster as provided in any of the above embodiments.

[0159] Reference below Fig.11, which shows a schematic diagram of the structure of the load balancer of the FreeSWITCH cluster suitable for implementing the embodiment of the present application. The load balancer of the FreeSWITCH cluster in the embodiment of the present application can include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.11 The load balancer of the FreeSWITCH cluster shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0160] like Fig.11 As shown, the load balancer of the FreeSWITCH cluster can include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. Various programs and data required for the operation of the load balancer of the FreeSWITCH cluster are also stored in RAM1004. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can run the load balancer of the FreeSWITCH cluster to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a model building device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have instead.

[0161] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0162] The load balancer of the FreeSWITCH cluster provided in the present application adopts the load balancing method of the FreeSWITCH cluster in the above-mentioned embodiment. Compared with the prior art, its beneficial effects are the same as the beneficial effects of the load balancing method of the FreeSWITCH cluster provided in the above-mentioned embodiment, and other technical features in the load balancer of the FreeSWITCH cluster are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0163] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0164] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

[0165] In addition, to achieve the above purpose, the present application also provides a FreeSWITCH cluster load balancing system, including:

[0166] Signaling server, registration center and FreeSWITCH cluster. Each FreeSWITCH node in the signaling server and FreeSWITCH cluster is connected to the registration center respectively.

[0167] The signaling server includes the ESL client and the above Fig.11 The load balancer shown;

[0168] The ESL client communicates with the external Web client and is used to convert the Http request sent by the Web client into a signaling request in the ESL format;

[0169] The load balancer is connected to the ESL client, and a computer program is built into the load balancer. The computer program is configured to implement the steps of the load balancing method of the FreeSWITCH cluster provided by any of the above technical solutions.

[0170] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes also be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs a specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.

[0171] The modules involved in the embodiments of the present application can be implemented by software or hardware, wherein the name of the module does not limit the unit itself in some cases.

[0172] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A load balancing method for a FreeSWITCH cluster, characterized in that: include: Get the registration information of all FreeSWITCH nodes in the FreeSWITCH cluster from the registration center; Establishing a persistent connection with the FreeSWITCH cluster through the registration information; When calling the ESL client to send a signaling request, selecting an application scenario applicable to the signaling request according to the traffic characteristics of the signaling request; According to the application scenario, select a corresponding load balancing strategy from predefined load balancing strategies; Using the long connection, the signaling request is forwarded to the FreeSWITCH node selected by the load balancing strategy.

2. The load balancing method according to claim 1, characterized in that: The step of establishing a long connection with the FreeSWITCH cluster through the registration information includes: Create a list of all service instances and a list of normal service instances; Monitor the registration center in real time, and add the newly registered FreeSWITCH nodes monitored to the list of all service instances; Establishing a persistent connection with the newly registered FreeSWITCH node through the ESL protocol; When a long connection with the newly registered FreeSWITCH node is successfully established, the newly registered FreeSWITCH node is added to the normal service instance list.

3. The load balancing method according to claim 1 or 2, characterized in that: The step of selecting an application scenario to which the signaling request is applicable according to the traffic characteristics of the signaling request when the ESL client is called to send the signaling request includes: Using the ESL client to convert the Http request sent by the external Web client into a signaling request; Extracting a traffic feature corresponding to the signaling message from the signaling request; Select an application scenario corresponding to the traffic characteristics.

4. The load balancing method according to claim 3, characterized in that: The step of selecting a corresponding load balancing strategy from predefined load balancing strategies according to the application scenario includes: Determine whether the signaling request is applicable to a stateful scenario or a stateless scenario; If it is determined to be applicable to the stateless scenario, a polling strategy or a random forwarding strategy is selected from the predefined load balancing strategy, and the signaling request is sent to the selected FreeSWITCH node; If it is determined to be applicable to a stateful scenario, a consistent hashing strategy is selected from the predefined load balancing strategy, and the signaling request is sent to the selected FreeSWITCH node.

5. The load balancing method according to claim 4, characterized in that: The step of selecting a polling strategy or a random forwarding strategy from the predefined load balancing strategy and sending the signaling request to the selected FreeSWITCH node includes: Obtain the request count of the signaling request, perform a modulo operation on the number of all FreeSWITCH nodes in the normal service instance list, and use the modulo operation result as the machine index corresponding to this signaling request; Select the FreeSWITCH node corresponding to the machine index to forward this signaling request; or, Input the node numbers of all FreeSWITCH nodes in the normal service instance list into the random number generation algorithm, and use the obtained random number as the machine index corresponding to this signaling request; Select the FreeSWITCH node corresponding to the machine index to forward this signaling request.

6. The load balancing method according to claim 4, characterized in that: The step of selecting a consistent hashing strategy from the predefined load balancing strategy and sending the signaling request to the selected FreeSWITCH node comprises: Setting a hash space, mapping the hash space into a virtual ring; Calculate the node hash result of each FreeSWITCH node in the normal service instance list, and map the node hash results to the virtual rings respectively; Performing hash calculation on the signaling request, and mapping the signaling hash result to the virtual ring; Find the FreeSWITCH node corresponding to the hash result of the nearest neighbor node from the location of the signaling hash result, and forward the signaling request.

7. The load balancing method according to claim 2, characterized in that: Before the step of forwarding the signaling request to the FreeSWITCH node selected by the load balancing strategy, the method further includes: Monitor the heartbeat detection events of each FreeSWITCH node in the list of all service instances; According to the heartbeat detection event, determining whether the FreeSWITCH node is available; If it is determined that the FreeSWITCH node is unavailable, deleting the FreeSWITCH node from the normal service instance list; Probing the unavailable FreeSWITCH node within a predetermined monitoring time; When the unavailable FreeSWITCH node fails to be detected, the long connection with the FreeSWITCH node is closed, and the unavailable FreeSWITCH node is deleted from the list of all service instances.

8. The load balancing method according to claim 1, wherein: After the step of establishing a long connection with the FreeSWITCH cluster through the registration information, the method further includes: Monitor the long connection with each FreeSWITCH node in the FreeSWITCH cluster in real time; When it is monitored that the long connection is disconnected, a timing thread is started, and a long connection with the disconnected FreeSWITCH node is re-established in the timing thread.

9. A load balancer for a FreeSWITCH cluster, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the load balancing method for a FreeSWITCH cluster as claimed in any one of claims 1 to 8.

10. A load balancing system for a FreeSWITCH cluster, characterized in that: include: A signaling server, a registration center and a FreeSWITCH cluster, wherein the signaling server and each FreeSWITCH node in the FreeSWITCH cluster are respectively connected to the registration center; wherein, The signaling server includes an ESL client and a load balancer as claimed in claim 9; The ESL client is connected to an external Web client for converting an Http request sent by the Web client into a signaling request in the form of an ESL protocol; The load balancer is connected to the ESL client, and a computer program is built into the load balancer. The computer program is configured to implement the steps of the load balancing method for the FreeSWITCH cluster according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Multiple-tier distributed cluster system

    CN102118433A

  • IVR (Interactive Voice Response) graphical configuration system and method based on Freeswitch

    CN111580725A

  • Real-time audio and video access method and device, equipment and storage medium

    CN117812047A

  • Freeswitch monitoring method, device, storage medium, and apparatus

    WO2021003923A1