CN111935029B - Gateway load balancing method and device, storage medium and electronic equipment - Google Patents

Gateway load balancing method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN111935029B
CN111935029B CN202010983440.9A CN202010983440A CN111935029B CN 111935029 B CN111935029 B CN 111935029B CN 202010983440 A CN202010983440 A CN 202010983440A CN 111935029 B CN111935029 B CN 111935029B
Authority
CN
China
Prior art keywords
gateway
addresses
address
time
reselection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010983440.9A
Other languages
Chinese (zh)
Other versions
CN111935029A (en
Inventor
葛凯凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010983440.9A priority Critical patent/CN111935029B/en
Publication of CN111935029A publication Critical patent/CN111935029A/en
Application granted granted Critical
Publication of CN111935029B publication Critical patent/CN111935029B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/12Avoiding congestion; Recovering from congestion
    • H04L47/125Avoiding congestion; Recovering from congestion by balancing the load, e.g. traffic engineering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a gateway load balancing method and device, a storage medium and electronic equipment. Wherein, the method comprises the following steps: the method comprises the steps of obtaining an IP address of each gateway in a first gateway set on first equipment to obtain a first group of IP addresses, randomly selecting N IP addresses in the first group of IP addresses, sending detection requests to the N gateways according to the N IP addresses on the first equipment respectively, selecting a first gateway which sends a detection response to the first equipment firstly from the N gateways, determining the IP address of the selected first gateway as the first IP address, and sending requests received on the first equipment to the first gateway according to the first IP address until a first reselection time. The invention solves the technical problems of more complex load balancing scheme and lower load balancing efficiency in the prior art.

Description

Gateway load balancing method and device, storage medium and electronic equipment
Technical Field
The invention relates to the field of computers, in particular to a gateway load balancing method and device, a storage medium and electronic equipment.
Background
At present, data storage services can be provided based on a distributed system, but in the process of using the storage services through a storage gateway of the distributed system, a plurality of user service requests are relatively concentrated to use the data storage services through one or more distributed nodes, and further, network congestion is caused, and the data storage services cannot be normally accessed.
For example, in an Openstack-based cloud platform, a Ceph distributed storage system is typically used to provide storage services. The cloud platform provides two computing services of a virtual machine and a bare computer for users to use, so that the users can install the services on the virtual machine or the bare computer in a classified manner according to actual needs. For example, services with relatively high performance requirements can be installed on bare computers (such as database services), as cloud platforms providing the data storage services become larger in scale, more bare computers need to be managed, and at this time, more data requests are received by a storage gateway.
However, currently, external services are usually used, for example, the Haproxy service and the Keepalive service are based on the virtual IP to achieve load balancing, and there are technical problems that the Haproxy service and the Keepalive service are mutually independent services, the Haproxy service and the Keepalive service need to be additionally installed, and the load balancing needs to be achieved based on the virtual IP, so that the external services need to be relied on, existing virtual IP resources have uncontrollable factors, a load balancing scheme is complex, and the load balancing efficiency is low.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
Embodiments of the present invention provide a gateway load balancing method and apparatus, a storage medium, and an electronic device, so as to at least solve the technical problems of a complex load balancing scheme and low load balancing efficiency in the related art.
According to an aspect of the embodiments of the present invention, there is provided a gateway load balancing method, including: acquiring the IP address of each gateway in a first gateway set on first equipment to obtain a first group of IP addresses; randomly selecting N IP addresses from the first group of IP addresses, wherein N is a natural number greater than 1, and the N IP addresses are the IP addresses of N gateways in the first gateway set respectively; sending a detection request to the N gateways on the first device according to the N IP addresses respectively; selecting the first gateway which firstly sends a probe response to the first device from the N gateways, and determining the IP address of the selected first gateway as the first IP address, wherein the probe response corresponds to the probe request; and sending the requests received on the first equipment to the first gateway according to the first IP address until the first reselection time.
According to another aspect of the embodiments of the present invention, there is also provided a gateway load balancing apparatus, including: the acquisition module is used for acquiring the IP address of each gateway in the first gateway set on the first equipment to obtain a first group of IP addresses; a selecting module, configured to randomly select N IP addresses from the first group of IP addresses, where N is a natural number greater than 1, and the N IP addresses are IP addresses of N gateways in the first gateway set respectively; a first sending module, configured to send, on the first device, probe requests to the N gateways according to the N IP addresses, respectively; a determining module, configured to select, from the N gateways, the first gateway that first sends a probe response to the first device, and determine an IP address of the selected first gateway as the first IP address, where the probe response corresponds to the probe request; and a second sending module, configured to send the requests received on the first device to the first gateway according to the first IP address until the first reselection time.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the above gateway load balancing method when running.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including a memory and a processor, where the memory stores a computer program, and the processor is configured to execute the above gateway load balancing method through the computer program.
In the embodiment of the invention, the purpose of replacing the technical scheme of load balancing based on virtual IP by using external services in the related technology is achieved by acquiring the IP address of each gateway in a first gateway set on first equipment to obtain a first group of IP addresses, randomly selecting N IP addresses in the first group of IP addresses, sending a detection request to the N gateways according to the N IP addresses on the first equipment respectively, selecting a first gateway which sends a detection response to the first equipment firstly from the N gateways, determining the IP address of the selected first gateway as the first IP address, sending the requests received on the first equipment to the first gateway according to the first IP address until the first reselection time, randomly selecting the IP address of the gateway from the acquired first gateway set on the first equipment, and sending the requests according to the selected IP address, therefore, the load balancing is independent of external services, the load balancing efficiency is improved, the technical effect of load balancing cost is reduced, and the technical problems that the load balancing scheme is complex and the load balancing efficiency is low in the related technology can be solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a schematic diagram of an application environment of an alternative gateway load balancing method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of an alternative gateway load balancing method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of an alternative gateway load balancing method according to an embodiment of the present invention;
fig. 4 is a schematic diagram of another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 5 is a schematic diagram of another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 6 is a schematic diagram of another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 7 is a schematic diagram of yet another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 8 is a schematic diagram of yet another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 9 is a schematic diagram of yet another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 10 is a schematic diagram of yet another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 11 is a schematic flow chart of another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 12 is a schematic flowchart of yet another alternative gateway load balancing method according to an embodiment of the present invention;
fig. 13 is a schematic structural diagram of an alternative gateway load balancing apparatus according to an embodiment of the present invention;
fig. 14 is a schematic structural diagram of an alternative electronic device according to an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, partial nouns or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
OpenStack: OpenStack is an open source Iaas management platform.
And (3) a Cinder: render is a component in Openstack that provides block storage.
Ceph: ceph is an open source distributed storage system and can simultaneously provide storage services of objects, blocks and files.
Iscsi: a protocol for transmitting scsi commands over a Tcp/IP network.
The invention is illustrated below with reference to examples:
according to an aspect of the embodiment of the present invention, a gateway load balancing method is provided, and optionally, in this embodiment, the gateway load balancing method may be applied to a hardware environment formed by a server 101 and a user terminal 103 as shown in fig. 1. As shown in fig. 1, a server 101 is connected to a terminal 103 through a network, and may be configured to provide a service to a user terminal or a client installed on the user terminal, where the target client may include a video client, an instant messaging client, a browser client, a game client, and the like. The database 105 may be provided on or separate from the server for providing data storage services for the server 101, and the network may include, but is not limited to: a wired network, a wireless network, wherein the wired network comprises: a local area network, a metropolitan area network, and a wide area network, the wireless network comprising: bluetooth, WIFI, and other wireless communication enabled networks, the user terminal 103 may be a target client configured terminal, and may include but is not limited to at least one of the following: mobile phones (e.g., Android phones, iOS phones, etc.), notebook computers, tablet computers, palm computers, MID (Mobile Internet Devices), PAD, desktop computers, smart televisions, etc., the server can be a single server, or a server cluster composed of a plurality of servers, or a cloud server, the application 107 providing the gateway load balancing service may be, but is not limited to being, displayed by the user terminal 103, the gateway load balancing service described above may be used through the portal of the gateway load balancing application 107 configured on the terminal, for example, the gateway load balancing method may be used based on the application 107, and information such as a connection state between the device and the gateway may be displayed through a display interface of the application 107, which is only an example and is not limited in this embodiment.
Optionally, as an optional implementation manner, as shown in fig. 2, the gateway load balancing method includes:
s202, acquiring the IP address of each gateway in a first gateway set on first equipment to obtain a first group of IP addresses;
s204, randomly selecting N IP addresses from the first group of IP addresses, wherein N is a natural number greater than 1, and the N IP addresses are respectively IP addresses of N gateways in the first gateway set;
s206, sending detection requests to the N gateways on the first equipment according to the N IP addresses respectively;
s208, selecting a first gateway which firstly sends a detection response to the first equipment from the N gateways, and determining the IP address of the selected first gateway as a first IP address, wherein the detection response corresponds to the detection request;
and S210, sending the requests received by the first equipment to the first gateway according to the first IP address until the first reselection time.
Optionally, in this embodiment, the network load balancing method may be applied to an application scenario including but not limited to that shown in fig. 3, and as shown in fig. 3, the application scenario may include but not limited to the following:
the service layer 302 includes a system layer where a user can directly complete operations, for example, the service layer may include but is not limited to a self-service platform for providing a display interface for applying resources to the user, the user may perform operations through the self-service platform according to service requirements to complete processes such as applying resources, a monitoring platform for monitoring resource usage of the monitoring platform, an operation and maintenance platform for providing an administrator operation interface, and host migration and other processes;
the cloud gateway layer 304 comprises a venus, an IP system and an rbac, wherein the venus provides a uniform network resource such as an original platform resource interface and an IP system management IP, and the rbac is used for performing authentication operation;
a base cloud layer 306, configured to configure virtual cloud services, including openstack providing laas services, Nova for managing the lifecycle of virtual machines, pane for managing the lifecycle of images, and finder for managing the lifecycle of volumes;
and the storage layer 308 is used for reading and using the block storage devices in the Ceph storage cluster through the iscsi protocol.
Optionally, in this embodiment, the first device may include, but is not limited to, the above-mentioned render client 310 in fig. 3, the first gateway may include, but is not limited to, the above-mentioned iscsi gateway 312 in fig. 3, and the second gateway may include, but is not limited to, the above-mentioned iscsi gateway 314 in fig. 3.
Optionally, in this embodiment, the first gateway set may include, but is not limited to, an iscsi gateway 312 and an iscsi gateway 314 included in the storage layer 308, and may also include, but is not limited to, other iscsi gateways, or storage gateways that are different from the iscsi gateway in type but have the same purpose.
The above is merely an example, and the present embodiment does not limit this in any way.
Optionally, in this embodiment, the random selection may include, but is not limited to, performing random selection by using a random number or a pseudo random number, configuring a corresponding identifier for each gateway in the first gateway set, and then randomly selecting the first IP address from the first group of IP addresses corresponding to the first gateway set in the form of a random number and a pseudo random number. The first IP address may be randomly selected from the first N IP addresses in the randomly ordered first group of IP addresses, or the first gateway may be determined to be the gateway corresponding to the first received probe response message by concurrently sending probe signals to the first group of gateways.
The above is only an example, and the specific process of performing random selection may include, but is not limited to, one or more of the above combinations and other manners capable of performing random selection, and this embodiment does not make any specific limitation.
Optionally, in this embodiment, the probe request is a probe request simultaneously sent in parallel, and the selecting the first gateway that sends the probe response to the first device first among the N gateways may include, but is not limited to, selecting a gateway with the highest network delay or processing speed as a storage gateway for receiving the request.
Optionally, in this embodiment, fig. 4 is a schematic diagram of an optional gateway load balancing method according to an embodiment of the present invention, which is further described below:
the probe response and the probe request may correspond to each other, including, but not limited to, as shown in fig. 4, the first device 402 randomly selects N gateways from the entire gateway set 404 to form a first gateway set 406, simultaneously sends probe request 1 to the gateway 408 based on the first set of gateway IPs in parallel, sends probe request 2 to the gateway 410, sends probe request 3, … to the gateway 412, sends probe request N to the gateway 414, and respectively receives probe response 1 returned by the gateway 408, probe response 2 returned by the gateway 410, probe response 3, … returned by the gateway 412, and probe response N returned by the gateway 414, and finally determines the gateway 412 corresponding to the first received probe response as the first gateway 416, by which, in case of a large number of gateways, a part of gateways can be randomly selected as objects that need to send probe information, and then, sending detection information to a part of selected gateways in parallel, and determining the gateway which responds most quickly as the first gateway for receiving the request subsequently, thereby achieving the technical effects of flexibly configuring the gateways and improving the load balancing efficiency.
By the embodiment, the purpose of replacing the technical scheme of load balancing based on virtual IP by using external services in the related art is achieved by randomly selecting the IP address of the gateway from the acquired first gateway set on the first device and sending the request according to the selected IP address in a manner of replacing the technical scheme of load balancing based on virtual IP by using external services in the related art in the first device by acquiring the IP address of each gateway in the first gateway set on the first device to obtain a first group of IP addresses, randomly selecting N IP addresses from the first group of IP addresses, sending the probe request to the N gateways according to the N IP addresses on the first device, selecting the first gateway which sends the probe response to the first device in the N gateways, determining the selected IP address of the first gateway as the first IP address, sending the request received by the first device to the first gateway according to the first IP address until the first reselection time, therefore, the load balancing is independent of external services, the load balancing efficiency is improved, the technical effect of load balancing cost is reduced, and the technical problems that the load balancing scheme is complex and the load balancing efficiency is low in the related technology can be solved.
In an optional embodiment, the randomly selecting N IP addresses in the first set of IP addresses includes: randomly sequencing the IP addresses in the first group of IP addresses to obtain a third group of IP addresses; and selecting the IP addresses with the first N bits from the third group of IP addresses, and determining the IP addresses as the N IP addresses.
Optionally, in this embodiment, the third group of IP addresses is a group of IP addresses determined after random ordering from the first group of IP addresses, and an IP address with N top bits arranged is selected from the third group of IP addresses, where N may be dynamically determined by a sending number requested in a period preset by the system or before the system or a number of the first group of gateways.
Optionally, in this embodiment, fig. 5 is a schematic diagram of an optional gateway load balancing method according to an embodiment of the present invention, which is further described below:
the association between the probe response and the probe request may include, but is not limited to, as shown in fig. 5, the first device 502 randomly selecting N gateways from all the gateway sets 514, randomly sorting the gateways, determining the first N gateways based on the sorting result, determining IP addresses of the selected 3 gateways, for example, gateway IP1, gateway IP2, and gateway IP3, simultaneously sending probe request 1 to the gateway 504 based on the gateway IP1, sending probe request 2 to the gateway 506, sending probe request 3 to the gateway 508, receiving probe response 1 returned by the gateway 504 based on the probe request 1, probe response 2 returned by the gateway 506 based on the probe request 2, probe response 3 returned by the gateway 508 based on the probe request 3, and finally determining the gateway 506 corresponding to the first received probe response as the first gateway 516.
It should be noted that, in fig. 5, the number Z of gateways in all the gateway sets 514 is greater than or equal to the number M of gateways in the first gateway set 510, and the number M of gateways in the first gateway set 510 is greater than or equal to the number N of gateways in the third gateway set 512.
The above is merely an example, and the present embodiment is not limited in any way.
According to the embodiment, firstly, under the condition that the number of gateways is large, a part of gateways can be randomly selected for sequencing to obtain a new group of gateways, a group of gateways of an object needing to send detection information are determined from the new group of gateways to send the detection information in parallel, and the gateway which responds most quickly is determined as the first gateway of a subsequent receiving request, so that the technical effects of flexibly configuring the gateways and improving the load balancing efficiency are achieved.
In an optional embodiment, after sending the request received at the first device to the first gateway according to the first IP address until the first reselection time, the method further includes: when the first reselection time is reached, randomly selecting a second IP address from a second group of IP addresses, wherein the second group of IP addresses are the group of IP addresses obtained by deleting the first IP address from the first group of IP addresses, and the second IP address is the IP address of a second gateway in the first gateway set; and after the first reselection time, sending the requests received by the first equipment to the second gateway according to the second IP address until the second reselection time.
Optionally, in this embodiment, the first reselection time and the second reselection time may include, but are not limited to, being preset by a system, for example, by setting a time threshold, when a duration of sending a request received by the first device to the first gateway according to the first IP address is greater than the time threshold, the time may be determined as the first reselection time or the second reselection time, and for example, by setting a request sending number threshold, when a request sending number of sending a request received by the first device to the first gateway according to the first IP address is greater than the request sending number threshold, the time may be determined as the first reselection time or the second reselection time.
The above is merely an example, and the present embodiment is not limited in any way.
Fig. 6 is a schematic diagram of an alternative network load balancing method according to an embodiment of the present invention, as shown in fig. 6, an iscsi device 604 for executing the network load balancing method may be, but is not limited to, disposed in the first device 602, wherein the network load balancing method is executed by a client 606 for connecting gateways, the first IP address is randomly selected from a first group of IP addresses corresponding to a first gateway set 608, and a first gateway 610 (corresponding to a storage gateway indicated by a thick line in fig. 6) in the first gateway set 608 is further determined.
The first device 602 may further include, but is not limited to, a management module 612, where the management module is configured to manage and control iscsi devices, and operate mirror management on requests arriving at a device layer, such as adding, deleting, and modifying "volume", creating, deleting, rolling back, and the like.
The first device 602 may further include, but is not limited to, a scheduling module 614, where the scheduling module is configured to select a storage gateway for connection, randomly select a target gateway (corresponding to the aforementioned first gateway) from the aforementioned storage gateways (corresponding to the aforementioned first group of gateways) through a random selection mechanism (the number of storage gateways may not be limited as shown in fig. 6), and send subsequent requests to the aforementioned target gateway.
The first device 602 may further include, but is not limited to, a timing module 616, wherein the timing module is configured to periodically reselect the storage gateway, that is, perform S208, to load the subsequent request.
The first device 602 may further include, but is not limited to, a reconnection module 618, where the reconnection module is configured to initiate reselection of a new target gateway after the previously selected target gateway is out of service (for example, the gateway fails), that is, perform S208.
The first device 602 may further include, but is not limited to, a client 606, wherein the client is configured to serve as a client connected to the storage gateway, and after the storage gateway is scheduled to be selected, a corresponding request is sent to the storage gateway through the network.
According to the embodiment, when the first reselection time is reached, the second IP address is randomly selected from the second group of IP addresses, after the first reselection time, the request received by the first device is sent to the second gateway according to the second IP address, and multiple reselection processes are achieved until the second reselection time, so that the technical effect of improving the load balancing efficiency can be achieved.
In an optional embodiment, the method further comprises: when the second reselection time is reached, randomly selecting a third IP address from a fourth group of IP addresses, wherein the fourth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the third IP address is an IP address of a third gateway in the first gateway set; and after the second reselection time, sending the requests received by the first device to the third gateway according to the third IP address until the third reselection time.
Optionally, in this embodiment, the reaching of the second reselection time may include, but is not limited to, being preset by a system, for example, by setting a time threshold, when a duration of sending the request received by the first device to the second gateway according to the second IP address is greater than the time threshold, the current time may be determined as reaching the second reselection time, and for example, by setting a request sending number threshold, when a request sending number of sending the request received by the first device to the second gateway according to the second IP address is greater than the request sending number threshold, the current time may be determined as reaching the second reselection time.
Optionally, in this embodiment, the fourth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the third IP address is an IP address of a third gateway in the first gateway set.
Alternatively, in this embodiment, as shown in fig. 6, the reaching of the second reselection time may be determined by the timing module 616 in fig. 6, after the reaching of the second reselection time, the first gateway 610 in the first gateway set 608 is deleted to determine the fourth group of IP addresses, the third IP address is determined by a random selection method, a gateway corresponding to the third IP address is determined as a third gateway, and a request is sent to the third gateway.
It should be noted that fig. 7 is a schematic diagram of an optional network load balancing method according to an embodiment of the present invention, as shown in fig. 7, where a manner of randomly selecting a third IP address may include, but is not limited to, configuring a gateway set corresponding to a fourth group of IP addresses as the gateway set 714 in fig. 7, the first device 702 randomly selects N gateways from the gateway set 714, performs random sorting, determines the first N gateways based on a result of the sorting, determines IP addresses of the selected 3 gateways, for example, the gateway IP1, the gateway IP2, and the gateway IP3, and simultaneously sends a probe request 1 to the gateway 704 based on the gateway IP1, sends a probe request 2 to the gateway 706, sends a probe request 3 to the gateway 708, and respectively receives a probe response 1 returned by the gateway based on the probe request 1, and a probe response 2 returned by the gateway 706 based on the probe request 2, the gateway 708 returns a probe response 3 based on the probe request 3, and finally determines the gateway 706 corresponding to the probe response received first as the third gateway 716.
According to the embodiment, the gateway can be randomly selected again under the condition that the preset condition is achieved, and then the network load balancing is flexibly configured, so that the technical effects of improving the load balancing efficiency and accelerating the speed of receiving the request by the gateway are achieved.
In an optional embodiment, said randomly selecting a second IP address from a second set of IP addresses upon reaching said first reselection time comprises: under the condition that the first reselection time is a predetermined time, randomly selecting the second IP address from the second group of IP addresses when the current time reaches the first reselection time, wherein the time interval between the first reselection time and the second reselection time is a preset time interval; or when the first reselection time is the time when the number of the sent requests reaches the predetermined number, determining that the first reselection time is reached and randomly selecting the second IP address from the second group of IP addresses when the number of the requests sent by the first device to the first gateway reaches the predetermined number after a fourth reselection time, where the sent requests are requests sent by the first device to the first gateway after the fourth reselection time, and the fourth reselection time is the previous reselection time of the first reselection time or an initial time before the first reselection time.
Optionally, in this embodiment, the preset time interval may be preset by a system, or may be dynamically adjusted according to the number of request transmissions in the current period.
For example, when the first reselection time is a predetermined time, and when the current time reaches the first reselection time, the second IP address is randomly selected from the second group of IP addresses, that is, when the preset time interval is reached, the reselection logic is executed (the second IP address is randomly selected from the second group of IP addresses), and the currently matched gateway is replaced with the newly selected gateway.
Optionally, in this embodiment, when the number of requests sent by the first device to the selected gateway reaches the preset threshold, the preset time interval may be, but is not limited to, shortened, and the preset time interval may be dynamically adjusted according to a variation of the number of requests.
Optionally, in this embodiment, the predetermined number may be preset by a system, or may be dynamically adjusted according to a request sending speed of a current period.
For example, when the first reselection time is a predetermined time, and when the current time reaches the first reselection time, the second IP address is randomly selected from the second group of IP addresses, that is, when the number of requests sent by the first device to the first gateway reaches a predetermined number, the reselection logic is executed (the second IP address is randomly selected from the second group of IP addresses), and the currently matched gateway is replaced with the newly selected gateway.
Optionally, in this embodiment, in a case that the speed of sending to the selected gateway by the first device reaches the preset threshold, the predetermined number may be adjusted, but is not limited to, and may be dynamically adjusted according to the amount of change of the requested number.
Through the embodiment, the matched gateways can be flexibly adjusted according to the number of the receiving requests of the current matched gateways or the matching time, and further, the technical effect of improving the network load balancing efficiency is achieved.
In an optional embodiment, the method further comprises: after the first reselection time and before the second reselection time, randomly selecting a fourth IP address from a fifth group of IP addresses under the condition that the second gateway is detected to have a fault, wherein the fifth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the fourth IP address is an IP address of a fourth gateway in the first gateway set; and before the second reselection time, sending the requests received by the first device to the fourth gateway according to the fourth IP address until the second reselection time.
Optionally, in this embodiment, whether the second gateway fails may be determined by, but not limited to, monitoring a link that transmits a request between the first device and the second gateway, and may also be determined by, but not limited to, monitoring a heartbeat signal between the first device and the second gateway.
Optionally, in this embodiment, in the case that the second gateway fails, the failed second gateway may be deleted from the gateway set to avoid randomly selecting the failed gateway again, and the method may further include, but is not limited to, sending a detection signaling to the failed gateway, and after detecting that the failed gateway is recovered to be normal, adding the recovered gateway to the gateway set.
Optionally, in this embodiment, a gateway that has failed or has a high failure rate in the gateway set may also be identified by identification, and in the process of randomly selecting a gateway, if the gateway with the identification is selected, the gateway with the identification is discarded, and the gateway with the identification is deleted from the gateway set, so that the randomly selected gateway can normally receive the request.
Through the embodiment, the gateway can be randomly selected again when the gateway breaks down, and further, the technical effect of improving the network load balancing efficiency can be achieved.
In an optional embodiment, the method further comprises: after the first reselection time and before the second reselection time, randomly selecting a fourth IP address from a fifth group of IP addresses under the condition that the second gateway is detected to have a fault, wherein the fifth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the fourth IP address is an IP address of a fourth gateway in the first gateway set; and before a fifth reselection time, sending all the requests received by the first device to the fourth gateway according to the fourth IP address until the fifth reselection time, where the fifth reselection time is a reselection time next to the second reselection time, or the fifth reselection time is a reselection time set by reselection and is later than the second reselection time.
Optionally, in this embodiment, the fifth reselection time is a reselection time set by reselection and is later than the second reselection time, where the reselection time is not limited to be when a failure of the second gateway is detected, and the gateway matching time is reset after the new gateway is selected, so as to avoid repeatedly reselecting the web page many times, reduce the resource overhead, and achieve the technical effect of improving the network load balancing efficiency.
In an optional embodiment, in a case where the fifth reselection time is a reselection time next to the second reselection time, a time interval between the first reselection time and the second reselection time is equal to a time interval between the second reselection time and the fifth reselection time; or when the fifth reselection time is a reselection time set by reselection and is later than the second reselection time, the fifth reselection time is a time when the number of sent requests reaches a predetermined number, where the sent requests are requests sent to the fourth gateway by the first device after the second gateway is detected to have a fault.
Optionally, in this embodiment, the fifth reselection time is a reselection time set for reselection and is later than the second reselection time, which includes but is not limited to reselecting a new gateway when it is detected that the number of sent requests reaches a predetermined number, and resetting the number of sent requests after the new gateway is selected, so as to avoid repeatedly reselecting a web page many times, reduce the overhead of resources, and achieve the technical effect of improving the network load balancing efficiency.
Optionally, in this embodiment, the fifth reselection time is a reselection time set by reselection and is later than the second reselection time, where the time interval between the first reselection time and the second reselection time is equal to the time interval between the second reselection time and the fifth reselection time, the method reselects a new gateway at random, and resets the time interval after the new gateway is selected, so as to avoid repeatedly reselecting the web page many times, reduce the overhead of resources, and achieve the technical effect of improving the network load balancing efficiency.
In an optional embodiment, the method further comprises: acquiring an IP address of each gateway in the first gateway set on second equipment to obtain the first group of IP addresses, wherein the first equipment and the second equipment establish communication connection with each gateway in the first gateway set; randomly selecting a fifth IP address from the first group of IP addresses, wherein the fifth IP address is an IP address of a fifth gateway in the first set of gateways; sending the request received by the second device to the fifth gateway according to the fifth IP address until a sixth reselection moment; when the sixth reselection time is reached, randomly selecting a sixth IP address from a sixth group of IP addresses, wherein the sixth group of IP addresses is a group of IP addresses obtained by deleting the fifth IP address from the first group of IP addresses, and the sixth IP address is an IP address of a sixth gateway in the first gateway set; and after the sixth reselection time, sending the requests received by the second device to the sixth gateway according to the sixth IP address until the seventh reselection time.
Optionally, in this embodiment, the second device may be the same as or different from the first device, and the second device is also configured with a structure as shown in fig. 6.
Fig. 8 is a schematic diagram of optional gateway load balancing according to an embodiment of the present invention, as shown in fig. 8, an IP address of each gateway in a first gateway set 804 is obtained on a second device 802 to obtain a first group of IP addresses, where both the first device 806 and the second device 802 establish a communication connection with each gateway in the first gateway set 804; randomly selecting a fifth IP address from the first set of IP addresses, wherein the fifth IP address is an IP address of a fifth gateway 806 in the first set of gateways; sending the request received by the second device to the fifth gateway 806 according to the fifth IP address until the sixth reselection time; when the sixth reselection time is reached, randomly selecting a sixth IP address from a sixth group of IP addresses, wherein the sixth group of IP addresses is a group of IP addresses obtained by deleting a fifth IP address from the first group of IP addresses, and the sixth IP address is an IP address of a sixth gateway 808 in the first gateway set; after the sixth reselection time, the requests received by the second device are all sent to the sixth gateway 808 according to the sixth IP address, until the seventh reselection time, the fifth gateway and the first gateway 810 may be the same or different, and the sixth gateway and the first gateway 810 may be the same or different, in other words, the first device 806 and the second device 802 are devices randomly selected independently from each other.
The invention is further illustrated by the following specific examples:
fig. 9 is a schematic diagram of an optional gateway load balancing method according to an embodiment of the present invention, and as shown in fig. 9, a Ceph iscsi gateway load balancing method is proposed, which is mainly divided into the following parts: the iscsi gateway connection selection scheduling mechanism, the timing reselection mechanism and the iscsi gateway service interruption reconnection mechanism.
For the iscsi gateway connection selection scheduling mechanism, the following description is made:
the Iscsi gateway connection selection scheduling mechanism is to select a target gateway among a plurality of gateways to transmit when an Iscsi driver of a shader (corresponding to the aforementioned first device) component serves as a client of the gateway to transmit a request to the gateway. Fig. 9 is a schematic diagram of a plurality of circumferentially selecting Iscsi gateways, two Iscsi drivers select different Iscsi gateways for communication, and an Iscsi driver internal module includes the following parts:
management module (corresponding to the aforementioned management module): the management is used as the management control of iscsi driver, and the mirror image management is operated on the request reaching the driver layer, and the request operations comprise the increment, deletion, modification and check of the volume, the creation, deletion and rollback of the snapshot and the like.
scheduler module (corresponding to the scheduling module described above): the scheduler is used for selecting the iscsi gateways for connection, selecting a target gateway from a plurality of iscsi gateways (the number of the iscsi gateways is more than three shown in figure 9) through a selection mechanism, and sending subsequent requests to the target gateway
timer module (corresponding to the timing module described previously): the timer timing module is mainly used for timing and reselecting the iscsi gateway and is used for loading different requests in an iscsi driver.
A reconnect module (corresponding to the aforementioned reconnection module): recannect is a reconnection module, and initiates rescheduling to select a new target gateway after the previously selected target gateway stops service (for example, the gateway fails).
gateway client module (corresponding to the client described earlier): the gateway client serves as a client of the iscsi gateway, and after the scheduler module selects a target iscsi gateway, the gateway sends a request of the iscsi volume to the iscsi gateway through the network by using a restful format.
Fig. 10 is a schematic flowchart of an alternative gateway load balancing method according to an embodiment of the present invention, where the flowchart includes the following steps:
s1002, acquiring the ip of all iscsi gateways through the configuration of the ring, and loading the ip to the schduler module;
s1004, randomly sequencing the loaded ips of all iscsi gateways;
s1006, filtering the concurrency detection windows of the iscsi gateways ip after random sequencing, and selecting the number of the gateways with the size and the number of the concurrency windows;
s1008, concurrently initiating a ping request probe (corresponding to the aforementioned probe information) to the filtered gateway, and waiting for a response to the probe request (corresponding to the aforementioned probe response);
s1010, setting the target iscsi gateway as the gateway which returns response first when the ping detection is sent concurrently.
According to the embodiment, the schduler module selects the target iscsi gateway and sends the subsequent requests to the selected iscsi gateway, so that the technical effects that the cloud platform can stably operate when a large number of bare computer resources are managed, and the iscsi gateway can be horizontally and infinitely expanded due to the fact that request loads can be balanced are achieved.
For the timing reselection mechanism, the following is made:
fig. 11 is a schematic flowchart of an optional gateway load balancing method according to an embodiment of the present invention, and as shown in fig. 11, the timing reselection mechanism excludes a current gateway from reselecting a target gateway after an iscsi driver finishes selecting the target gateway to send a request for a period of time, and determines a reselection time based on different indicators, where the indicators may include but are not limited to a fixed time interval, the statistical time after the iscsi driver finishes selecting the target gateway, and reselection is performed after the fixed time interval is reached; indicators may also include, but are not limited to: and counting the number of the sent fixed requests after the iscsi driver selects the target gateway, and reselecting after the number of the fixed requests is reached. If at least one of the indexes is satisfied, the reselection mechanism is started, and the steps are as follows:
s1102, reading all ip of iscsi gateway from the circular configuration.
S1104, excluding the target iscsi gateway, and acquiring other iscsi gateway sets except the standard iscsi gateway in all the iscsi gateways;
s1106, randomly sequencing the loaded gateways ip in other iscsi gateway sets;
s1108, filtering the concurrency detection windows of the iscsi gateways ip after random sequencing, and selecting the number of the gateways with the size and the number of the concurrency windows;
s1110, concurrently initiating a ping request probe (corresponding to the aforementioned probe information) to the filtered gateways, and waiting for a response to the probe request (corresponding to the aforementioned probe response);
s1112 sets the new target iscsi gateway as the gateway that returns a response first when the ping probe is sent concurrently.
For the iscsi gateway service interruption reconnection mechanism, the following description is made:
fig. 12 is a flowchart illustrating an alternative gateway load balancing method according to an embodiment of the present invention, and as shown in fig. 12, after a target gateway is selected, subsequent requests are sent to the selected target gateway by the iscsi driver when a reselection indicator is not satisfied. When the target gateway service fails, the iscsi driver needs to enter a mechanism for reselecting the iscsi gateway similarly, and an available gateway is reselected to send a request, so that the gateway switching without the perceived failure is achieved.
The Iscsi gateway service failure reconnection mechanism comprises the following steps:
s1202, after a gateway client of an iscsi driver sends a request, if an iscsi gateway unavailable response is received, a reconnection mechanism is entered;
s1204, reading all iscsi gateways ip from the ring configuration;
s1206, removing the target iscsi gateway with the fault, and acquiring other iscsi gateway sets except the iscsi gateway with the fault in all the iscsi gateways;
s1208, randomly sequencing the loaded gateways ip in other iscsi gateway sets;
s1210, filtering the concurrency detection windows of the iscsi gateways ip after random sequencing, and selecting the number of the gateways with the size and the number of the concurrency windows;
s1212, the filtered gateways concurrently initiate ping request probes (corresponding to the aforementioned probe information) and wait for responses to the probe requests (corresponding to the aforementioned probe responses);
s1214, set the new target iscsi gateway as the gateway that returned the response first when the ping probe was sent concurrently.
By the embodiment, when the gateway fails, a new target gateway can be reselected, so that a subsequent iscsi driver request sends a new target gateway, and switching without sensing can be completed when the iscsi gateway fails.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
According to another aspect of the embodiment of the present invention, there is also provided a gateway load balancing apparatus for implementing the gateway load balancing method. As shown in fig. 13, the apparatus includes:
an obtaining module 1302, configured to obtain, on a first device, an IP address of each gateway in a first gateway set, to obtain a first group of IP addresses;
a selecting module 1304, configured to randomly select N IP addresses from the first group of IP addresses, where N is a natural number greater than 1, and the N IP addresses are IP addresses of N gateways in the first gateway set respectively;
a first sending module 1306, configured to send, on the first device, probe requests to the N gateways according to the N IP addresses, respectively;
a determining module 1308, configured to select, from the N gateways, the first gateway that first sends a probe response to the first device, and determine an IP address of the selected first gateway as the first IP address, where the probe response corresponds to the probe request;
a second sending module 1310, configured to send the requests received on the first device to the first gateway according to the first IP address until the first reselection time.
In an optional embodiment, the selection module includes: the sorting unit is used for randomly sorting the IP addresses in the first group of IP addresses to obtain a third group of IP addresses; and the selecting unit is used for selecting the IP addresses with the first N bits in the third group of IP addresses and determining the IP addresses as the N IP addresses.
In an optional embodiment, the apparatus is further configured to: the request received by the first device is sent to the first gateway according to the first IP address until a first reselection time, and a second IP address is randomly selected from a second group of IP addresses when the first reselection time is reached, where the second group of IP addresses is a group of IP addresses obtained by deleting the first IP address from the first group of IP addresses, and the second IP address is an IP address of a second gateway in the first gateway set; and after the first reselection time, sending the requests received by the first equipment to the second gateway according to the second IP address until the second reselection time.
In an optional embodiment, the apparatus is further configured to: when the second reselection time is reached, randomly selecting a third IP address from a fourth group of IP addresses, wherein the fourth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the third IP address is an IP address of a third gateway in the first gateway set; and after the second reselection time, sending the requests received by the first device to the third gateway according to the third IP address until the third reselection time.
In an optional embodiment, the apparatus is further configured to randomly select a second IP address from a second set of IP addresses upon reaching the first reselection time by: under the condition that the first reselection time is a predetermined time, randomly selecting the second IP address from the second group of IP addresses when the current time reaches the first reselection time, wherein the time interval between the first reselection time and the second reselection time is a preset time interval; or when the first reselection time is the time when the number of the sent requests reaches the predetermined number, determining that the first reselection time is reached and randomly selecting the second IP address from the second group of IP addresses when the number of the requests sent by the first device to the first gateway reaches the predetermined number after a fourth reselection time, where the sent requests are requests sent by the first device to the first gateway after the fourth reselection time, and the fourth reselection time is the previous reselection time of the first reselection time or an initial time before the first reselection time.
In an optional embodiment, the apparatus is further configured to: after the first reselection time and before the second reselection time, randomly selecting a fourth IP address from a fifth group of IP addresses under the condition that the second gateway is detected to have a fault, wherein the fifth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the fourth IP address is an IP address of a fourth gateway in the first gateway set; and before the second reselection time, sending the requests received by the first device to the fourth gateway according to the fourth IP address until the second reselection time.
In an optional embodiment, the apparatus is further configured to: after the first reselection time and before the second reselection time, randomly selecting a fourth IP address from a fifth group of IP addresses under the condition that the second gateway is detected to have a fault, wherein the fifth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the fourth IP address is an IP address of a fourth gateway in the first gateway set; and before a fifth reselection time, sending all the requests received by the first device to the fourth gateway according to the fourth IP address until the fifth reselection time, where the fifth reselection time is a reselection time next to the second reselection time, or the fifth reselection time is a reselection time set by reselection and is later than the second reselection time.
In an optional embodiment, in a case where the fifth reselection time is a reselection time next to the second reselection time, a time interval between the first reselection time and the second reselection time is equal to a time interval between the second reselection time and the fifth reselection time; or when the fifth reselection time is a reselection time set by reselection and is later than the second reselection time, the fifth reselection time is a time when the number of sent requests reaches a predetermined number, where the sent requests are requests sent to the fourth gateway by the first device after the second gateway is detected to have a fault.
In an optional embodiment, the apparatus is further configured to: acquiring an IP address of each gateway in the first gateway set on second equipment to obtain the first group of IP addresses, wherein the first equipment and the second equipment establish communication connection with each gateway in the first gateway set; randomly selecting a fifth IP address from the first group of IP addresses, wherein the fifth IP address is an IP address of a fifth gateway in the first set of gateways; sending the request received by the second device to the fifth gateway according to the fifth IP address until a sixth reselection moment; when the sixth reselection time is reached, randomly selecting a sixth IP address from a sixth group of IP addresses, wherein the sixth group of IP addresses is a group of IP addresses obtained by deleting the fifth IP address from the first group of IP addresses, and the sixth IP address is an IP address of a sixth gateway in the first gateway set; and after the sixth reselection time, sending the requests received by the second device to the sixth gateway according to the sixth IP address until the seventh reselection time.
According to another aspect of the embodiment of the present invention, there is also provided an electronic device for implementing the gateway load balancing method, where the electronic device may be the terminal device or the server shown in fig. 1. The present embodiment takes the electronic device as an example for explanation. As shown in fig. 14, the electronic device comprises a memory 1402 and a processor 1404, the memory 1402 having stored therein a computer program, the processor 1404 being arranged to execute the steps of any of the method embodiments described above by means of the computer program.
Optionally, in this embodiment, the electronic device may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, acquiring the IP address of each gateway in the first gateway set on the first device to obtain a first group of IP addresses;
s2, randomly selecting N IP addresses from the first group of IP addresses, wherein N is a natural number greater than 1, and the N IP addresses are respectively IP addresses of N gateways in the first gateway set;
s3, sending detection requests to N gateways on the first device according to N IP addresses;
s4, selecting a first gateway which firstly sends a detection response to the first equipment from the N gateways, and determining the IP address of the selected first gateway as a first IP address, wherein the detection response corresponds to the detection request;
and S5, sending the requests received by the first device to the first gateway according to the first IP address until the first reselection time.
Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 14 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 14 is a diagram illustrating a structure of the electronic device. For example, the electronics may also include more or fewer components (e.g., network interfaces, etc.) than shown in FIG. 14, or have a different configuration than shown in FIG. 14.
The memory 1402 may be configured to store software programs and modules, such as program instructions/modules corresponding to the gateway load balancing method and apparatus in the embodiments of the present invention, and the processor 1404 executes various functional applications and data processing by running the software programs and modules stored in the memory 1402, that is, implementing the gateway load balancing method described above. Memory 1402 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 1402 may further include memory located remotely from the processor 1404, which may be connected to a terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. The memory 1402 may be, but not limited to, specifically configured to store information such as an IP address and a data request of a gateway. As an example, as shown in fig. 14, the memory 1402 may include, but is not limited to, an obtaining module 1302, a selecting module 1304, a first sending module 1306, a determining module 1308, and a second sending module 1310 in the gateway load balancing apparatus. In addition, the gateway load balancing apparatus may further include, but is not limited to, other module units in the gateway load balancing apparatus, which is not described in detail in this example.
Optionally, the transmitting device 1406 is used for receiving or sending data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmission device 1406 includes a Network adapter (NIC) that can be connected to a router via a Network cable and other Network devices to communicate with the internet or a local area Network. In one example, the transmitting device 1406 is a Radio Frequency (RF) module, which is used to communicate with the internet by wireless means.
In addition, the electronic device further includes: a display 1408 for displaying the set of gateways; and a connection bus 1410 for connecting the respective module parts in the above-described electronic apparatus.
In other embodiments, the terminal device or the server may be a node in a distributed system, where the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting a plurality of nodes through a network communication. Nodes can form a Peer-To-Peer (P2P, Peer To Peer) network, and any type of computing device, such as a server, a terminal, and other electronic devices, can become a node in the blockchain system by joining the Peer-To-Peer network.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in the various alternative implementations of the aspects of acquiring, selecting and sending in the gateway load balancing process, wherein the computer program is configured to execute the steps in any one of the method embodiments described above when running.
Alternatively, in the present embodiment, the above-mentioned computer-readable storage medium may be configured to store a computer program for executing the steps of:
s1, acquiring the IP address of each gateway in the first gateway set on the first device to obtain a first group of IP addresses;
s2, randomly selecting N IP addresses from the first group of IP addresses, wherein N is a natural number greater than 1, and the N IP addresses are respectively IP addresses of N gateways in the first gateway set;
s3, sending detection requests to N gateways on the first device according to N IP addresses;
s4, selecting a first gateway which firstly sends a detection response to the first equipment from the N gateways, and determining the IP address of the selected first gateway as a first IP address, wherein the detection response corresponds to the detection request;
and S5, sending the requests received by the first device to the first gateway according to the first IP address until the first reselection time.
Alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, network devices, etc.) to execute all or part of the steps of the method according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A gateway load balancing method is characterized by comprising the following steps:
acquiring the IP address of each gateway in a first gateway set on first equipment to obtain a first group of IP addresses;
randomly selecting N IP addresses from the first group of IP addresses, wherein N is a natural number greater than 1, and the N IP addresses are the IP addresses of N gateways in the first gateway set respectively;
sending a detection request to the N gateways on the first device according to the N IP addresses respectively;
selecting a first gateway which firstly sends a detection response to the first device from the N gateways, and determining the IP address of the selected first gateway as a first IP address, wherein the detection response corresponds to the detection request;
sending the requests received by the first equipment to the first gateway according to the first IP address until a first reselection moment;
when the first reselection time is reached, randomly selecting a second IP address from a second group of IP addresses, wherein the second group of IP addresses are the group of IP addresses obtained by deleting the first IP address from the first group of IP addresses, and the second IP address is the IP address of a second gateway in the first gateway set;
after the first reselection time, sending the requests received by the first device to the second gateway according to the second IP address until a second reselection time, where the first reselection time is a predetermined time or a time when the number of sent requests reaches a predetermined number, and the second reselection time is a time when a time length for sending the requests received by the first device to the second gateway according to the second IP address is greater than a time threshold, or a time when the number of sent requests for sending the requests received by the first device to the second gateway according to the second IP address is greater than a request sending number threshold;
the method further comprises the following steps: after the first reselection time and before the second reselection time, randomly selecting a fourth IP address from a fifth group of IP addresses under the condition that the second gateway is detected to have a fault, wherein the fifth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the fourth IP address is an IP address of a fourth gateway in the first gateway set;
before a fifth reselection time, sending all the requests received by the first device to the fourth gateway according to the fourth IP address until the fifth reselection time, where the fifth reselection time is a reselection time next to the second reselection time, or the fifth reselection time is a reselection time set by reselection and is later than the second reselection time;
in the case that the fifth reselection time is a reselection time next to the second reselection time, a time interval between the first reselection time and the second reselection time is equal to a time interval between the second reselection time and the fifth reselection time; or
And when the fifth reselection time is a reselection time set by reselection and is later than the second reselection time, the fifth reselection time is a time when the number of sent requests reaches a predetermined number, wherein the sent requests are requests sent to the fourth gateway by the first device after the second gateway is detected to have a fault.
2. The method of claim 1, wherein randomly selecting N IP addresses from the first set of IP addresses comprises:
randomly sequencing the IP addresses in the first group of IP addresses to obtain a third group of IP addresses;
and selecting the IP addresses with the first N bits from the third group of IP addresses, and determining the IP addresses as the N IP addresses.
3. The method of claim 1, further comprising:
when the second reselection time is reached, randomly selecting a third IP address from a fourth group of IP addresses, wherein the fourth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the third IP address is an IP address of a third gateway in the first gateway set;
and after the second reselection time, sending the requests received by the first device to the third gateway according to the third IP address until the next reselection time.
4. The method of claim 1, wherein randomly selecting a second IP address from a second set of IP addresses upon reaching the first reselection time comprises:
under the condition that the first reselection time is a predetermined time, randomly selecting the second IP address from the second group of IP addresses when the current time reaches the first reselection time, wherein the time interval between the first reselection time and the second reselection time is a preset time interval; or
And when the first reselection time is the time when the number of the sent requests reaches a predetermined number, determining that the first reselection time is reached and randomly selecting the second IP address from the second group of IP addresses when the number of the requests sent by the first device to the first gateway reaches the predetermined number after a fourth reselection time, where the sent requests are requests sent by the first device to the first gateway after the fourth reselection time, and the fourth reselection time is the previous reselection time of the first reselection time or an initial time before the first reselection time.
5. The method according to any one of claims 1 and 3, further comprising:
acquiring an IP address of each gateway in the first gateway set on second equipment to obtain the first group of IP addresses, wherein the first equipment and the second equipment establish communication connection with each gateway in the first gateway set;
randomly selecting a fifth IP address from the first group of IP addresses, wherein the fifth IP address is an IP address of a fifth gateway in the first set of gateways;
sending the requests received by the second device to the fifth gateway according to the fifth IP address until a sixth reselection time, wherein the sixth reselection time is a predetermined time or a time when the number of the sent requests reaches a predetermined number;
when the sixth reselection time is reached, randomly selecting a sixth IP address from a sixth group of IP addresses, wherein the sixth group of IP addresses is a group of IP addresses obtained by deleting the fifth IP address from the first group of IP addresses, and the sixth IP address is an IP address of a sixth gateway in the first gateway set;
and after the sixth reselection time, sending the requests received by the second device to the sixth gateway according to the sixth IP address until a seventh reselection time, where the seventh reselection time is a time when a time length for sending the requests received by the second device to the sixth gateway according to the sixth IP address is greater than a time threshold, or a time when a number of requests sent by the second device to the sixth gateway according to the sixth IP address is greater than a request sending number threshold.
6. A gateway load balancing apparatus, comprising:
the acquisition module is used for acquiring the IP address of each gateway in the first gateway set on the first equipment to obtain a first group of IP addresses;
a selecting module, configured to randomly select N IP addresses from the first group of IP addresses, where N is a natural number greater than 1, and the N IP addresses are IP addresses of N gateways in the first gateway set respectively;
a first sending module, configured to send, on the first device, probe requests to the N gateways according to the N IP addresses, respectively;
a determining module, configured to select a first gateway that first sends a probe response to the first device from the N gateways, and determine an IP address of the selected first gateway as a first IP address, where the probe response corresponds to the probe request;
a second sending module, configured to send, to the first gateway, the request received on the first device according to the first IP address until a first reselection time;
the device is further configured to randomly select a second IP address from a second group of IP addresses when the first reselection time is reached, where the second group of IP addresses is a group of IP addresses obtained by deleting the first IP address from the first group of IP addresses, and the second IP address is an IP address of a second gateway in the first gateway set;
after the first reselection time, sending the requests received by the first device to the second gateway according to the second IP address until a second reselection time, where the first reselection time is a predetermined time or a time when the number of sent requests reaches a predetermined number, and the second reselection time is a time when a time length for sending the requests received by the first device to the second gateway according to the second IP address is greater than a time threshold, or a time when the number of sent requests for sending the requests received by the first device to the second gateway according to the second IP address is greater than a request sending number threshold;
the apparatus is further configured to: after the first reselection time and before the second reselection time, randomly selecting a fourth IP address from a fifth group of IP addresses under the condition that the second gateway is detected to have a fault, wherein the fifth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the fourth IP address is an IP address of a fourth gateway in the first gateway set;
before a fifth reselection time, sending all the requests received by the first device to the fourth gateway according to the fourth IP address until the fifth reselection time, where the fifth reselection time is a reselection time next to the second reselection time, or the fifth reselection time is a reselection time set by reselection and is later than the second reselection time;
in the case that the fifth reselection time is a reselection time next to the second reselection time, a time interval between the first reselection time and the second reselection time is equal to a time interval between the second reselection time and the fifth reselection time; or
And when the fifth reselection time is a reselection time set by reselection and is later than the second reselection time, the fifth reselection time is a time when the number of sent requests reaches a predetermined number, wherein the sent requests are requests sent to the fourth gateway by the first device after the second gateway is detected to have a fault.
7. The apparatus of claim 6, wherein the selection module comprises:
the sorting unit is used for randomly sorting the IP addresses in the first group of IP addresses to obtain a third group of IP addresses;
and the selecting unit is used for selecting the IP addresses with the first N bits in the third group of IP addresses and determining the IP addresses as the N IP addresses.
8. The apparatus of claim 6, wherein the apparatus is further configured to:
when the second reselection time is reached, randomly selecting a third IP address from a fourth group of IP addresses, wherein the fourth group of IP addresses is a group of IP addresses obtained by deleting the second IP address from the first group of IP addresses, and the third IP address is an IP address of a third gateway in the first gateway set;
and after the second reselection time, sending the requests received by the first device to the third gateway according to the third IP address until the next reselection time.
9. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a stored program, wherein the program is executed by a terminal device or a computer to perform the method of any one of claims 1 to 5.
10. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and wherein the processor is arranged to carry out the method of any one of claims 1 to 5 by executing the computer program.
CN202010983440.9A 2020-09-18 2020-09-18 Gateway load balancing method and device, storage medium and electronic equipment Active CN111935029B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010983440.9A CN111935029B (en) 2020-09-18 2020-09-18 Gateway load balancing method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010983440.9A CN111935029B (en) 2020-09-18 2020-09-18 Gateway load balancing method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN111935029A CN111935029A (en) 2020-11-13
CN111935029B true CN111935029B (en) 2021-06-08

