Load balancing method and related equipment thereof
By configuring container groups and service ports on the IoT platform and using load balancers to route access requests, the problem of limited concurrent connections in IoT devices is solved, and efficient concurrent connections are achieved in resource-constrained scenarios.
Patent Information
- Application Number
- CN202310913737.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2025-02-07
AI Technical Summary
The number of concurrent connections to IoT devices is limited by the LVS server configuration resources and backend server resources, and it is difficult to meet the predetermined requirements.
Configure container groups through the container orchestration engine and configure a predetermined number of service ports for them, and use a pre-built load balancer to route access requests from IoT devices to the container group to achieve load balancing.
In the scenario of resource limitation, the demand for concurrent connections with a large number of large numbers and scales is met, and the access efficiency of IoT devices to predetermined services is improved.
Smart Images

Figure CN119402499A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of Internet of Things, and in particular to a load balancing method and related equipment. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by its inclusion in this section.
[0003] In the privatized delivery and deployment scenarios of the Internet of Things (IoT), due to the fragmentation of load balancer-related products, it is impossible to use them out of the box when they are delivered and deployed. There are even no available load balancer products to choose from. It is necessary to build a load balancer based on the deployment scenario of the IoT.
[0004] LVS server is the full name of Linux Virtual Server, which is a highly scalable and highly available server built on a real server cluster. When building a load balancer by yourself, due to the NAT mode (NAT is the full name of Network Address Translation, which means Network Address Translation in Chinese) commonly used in the load balancer deployed on the LVS server operating system, the LVS server needs to have enough source IP (IP is the abbreviation of Internet Protocol Address) or network card configuration resources and enough backend servers to ensure the number of concurrent connections of IoT devices to the IoT, so as to ensure that the load balancer can connect a certain number of IoT devices to the IoT. Among them, the backend server is the server that provides specific services for IoT devices. The services here include solving the protocol plug-in for IoT devices to access the IoT. The load balancer is responsible for forwarding the access from IoT devices to the backend server to achieve the purpose of connecting IoT devices to the IoT.
[0005] However, in the lightweight delivery scenario of IoT, since it is impossible to provide enough configuration resources and backend servers for the load balancer, the number of concurrent connections of IoT devices will be limited by the LVS server configuration resources and backend server resources and it will be difficult to meet the predetermined requirements. Summary of the invention
[0006] The load balancing method and related devices provided by the embodiments of the present invention at least solve the problem that the number of concurrent connections of IoT devices is limited by the configuration resources of the LVS server and the resources of the backend server and is difficult to meet the predetermined requirements.
[0007] According to one aspect of the present invention, a load balancing method is provided, the method being applied to an Internet of Things platform, the method comprising:
[0008] Determine the intended services for IoT platform deployment;
[0009] One or more containers for implementing the predetermined service are configured through a container orchestration engine, and a predetermined number of service ports are configured for a container group consisting of one or more of the containers through the container orchestration engine, wherein the predetermined number is determined according to the number of IoT devices that need to access the predetermined service;
[0010] The access request of the IoT device for the predetermined service is routed to the container in the container group by using the service port through a pre-built load balancer.
[0011] In some embodiments, before routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through a pre-built load balancer, the method further includes:
[0012] Configuring a predetermined routing rule in the load balancer, wherein the routing rule is a rule for the IoT device to access a predetermined service corresponding to the container;
[0013] Then, the step of routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through the pre-built load balancer includes:
[0014] The load balancer routes the access request to the container using the service port based on the routing rule.
[0015] In some embodiments, the step of configuring a predetermined routing rule in the load balancer includes:
[0016] Obtain a first port number for identifying the container group, configure a second port number for identifying the load balancer based on the first port number, and configure a third port number for the service port based on the second port number;
[0017] Configuring the routing rule determined based on the first port number, the second port number, and the third port number on the load balancer, wherein the routing rule includes triggering the load balancer to forward the access request to the service port corresponding to any one of the third port numbers when the IoT device sends the access request to the load balancer based on the second port number, so as to route the access request to the container corresponding to the first port number by using the service port;
[0018] Then, the step of routing the access request to the container by using the service port based on the routing rule by the load balancer includes:
[0019] Sending the first port number and the third port number to the load balancer;
[0020] Receiving, through the load balancer, the access request sent by the IoT device based on the second port number;
[0021] The load balancer forwards the access request to the service port corresponding to any one of the third port numbers based on the routing rule, the first port number and the third port number, so as to route the access request to the container corresponding to the first port number using the service port.
[0022] In some embodiments, the steps of constructing the load balancer include:
[0023] Determine the computing nodes where the load balancing service needs to be deployed, so as to construct and obtain the load balancer by deploying the load balancing service on the computing nodes, wherein the load balancing service includes service software that provides load balancing.
[0024] In some embodiments, the step of deploying the load balancing service on the computing node includes:
[0025] Querying a target computing node with a load balancing label and obtaining a location identifier of the target computing node, wherein the load balancing label is a label used to identify the target computing node on which the load balancing service is to be deployed;
[0026] The load balancing service is deployed for the corresponding target computing node based on the location identifier.
[0027] In some embodiments, the step of deploying the load balancing service for the corresponding target computing node based on the location identifier further includes:
[0028] Deploy a keep-alive component and configuration information of the keep-alive component for the corresponding target computing node based on the location identifier, wherein the configuration information includes the location identifier of another target computing node;
[0029] Then, the step of routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through the pre-built load balancer further includes:
[0030] When the target computing node where the load balancer is located fails, the keep-alive component determines a backup load balancer according to the configuration information, wherein the backup load balancer is a load balancer constructed by deploying the load balancing service on another target computing node;
[0031] The access request is routed to the container by the backup load balancer using the service port.
[0032] According to another aspect of the present invention, a load balancing device is provided, wherein the device is used to implement the load balancing method.
[0033] According to another aspect of the present invention, an Internet of Things platform is provided, and the platform includes the load balancing device.
[0034] According to another aspect of the present invention, there is provided an electronic device, comprising: a processor, and a memory storing a program, wherein the program comprises instructions, and when the instructions are executed by the processor, the processor executes the load balancing method.
[0035] According to another aspect of the present invention, a non-transitory machine-readable medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the load balancing method.
[0036] Beneficial effects of the embodiments of the present invention:
[0037] After configuring the corresponding container group for the scheduled service deployed by the Internet of Things platform through the container orchestration engine, the embodiment of the present invention configures the service port for the container group through the container orchestration engine. The number of the service ports is determined based on the number of Internet of Things devices. Then, the load balancer uses the service port to route the access request of the Internet of Things device for the scheduled service to the container group, thereby enabling the Internet of Things device to access the corresponding scheduled service. Since a scheduled service exposes multiple service ports to the Internet of Things device, the demand for a large number of concurrent connections can be met in a resource-constrained scenario.
[0038] The details of one or more embodiments of the invention are set forth in the following drawings and description so that other features, objects, and advantages of the invention are more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other embodiments can be obtained based on these drawings without creative work.
[0040] Figure 1 A schematic diagram of a load balancing method according to an embodiment of the present invention;
[0041] Figure 2 A schematic diagram of a process for adaptively updating and configuring routing rules of a load balancer provided in one embodiment of the present invention;
[0042] Figure 3 A schematic diagram of a process of forwarding access requests of IoT devices based on routing rules by a load balancer provided in one embodiment of the present invention;
[0043] Figure 4 A schematic diagram of a process for deploying a load balancer provided in one embodiment of the present invention;
[0044] Figure 5 A schematic diagram of a process of forwarding an access request of an Internet of Things device through a backup load balancer provided in one embodiment of the present invention;
[0045] Figure 6 An architectural diagram of a method for implementing load balancing on an Internet of Things platform provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0046] Embodiments of the present embodiment will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present embodiment are shown in the accompanying drawings, it should be understood that the present embodiment can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, which are instead provided for a more thorough and complete understanding of the present embodiment. It should be understood that the drawings and embodiments of the present embodiment are only for exemplary purposes and are not intended to limit the scope of protection of the present embodiment.
[0047] In order to solve the problem that the number of concurrent connections of IoT devices is limited by the configuration resources of LVS servers and the resources of backend servers and is difficult to meet the predetermined requirements, the first embodiment of the present invention provides a load balancing method, which is applied to the IoT platform, such as Figure 1 As shown, the method comprises the following steps:
[0048] Step S11: Determine the scheduled services deployed by the IoT platform, where the scheduled services include communication services, management background services, etc. Among them, communication services include the MQTT communication protocol, which stands for Message Queuing Telemetry Transport. This protocol supports all platforms and can connect almost all IoT devices to the outside world. In addition to supporting the standard MQTT communication protocol and COAP device access protocol (COAP is a computer protocol applied to the IoT), the IoT platform also supports customers to develop private protocols or industry protocols based on the Transmission Control Protocol TCP to meet the communication services of device communication specifications in different fields.
[0049] Step S12: One or more containers for implementing the predetermined service are configured through the container orchestration engine, and a predetermined number of service ports are configured for a container group consisting of the one or more containers through the container orchestration engine, wherein the predetermined number is determined according to the number of IoT devices that need to access the predetermined service.
[0050] Types of container orchestration engines include kubernetes, OpenShift, Nomad, Docker Compose, Cloudify, etc. Among them, OpenShift is a cloud development platform as a service (PaaS). The free and open source cloud computing platform enables developers to create, test and run their applications and deploy them to the cloud. Nomad is a simple, flexible and easy-to-use workload coordinator that can deploy and manage containers and non-containerized applications on a large scale both on-premises and in the cloud. Nomad runs as a single binary file and takes up few resources. Docker Compose is used to define and run multi-container applications that can work together. It describes mutually shared service groups that share software dependencies and are orchestrated and scaled. Cloudify is an open source cloud orchestration tool for deployment automation and lifecycle management of containers and microservices, providing on-demand clusters, automatic repairs, and expansion at the infrastructure level. kubernetes, referred to as K8s, is an open source for managing containerized applications on multiple hosts in a cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and efficient. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance. The traditional way to deploy applications is to install applications through plug-ins or scripts. The disadvantage of this is that the operation, configuration, management, and entire life cycle of the application will be bound to the current operating system, which is not conducive to application upgrades, updates, rollbacks, and other operations. Of course, some functions can be implemented by creating virtual machines, but virtual machines are very heavy and not conducive to portability. The new way is to implement it by deploying containers. Each container is isolated from each other, each container has its own file system, and the processes between containers will not affect each other, and computing resources can be distinguished. Compared with virtual machines, containers can be deployed quickly. Because containers are decoupled from the underlying facilities and machine file systems, they can be migrated between different clouds and different versions of operating systems. The embodiment of the present invention deploys containers that implement predetermined services by means of Kubernetes deployment containers, and configures a predetermined number of service ports for a container group composed of containers (referred to as pods). The service port is a service of the node type (nodeport) provided by Kubernetes. As an abstract resource type of Kubernetes, the service has the greatest function of acting as a proxy for the backend container Pod, integrating multiple backend Pods (the pods that implement predetermined services in the embodiment of the present invention) so that when the outside (the Internet of Things device in the embodiment of the present invention) accesses it, it feels like only one service rather than multiple Pods, thereby avoiding the use of Pod or NodePort addresses to access services (the IP addresses of the two are often not stable enough).For example, if multiple containers (pods) are deployed for the MQTT communication protocol, the container group composed of these multiple MQTT communication protocol pods corresponds to multiple corresponding service ports. The IoT device can access this service port, and the service port forwards the access of the IoT device to the corresponding pod. When a scheduled service originally only ensures the concurrent access of N IoT devices, the concurrent connection access requirements of 4N IoT devices can be achieved through the four exposed service ports, which ensures the number of IoT devices that can access the IoT platform concurrently under the condition that the resources of each server (such as the configuration resources of the LVS server required for the load balancer to access the IoT device and the number of backend servers) are limited. If the number of connected targets is one million IoT devices, in order to ensure the concurrent connection number of IoT devices during load balancing, the predetermined number of service ports can be set to four, that is, a scheduled service can expose four accessible service ports to IoT devices. When the concurrent connection of only 250,000 IoT devices can be ensured, the concurrent connection of one million IoT devices can be achieved through four service ports.
[0051] Step S13: Use the service port to route the access request of the IoT device for the scheduled service to the container in the container group through the pre-built load balancer. Thus, the IoT platform uses the service port to load balance the access request of the IoT device to the scheduled service through the load balancer. Since a scheduled service adaptively exposes multiple service ports to the IoT device, any service port can route the access request of the IoT device to the correct container that can implement the scheduled service. In the lightweight delivery scenario of the IoT platform, even if it is not possible to provide enough back-end servers (equivalent to the container group corresponding to the scheduled service in the embodiment of the present invention) and LVS server configuration resources, the number of IoT devices that can access the IoT platform concurrently can be ensured.
[0052] Specifically, when determining the scheduled service deployed by the IoT platform in step S11, the IoT platform provided by the embodiment of the present invention can call the list-watch mechanism of Kubernets to determine the scheduled service deployed by the IoT platform. The List-Watch mechanism is a mechanism for monitoring changes in resource objects. By using the List and Watch operations provided by the K8s API Server, it is possible to monitor and respond to resource objects in the K8s cluster. That is, the list-watch mechanism includes two parts, namely the list operation and the watch operation. The list operation is to call the list API of resources (such as the scheduled service resources deployed by the IoT platform in the embodiment of the present invention, the computing node resources mentioned below, etc.) to list the resources, which is implemented based on the HTTP short link. The watch operation is to call the watch API of the resource to listen to resource change events, which is implemented based on the HTTP long link. The embodiment of the present invention monitors the scheduled service based on the list-watch mechanism, which can easily and quickly discover the scheduled services that have been deployed and / or newly added by the IoT platform, thereby improving the deployment efficiency of the service port for automatically deploying the scheduled service.
[0053] It can be seen that after the embodiment of the present invention configures the corresponding container group for the scheduled service deployed by the Internet of Things platform through the container orchestration engine, the container orchestration engine configures the service port for the container group, the number of which is determined based on the number of Internet of Things devices, and then the load balancer uses the service port to route the access request of the Internet of Things device for the scheduled service to the container group, thereby enabling the Internet of Things device to access the corresponding scheduled service. Since a scheduled service exposes multiple service ports to the Internet of Things device, it can meet the demand for a large number of concurrent connections in a resource-constrained scenario.
[0054] Before routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through the pre-built load balancer in step S13, the method provided by the embodiment of the present invention also includes: configuring a predetermined routing rule in the load balancer, wherein the routing rule is a rule for the IoT device to access the predetermined service corresponding to the container. Then, in step S13, the step of routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through the pre-built load balancer includes: routing the access request to the container by using the service port based on the routing rule through the load balancer. The embodiment of the present invention hot updates the routing rules to the load balancer in real time, and when the IoT device accesses the predetermined service through the load balancer, the load balancer load balances the access request of the IoT device to the correct backend pod based on the routing rules.
[0055] like Figure 2As shown, the steps of configuring a predetermined routing rule in a load balancer include:
[0056] Step S21: Obtain a first port number for identifying a container group, configure a second port number for identifying a load balancer based on the first port number, and configure a third port number for a service port based on the second port number.
[0057] Step S22: configuring the routing rules determined based on the first port number, the second port number and the third port number on the load balancer, wherein the routing rules include triggering the load balancer to forward the access request to a service port corresponding to any third port number when the IoT device sends an access request to the load balancer based on the second port number, so as to route the access request to the container corresponding to the first port number using the service port.
[0058] like Figure 3 As shown in the figure, the steps of routing the access request to the container by using the service port based on the routing rules through the load balancer include:
[0059] Step S31: Send the first port number and the third port number to the load balancer.
[0060] Step S32: receiving an access request sent by the IoT device based on the second port number through the load balancer.
[0061] Step S33: forwarding the access request to a service port corresponding to any third port number through the load balancer based on the routing rule, the first port number and the third port number, so as to route the access request to the container corresponding to the first port number using the service port.
[0062] Therefore, the embodiment of the present invention automatically mounts the scheduled service to the load balancer through the routing rules configured for the load balancer, without the need for the user to manually mount the IP address of the back-end server and the port of the scheduled service to the load balancer, so that the load balancer can load balance the access request of the Internet of Things device to the corresponding scheduled service using the service port, thereby realizing the automatic deployment of the load balancing of the Internet of Things platform, which can be delivered and deployed out of the box. When a new scheduled service is added or the port number of the scheduled service changes, the Internet of Things platform can update the routing rules deployed in the corresponding load balancer in real time based on the newly added port number or the changed port number through the delivery component deployed by the platform itself (the delivery component is mainly responsible for application deployment control, including parameter initialization, process control, etc.), which greatly reduces the deployment and manual operation and maintenance costs.
[0063] Therefore, the load balancer of the embodiment of the present invention can realize adaptive routing control, and can automatically register predetermined services such as protocol plug-ins of the Internet of Things scenario to the load balancer. Each predetermined service adaptively exposes a predetermined number of service ports to the Internet of Things device, thereby realizing lightweight and zero-configuration horizontal expansion of the number of concurrent connections of the Internet of Things devices.
[0064] In an embodiment of the present invention, the step of building a load balancer includes: determining the computing nodes where the load balancing service needs to be deployed, so as to obtain the load balancer by deploying the load balancing service on the computing nodes, and the load balancing service includes service software that provides load balancing. The computing nodes can be physical machines or virtual machines in the k8s cluster, mainly points that are controlled by the master server (the server that is mainly responsible for controlling the cluster) in the k8s cluster. When determining the computing nodes where the load balancing service needs to be deployed, the Internet of Things platform provided in the embodiment of the present invention can call the Kubernets list-watch mechanism to query the computing nodes where the load balancing service needs to be deployed and list the corresponding budget nodes, and then deploy the load balancing service to the corresponding computing nodes. Therefore, the embodiment of the present invention can achieve the decoupling of the load balancing service and the Internet of Things platform delivery environment through the node management of Kubernets, realize the automatic deployment of the corresponding services, and greatly improve the deployment efficiency of the service. The load balancing service here is such as HAProxy. HAProxy is a free and open source software written in C language, which provides high-availability load balancing. Such as Figure 4 As shown in the figure, the steps of deploying a load balancing service on a computing node include:
[0065] Step S41: querying a target computing node with a load balancing label and obtaining a location identifier of the target computing node, wherein the load balancing label is a label used to identify the target computing node where a load balancing service needs to be deployed.
[0066] Step S42: deploying a load balancing service for the corresponding target computing node based on the location identifier.
[0067] Specifically, the Internet of Things platform in the embodiment of the present invention can query the target computing node identified with the load balancing label and obtain its location identifier by calling the list-watch mechanism of Kubernetes, and then list the target computing nodes that need to deploy the load balancing service according to the location identifier in the form of a list, without the need to manually find and determine the corresponding target computing nodes. During deployment, the Internet of Things platform calls the open interface createdeployment of Kubernetes to deploy the load balancing service for the target computing node, which greatly improves the deployment efficiency of the load balancer, and thereby improves the efficiency of the Internet of Things devices accessing the Internet of Things platform.
[0068] In an embodiment of the present invention, in order to ensure that when a single computing node fails, the access requirements of the IoT devices can still be load balanced to the backend pod, the step of deploying a load balancing service for the corresponding target computing node based on the location identifier in the embodiment of the present invention also includes: deploying a keep-alive component and configuration information of the keep-alive component for the corresponding target computing node based on the location identifier, wherein the configuration information includes the location identifier of another target computing node. A keep-alive component such as keepalived is a service software in cluster management that ensures high availability of the cluster. Its function is similar to the heartbeat service, which is used to prevent single point failures. Then, if Figure 5 As shown, in step S13, the step of routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through the pre-built load balancer also includes:
[0069] Step S51: When a target computing node where the load balancer is located fails, a backup load balancer is determined according to configuration information by a keep-alive component. The backup load balancer is a load balancer constructed by deploying a load balancing service on another target computing node.
[0070] Step S52: Routing the access request to the container using the service port through the backup load balancer.
[0071] In the embodiment of the present invention, when a target computing node running a load balancer fails and cannot provide load balancing services for IoT devices, the backup load balancer selected by the keepalive component routes the access request of the IoT device to the pod using the service port, thereby ensuring the concurrent connection requirements of the IoT device. Therefore, the embodiment of the present invention utilizes the node and container management capabilities of Kubernets to decouple the open source load balancing service (such as HAProxy) and the high-availability keepalive component (such as KeepAlived) from the delivery environment, and performs automated deployment and configuration to achieve out-of-the-box use.
[0072] The second embodiment of the present invention provides a load balancing device, which is used to implement a load balancing method. For details of the load balancing method, please refer to the content provided in the first embodiment of the present invention, and the embodiment of the present invention will not be repeated here.
[0073] After the load balancing device provided by the embodiment of the present invention configures the corresponding container group for the scheduled service deployed by the Internet of Things platform through Kubernets, it configures the service port for the container group through Kubernets. The number of the service ports is determined based on the number of devices of the Internet of Things. Then, the load balancer uses the service port to route the access request of the Internet of Things device for the scheduled service to the container group, thereby realizing the access of the Internet of Things device to the corresponding scheduled service. Since a scheduled service exposes multiple service ports to the Internet of Things device, it meets the demand for a large number of concurrent connections in a lightweight delivery scenario with limited resources.
[0074] The third embodiment of the present invention provides an Internet of Things platform, which includes a load balancing device. For details of the load balancing device, please refer to the content provided in the second embodiment of the present invention, and the embodiment of the present invention will not be repeated here.
[0075] The Internet of Things platform provided by the embodiment of the present invention can configure the corresponding container group for the scheduled service deployed by the Internet of Things platform through Kubernets, and then configure the service port for the container group through Kubernets. The number of the service ports is determined based on the number of Internet of Things devices, and then the access request of the Internet of Things device for the scheduled service is routed to the container group by the load balancer using the service port, so as to realize the access of the Internet of Things device to the corresponding scheduled service. Since a scheduled service exposes multiple service ports to the Internet of Things device, the demand for a large number of concurrent connections can be met in a lightweight delivery scenario with limited resources.
[0076] The fourth embodiment of the present invention provides an electronic device, comprising: a processor, and a memory for storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes a load balancing method. For details of the load balancing method, please refer to the content provided in the first embodiment of the present invention, and the embodiment of the present invention will not be repeated here.
[0077] The fifth embodiment of the present invention provides a non-transitory machine-readable medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute a load balancing method. For details of the load balancing method, please refer to the content provided in the first embodiment of the present invention, and the embodiment of the present invention will not be repeated here.
[0078] The sixth embodiment of the present invention further provides a computer program product, including a computer program, wherein when the computer program is executed by a processor of a computer, it is used to enable the computer to execute the load balancing method provided by the first embodiment of the present invention.
[0079] The seventh embodiment of the present invention provides an application embodiment of a load balancing method, which utilizes the node and container management capabilities of the container orchestration engine Kubernetes to decouple load balancing services (such as HAProxy), keep-alive components (such as KeepAlived), etc. from the delivery environment and realize automated containerized deployment, thereby obtaining a load balancer with a keep-alive function. The list-watch mechanism of Kubernetes is used to query and determine the scheduled services (such as MQTT communication protocol, custom protocol plug-in, management background, etc.) deployed on the Internet of Things platform, and then one or more containers for implementing the scheduled services are configured through Kubernetes, and a predetermined number of service ports are configured for a container group consisting of one or more containers through Kubernetes, wherein the predetermined number is determined according to the number of devices of the Internet of Things devices that need to access the scheduled service. At the same time, in order to ensure that the load balancer forwards the access request of the Internet of Things device to the container where the corresponding scheduled service is located, the routing rules determined based on the port number of the container group where the scheduled service is located are issued and deployed to the load balancer, thereby performing a hot update on the operation configuration of the load balancer.
[0080] The overall architecture of the IoT platform when implementing the load balancing method is as follows Figure 6 As shown. Among them, each container group implements the predetermined services provided by the Internet of Things platform (such as MQTT communication protocol, management background and other services), deployment delivery components (delivery components are mainly responsible for application deployment control, including parameter initialization, process control), etc. The Internet of Things platform in the embodiment of the present invention can update the routing rules in the load balancer in real time based on the newly added port number or changed port number of the platform through the delivery component, which can greatly reduce the deployment and manual operation and maintenance costs.
[0081] First, the Internet of Things platform of the embodiment of the present invention calls the list-watch mechanism of Kubernets to deploy the load balancer, and uses list-watch to find out the location identifier (such as IP address) of the server (that is, the computing node mentioned in the first embodiment of the present invention) that has been tagged with a load balancing label in the Kubernets cluster, so as to deploy a load balancing service (such as HAProxy) for the corresponding server based on the location identifier. At the same time, in order to ensure that when a single server node running a load balancer fails, the access requirements of the Internet of Things device can still be load balanced to the back-end pod through the load balancer, the embodiment of the present invention also deploys a keep-alive component (such as keepalived) for the server where the load balancer is located. Therefore, when the server where the load balancer is located fails, the keep-alive component is used to determine the backup load balancer running on another server according to the location identifier of another server, so that the access request of the Internet of Things device is routed to the container where the predetermined service is located through the backup load balancer using the deployed service port.
[0082] Secondly, when configuring the service port for the scheduled service and updating the routing rules for the load balancer, the embodiment of the present invention calls the list-watch mechanism of Kubernetes to determine whether there is a newly added scheduled service on the Internet of Things platform. If so, after deploying the corresponding container pod for the scheduled service, a service port is created for the scheduled service. When creating, Kubernetes's cresteservice is called to set multiple service ports for the scheduled service according to the number of IoT devices, thereby ensuring that the load balancer can forward access requests from millions of IoT devices to the scheduled service. Then, the routing rules in the load balancer are updated based on the port number of the newly added scheduled service through the delivery component, so that the load balancer can correctly forward the access request to the new scheduled service (such as a protocol plug-in) by loading the newly configured routing rules. Among them, the step of the delivery component updating the routing rules based on the port number of the newly added scheduled service includes:
[0083] 1. Set the first port number of the scheduled service to A (such as the port number of the protocol plug-in. The setting range of the port number open to the user for configuration in the embodiment of the present invention is 30000-31000).
[0084] 2. Taking a massive connection target of 1 million IoT devices as an example, the number of service ports for adaptive configuration is four.
[0085] 3. If the port step is set to 10,000 and the second port number of the load balancer is set to B, then B=A+10000.
[0086] 4. The starting value of the third port number of the adaptively registered service port supporting massive connections is C=B+(31000-30000), and the third port numbers of the four service ports configured for the newly added scheduled services are C+1, C+2, C+3, and C+4 respectively.
[0087] 5. If A is 30000, then the access port (i.e. the second port number) of the load balancer is 40000, and the third port numbers of the four service ports are 41001, 41002, 41003, and 41004 respectively.
[0088] 6. The routing rules determined based on the first port number, the second port number and the third port number are: the IoT device sends the access request to the load balancer by accessing the second port number 40000 of the load balancer, and the load balancer will load balance and forward the access request to the service ports corresponding to the third port numbers 41001, 41002, 41003, 41004, etc. These four service ports can map the access request to the predetermined service corresponding to the first port number 30000.
[0089] In view of the concurrent connection number demand of the Internet of Things platform, the embodiment of the present invention needs to deploy enough backend servers or load balancers to mount enough source IPs or network cards to achieve the required number of concurrent connections, because the NAT (network address translation) of the load balancer is limited by the number of backend servers and the number of source IPs or network cards. For example, 1 million connections require 16 backend servers, but the resources of the privatized delivery scenario are limited. For example, a 16c32g server cannot be split into 4 4c8g servers to increase the number. Mixed deployment will cause resource fragmentation and low resource utilization. In addition, it is impossible to allocate enough source IPs or network cards to the load balancer. In this regard, when sufficient resources cannot be provided for the load balancer to use to meet the concurrent connection number requirements of the Internet of Things devices, the embodiment of the present invention adaptively exposes multiple service ports of the backend scheduled service to horizontally expand the number of concurrent device connections. For example, 4 servers expose the same scheduled service to 4 service ports to achieve the concurrent connection effect of 16 servers, which meets the number of concurrent connections while improving the resource utilization of the server.
[0090] As can be seen from the above, the embodiment of the present invention uses the list-watch mechanism of Kubernets to lock the server node where the load balancing service and keep-alive component need to be deployed and the location identifier of the server node, and calls the deployment component Deployment of Kubernets to automatically implement the deployment of the load balancing service and the keep-alive component. After the routing rule configuration is updated, the exec provided by Kubernets (exec can connect to the specified container and execute commands) is used to execute the reload script in the server where the load balancer is deployed to realize the automatic hot update of the routing rules required by the load balancer. When the user submits a new scheduled service on the platform, the reload script is used to trigger the load balancer to load the routing rules corresponding to the new scheduled service to ensure that the load balancer can correctly forward the access of the IoT device to this new scheduled service, realize the update and configuration of adaptive routing control, dynamically discover services and automatically mount them to the load balancer, and greatly reduce the cost of manual operation and maintenance. At the same time, the Kubernetes service is used to expose multiple service ports of the same backend scheduled service (the service port is a nodeport type service in Kubernetes), so that the load balancer can guarantee the number of concurrent connections without consuming multiple source IPs or network cards. The number of connections of IoT devices concurrently forwarded to the same scheduled service is the number of server nodes * the number of service ports.
[0091] *65535 ports (* is a multiplication operator). 65535 ports are the theoretically available ports for backend reservation services of the load balancer. While meeting the number of concurrent connections of IoT devices in resource-constrained scenarios, it also improves the resource utilization of the server.
[0092] The computer programs for implementing the methods of the embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer programs are executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer programs may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0093] In the context of an embodiment of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0094] It should be noted that the term "including" and its variations used in the embodiments of the present invention are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".
[0095] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0096] The various steps described in the method implementation methods provided in the embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method implementation methods may include additional steps and / or omit the steps shown. The scope of protection of the present invention is not limited in this respect.
[0097] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same or similar parts between the various embodiments refer to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment.
[0098] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the attached claims.
Claims
1. A load balancing method, the method being applied to an Internet of Things platform, the method comprising: Determine the intended services for IoT platform deployment; One or more containers for implementing the predetermined service are configured through a container orchestration engine, and a predetermined number of service ports are configured for a container group consisting of one or more of the containers through the container orchestration engine, wherein the predetermined number is determined according to the number of IoT devices that need to access the predetermined service; The access request of the IoT device for the predetermined service is routed to the container in the container group by using the service port through a pre-built load balancer.
2. The method according to claim 1, wherein: Before routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through a pre-built load balancer, the method further includes: Configuring a predetermined routing rule in the load balancer, wherein the routing rule is a rule for the IoT device to access a predetermined service corresponding to the container; Then, the step of routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through the pre-built load balancer includes: The load balancer routes the access request to the container using the service port based on the routing rule.
3. The method according to claim 2, wherein: The step of configuring a predetermined routing rule in the load balancer comprises: Obtain a first port number for identifying the container group, configure a second port number for identifying the load balancer based on the first port number, and configure a third port number for the service port based on the second port number; Configuring the routing rule determined based on the first port number, the second port number, and the third port number on the load balancer, wherein the routing rule includes triggering the load balancer to forward the access request to the service port corresponding to any one of the third port numbers when the IoT device sends the access request to the load balancer based on the second port number, so as to route the access request to the container corresponding to the first port number by using the service port; Then, the step of routing the access request to the container by using the service port based on the routing rule by the load balancer includes: Sending the first port number and the third port number to the load balancer; Receiving, through the load balancer, the access request sent by the IoT device based on the second port number; The load balancer forwards the access request to the service port corresponding to any one of the third port numbers based on the routing rule, the first port number and the third port number, so as to route the access request to the container corresponding to the first port number using the service port.
4. The method according to claim 1, wherein: The steps of constructing the load balancer include: Determine the computing nodes where the load balancing service needs to be deployed, so as to construct and obtain the load balancer by deploying the load balancing service on the computing nodes, wherein the load balancing service includes service software that provides load balancing.
5. The method according to claim 4, wherein: The step of deploying the load balancing service on the computing node includes: Querying a target computing node with a load balancing label and obtaining a location identifier of the target computing node, wherein the load balancing label is a label used to identify the target computing node on which the load balancing service is to be deployed; The load balancing service is deployed for the corresponding target computing node based on the location identifier.
6. The method according to claim 5, wherein: The step of deploying the load balancing service for the corresponding target computing node based on the location identifier also includes: Deploy a keep-alive component and configuration information of the keep-alive component for the corresponding target computing node based on the location identifier, wherein the configuration information includes the location identifier of another target computing node; Then, the step of routing the access request of the IoT device for the predetermined service to the container in the container group by using the service port through the pre-built load balancer further includes: When the target computing node where the load balancer is located fails, the keep-alive component determines a backup load balancer according to the configuration information, wherein the backup load balancer is a load balancer constructed by deploying the load balancing service on another target computing node; The access request is routed to the container by the backup load balancer using the service port.
7. A load balancing device, used to implement the load balancing method described in any one of claims 1 to 6.
8. An Internet of Things platform, comprising the load balancing device according to claim 7.
9. An electronic device, comprising: A processor, and a memory storing a program, wherein the program comprises instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 6.
10. A non-transitory machine-readable medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.
Citation Information
Cited By
Developer access system, developer access method, and program product
CN120880700A