Gateway load balancing method, device, equipment and storage medium
The switch forwards the client's data read and write requests based on the load information of multiple NFS gateways, and with the support of the gateway and cluster lock mechanism, the load balancing and high availability of the NFS gateway are realized, solving the problems of gateway performance limitations and load imbalance in the prior art.
Patent Information
- Application Number
- CN202411754496.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-02
AI Technical Summary
Existing NFS gateways need to reconfigure resources when switching master and backup nodes. Data reading and writing are easily restricted by gateway performance and are difficult to achieve load balancing.
The switch receives the client's data read and write requests, and determines the corresponding gateways of the client based on the load information of multiple gateways, so as to realize load balancing forwarding of data requests. The gateway performs gateway lock verification upon receiving the request, and after passing the verification, acquires the cluster lock from the target cluster to perform data read and write operations.
The load balancing of the NFS gateway is realized, which avoids single point of bottlenecks, improves data read and write performance, and ensures the consistency of the file system through gateway locks and cluster locks.
Smart Images

Figure CN119728693A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data processing, and specifically, to a gateway load balancing method, apparatus, device and storage medium. Background Art
[0002] In the storage system of the cloud platform, the NFS gateway provides file storage services to users, and users write data to the cluster through the NFS gateway. In the prior art, the NFS gateway provides services to users in the form of master and backup nodes, and restores services through the backup node when the master node fails.
[0003] In the prior art, the active and standby nodes have different roles and different states. When the active and standby nodes switch, resources need to be reconfigured, and the reading and writing of data is easily limited by the performance of the gateway. Summary of the invention
[0004] The embodiments of the present application provide a gateway load balancing method, apparatus, device and storage medium, aiming to achieve load balancing of an NFS gateway.
[0005] A first aspect of an embodiment of the present application provides a gateway load balancing method, the method comprising: The switch receives the data read and write request sent by the client; The switch determines the gateway corresponding to the client according to load information of multiple gateways connected to the switch; The switch sends the data read and write request to the gateway; The gateway performs gateway lock verification on the data read and write request; When the gateway lock is verified, the gateway obtains the corresponding cluster lock from the target cluster; When the gateway obtains the cluster lock, it executes the operation corresponding to the data read and write request.
[0006] Optionally, the method further comprises: The switch determines that the gateway fails when failing to receive the heartbeat information sent by the gateway; When determining that the gateway fails, the switch switches the traffic of the client to another gateway according to the load information of the remaining gateways.
[0007] Optionally, the switch determines the gateway corresponding to the client according to load information of multiple gateways connected to the switch, including: the switch obtains the load information of the multiple gateways; The switch determines, according to the load information, a gateway having the lowest load flow among the plurality of gateways; The gateway with the lowest load flow is used as the gateway corresponding to the client.
[0008] Optionally, the gateway performs gateway lock verification on the data read and write request, including: The gateway obtains the client serial ID contained in the data read / write request; The gateway compares the client serial ID with the server serial ID in the gateway; The gateway determines that the gateway lock verification is passed when the server serial ID is equal to the client serial ID plus one; The gateway determines, if the server sequence ID is not equal to the client sequence ID plus one, whether the server sequence ID is equal to the client sequence ID; When the server serial ID is not equal to the client serial ID, the gateway determines that the gateway lock verification fails.
[0009] Optionally, the method further comprises: The gateway determines, when the server sequence ID is equal to the client sequence ID, that the data read and write request is a retry request; The gateway returns the cached response data to the client.
[0010] Optionally, when the gateway lock verification is passed, the gateway obtains a corresponding cluster lock from the target cluster, including: The gateway determines a required lock and an expected lock corresponding to the data read / write request according to a request type corresponding to the data read / write request; The gateway sends a cluster lock acquisition request to the target cluster to acquire the required lock and the desired lock; The target cluster searches for the corresponding required lock and the desired lock according to the cluster lock acquisition request; When the target cluster finds the required lock and the desired lock, the target cluster sends the required lock and the desired lock to the gateway.
[0011] Optionally, when the gateway obtains the cluster lock, the gateway executes an operation corresponding to the data read / write request, including: When the gateway obtains the cluster lock, checking whether the cluster lock includes a required lock and a desired lock; When the cluster lock includes only the required lock, the gateway sets a cache corresponding to the data read and write request; When the cache is set, the gateway performs the operation corresponding to the required lock and waits for the desired lock sent by the target cluster; The gateway, upon receiving the desired lock, reads the cache; The gateway executes the operation corresponding to the desired lock.
[0012] A second aspect of an embodiment of the present application provides a gateway load balancing device, the device comprising: Request receiving module, used for the switch to receive data read and write requests sent by the client; A gateway corresponding module, used for the switch to determine the gateway corresponding to the client according to the load information of multiple gateways connected to the switch; A request forwarding module, used for the switch to send the data read and write request to the gateway; A gateway lock verification module, used for the gateway to perform gateway lock verification on the data read and write request; A cluster lock acquisition module, used for the gateway to acquire the corresponding cluster lock from the target cluster when the gateway lock verification passes; The operation execution module is used for the gateway to execute the operation corresponding to the data read and write request when the gateway obtains the cluster lock.
[0013] Optionally, the device further comprises: A fault determination module, configured to determine that the gateway fails when the switch cannot receive the heartbeat information sent by the gateway; The traffic switching module is used for switching the traffic of the client to another gateway according to the load information of the remaining gateways when the switch determines that the gateway fails.
[0014] Optionally, the gateway determination module includes: a load information acquisition submodule, which is used for the switch to acquire the load information of the plurality of gateways; A flow determination submodule, configured for the switch to determine a gateway having the lowest load flow among the plurality of gateways according to the load information; The gateway determination submodule is used to select the gateway with the lowest load flow as the gateway corresponding to the client.
[0015] Optionally, the gateway lock verification module includes: A first gateway lock verification submodule, used for the gateway to obtain the client serial ID contained in the data read and write request; A second gateway lock verification submodule, used for the gateway to compare the client serial ID with the server serial ID in the gateway; A third gateway lock verification submodule, used for the gateway to determine that the gateway lock verification is passed when the server serial ID is equal to the client serial ID plus one; A fourth gateway lock verification submodule, used for 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 for the gateway to determine that the gateway lock verification fails when the server serial ID is not equal to the client serial ID.
[0016] Optionally, the gateway lock verification module further includes: A sixth gateway lock verification submodule, used for the gateway to determine that the data read and write request is a retry request when the server sequence ID is equal to the client sequence ID; The seventh gateway lock verification submodule is used for the gateway to return the cached response data to the client.
[0017] Optionally, the cluster lock acquisition module includes: A cluster lock determination submodule, used for the gateway to determine a required lock and a desired lock corresponding to the data read and write request according to the request type corresponding to the data read and write request; A cluster lock acquisition submodule, configured for the gateway to send a cluster lock acquisition request to the target cluster to acquire the required lock and the desired lock; A cluster lock search submodule, configured for the target cluster to search for the corresponding required lock and the desired lock according to the cluster lock acquisition request; The cluster lock sending submodule is used for the target cluster to send the required lock and the expected lock to the gateway when the required lock and the expected lock are found.
[0018] Optionally, the operation execution module includes: A cluster lock confirmation submodule, used for the gateway to check whether the cluster lock contains a required lock and an expected lock when the cluster lock is acquired; A cache setting submodule, used for setting a cache corresponding to the data read and write request when the gateway only includes the required lock in the cluster lock; A first operation execution submodule, configured for the gateway to execute the operation corresponding to the required lock when the cache is set, and wait for the desired lock sent by the target cluster; A cache reading submodule, configured for the gateway to read the cache when receiving the desired lock; The second operation execution submodule is used for the gateway to execute the operation corresponding to the desired lock.
[0019] A third aspect of an embodiment of the present application provides a readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the method described in the first aspect of the present application are implemented.
[0020] A fourth aspect of an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method described in the first aspect of the present application are implemented.
[0021] Using the gateway load balancing method provided in the present application, the switch receives a data read and write request sent by a client; 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 and write request to the gateway; the gateway performs gateway lock verification on the data read and write request; when the gateway lock verification passes, the gateway obtains the corresponding cluster lock from the target cluster; when the gateway obtains the cluster lock, it executes the operation corresponding to the data read and write request.
[0022] In this method, the switch is connected to multiple gateways. When receiving a request sent by a client, the switch sends the request to the corresponding gateway according to the load condition of each gateway in the multiple gateways, thereby realizing flexible selection of the corresponding gateway for the client according to the gateway load condition, realizing multi-gateway load balancing, and setting a gateway lock and a cluster lock to ensure the consistency of files in the cluster in an environment of multi-gateway load balancing. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0024] Figure 1 Figure 1 This is a schematic diagram of the traditional NFS gateway service; Figure 2 is a flow chart of a gateway load balancing method proposed in an embodiment of the present application; Figure 3 This is a schematic diagram of NFS gateway load balancing proposed in an embodiment of the present application; Figure 4 This is a schematic diagram of a gateway lock proposed in an embodiment of the present application; Figure 5 is a schematic diagram of a gateway lock mechanism proposed in an embodiment of the present application; Figure 6is a schematic diagram of a cluster lock mechanism proposed in an embodiment of the present application; Figure 7 This is a schematic diagram of a gateway failure proposed in an embodiment of the present application; Figure 8 is a schematic diagram of a gateway load balancing device proposed in an embodiment of the present application; Fig. 9 It is a schematic diagram of an electronic device proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] With the rapid development of cloud computing technology and the establishment of a new generation of cloud platforms, the demand for file storage is increasing. In cloud storage systems, data storage is organized in clusters, and user file data is stored in the cluster in the form of copies or erasure codes. There are two ways for a user's virtual machine to read and write data. The first way is to read and write through the cluster's private protocol. The cluster creates different file systems for different users and grants different user permissions. The advantages of this method are that there is no need for gateway devices and no gateway performance loss, but the disadvantages are that permission management is complex, security is not high, and a dedicated client is required. The second way is to set up a gateway on the upper layer of the cluster, and the user writes data to the cluster through the gateway through the NFS (Network File System) protocol, and performs permission verification on the gateway. This method requires additional gateway devices and has a small amount of performance loss, but the permission management is simple, security is high, no dedicated client is required, and the user is simple to use and user read and write management is simple. Therefore, in file storage services, NFS gateways are mostly used to provide file storage services to user virtual machines. Users can mount file systems through the standard NFS protocol. For example, the server provides the user with the mount path: 100.126.0.100: / mnt / nfs / storage. The user can execute the command on the client: mount -t nfs 100.126.0.100: / mnt / nfs / storage / mnt / local / test to write the file to the server through the NFS protocol.
[0027] Traditional NFS servers provide file storage services to users and need to use IP addresses to provide services. Clients use IP addresses to find the corresponding servers. Once the NFS gateway node fails, users will not be able to read and write data. For this reason, the NFS gateway is improved and uses the "primary and standby VIP" method to provide users with mounting. The principle is that once the primary node fails, the standby node will restore resources, configure VIP, and continue to provide services. However, the primary and standby nodes have different roles and thus different states. When switching between the primary and standby nodes, resources need to be configured on the standby node. In addition, when users mount based on IP addresses, the gateway node is likely to become a bottleneck point, thereby reaching the upper limit of read and write performance.
[0028] refer to Figure 1 , Figure 1 This is a schematic diagram of a traditional NFS gateway service. Figure 1 As shown in the figure, the traditional NFS gateway node runs the NFS-SERVER process. The user virtual machine acts as NFS-CLENT and executes the mount command to mount the file system. The mount 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 standby node will restore resources, configure VIP, and continue to provide services. For example Figure 1 In the example, the 100.126.1.1 node and the 100.126.1.2 node are mutually active and standby. Initially, the active node will be configured with VIP: 100.86.2.2. Users use the NFS protocol to read and write the file system by mounting the 100.86.2.2 node. Once the active node fails, VIP: 100.86.2.2 will automatically switch to the standby node. During the switch, the client read and write IO is blocked and retried. After the switch is successful, the retry will also be successful and IO will be restored. However, in this active and standby mode, VIP can only be configured on one node, and the user's read and write gateway is single. The gateway node is likely to become a bottleneck point, thus reaching the upper limit of read and write performance.
[0029] refer to Figure 2 , Figure 2 Flowchart of a gateway load balancing method proposed in one embodiment of the present application. Figure 2 As shown, the method comprises the following steps: S11: The switch receives a data read / write request sent by the client.
[0030] In this embodiment, the switch (leaf) is used for data transmission between the client (vm) and the NFS gateway. The data read and write request is a request sent by the switch when reading or writing a file to the storage cluster.
[0031] refer to Figure 3 , Figure 3: is a schematic diagram of NFS gateway load balancing proposed in an embodiment of the present application, such as Figure 3 As shown, the switch receives the data read and write request sent by the client.
[0032] S12: The switch determines the gateway corresponding to the client according to load information of multiple gateways connected to the switch.
[0033] In this embodiment, the gateway is also called an internetwork connector or a protocol converter. The gateway realizes network interconnection above the network layer and is a complex network interconnection device. It is only used for interconnection of two networks with different high-level protocols. The NFS gateway is configured with a gateway of the NFS protocol. The gateway can be used for both wide area network interconnection and local area network interconnection. The gateway is a computer system or device that performs the important task of conversion. The load information of the gateway includes the traffic size of the gateway load, the occupancy rate of the gateway resources, and other gateway-related information.
[0034] In this embodiment, the switch finds the gateway with the smallest load according to the load information of multiple gateways, and determines the gateway as the gateway corresponding to the client.
[0035] In this embodiment, the switch and the gateway are configured with the BGP protocol (Border Gateway Protocol), which is an autonomous system routing protocol running on TCP and is used to exchange routing information between different autonomous systems (AS) on the Internet. And the ECMP protocol (Equal-Cost Multipath Routing) is an equal-cost multipath routing protocol, which is mainly used to use multiple links simultaneously in a network environment to increase transmission bandwidth and achieve load balancing. In the system initialization configuration phase, the same VIP (virtual IP) is configured in all NFS gateway nodes, all gateway nodes are configured with the same AS number (Autonomous System Number), 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, keepalive messages (heartbeat messages, used to notify the switch that the node is operating normally) are continuously sent.
[0036] In this embodiment, the switch determines the gateway corresponding to the client according to the load information of the multiple gateways connected to the switch. The specific steps include: S12-1: the switch obtains the load information of the multiple gateways.
[0037] In this embodiment, the switch obtains the load information of each gateway from the gateway.
[0038] S12-2: The switch determines a gateway with the lowest load flow among the multiple gateways according to the load information.
[0039] In this embodiment, the switch determines a gateway with the lowest load flow from multiple gateways according to the obtained load information.
[0040] S12-3: Use the gateway with the lowest load flow as the gateway corresponding to the client.
[0041] In this embodiment, the gateway with the lowest load flow is used as the gateway corresponding to the client, and the data read and write request sent by the client is forwarded to the gateway. The client subsequently uses the gateway to write to the cluster.
[0042] S13: The switch sends the data read / write request to the gateway.
[0043] In this embodiment, Figure 3 As shown, after receiving the data read / write request, the switch sends the data read / write request to the gateway.
[0044] S14: The gateway performs gateway lock verification on the data read and write request.
[0045] In this embodiment, reference Figure 4 , Figure 4 Schematic diagram of a gateway lock proposed in an embodiment of the present application. Figure 4 As shown in the figure, when different clients mount the same file system, different clients may write to the cluster via the same NFS gateway. In this case, in order to ensure the consistency of the file system, a gateway lock is set at 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.
[0046] In this embodiment, after receiving the data read and write request, the gateway performs gateway lock verification on the data read and write request. The specific steps include: S14-1: The gateway obtains the client serial ID included in the data read / write request.
[0047] In this embodiment, the client sequence ID is a sequence number stored in the client, with an initial value of 0. Each time an operation that causes a state change, such as an operation of writing data, is initiated, the sequence number is incremented by 1.
[0048] In this embodiment, reference Figure 5 , Figure 5 Schematic diagram of the gateway lock mechanism proposed in one embodiment of the present application. Figure 5 As shown, when the client initiates an operation that causes the state of the storage cluster to change, the client sequence ID is increased by 1, and the corresponding data operation request is sent to the server, which is the gateway.
[0049] S14-2: The gateway compares the client serial ID with the server serial ID in the gateway.
[0050] In this embodiment, the server serial ID is a serial number stored in the gateway, and its initial value is 1. After each operation of the client is executed, the serial number is increased by 1.
[0051] In this embodiment, Figure 5 As shown, the gateway compares the client serial ID with the server serial ID.
[0052] S14-3: The gateway determines that the gateway lock verification is successful when the server serial ID is equal to the client serial ID plus one.
[0053] In this embodiment, Figure 5 As shown, the gateway determines that the gateway lock verification has passed when the server serial ID is equal to the client serial ID plus one.
[0054] S14-4: When 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.
[0055] In this embodiment, Figure 5 As shown, when 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.
[0056] S14-5: When the server serial ID is not equal to the client serial ID, the gateway determines that the gateway lock verification fails.
[0057] In this embodiment, Figure 5 As shown, when the server serial ID is not equal to the client serial ID, the gateway determines that the gateway lock verification has not passed, and refuses to execute the operation request sent by the client.
[0058] In this embodiment, the method further includes: S14-6: When the server sequence ID is equal to the client sequence ID, the gateway determines that the data read and write request is a retry request.
[0059] In this embodiment, the retry request is a request that is the same as the last request resent by the client when the previous request fails.
[0060] In this embodiment, Figure 5 As shown, when the server sequence ID is equal to the client sequence ID, the gateway determines that the data read and write request is a retry request.
[0061] S14-7: The gateway returns the cached response data to the client.
[0062] 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 returned to the client after execution.
[0063] In this embodiment, Figure 5 As shown, when the gateway determines that the data read and write request of the client is a retry request, the gateway returns the cached response data to the client.
[0064] S15: When the gateway lock verification is passed, the gateway obtains the corresponding cluster lock from the target cluster.
[0065] In this embodiment, the target cluster is the cluster accessed by the client. The cluster lock is a general term for various types of data locks in the cluster. Among the cluster locks, when different clients mount the same file system, different clients may write to the cluster via different NFS gateways. At this time, multiple NFS gateway nodes write data to the cluster in parallel, and a cluster lock is required to ensure the consistency of the file system. A very sophisticated locking mechanism is implemented in the cluster metadata server to protect the status of various metadata. There are different locks in the metadata server covering different parts of the inode and dentry. In addition, the metadata server uses different types of locks because different metadata behaves differently in different situations.
[0066] As shown in the following table: Table 1
[0067] In this embodiment, when the gateway lock verification is passed, the gateway obtains the corresponding cluster lock from the target cluster. The cluster lock includes a required lock and a desired lock. The specific steps include: S15-1: The gateway determines a required lock and a desired lock corresponding to the data read / write request according to the request type corresponding to the data read / write request.
[0068] In this embodiment, the required lock is a cluster lock that is required to execute the current operation, and the expected lock is a cluster lock that is required to execute the subsequent operation.
[0069] In this embodiment, the gateway determines the required lock and expected lock corresponding to the data read and write request according to the request type of the data read and write request. For example, when the user needs to cache the mtime file and the size file locally and read and use them, the required lock 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 required, that is, the expected lock is Fx.
[0070] S15-2: The gateway sends a cluster lock acquisition request to the target cluster to acquire the required lock and the desired lock.
[0071] In this embodiment, reference Figure 6 , Figure 6 Schematic diagram of the cluster lock mechanism proposed in one embodiment of the present application. Figure 6 As shown in the figure, NFS-SERVER acts as the server of NFS-CLIENT and also implements the client of the cluster. When clients of multiple clusters perform operations such as open, read, and write, they need to obtain the required lock and the desired lock first.
[0072] In this embodiment, the client (gateway) first determines the required locks and desired locks, sends a request to the metadata service of the target cluster, and waits for the inode (index node, a component that manages metadata) to return data to obtain the required locks and desired locks.
[0073] S15-3: The target cluster searches for the corresponding required lock and the desired lock according to the cluster lock acquisition request.
[0074] In this embodiment, Figure 6 As shown, after receiving the cluster lock acquisition request, the target cluster processes the request and traverses all cluster locks to find the corresponding required locks and desired locks.
[0075] S15-4: When the target cluster finds the required lock and the desired lock, the target cluster sends the required lock and the desired lock to the gateway.
[0076] In this embodiment, Figure 6 As shown, when the target cluster finds the required lock and the expected lock, it sends the required lock and the expected lock to the gateway.
[0077] In this embodiment, Figure 6 As shown in the figure, if the target cluster does not find the corresponding expected lock, it checks all clients that have the lock and performs revoke, that is, retrieves the corresponding cluster lock from the client that has obtained the lock. At this time, the client is the gateway, and the retrieved lock is granted to the client (gateway) that sent the request.
[0078] S16: When the gateway obtains the cluster lock, the gateway executes the operation corresponding to the data read and write request.
[0079] In this embodiment, when the gateway obtains the cluster lock, it executes the operation corresponding to the data read and write request. The specific steps include: S16-1: After obtaining the cluster lock, the gateway checks whether the cluster lock includes a required lock and a desired lock.
[0080] In this embodiment, Figure 6 As shown in the figure, when the gateway obtains the cluster lock, it checks whether the cluster lock contains the required lock and the expected lock. The cluster lock returned by the cluster metadata service may only include the required lock, and the expected lock has not been released yet and may be sent later.
[0081] S16-2: When the cluster lock includes only the required lock, the gateway sets a cache corresponding to the data read and write request.
[0082] In this embodiment, Figure 6 As shown, when the gateway contains only required locks in the cluster lock, a cache corresponding to the data read and write request is set to temporarily store the response data corresponding to the data read and write request.
[0083] S16-3: When the cache is set, the gateway executes the operation corresponding to the required lock and waits for the desired lock sent by the target cluster.
[0084] In this embodiment, Figure 6 As shown, when the cache is set, the gateway first executes the operation corresponding to the required lock and waits for the expected lock sent by the target cluster.
[0085] S16-4: Upon receiving the desired lock, the gateway reads the cache.
[0086] In this embodiment, Figure 6 As shown, upon receiving the desired lock, the gateway reads the data in the cache.
[0087] S16-5: The gateway executes the operation corresponding to the desired lock.
[0088] In this embodiment, Figure 6 As shown, when the cache is read, the gateway executes the operation corresponding to the expected lock. After all operations are executed, the data in the read cache and the data after the operation corresponding to the expected lock is executed are returned to the user end that issued the data read and write request.
[0089] For example, NFS-SERVER (gateway) determines that the required lock is Fs and the expected lock is Fx, and sends a request to the target cluster to obtain these two locks. The target cluster first returns the required lock Fs. The gateway sets the cache and first uses the Fs lock to extract the corresponding file in the cluster, add it to the cache, and wait for the Fx lock. After the target cluster retrieves the Fx lock from another gateway, it sends the Fx lock to the gateway. The gateway uses the Fx lock to extract the corresponding file in the target cluster, take out the file in the cache, and send the taken file to the NFS-CLIENT end.
[0090] In this embodiment, the consistency of cluster files is ensured by setting a gateway lock and a cluster lock.
[0091] In another embodiment of the present application, the method further includes: S21: When the switch cannot receive the heartbeat information sent by the gateway, it determines that the gateway fails.
[0092] In this embodiment, reference Figure 7 , Figure 7 is a schematic diagram of a gateway failure proposed in an embodiment of the present application, such as Figure 7 As shown in the figure, the switch leaf continuously receives keepalive messages (heartbeat information) sent from the NFS gateway and monitors each module therein. When a device in the NFS gateway, such as a network card, fails, the NFS gateway stops sending messages. At this time, the switch cannot receive the heartbeat information sent by the gateway and determines that the gateway has failed.
[0093] S22: When the switch determines that the gateway fails, it switches the traffic of the client to another gateway according to the load information of the remaining gateways.
[0094] In this embodiment, when determining that a gateway fails, the switch obtains load information of the remaining gateways, determines a gateway with the smallest load according to the load information of the remaining gateways, and switches the client's traffic to the gateway.
[0095] For example, leaf configures the gateway node IP and performs load balancing through the ECMP protocol, which means that all gateways are master nodes and have completely equal roles. When mounting the file system, the user executes the command: mount -t nfs100.86.1.1: / mnt / nfs / storage / mnt / local / test to establish a connection with the NFS-SERVER through the NFS protocol. When the request is sent to leaf, leaf will select a gateway based on the load of each gateway and establish a connection. Once the connection is established, subsequent NFS clients will always read and write data through this gateway node. Once a node fails, leaf cannot receive the BGP heartbeat and automatically switches traffic to other gateway nodes. During the switching period, the client read and write IO is blocked for 5 seconds and retries are performed. After the switch is successful, the retry will also be successful and IO will be restored within 5 seconds.
[0096] In this embodiment, when a gateway fails, the switch can switch the client's traffic to another gateway, ensuring uninterrupted service and achieving high availability of the gateway.
[0097] 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.
[0098] In this embodiment, the types and methods of management that a user can perform on the file system are shown in the following table: Table 2
[0099] The characteristics met by the gateway are shown in the following table: Table 3
[0100] In the above embodiments of the present application, the NFS gateway adopts the BGP+ECMP protocol to implement high availability and load balancing methods, thereby enhancing the performance of the storage system. When a gateway fails, it can be switched according to the load conditions, thereby improving business execution efficiency and equipment utilization. In addition, by setting a gateway lock and a cluster lock, while achieving high availability and load balancing of the NFS gateway, the consistency of data in the storage system is ensured.
[0101] Based on the same inventive concept, an embodiment of the present application provides a gateway load balancing device. Figure 8 , Figure 8 8 is a schematic diagram of a gateway load balancing device 800 proposed in an embodiment of the present application. Figure 8 As shown, the device comprises: Request receiving module 801, used for the switch to receive data read and write requests sent by the client; A gateway corresponding module 802, configured for the switch to determine the gateway corresponding to the client according to load information of multiple gateways connected to the switch; The request forwarding module 803 is used for the switch to send the data read and write request to the gateway; A gateway lock verification module 804 is used for the gateway to perform gateway lock verification on the data read and write request; The cluster lock acquisition module 805 is used for the gateway to acquire the corresponding cluster lock from the target cluster when the gateway lock verification is passed; The operation execution module 806 is used for the gateway to execute the operation corresponding to the data read and write request when the cluster lock is acquired.
[0102] Optionally, the device further comprises: A fault determination module, configured to determine that the gateway fails when the switch cannot receive the heartbeat information sent by the gateway; The traffic switching module is used for switching the traffic of the client to another gateway according to the load information of the remaining gateways when the switch determines that the gateway fails.
[0103] Optionally, the gateway determination module includes: a load information acquisition submodule, which is used for the switch to acquire the load information of the plurality of gateways; A flow determination submodule, configured for the switch to determine a gateway having the lowest load flow among the plurality of gateways according to the load information; The gateway determination submodule is used to select the gateway with the lowest load flow as the gateway corresponding to the client.
[0104] Optionally, the gateway lock verification module includes: A first gateway lock verification submodule, used for the gateway to obtain the client serial ID contained in the data read and write request; A second gateway lock verification submodule, used for the gateway to compare the client serial ID with the server serial ID in the gateway; A third gateway lock verification submodule, used for the gateway to determine that the gateway lock verification is passed when the server serial ID is equal to the client serial ID plus one; A fourth gateway lock verification submodule, used for 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 for the gateway to determine that the gateway lock verification fails when the server serial ID is not equal to the client serial ID.
[0105] Optionally, the gateway lock verification module further includes: A sixth gateway lock verification submodule, used for the gateway to determine that the data read and write request is a retry request when the server sequence ID is equal to the client sequence ID; The seventh gateway lock verification submodule is used for the gateway to return the cached response data to the client.
[0106] Optionally, the cluster lock acquisition module includes: A cluster lock determination submodule, used for the gateway to determine a required lock and a desired lock corresponding to the data read and write request according to the request type corresponding to the data read and write request; A cluster lock acquisition submodule, configured for the gateway to send a cluster lock acquisition request to the target cluster to acquire the required lock and the desired lock; A cluster lock search submodule, configured for the target cluster to search for the corresponding required lock and the desired lock according to the cluster lock acquisition request; The cluster lock sending submodule is used for the target cluster to send the required lock and the expected lock to the gateway when the required lock and the expected lock are found.
[0107] Optionally, the operation execution module includes: A cluster lock confirmation submodule, used for the gateway to check whether the cluster lock contains a required lock and an expected lock when the cluster lock is acquired; A cache setting submodule, used for setting a cache corresponding to the data read and write request when the gateway only includes the required lock in the cluster lock; A first operation execution submodule, configured for the gateway to execute the operation corresponding to the required lock when the cache is set, and wait for the desired lock sent by the target cluster; A cache reading submodule, configured for the gateway to read the cache when receiving the desired lock; The second operation execution submodule is used for the gateway to execute the operation corresponding to the desired lock.
[0108] Based on the same inventive concept, another embodiment of the present application provides a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the gateway load balancing method as described in any of the above embodiments of the present application.
[0109] Based on the same inventive concept, another embodiment of the present application provides an electronic device, Figure 5It is a schematic diagram of an electronic device 500 proposed in one embodiment of the present application, including a memory 501, a processor 502 and a computer program stored in the memory and executable on the processor, and when the processor is executed, the steps in the gateway load balancing method described in any of the above embodiments of the present application are implemented.
[0110] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0111] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0112] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt 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 codes.
[0113] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0114] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0115] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0116] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0117] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0118] The gateway load balancing method, device, equipment and storage medium provided by the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A gateway load balancing method, characterized in that: The method comprises: The switch receives the data read and write request sent by the client; The switch determines the gateway corresponding to the client according to load information of multiple gateways connected to the switch; The switch sends the data read and write request to the gateway; The gateway performs gateway lock verification on the data read and write request; When the gateway lock is verified, the gateway obtains the corresponding cluster lock from the target cluster; When the gateway obtains the cluster lock, it executes the operation corresponding to the data read and write request.
2. The gateway load balancing method according to claim 1, characterized in that: The method further comprises: The switch determines that the gateway fails when failing to receive the heartbeat information sent by the gateway; When determining that the gateway fails, the switch switches the traffic of the client to another gateway according to 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 according to load information of multiple gateways connected to the switch, including: The switch obtains the load information of the plurality of gateways; The switch determines, according to the load information, a gateway having the lowest load flow among the plurality of gateways; The gateway with the lowest load flow is used as the gateway corresponding to the client.
4. The gateway load balancing method according to claim 1, characterized in that: The gateway performs gateway lock verification on the data read and write request, including: The gateway obtains the client serial ID contained in the data read / write request; The gateway compares the client serial ID with the server serial ID in the gateway; The gateway determines that the gateway lock verification is passed when the server serial ID is equal to the client serial ID plus one; The gateway determines, if the server sequence ID is not equal to the client sequence ID plus one, whether the server sequence ID is equal to the client sequence ID; When the server serial ID is not equal to the client serial ID, the gateway determines that the gateway lock verification fails.
5. The gateway load balancing method according to claim 4, characterized in that: The method further comprises: The gateway determines, when the server sequence ID is equal to the client sequence ID, that the data read and write request is a retry request; The gateway returns the cached response data to the client.
6. The gateway load balancing method according to claim 1, characterized in that: When the gateway lock is verified, the gateway obtains the corresponding cluster lock from the target cluster, including: The gateway determines a required lock and an expected lock corresponding to the data read / write request according to a request type corresponding to the data read / write request; The gateway sends a cluster lock acquisition request to the target cluster to acquire the required lock and the desired lock; The target cluster searches for the corresponding required lock and the desired lock according to the cluster lock acquisition request; When the target cluster finds the required lock and the desired lock, the target cluster sends the required lock and the desired lock to the gateway.
7. The gateway load balancing method according to claim 1, characterized in that: When the gateway obtains the cluster lock, the gateway executes the operation corresponding to the data read / write request, including: When the gateway obtains the cluster lock, checking whether the cluster lock includes a required lock and a desired lock; When the cluster lock includes only the required lock, the gateway sets a cache corresponding to the data read and write request; When the cache is set, the gateway performs the operation corresponding to the required lock and waits for the desired lock sent by the target cluster; The gateway, upon receiving the desired lock, reads the cache; The gateway executes the operation corresponding to the desired lock.
8. A gateway load balancing device, characterized in that: The device comprises: A first receiving module, used for the switch to receive a data read and write request sent by a client; A gateway corresponding module, used for the switch to determine the gateway corresponding to the client according to the load information of multiple gateways connected to the switch; A first sending module, used for the switch to send the data read and write request to the gateway; A gateway lock verification module, used for the gateway to perform gateway lock verification on the data read and write request; A cluster lock acquisition module, used for the gateway to acquire the corresponding cluster lock from the target cluster when the gateway lock verification passes; The operation execution module is used for the gateway to execute the operation corresponding to the data read and write request when the gateway obtains the cluster lock.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 7 are implemented.
10. 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, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Adaptive load balancing
CN107409096A
Load balancing method and device
CN107566466A
Method and device for achieving load balancing, electronic equipment and readable storage medium
CN113553184A
Distributed load balancer health management using data center network manager
CN113796048A
Cluster load processing method and device, storage medium and electronic equipment
CN117544624A