Family

ID=73335127

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010983440.9A Active CN111935029B (en) 2020-09-18 2020-09-18 Gateway load balancing method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111935029B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112995312A (en) * 2021-02-20 2021-06-18 广东省安心加科技有限公司 Communication management method and communication management device based on cloud server of Internet of things

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101902400A (en) * 2010-07-21 2010-12-01 成都市华为赛门铁克科技有限公司 Gateway load balancing method, system and client device
CN103546590A (en) * 2013-10-18 2014-01-29 北京奇虎科技有限公司 Method and device for choosing DNS (domain name server)
CN105100152A (en) * 2014-05-14 2015-11-25 腾讯科技(深圳)有限公司 Application server selection method and system, and application client
CN105227276A (en) * 2015-09-30 2016-01-06 河南大学 A kind of peer-to-peer network data transmission method based on UDT
CN108063840A (en) * 2018-01-23 2018-05-22 广东欧珀移动通信有限公司 Access the method and Related product of network

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016219859A (en) * 2015-05-14 2016-12-22 富士通株式会社 Controller, controller control device, and control method
CN108243113B (en) * 2016-12-26 2020-06-16 深圳市中兴微电子技术有限公司 Random load balancing method and device
CN108449772A (en) * 2017-02-16 2018-08-24 网宿科技股份有限公司 Routing resource and system, node server based on multi-path transmission protocol
CN110417564B (en) * 2018-04-26 2022-09-02 北京东土军悦科技有限公司 Full-mesh link protection method, device, equipment and storage medium
CN110611701B (en) * 2018-08-21 2022-10-11 汇链丰(北京)科技有限公司 Parameter configuration and transaction processing method based on block chain
CN110233875A (en) * 2019-05-10 2019-09-13 厦门网宿有限公司 A kind of data processing method, object storage gateway pond and operation system
CN116366656A (en) * 2019-08-18 2023-06-30 朗德万斯公司 Method and system for forming a network of devices
CN111064781A (en) * 2019-12-10 2020-04-24 北京金山云网络技术有限公司 Multi-container cluster monitoring data acquisition method and device and electronic equipment
CN111258765B (en) * 2020-01-17 2023-08-22 深圳乐信软件技术有限公司 Load balancing method, device, computing equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101902400A (en) * 2010-07-21 2010-12-01 成都市华为赛门铁克科技有限公司 Gateway load balancing method, system and client device
CN103546590A (en) * 2013-10-18 2014-01-29 北京奇虎科技有限公司 Method and device for choosing DNS (domain name server)
CN105100152A (en) * 2014-05-14 2015-11-25 腾讯科技(深圳)有限公司 Application server selection method and system, and application client
CN105227276A (en) * 2015-09-30 2016-01-06 河南大学 A kind of peer-to-peer network data transmission method based on UDT
CN108063840A (en) * 2018-01-23 2018-05-22 广东欧珀移动通信有限公司 Access the method and Related product of network

