A gateway load balancing method, device, equipment and storage medium
By selecting a gateway based on gateway load information and setting gateway locks and cluster locks through the switch, the performance bottleneck of the NFS gateway when the master node fails is resolved, load balancing and high availability are achieved, and the performance and data consistency of the storage system are improved.
Patent Information
- Application Number
- CN202411754496.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2044-12-02
AI Technical Summary
In existing technologies, NFS gateways need to reconfigure resources when the master node fails, which limits read and write performance and makes the gateway node a bottleneck, failing to achieve effective load balancing and high availability.
The switch selects the gateway with the lowest load based on the load information of multiple gateways to forward data requests, and sets gateway locks and cluster locks in the gateway and cluster to ensure file system consistency. At the same time, it dynamically switches traffic to other gateways when a gateway fails.
It achieves load balancing and high availability of the NFS gateway, improves the performance and device utilization of the storage system, and ensures data consistency.
Smart Images

Figure CN119728693B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of data processing, in particular to a gateway load balancing method and device, equipment and storage medium. BACKGROUND
[0002] In a storage system of a cloud platform, an NFS gateway is used to provide file storage services for users, and the users write data into a cluster through the NFS gateway. In the prior art, the NFS gateway provides services for users in a master-slave node mode, and when the master node fails, the standby node is used to recover the services.
[0003] In the prior art, the master node and the standby node have different roles and different states, and when the master node and the standby node are switched, resources need to be reconfigured, and the reading and writing of data are easily limited by the performance of the gateway. SUMMARY
[0004] Embodiments of the present application provide a gateway load balancing method, device, equipment and storage medium, which aims to balance the load of the NFS gateway.
[0005] The first aspect of the embodiments of the present application provides a gateway load balancing method, which comprises:
[0006] The switch receives a data read-write request sent by a client;
[0007] The switch determines a gateway corresponding to the client according to load information of a plurality of gateways connected to the switch;
[0008] The switch sends the data read-write request to the gateway;
[0009] The gateway performs gateway lock verification on the data read-write request;
[0010] The gateway acquires a corresponding cluster lock from a target cluster if the gateway lock verification is passed;
[0011] The gateway executes an operation corresponding to the data read-write request if the cluster lock is acquired.
[0012] Optionally, the method further comprises:
[0013] The switch determines that the gateway fails if the heartbeat information sent by the gateway cannot be received;
[0014] The switch switches the traffic of the client to another gateway according to the load information of the remaining gateways if it is determined that the gateway fails.
[0015] Optionally, the switch determines the gateway corresponding to the client according to load information of a plurality of gateways connected to the switch, comprising: the switch acquires the load information of the plurality of gateways;
[0016] The switch determines a gateway with the lowest load flow among the plurality of gateways according to the load information;
[0017] The gateway with the lowest load flow is taken as the gateway corresponding to the client.
[0018] Optionally, the gateway performs gateway lock verification on the data read-write request, comprising:
[0019] The gateway acquires a client sequence id contained in the data read-write request;
[0020] The gateway compares the client sequence id with a server sequence id in the gateway;
[0021] The gateway determines that the gateway lock verification is passed when the server sequence id is equal to the client sequence id plus one;
[0022] The gateway determines whether the server sequence id is equal to the client sequence id when the server sequence id is not equal to the client sequence id plus one;
[0023] The gateway determines that the gateway lock verification is not passed when the server sequence id is not equal to the client sequence id.
[0024] Optionally, the method further comprises:
[0025] The gateway determines that the data read-write request is a retry request when the server sequence id is equal to the client sequence id;
[0026] The gateway returns the cached response data to the client.
[0027] Optionally, the gateway acquires a corresponding cluster lock from a target cluster when the gateway lock verification is passed, comprising:
[0028] The gateway determines a must lock and an expected lock corresponding to the data read-write request according to a request type corresponding to the data read-write request;
[0029] The gateway sends a cluster lock acquisition request to the target cluster to acquire the must lock and the expected lock;
[0030] The target cluster finds the must lock and the expected lock corresponding to the cluster lock acquisition request according to the cluster lock acquisition request;
[0031] The target cluster sends the must lock and the expect lock to the gateway in case that the must lock and the expect lock are found.
[0032] Optionally, the gateway executes an operation corresponding to the data read-write request in case that the cluster lock is acquired, including:
[0033] The gateway checks whether the cluster lock contains a must lock and an expect lock in case that the cluster lock is acquired.
[0034] The gateway sets a cache corresponding to the data read-write request in case that the cluster lock contains only the must lock.
[0035] The gateway executes an operation corresponding to the must lock and waits for the expect lock sent by the target cluster in case that the cache is set.
[0036] The gateway reads the cache in case that the expect lock is received.
[0037] The gateway executes an operation corresponding to the expect lock.
[0038] The second aspect of the embodiment of the application provides a gateway load balancing device, and the device includes:
[0039] A request receiving module is configured to receive, by a switch, a data read-write request sent by a client.
[0040] A gateway corresponding module is configured to determine, by the switch, a gateway corresponding to the client according to load information of a plurality of gateways connected to the switch.
[0041] A request forwarding module is configured to send, by the switch, the data read-write request to the gateway.
[0042] A gateway lock verification module is configured to perform, by the gateway, gateway lock verification on the data read-write request.
[0043] A cluster lock acquiring module is configured to acquire, by the gateway, a corresponding cluster lock from a target cluster in case that the gateway lock verification is passed.
[0044] An operation executing module is configured to execute, by the gateway, an operation corresponding to the data read-write request in case that the cluster lock is acquired.
[0045] Optionally, the device further includes:
[0046] A fault determining module is configured to determine, by the switch, that the gateway is faulty in case that the heartbeat information sent by the gateway cannot be received.
[0047] The traffic switching module is configured to switch the traffic of the client to another gateway according to load information of the remaining gateways in case that the gateway is determined to be faulty.
[0048] Optionally, the gateway determining module comprises a load information obtaining sub-module configured to obtain the load information of the plurality of gateways by the switch.
[0049] The traffic determining sub-module is configured to determine a gateway with the lowest load traffic from the plurality of gateways according to the load information.
[0050] The gateway determining sub-module is configured to determine the gateway with the lowest load traffic as the corresponding gateway of the client.
[0051] Optionally, the gateway lock verification module comprises:
[0052] The first gateway lock verification sub-module is configured to obtain a client sequence id contained in the data read / write request by the gateway.
[0053] The second gateway lock verification sub-module is configured to compare the client sequence id with a server sequence id in the gateway.
[0054] The third gateway lock verification sub-module is configured to determine that the gateway lock verification is passed in case that the server sequence id is equal to the client sequence id plus one.
[0055] The fourth gateway lock verification sub-module is configured to determine whether the server sequence id is equal to the client sequence id in case that the server sequence id is not equal to the client sequence id plus one.
[0056] The fifth gateway lock verification sub-module is configured to determine that the gateway lock verification is not passed in case that the server sequence id is not equal to the client sequence id.
[0057] Optionally, the gateway lock verification module further comprises:
[0058] The sixth gateway lock verification sub-module is configured to determine that the data read / write request is a retry request in case that the server sequence id is equal to the client sequence id.
[0059] The seventh gateway lock verification sub-module is configured to return the cached response data to the client by the gateway.
[0060] Optionally, the cluster lock obtaining module comprises:
[0061] The cluster lock determination submodule is configured to determine, by the gateway, a must lock and an expected lock corresponding to the data read-write request according to a request type of the data read-write request.
[0062] The cluster lock acquisition submodule is configured to send, by the gateway, a cluster lock acquisition request to the target cluster to acquire the must lock and the expected lock.
[0063] The cluster lock search submodule is configured to search, by the target cluster, the must lock and the expected lock corresponding to the cluster lock acquisition request.
[0064] The cluster lock sending submodule is configured to send, by the target cluster, the must lock and the expected lock to the gateway if the must lock and the expected lock are found.
[0065] Optionally, the operation execution module comprises:
[0066] The cluster lock confirmation submodule is configured to check, by the gateway, whether the cluster lock contains the must lock and the expected lock if the cluster lock is acquired.
[0067] The cache setting submodule is configured to set, by the gateway, a cache corresponding to the data read-write request if the must lock is contained in the cluster lock.
[0068] The first operation execution submodule is configured to execute, by the gateway, an operation corresponding to the must lock and wait for the expected lock sent by the target cluster if the cache is set.
[0069] The cache reading submodule is configured to read, by the gateway, the cache if the expected lock is received.
[0070] The second operation execution submodule is configured to execute, by the gateway, an operation corresponding to the expected lock.
[0071] The third aspect of the embodiment of the present application provides a readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement steps in the method of the first aspect of the present application.
[0072] The fourth aspect of the embodiment of the present application provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement steps of the method of the first aspect of the present application.
[0073] The gateway load balancing method provided in the application comprises the following steps: a switch receives a data read / write request sent by a client; the switch determines a gateway corresponding to the client according to load information of a plurality of gateways connected to the switch; the switch sends the data read / write request to the gateway; the gateway performs gateway lock verification on the data read / write request; the gateway acquires a corresponding cluster lock from a target cluster if the gateway lock verification is passed; and the gateway executes an operation corresponding to the data read / write request if the cluster lock is acquired.
[0074] In the method, the switch is connected to a plurality of gateways, and when receiving a request sent by a client, the request is sent to a corresponding gateway according to the load condition of each gateway in the plurality of gateways, so that the corresponding gateway is flexibly selected for the client according to the load condition of the gateway, the load of the plurality of gateways is balanced, and the gateway lock and the cluster lock are set to ensure the consistency of files in the cluster in the environment of the load balancing of the plurality of gateways. BRIEF DESCRIPTION OF DRAWINGS
[0075] In order to more clearly illustrate the technical solutions of the embodiments of the application, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the application. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without any creative labor.
[0076] Figure 1 Figure 1 is a schematic diagram of a traditional NFS gateway service;
[0077] Figure 2 is a flowchart of a gateway load balancing method according to an embodiment of the application;
[0078] Figure 3 is a schematic diagram of NFS gateway load balancing according to an embodiment of the application;
[0079] Figure 4 is a schematic diagram of a gateway lock according to an embodiment of the application;
[0080] Figure 5 is a schematic diagram of a gateway lock mechanism according to an embodiment of the application;
[0081] Figure 6 is a schematic diagram of a cluster lock mechanism according to an embodiment of the application;
[0082] Figure 7 is a schematic diagram of gateway failure according to an embodiment of the application;
[0083] Figure 8 is a schematic diagram of a gateway load balancing device according to an embodiment of the application;
[0084] Figure 9 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0085] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all of them. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0086] With the rapid development of cloud computing technology and the establishment of a new generation of cloud platform, the demand for file storage is increasing. In a cloud storage system, data storage is in the form of a cluster, and user file data is stored in the cluster in the form of a copy or erasure code. There are two ways for a user's virtual machine to read and write data. The first way is to read and write through a private protocol of the cluster. The cluster creates different file systems for different users and gives different users different permissions. This way has the advantages of no need for a gateway device and no performance loss of the gateway, but has the disadvantages of complex permission management, low security, and the need for a dedicated client. The second way is to set a gateway on the upper layer of the cluster, and the user writes data to the cluster through the NFS (Network File System) protocol via the gateway, and performs permission verification on the gateway. This way requires an additional gateway device and has a small amount of performance loss, but has the advantages of simple permission management, high security, no need for a dedicated client, simple use for the user, and simple read-write management for the user. Therefore, in file storage services, the NFS gateway mode is mostly used to provide file storage services to user virtual machines. Users can mount a file system through a standard NFS protocol. For example, the server provides a mounting path for the user: 100.126.0.100: / mnt / nfs / storage, and the user can execute the command: mount -t nfs 100.126.0.100: / mnt / nfs / storage / mnt / local / test on the client to write files to the server through the NFS protocol.
[0087] The traditional NFS server provides file storage service for users, and needs to use an IP address to provide the service. The client finds the corresponding server through the IP address. Once the NFS gateway node fails, the user will not be able to read and write data. Therefore, the NFS gateway is improved, and a "primary and backup VIP" mode is used to provide mounting for users. The principle is that once the primary node fails, the backup node will recover the resources, configure the VIP, and continue to provide the service. However, the primary and backup nodes have different roles and different states, and when the primary and backup nodes are switched, the resources need to be configured on the backup node. Moreover, the users mount based on the IP address, and the gateway node is easy to become a bottleneck point, thereby reaching the upper limit of the read-write performance.
[0088] Reference Figure 1 , Figure 1 is a schematic diagram of a traditional NFS gateway service, as shown in Figure 1 , the traditional NFS gateway node runs an NFS-SERVER process. The user virtual machine acts as an NFS-CLENT and executes a mounting command to mount the file system. The mounting command sends an RPC request, which is sent by the host to the switch. The switch forwards the request to the corresponding NFS gateway according to the IP address. In the traditional NFS gateway, once the primary node fails, the backup node will recover the resources, configure the VIP, and continue to provide the service. For example Figure 1 , the 100.126.1.1 node and the 100.126.1.2 node are primary and backup to each other. Initially, the primary node will configure the VIP: 100.86.2.2, and the user will use the NFS protocol to read and write the file system by mounting the 100.86.2.2 node. Once the primary node fails, the VIP: 100.86.2.2 will be automatically switched to the backup node. During the switching period, the client read-write IO is blocked and retries. After the switching is successful, the retry is also successful, and the IO is also restored. However, in this primary and backup mode, the VIP can only be configured on one node, and the gateway for user reading and writing is single, and the gateway node is easy to become a bottleneck point, thereby reaching the upper limit of the read-write performance.
[0089] Reference Figure 2 , Figure 2 is a flowchart of a gateway load balancing method according to an embodiment of the present application. As shown in Figure 2 , the method comprises the following steps:
[0090] S11: The switch receives a data read-write request sent by the client.
[0091] In this embodiment, the switch (leaf) is used for data transmission between the client (vm) and the NFS gateway. The data read-write request is a request sent by the switch when reading or writing a file in the storage cluster.
[0092] Reference Figure 3 ,Figure 3 is a schematic diagram of load balancing of an NFS gateway according to an embodiment of the present application, as shown in Figure 3 The switch receives a data read / write request sent by a client.
[0093] S12: The switch determines a gateway corresponding to the client according to load information of a plurality of gateways connected to the switch.
[0094] In this embodiment, a gateway is also called an inter-network connector or a protocol converter. The gateway realizes network interconnection at a network layer or above, is a complex network interconnection device, and is used only for network interconnection of two networks with different high-layer protocols. The NFS gateway is configured with an NFS protocol. The gateway can be used for wide area network interconnection or local area network interconnection. The gateway is a computer system or device that acts as a conversion responsibility. The load information of the gateway includes gateway load traffic size, gateway resource occupancy rate, and other gateway-related information.
[0095] In this embodiment, the switch finds a gateway with the smallest load according to load information of a plurality of gateways, and determines the gateway as a gateway corresponding to the client.
[0096] In this embodiment, the switch and the gateway are both configured with a BGP (Border Gateway Protocol) protocol, which is an autonomous system routing protocol running on TCP and is used for exchanging routing information between different autonomous systems (AS) on the Internet. The ECMP (Equal-Cost Multipath Routing) protocol is an equal-cost multipath routing protocol, which is mainly used for simultaneously using multiple links in a network environment to increase transmission bandwidth and implement load balancing. In the system initialization configuration phase, the same VIP (virtual IP) is configured in all NFS gateway nodes, the same AS number (Autonomous System Number) is configured in all gateway nodes, and the FRR process (protection process) is started. The NFS gateway sends a message to the switch to establish a connection. After the connection is successfully established, the keepalive message (heartbeat message used to notify the switch that the node is running normally) is continuously sent.
[0097] In this embodiment, the specific steps in which the switch determines the gateway corresponding to the client according to load information of a plurality of gateways connected to the switch include the following steps.
[0098] In this embodiment, the switch obtains the load information of the gateway from each gateway.
[0099] S12-2: The switch determines a gateway with the lowest load traffic from the plurality of gateways according to the load information.
[0100] In this embodiment, the switch determines a gateway with the lowest load traffic from the plurality of gateways according to the obtained load information.
[0101] S12-3: The gateway with the lowest load traffic is taken as the gateway corresponding to the client.
[0102] In this embodiment, the gateway with the lowest load traffic is taken as the gateway corresponding to the client, and the data read-write request sent by the client is forwarded to the gateway, and the client uses the gateway to write to the cluster subsequently.
[0103] S13: The switch sends the data read-write request to the gateway.
[0104] In this embodiment, as shown in Figure 3 , the switch sends the data read-write request to the gateway after receiving the data read-write request.
[0105] S14: The gateway performs gateway lock verification on the data read-write request.
[0106] In this embodiment, reference is made to Figure 4 , Figure 4 is a gateway lock diagram according to an embodiment of the present application, as shown in Figure 4 , when different clients mount the same file system, different clients may write to the cluster through the same NFS gateway, at this time, in order to ensure the consistency of the file system, the gateway lock is set in the NFS layer. The user system in the client calls the program corresponding to the gateway lock, and carries the gateway lock verification information when sending the request.
[0107] In this embodiment, the gateway performs gateway lock verification on the data read-write request after receiving the data read-write request, and the specific steps include:
[0108] S14-1: The gateway obtains the client sequence id contained in the data read-write request.
[0109] In this embodiment, the client sequence id is a sequence number stored in the client, and the initial value is 0, and the sequence number is incremented by 1 each time an operation that causes state change is initiated, for example, a data write operation.
[0110] In this embodiment, reference is made to Figure 5 , Figure 5 is a gateway lock mechanism diagram according to an embodiment of the present application, as shown in Figure 5As shown, when the client initiates an operation causing a state change of the storage cluster, the client sequence id is incremented by 1, and the corresponding data operation request is sent to the server, which is the gateway.
[0111] S14-2: The gateway compares the client sequence id with the server sequence id in the gateway.
[0112] In this embodiment, the server sequence id is a sequence number stored in the gateway, and the initial value is 1. After each execution of the client's operation, the sequence number is incremented by 1.
[0113] In this embodiment, as shown, Figure 5 The gateway compares the client sequence id with the server sequence id.
[0114] S14-3: The gateway determines that the gateway lock verification is passed when the server sequence id is equal to the client sequence id plus one.
[0115] In this embodiment, as shown, Figure 5 The gateway determines that the gateway lock verification is passed when the server sequence id is equal to the client sequence id plus one.
[0116] S14-4: The gateway determines whether the server sequence id is equal to the client sequence id when the server sequence id is not equal to the client sequence id plus one.
[0117] In this embodiment, as shown, Figure 5 The gateway determines whether the server sequence id is equal to the client sequence id when the server sequence id is not equal to the client sequence id plus one.
[0118] S14-5: The gateway determines that the gateway lock verification is not passed when the server sequence id is not equal to the client sequence id.
[0119] In this embodiment, as shown, Figure 5 The gateway determines that the gateway lock verification is not passed when the server sequence id is not equal to the client sequence id. At this time, the execution of the operation request sent by the client is rejected.
[0120] In this embodiment, the method further comprises:
[0121] S14-6: The gateway determines that the data read-write request is a retry request when the server sequence id is equal to the client sequence id.
[0122] In this embodiment, the retry request is the same request as the last time re-sent by the client in the case of previous request failure.
[0123] In this embodiment, as shown in Figure 5 The gateway determines that the data read-write request is a retry request when the service end sequence id is equal to the client sequence id.
[0124] S14-7: The gateway returns the cached response data to the client.
[0125] In this embodiment, the cached response data is the response data stored by the gateway after executing the operation. Since the corresponding cluster lock is not obtained, the operation may not be executed immediately. At this time, the data is cached first, and after the execution is completed, it is returned to the client.
[0126] In this embodiment, as shown in Figure 5 The gateway returns the cached response data to the client when it is determined that the data read-write request of the client is a retry request.
[0127] S15: The gateway obtains the corresponding cluster lock from the target cluster when the gateway lock verification is passed.
[0128] In this embodiment, the target cluster is the cluster accessed by the client. The cluster lock is the general term of various types of data locks in the cluster. When different clients mount the same file system, different clients may write to the cluster through different NFS gateways. At this time, multiple NFS gateway nodes write data to the cluster in parallel, and the cluster lock is needed to ensure the consistency of the file system. A very fine lock mechanism is implemented in the cluster metadata server to protect the state of various metadata. Different locks are used in the metadata server because different metadata have different behaviors in different situations.
[0129] As shown in the following table:
[0130] Table 1
[0131]
[0132] In this embodiment, the gateway obtains the corresponding cluster lock from the target cluster when the gateway lock verification is passed. The cluster lock includes mandatory locks and expected locks. The specific steps include:
[0133] S15-1: The gateway determines the mandatory lock and the expected lock corresponding to the data read-write request according to the request type corresponding to the data read-write request.
[0134] In this embodiment, the mandatory lock is a cluster lock that must be possessed to execute the current operation, and the expected lock is a cluster lock required for subsequent step operations.
[0135] In this embodiment, the gateway determines the must lock and the expected lock corresponding to the data read-write request according to the request type of the data read-write request. For example, when a user needs to cache and read the mtime file and the size file locally, the must lock needed is the Fs lock. If the user also needs to cache the mtime file and the size file locally and modify and read them, the Fx lock is also needed, that is, the expected lock is the Fx lock.
[0136] S15-2: The gateway sends a cluster lock acquisition request to the target cluster to acquire the must lock and the expected lock.
[0137] In this embodiment, reference is made to Figure 6 , Figure 6 is a schematic diagram of a cluster lock mechanism according to an embodiment of the present application, as shown in Figure 6 , the NFS-SERVER acts as a server of the NFS-CLIENT and also acts as a client of the cluster. When multiple cluster clients perform operations such as open, read, write, etc., the must lock and the expected lock need to be acquired first.
[0138] In this embodiment, the client (gateway) first determines the must lock and the expected lock needed, sends a request to the metadata service of the target cluster, and waits for the inode to return data to acquire the must lock and the expected lock.
[0139] S15-3: The target cluster finds the must lock and the expected lock corresponding to the cluster lock acquisition request.
[0140] In this embodiment, as shown in Figure 6 , after the target cluster receives the cluster lock acquisition request, the request is processed, and all cluster locks are traversed to find the must lock and the expected lock.
[0141] S15-4: The target cluster sends the must lock and the expected lock to the gateway when the must lock and the expected lock are found.
[0142] In this embodiment, as shown in Figure 6 , the target cluster sends the must lock and the expected lock to the gateway when the must lock and the expected lock are found.
[0143] In this embodiment, as shown in Figure 6 , if the target cluster does not find the corresponding expected lock, all clients that have the lock are checked to revoke, that is, the cluster lock is taken back from the client that has acquired the lock, and the client at this time is the gateway. The taken-back lock is granted to the client (gateway) that sends the request.
[0144] S16: The gateway executes the operation corresponding to the data read-write request in the case of obtaining the cluster lock.
[0145] In this embodiment, the gateway executes the operation corresponding to the data read-write request in the case of obtaining the cluster lock, and the specific steps include:
[0146] S16-1: The gateway checks whether the cluster lock contains the must lock and the expected lock in the case of obtaining the cluster lock.
[0147] In this embodiment, as shown in the figure, Figure 6 the gateway checks whether the cluster lock contains the must lock and the expected lock in the case of obtaining the cluster lock. The cluster lock returned in the metadata service of the cluster may only include the must lock, and the expected lock has not been released yet, which may be sent subsequently.
[0148] S16-2: The gateway sets the cache corresponding to the data read-write request in the case of the cluster lock containing only the must lock.
[0149] In this embodiment, as shown in the figure, Figure 6 the gateway sets the cache corresponding to the data read-write request in the case of the cluster lock containing only the must lock, which is used to temporarily store the response data corresponding to the data read-write request.
[0150] S16-3: The gateway executes the operation corresponding to the must lock and waits for the expected lock sent by the target cluster in the case of the cache being set.
[0151] In this embodiment, as shown in the figure, Figure 6 the gateway executes the operation corresponding to the must lock and waits for the expected lock sent by the target cluster in the case of the cache being set.
[0152] S16-4: The gateway reads the cache in the case of receiving the expected lock.
[0153] In this embodiment, as shown in the figure, Figure 6 the gateway reads the data in the cache in the case of receiving the expected lock.
[0154] S16-5: The gateway executes the operation corresponding to the expected lock.
[0155] In this embodiment, as shown in the figure, Figure 7 the gateway executes the operation corresponding to the expected lock in the case of the cache being read, and returns the data in the cache read and the data after executing the operation corresponding to the expected lock to the user terminal issuing the data read-write request after all operations are executed.
[0156] For example, the NFS-SERVER (gateway) determines that the must lock is Fs and the expect lock is Fx, sends a request to the target cluster to acquire the two locks, the target cluster returns the must lock Fs first, the gateway sets a cache, uses the Fs lock first, extracts the corresponding file in the cluster and adds the file in the cache, waits for the Fx lock, the target cluster sends the Fx lock to the gateway after retrieving the Fx lock from another gateway, the gateway extracts the corresponding file in the target cluster through the Fx lock, takes out the file in the cache, and sends the taken-out file to the NFS-CLIENT end.
[0157] In the embodiment, the consistency of the cluster file is ensured by setting the gateway lock and the cluster lock.
[0158] In another embodiment of the application, the method further comprises:
[0159] S21: The switch determines that the gateway fails in a case where the heartbeat information sent by the gateway cannot be received.
[0160] In the embodiment, reference is made to Figure 7 , Figure 7 is a gateway failure schematic diagram provided by an embodiment of the application, as shown in Figure 8 The switch leaf continuously receives the keepalive packet (heartbeat information) sent from the NFS gateway, monitors each module therein, when a device in the NFS gateway, for example, a network card, fails, the NFS gateway stops sending the packet, at this time, the switch cannot receive the heartbeat information sent by the gateway, and determines that the gateway fails.
[0161] S22: The switch switches the traffic of the client to another gateway according to the load information of the remaining gateway in a case where the gateway is determined to fail.
[0162] In the embodiment, the switch acquires the load information of the remaining gateway in a case where the gateway is determined to fail, determines a gateway with the minimum load according to the load information of the remaining gateway, and switches the traffic of the client to the gateway.
[0163] For example, the leaf configures gateway node IP and performs load balancing through the ECMP protocol, which means that all gateways are master nodes and the roles are completely equal. When a user mounts a file system, the user executes a command: mount -t nfs 100.86.1.1: / mnt / nfs / storage / mnt / local / test, so as to establish a connection with the NFS-SERVER through the NFS protocol. When a request is sent to the leaf, the leaf selects a gateway according to the load of each gateway and establishes a connection. Once the connection is established, subsequent NFS clients will always read and write data through the gateway node. Once a node fails, the leaf cannot receive a BGP heartbeat, and automatically switches traffic to another gateway node. During the switching, the client read-write IO is blocked within 5 seconds, and a retry is performed. After the switching is successful, the retry is also successful, and the IO is also recovered within 5 seconds.
[0164] In the embodiment, when a certain gateway fails, the switch can switch the traffic of the client to another gateway, so as to ensure service interruption and realize high availability of the gateway.
[0165] In another embodiment of the present application, the file system service in the target cluster is provided to the user in the form of a cloud service, and the user can manage the file system.
[0166] In the embodiment, the management type and the management method of the file system that can be performed by the user are shown in the following table:
[0167] Table 2
[0168]
[0169] The characteristics of the gateway are shown in the following table:
[0170] Table 3
[0171]
[0172] In the above embodiment of the present application, the NFS gateway adopts the BGP+ECMP protocol to realize the high availability and load balancing method, so as to strengthen the performance of the storage system. When the gateway fails, the gateway can be switched according to the load, so as to improve the business execution efficiency and improve the device utilization. In addition, by setting the gateway lock and the cluster lock, the data consistency in the storage system is ensured while realizing the high availability and load balancing of the NFS gateway.
[0173] Based on the same inventive concept, an embodiment of the present application provides a gateway load balancing device. Referring to Figure 8 , Figure 8 FIG. 8 is a schematic diagram of a gateway load balancing device 800 according to an embodiment of the present application. As shown in FIG. 8, the gateway load balancing device 800 includes a gateway 810, a switch 820, and a cluster 830. Figure 5As shown, the device comprises:
[0174] The request receiving module 801 is configured to receive a data read / write request sent by a client by the switch;
[0175] The gateway corresponding module 802 is configured to determine a gateway corresponding to the client according to load information of a plurality of gateways connected to the switch by the switch;
[0176] The request forwarding module 803 is configured to send the data read / write request to the gateway by the switch;
[0177] The gateway lock verification module 804 is configured to perform gateway lock verification on the data read / write request by the gateway;
[0178] The cluster lock obtaining module 805 is configured to obtain a corresponding cluster lock from a target cluster in the case where the gateway lock verification is passed by the gateway;
[0179] The operation executing module 806 is configured to execute an operation corresponding to the data read / write request in the case where the cluster lock is obtained by the gateway.
[0180] Optionally, the device further comprises:
[0181] The fault determining module is configured to determine that the gateway is faulty in the case where the heartbeat information sent by the gateway cannot be received by the switch;
[0182] The traffic switching module is configured to switch traffic of the client to another gateway according to load information of the remaining gateways in the case where it is determined that the gateway is faulty by the switch.
[0183] Optionally, the gateway determining module comprises a load information obtaining submodule configured to obtain the load information of a plurality of the gateways by the switch;
[0184] The traffic determining submodule is configured to determine a gateway with the lowest load traffic in a plurality of the gateways according to the load information by the switch;
[0185] The gateway determining submodule is configured to determine the gateway with the lowest load traffic as the gateway corresponding to the client.
[0186] Optionally, the gateway lock verification module comprises:
[0187] The first gateway lock verification submodule is configured to obtain a client sequence id contained in the data read / write request by the gateway;
[0188] The second gateway lock verification submodule is configured to compare the client sequence id with a server sequence id in the gateway by the gateway;
[0189] The third gateway lock verification submodule is configured to determine that the gateway lock verification is passed when the service end sequence id is equal to the client sequence id plus one.
[0190] The fourth gateway lock verification submodule is configured to determine whether the service end sequence id is equal to the client sequence id when the service end sequence id is not equal to the client sequence id plus one.
[0191] The fifth gateway lock verification submodule is configured to determine that the gateway lock verification is not passed when the service end sequence id is not equal to the client sequence id.
[0192] Optionally, the gateway lock verification module further comprises:
[0193] The sixth gateway lock verification submodule is configured to determine that the data read-write request is a retry request when the service end sequence id is equal to the client sequence id.
[0194] The seventh gateway lock verification submodule is configured to return the cached response data to the client by the gateway.
[0195] Optionally, the cluster lock acquisition module comprises:
[0196] The cluster lock determination submodule is configured to determine the necessary lock and the expected lock corresponding to the data read-write request according to the request type corresponding to the data read-write request.
[0197] The cluster lock acquisition submodule is configured to send a cluster lock acquisition request to the target cluster to acquire the necessary lock and the expected lock.
[0198] The cluster lock finding submodule is configured to find the necessary lock and the expected lock corresponding to the cluster lock acquisition request according to the target cluster.
[0199] The cluster lock sending submodule is configured to send the necessary lock and the expected lock to the gateway when the necessary lock and the expected lock are found.
[0200] Optionally, the operation execution module comprises:
[0201] The cluster lock confirmation submodule is configured to check whether the cluster lock contains the necessary lock and the expected lock when the cluster lock is acquired.
[0202] The cache setting submodule is configured to set the cache corresponding to the data read-write request when the cluster lock contains only the necessary lock.
[0203] a first operation execution submodule, configured to execute the operation corresponding to the must lock and wait for the expected lock sent by the target cluster if the cache is set up;
[0204] a cache reading submodule, configured to read the cache if the expected lock is received;
[0205] a second operation execution submodule, configured to execute the operation corresponding to the expected lock.
[0206] Based on the same inventive concept, another embodiment of the present application provides a readable storage medium, which stores a computer program, and the program is executed by a processor to implement the steps in the gateway load balancing method according to any one of the above embodiments of the present application.
[0207] Based on the same inventive concept, another embodiment of the present application provides an electronic device, Figure 1 is a schematic diagram of an electronic device 500 according to an embodiment of the present application, which comprises a memory 501, a processor 502, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the steps in the gateway load balancing method according to any one of the above embodiments of the present application.
[0208] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts are described in the part of the method embodiment.
[0209] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same and similar parts between the embodiments can be referred to each other.
[0210] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a device, or a computer program product. Therefore, the embodiments of the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0211] The embodiments of the present application are described with reference to the flowchart illustrations and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present application. It is understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal devices to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal devices, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0212] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal devices to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0213] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal devices, such that a series of operational steps are performed on the computer or other programmable terminal devices to produce a computer implemented process so that the instructions executed on the computer or other programmable terminal devices provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. one or more functions specified in the flowchart illustrations and / or block diagrams.
[0214] Although preferred embodiments of the present application have been described, those skilled in the art will be able to make additional modifications and variations to these embodiments once they have the benefit of the foregoing description. Accordingly, the appended claims are intended to cover all modifications and variations of the preferred embodiments that fall within the scope of the present application.
[0215] Finally, it is to be understood that the phraseology or terminology such as "first" and "second" etc. used herein is merely intended to differentiate one entity or operation from another entity or operation, without necessarily requiring or implying any actual such relationship or order between such entities or operations. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0216] The gateway load balancing method, device, equipment and storage medium provided by the present application are described in detail above, and the principles and implementation manners of the present application are described by applying specific examples. The above description of the embodiments is only used to help understand the method of the present application and its core idea; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manner and application range will be changed, and the above description of the present application should not be understood as a limitation.
Claims
1. A gateway load balancing method, characterized in that, The method includes: The switch receives data read / write requests sent by clients; The switch determines the gateway corresponding to the client based on the load information of multiple gateways connected to the switch. The switch sends the data read / write request to the gateway; The gateway performs gateway lock verification on the data read / write request; If the gateway lock verification is successful, the gateway acquires the corresponding cluster lock from the target cluster. When the gateway acquires the cluster lock, it executes the operation corresponding to the data read / write request. The gateway performs gateway lock verification on the data read / write request, including: The gateway obtains the client sequence ID contained in the data read / write request; The gateway compares the client sequence ID with the server sequence ID in the gateway; The gateway determines that the gateway lock verification is successful if the server-side sequence ID is equal to the client-side sequence ID plus one. If the server sequence ID is not equal to the client sequence ID plus one, the gateway determines whether the server sequence ID is equal to the client sequence ID. If the server-side sequence ID is not equal to the client-side sequence ID, the gateway determines that the gateway lock verification has failed.
2. The gateway load balancing method according to claim 1, characterized in that, The method further includes: If the switch cannot receive heartbeat information sent by the gateway, it determines that the gateway has malfunctioned. If the switch determines that the gateway has failed, it will switch the client's traffic to another gateway based on the load information of the remaining gateways.
3. The gateway load balancing method according to claim 1, characterized in that, The switch determines the gateway corresponding to the client based on the load information of multiple gateways connected to the switch, including: The switch acquires the load information of multiple gateways; The switch determines the gateway with the lowest load traffic among the multiple gateways based on the load information; The gateway with the lowest load traffic is selected as the gateway corresponding to the client.
4. The gateway load balancing method according to claim 1, characterized in that, The method further includes: If the server sequence ID is equal to the client sequence ID, the gateway determines that the data read / write request is a retry request. The gateway returns the cached response data to the client.
5. The gateway load balancing method according to claim 1, characterized in that, If the gateway lock verification is successful, the gateway acquires the corresponding cluster lock from the target cluster, including: The gateway determines the required lock and the desired lock corresponding to the data read / write request based on the request type corresponding to the data read / write request. The gateway sends a cluster lock acquisition request to the target cluster in order to acquire the required lock and the desired lock; The target cluster searches for the required lock and the desired lock based on the cluster lock acquisition request. If the target cluster finds the required lock and the desired lock, it sends the required lock and the desired lock to the gateway.
6. The gateway load balancing method according to claim 1, characterized in that, When the gateway acquires the cluster lock, it executes the operation corresponding to the data read / write request, including: When the gateway acquires the cluster lock, it checks whether the cluster lock contains both required locks and desired locks. If the gateway contains only the required locks in the cluster locks, it sets the cache corresponding to the data read / write request. Once the cache is set up, the gateway executes the operation corresponding to the required lock and waits for the desired lock sent by the target cluster. Upon receiving the desired lock, the gateway reads the cache; The gateway performs the operation corresponding to the desired lock.
7. A gateway load balancing device, characterized in that, The device includes: The first receiving module is used by the switch to receive data read / write requests sent by the client. The gateway correspondence module is used by the switch to determine the gateway corresponding to the client based on the load information of multiple gateways connected to the switch. The first sending module is used for the switch to send the data read / write request to the gateway; The gateway lock verification module is used for the gateway to perform gateway lock verification on the data read / write request; The cluster lock acquisition module is used by the gateway to acquire the corresponding cluster lock from the target cluster when the gateway lock verification is successful. An operation execution module is used by the gateway to execute the operation corresponding to the data read / write request when the gateway acquires the cluster lock; The gateway lock verification module includes: The first gateway lock verification submodule is used for the gateway to obtain the client sequence ID contained in the data read / write request; The second gateway lock verification submodule is used by the gateway to compare the client sequence ID with the server sequence ID in the gateway; The third gateway lock verification submodule is used by the gateway to determine that the gateway lock verification is successful when the server-side sequence ID is equal to the client-side sequence ID plus one. The fourth gateway lock verification submodule is used by the gateway to determine whether the server sequence ID is equal to the client sequence ID when the server sequence ID is not equal to the client sequence ID plus one. The fifth gateway lock verification submodule is used by the gateway to determine that the gateway lock verification has failed when the server-side sequence ID is not equal to the client-side sequence ID.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Load balancing method and device
CN107566466A