Also Published As

Publication number Publication date
CN111935029A (en) 2020-11-13

Similar Documents

Publication Publication Date Title
US11940965B2 (en) Data migration method and apparatus
CN108040108B (en) Communication switching method, device, coordination server and readable storage medium
CN106302565B (en) Scheduling method and system of service server
CN108370341B (en) Resource allocation method, virtual network function manager and network element management system
CN110311831B (en) Container cloud-based system resource monitoring method and related equipment
CN113568884B (en) File management method and device, electronic equipment and storage medium
CN109547524B (en) User behavior storage method, device, equipment and storage medium based on Internet of things
CN111723024B (en) Data processing method, device and system, client server and storage server
CN107666493B (en) Database configuration method and equipment thereof
WO2016082078A1 (en) Path management system, device and method
CN110753091A (en) Cloud platform management method and device
CN111431730B (en) Service processing method, system, computer equipment and readable medium
CN103684926A (en) Method and device for testing network speed of local area network
CN109561054A (en) A kind of data transmission method, controller and access device
CN110740155B (en) Request processing method and device in distributed system
CN111935029B (en) Gateway load balancing method and device, storage medium and electronic equipment
CN113411363A (en) Uploading method of image file, related equipment and computer storage medium
US9544371B1 (en) Method to discover multiple paths to disk devices cluster wide
CN113810216A (en) Cluster fault switching method and device and electronic equipment
CN112363980A (en) Data processing method and device for distributed system
CN106550002B (en) paas cloud hosting system and method
CN115086194A (en) Data transmission method for cloud application, computing equipment and computer storage medium
CN103457771A (en) Method and device for HA virtual machine cluster management
JP6394212B2 (en) Information processing system, storage device, and program
CN111200512B (en) Network connection disaster recovery method, terminal equipment, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant