A Knative Automatic Resizing Method and System Based on eBPF Programs
By using eBPF programs, data flow monitoring and scaling decisions are reduced from layer seven to layer four. By combining kernel-mode and user-mode programs, the problem of time-consuming new request discovery in the knative system is solved, achieving fast response and high-performance automatic scaling.
Patent Information
- Application Number
- CN202411596220.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-11-11
AI Technical Summary
In existing technologies, Knative systems based on a seven-layer proxy take a long time to detect new requests, resulting in slow autoscale response time and poor overall performance.
By adopting an eBPF-based approach, data flow monitoring and scaling decisions are reduced from layer seven to layer four. The eBPF program monitors the data flow and synchronizes information with the Autoscaler component to achieve automatic scaling. Kernel-mode and user-mode programs work together to forward data packets.
It speeds up the response of the knative system, reduces the number of components, lowers system complexity, and optimizes the scaling decisions of the Autoscaler component.
Smart Images

Figure CN119484546B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud-native serverless technology, specifically to a knative automatic scaling method and system based on eBPF programs. Background Technology
[0002] Cloud-native serverless technologies, exemplified by Knative, monitor, proxy, and cache client HTTP requests. When there are no requests, Knative can shut down backend service containers, thus saving resources and enabling flexible scheduling. When a new request arrives, Knative detects the new connection, caches it, and then starts the backend service container. Once the service container is up and running, Knative forwards the cached request to the backend service container to complete the service. Currently, the solutions for discovering connections, notifying the autoscaler component (a Knative component whose main function is to automatically control the number of containers under load), and caching requests are all based on layer 7 proxies, such as Envoy (an open-source high-performance proxy). However, these layer 7 proxies are generally located in user space, so when a new connection is detected, it has already been processed by the kernel network stack, resulting in significant time consumption and some filtering by the network stack.
[0003] EBPF (Extended Berkeley Packet Filter, a kernel bypass technology) allows externally loaded programs to execute within the kernel, similar to a virtual machine running in the kernel, enabling real-time loading and unloading. It also allows for real-time data interaction with user space.
[0004] The technical problem that needs to be solved is how to reduce the discovery of new requests from layer seven to layer four, speed up autoscale response time, and improve overall performance. Summary of the Invention
[0005] The technical objective of this invention is to address the above-mentioned shortcomings by providing a knative automatic scaling method and system based on eBPF programs, in order to solve the technical problem of how to reduce the discovery of new requests from layer seven to layer four, accelerate autoscale response time, and improve overall performance.
[0006] In a first aspect, the present invention provides a knative automatic scaling method based on an eBPF program. This method implements automatic scaling based on the knative specification using an eBPF program, an Autoscaler component, and a user-space program. The user-space program acts as a Layer 7 proxy for nodes, providing network proxy, load balancing, and service discovery functions. The method includes the following steps:
[0007] Data flow monitoring: For Kubernetes cluster nodes, each node's operating system runs an eBPF program as a daemon process. The eBPF program monitors the data flow entering the node's Layer 4 proxy and monitors the current network operating status as monitoring information. The eBPF program also creates a data structure to record the availability status of the business load containers corresponding to each backend service.
[0008] Data Stream Synchronization: When the eBPF program detects a data stream entering the fourth-layer proxy, it synchronizes the data stream-related information and monitoring information to the Autoscaler component. It also uses the data structure records to determine whether there is a business load container for the backend service corresponding to the data stream. If not, it sends a scaling event notification to the Autoscaler component.
[0009] Scaling decision: Based on data flow information, monitoring information, scaling event announcements, and the current status of the business-responsible containers of each backend service, the Autoscaler component makes a scaling decision for the business load container and returns a response to the eBPF program. Based on the response, the eBPF program updates its local data structure.
[0010] Packet forwarding: When a data stream entering the fourth-layer proxy establishes a connection with an eBPF program, the eBPF program makes a decision on packet forwarding based on the content recorded in the data structure. The packet is either forwarded directly to the corresponding workload container, or forwarded to the user-space program and cached by the user-space program. When the Autoscaler component expands the workload container of the backend service related to the data stream and notifies the user-space program that the workload container is available, the user-space program forwards the packet to the workload container of its corresponding backend service.
[0011] Preferably, the eBPF program includes a kernel-mode program and a user-mode program;
[0012] The kernel-mode program is used to monitor the data flow entering the node's fourth-layer agent and monitor the current network operation status as monitoring information. It also synchronizes the data flow-related information and monitoring information to the Autoscaler component.
[0013] The kernel-mode program creates a local data structure to record the availability status of the business load containers corresponding to each backend service. Based on the records in the local data structure, it determines whether there is a business load container for the backend service corresponding to the data flow. If not, it generates a scaling event notification and calls the user-mode program. The user-mode program is used to send the scaling event notification to the Autoscaler component based on the interface specification of the Autoscaler component.
[0014] When the data stream entering the fourth-layer agent establishes a connection with the kernel-mode program, the kernel-mode program makes decisions on the forwarding of data packets based on the content recorded in the data structure, and calls the user-mode program based on the decisions. The user-mode program is used to forward the data packets directly to the corresponding business load container, or to forward the data packets to the Envoy program.
[0015] Preferably, when the data packet reaches the kernel program of the eBPF program, the kernel program makes a decision on forwarding the data packet based on the record content of the data structure. If the business load container of the backend service corresponding to the data packet does not meet the service conditions, the kernel program modifies the data packet, modifies the data packet header to the data packet that reaches the Envoy program, and stores the original information in the data packet in the socketbuffer structure. The modified data packet is then forwarded to the user-space program of the eBPF program.
[0016] The user-space program buffers the received data packets. When the user-space program receives a notification from the Autoscaler component that the load balancing container is available, it modifies the data packet header to indicate that the load balancing container for the corresponding backend service has been reached, and then sends the modified data packet to the load balancing container of the corresponding backend service.
[0017] As a preferred choice, the user-space program uses the Envoy program, which is an open-source, high-performance proxy.
[0018] Preferably, the data stream is a TCP / UDP data stream.
[0019] In a second aspect, the present invention provides a knative automatic scaling system based on an eBPF program, which is used to achieve automatic scaling based on the knative specification through a knative automatic scaling method based on an eBPF program as described in any of the first aspects. The system includes an eBPF program component, an Autoscaler component, and a user-space program component.
[0020] For Kubernetes cluster nodes, each node's operating system runs eBPF program components and user-space program components. The user-space program components act as the node's Layer 7 proxy, providing network proxy, load balancing, and service discovery functions, while the eBPF program components act as the node's Layer 4 proxy.
[0021] The eBPF program component performs the following actions through the eBPF program: monitoring the data flow entering the fourth-layer agent of the node, monitoring the current network operating status as monitoring information, and creating a data structure in the eBPF program to record the availability status of the business load containers corresponding to each backend service.
[0022] When the eBPF program detects a data flow entering the fourth-layer proxy, the eBPF program component performs the following actions: Synchronizes data flow-related information and monitoring information to the Autoscaler component, and determines whether a business load container for the corresponding backend service exists based on the data structure records. If not, it sends a scaling event notification to the Autoscaler component. Correspondingly, the Autoscaler component performs the following actions: Based on data flow-related information, monitoring information, scaling event notification, and the current status of the business load containers for each backend service, it makes a scaling decision for the business load container and returns a response to the eBPF program component. Correspondingly, the eBPF program component updates its local data structure based on the response.
[0023] When a data stream entering the fourth-layer proxy establishes a connection with an eBPF program, the eBPF program component performs the following actions: based on the content recorded in the data structure, it makes a decision on the forwarding of the data packet, either directly forwarding the data packet to the corresponding workload container or forwarding the data packet to the user-space program. Correspondingly, the user-space program component performs the following actions: caches the data packet, and when the Autoscaler component expands the workload container of the backend service related to the data stream and notifies the user-space program that the workload container is available, it forwards the data packet to the workload container of its corresponding backend service.
[0024] Preferably, the eBPF program includes a kernel-mode program and a user-mode program;
[0025] The kernel-mode program is used to monitor the data flow entering the node's fourth-layer agent and monitor the current network operation status as monitoring information. It also synchronizes the data flow-related information and monitoring information to the Autoscaler component.
[0026] The kernel-mode program creates a local data structure to record the availability status of the business load containers corresponding to each backend service. Based on the records in the local data structure, it determines whether there is a business load container for the backend service corresponding to the data flow. If not, it generates a scaling event notification and calls the user-mode program. The user-mode program is used to send the scaling event notification to the Autoscaler component based on the interface specification of the Autoscaler component.
[0027] When the data stream entering the fourth-layer agent establishes a connection with the kernel-mode program, the kernel-mode program makes decisions on the forwarding of data packets based on the content recorded in the data structure, and calls the user-mode program based on the decisions. The user-mode program is used to forward the data packets directly to the corresponding business load container, or to forward the data packets to the Envoy program.
[0028] Preferably, when the data packet reaches the kernel program of the eBPF program, the kernel program makes a decision on forwarding the data packet based on the record content of the data structure. If the business load container of the backend service corresponding to the data packet does not meet the service conditions, the kernel program modifies the data packet, modifies the data packet header to the data packet that reaches the Envoy program, and stores the original information in the data packet in the socketbuffer structure. The modified data packet is then forwarded to the user-space program of the eBPF program.
[0029] The user-space program buffers the received data packets. When the user-space program receives a notification from the Autoscaler component that the load balancing container is available, it modifies the data packet header to indicate that the load balancing container for the corresponding backend service has been reached, and then sends the modified data packet to the load balancing container of the corresponding backend service.
[0030] As a preferred choice, the user-space program uses the Envoy program, which is an open-source, high-performance proxy.
[0031] Preferably, the data stream is a TCP / UDP data stream.
[0032] The knative automatic expansion method and system based on eBPF programs of the present invention have the following advantages:
[0033] 1. It can start the automatic scaling process of the business workload container when establishing the fourth layer connection, which speeds up the response speed of the knative system, while completing the same function with fewer components and reducing system complexity;
[0034] 2. A data structure is established in the eBPF program to record the availability status of the business load containers corresponding to each backend service. When the eBPF program monitors the data flow entering the fourth-layer proxy, it determines whether the business load container corresponding to the data flow exists based on the records in the data structure. If it does not exist, it sends a scaling event notification to the Autoscaler component. Based on the data flow information, monitoring information, scaling event notification, and the current status of the business load containers of each backend service, the Autoscaler component makes a decision on scaling up the business load containers and returns a response to the eBPF program. Based on the response, the eBPF program updates its local data structure. This solution optimizes the capacity of the Autoscaler component and speeds up the scaling decision of the Autoscaler component. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] The invention will be further described below with reference to the accompanying drawings.
[0037] Figure 1 This is a flowchart of a knative automatic scaling method based on an eBPF program, as shown in Example 1.
[0038] Figure 2 This is a block diagram illustrating the working principle of a knative automatic expansion system based on an eBPF program, as shown in Example 2. Detailed Implementation
[0039] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0040] This invention provides a knative automatic scaling method and system based on eBPF programs, which solves the technical problem of how to reduce the discovery of new requests from layer 7 to layer 4 and speed up autoscale response time and improve overall performance.
[0041] Example 1:
[0042] This invention discloses a knative automatic scaling method based on an eBPF program. It implements automatic scaling based on the knative specification using an eBPF program, an Autoscaler component, and a user-space program. The user-space program acts as a Layer 7 proxy for nodes and has network proxy, load balancing, and service discovery functions.
[0043] The method includes four steps: data flow monitoring, data flow synchronization, capacity expansion decision-making, and packet forwarding.
[0044] Step S100 Data Flow Monitoring: For Kubernetes cluster nodes, each node's operating system runs an eBPF program as a daemon process. The eBPF program monitors the data flow entering the node's Layer 4 proxy and monitors the current network operating status as monitoring information. The eBPF program also creates a data structure to record the availability status of the business load containers corresponding to each backend service.
[0045] Step S200 Data Stream Synchronization: When the eBPF program detects a data stream entering the fourth-layer agent, it synchronizes the data stream-related information and monitoring information to the Autoscaler component. It also determines whether the business load container of the backend service corresponding to the data stream exists through the records of the data structure. If it does not exist, it sends a scaling event notification to the Autoscaler component.
[0046] Step S300 Scaling Decision: Based on data flow related information, monitoring information, scaling event announcements, and the current status of the business-responsible containers of each backend service, the Autoscaler component makes a scaling decision on the business load container and returns a response to the eBPF program. Based on the response, the eBPF program updates its local data structure.
[0047] Step S400 Packet Forwarding: When the data stream entering the fourth-layer proxy establishes a connection with the eBPF program, the eBPF program makes a decision on packet forwarding based on the content recorded in the data structure. The packet is forwarded directly to the corresponding service load container, or the packet is forwarded to the user-space program and cached by the user-space program. When the Autoscaler component expands the service load container of the backend service related to the data stream and notifies the user-space program that the service load container is available, the user-space program forwards the packet to the service load container of its corresponding backend service.
[0048] As a specific implementation of the user-space program, the user-space program is the Envoy program. The data stream monitored by the fourth-layer agent is a TCP / UDP data stream.
[0049] As a specific implementation of the eBPF program, it includes an eBPF kernel-mode program and an eBPF user-mode program. The eBPF kernel-mode program monitors the data flow entering the node's Layer 4 proxy and monitors the current network operating status as monitoring information. It synchronizes the data flow-related information and monitoring information to the Autoscaler component. The eBPF kernel-mode program locally creates a data structure to record the availability status of the service load containers corresponding to each backend service. Based on the records in the local data structure, it determines whether there is a service load container for the backend service corresponding to the data flow. If not, it generates a scaling event notification and calls the eBPF user-mode program. The eBPF user-mode program sends the scaling event notification to the Autoscaler component based on the interface specifications of the Autoscaler component. When the data flow entering the Layer 4 proxy establishes a connection with the eBPF kernel-mode program, the eBPF kernel-mode program makes a decision on packet forwarding based on the content recorded in the data structure and calls the eBPF user-mode program based on the decision. The eBPF user-mode program forwards the data packet directly to the corresponding service load container or forwards the data packet to the user-mode program.
[0050] As a specific implementation of data forwarding, when a data packet reaches the eBPF kernel program of the eBPF program, the eBPF kernel program makes a decision on forwarding the data packet based on the record content of the data structure. If the service load container of the corresponding backend service does not meet the service conditions, the eBPF kernel program modifies the data packet, changes the data packet header to the data packet that will reach the user-space program, and stores the original information in the data packet in the socketbuffer structure. The modified data packet is then forwarded to the user-space program through the eBPF user-space program. The user-space program buffers the received data packets. When the user-space program receives a service load container availability notification from the Autoscaler component, it modifies the data packet header to the service load container that will reach the corresponding backend service and sends the modified data packet to the service load container of its corresponding backend service.
[0051] In this embodiment, the eBPF program runs continuously as a daemon process on the operating system of each Kubernetes (a Kubernetes, open-source container orchestration platform) node. This eBPF program consists of an eBPF kernel-mode program and an eBPF user-mode program. The eBPF kernel-mode program monitors the Layer 4 data streams entering the node, i.e., TCP / UDP data streams, and completes data reporting when the data stream is established. The eBPF user-mode program acts as a man-in-the-middle, recording data and facilitating data synchronization between the eBPF kernel-mode program and the Autoscaler component.
[0052] For eBPF programs, eBPF kernel-mode programs and eBPF user-mode programs have the following functions:
[0053] (1) The eBPF kernel program monitors each newly established Layer 4 data stream and synchronizes and records it with the Autoscaler component. When a service without a load container in the backend is captured by the kernel program, the kernel program will notify the Autoscaler component of the TCP / UDP ack information of the data stream and trigger the container creation process of the Autoscaler component.
[0054] (2) The eBPF kernel-mode program will also output the statistical information of the 4-layer data flow to the Autoscaler component for dynamically adjusting the number of backend load containers.
[0055] (3) eBPF kernel-mode programs can choose to continue sending subsequent data streams to user-mode programs or send them directly to the backend business load container.
[0056] (4) eBPF user-mode programs will notify the Autoscaler component of various events according to the data type from the kernel-mode program and the interface specification of the Autoscaler component.
[0057] A Layer 7 proxy runs in user space. Taking the Envoy program as an example, it exists as the queue-proxy component in the knative design. When a Layer 4 data stream connection TCP / UDP ack packet arrives at the eBPF kernel program, the eBPF kernel program modifies the packet header to match the packet destined for the user-space program Envoy and saves the original information in the kernel's information storage structure, socketbuffer. The user-space program Envoy temporarily stores the TCP / UDP ack packet based on notifications from the Autoscaler component and, after meeting certain conditions, modifies the TCP / UDP ack packet to the correct information before sending it to the appropriate workload container.
[0058] Based on the data packet forwarding method disclosed in this embodiment, taking the TCP three-way handshake as an example, the data packet forwarding steps are as follows:
[0059] (1) When the eBPF program detects the first connection packet in the TCP sync three-way handshake, if the service load container corresponding to the current TCP connection is zero, the eBPF program will forward the current TCP sync packet to the user-space Envoy program for temporary storage.
[0060] (2) After the corresponding service load container is started by the Autoscaler component, the Autoscaler component sends a notification to the Envoy program that the corresponding service load container has been started. The Envoy program modifies the temporarily stored data packets to the correct target IP and target port and then sends them to the started service load container.
[0061] (3) After the Autoscaler component starts the corresponding service load container, the eBPF program can hear that the corresponding service load container has been started. Subsequently, after the eBPF program takes over the same TCP sync data packet based on retry, it will directly forward the TCP sync data packet to the corresponding service load container that has been started.
[0062] (4) All subsequent identical TCP sync data will be directly forwarded by the eBPF program to the backend load container, without needing to be forwarded to the Envoy program for caching.
[0063] This embodiment uses an eBPF program to implement the ingress gateway function (a module in the knative functional design) in the knative design, and uses a gateway proxy in user space to implement the queue-proxy function. This method implements the automatic resource scaling capability of the Autoscaler component under the knative design framework. Based on an eBPF program, this method can complete automatic scaling faster, reduce the required components, and lower system complexity.
[0064] Example 2:
[0065] A knative automatic scaling system based on eBPF programs includes eBPF program components, an Autoscaler component, and user-space program components.
[0066] For Kubernetes cluster nodes, each node's operating system runs eBPF program components and user-space program components. The user-space program components act as the node's Layer 7 proxy, providing network proxy, load balancing, and service discovery functions, while the eBPF program components act as the node's Layer 4 proxy.
[0067] The eBPF program component performs the following actions through the eBPF program: monitoring the data flow entering the fourth-layer agent of the node and monitoring the current network operating status as monitoring information; and creating a data structure in the eBPF program to record the availability status of the business load containers corresponding to each backend service.
[0068] When the eBPF program detects a data flow entering the Layer 4 proxy, the eBPF program component performs the following actions: Synchronizes data flow-related information and monitoring information to the Autoscaler component, and determines whether a business load container corresponding to the backend service of the data flow exists based on the data structure records. If not, it sends a scaling event notification to the Autoscaler component. Correspondingly, the Autoscaler component performs the following actions: Based on the data flow-related information, monitoring information, scaling event notification, and the current status of the business load containers of each backend service, it makes a scaling decision for the business load container and returns a response to the eBPF program component. Correspondingly, the eBPF program component updates its local data structure based on the response.
[0069] When a data stream entering the fourth-layer proxy establishes a connection with an eBPF program, the eBPF program component performs the following actions: based on the content recorded in the data structure, it makes a decision on the forwarding of the data packet, either directly forwarding the data packet to the corresponding workload container or forwarding the data packet to the user-space program. Correspondingly, the user-space program component performs the following actions: caches the data packet, and when the Autoscaler component expands the workload container of the backend service related to the data stream and notifies the user-space program that the workload container is available, it forwards the data packet to the workload container of its corresponding backend service.
[0070] In this embodiment, as a specific implementation of the eBPF program, it includes an eBPF kernel-mode program and an eBPF user-mode program. The eBPF kernel-mode program is used to monitor the data flow entering the node's Layer 4 agent and monitor the current network operating status as monitoring information. It synchronizes the data flow-related information and monitoring information to the Autoscaler component. The eBPF kernel-mode program locally creates a data structure to record the availability status of the business load containers corresponding to each backend service, and determines whether a data flow exists based on the records in the local data structure. If the corresponding backend service's workload container does not exist, a scaling event notification is generated, and the eBPF user-space program is invoked. The eBPF user-space program is used to send a scaling event notification to the Autoscaler component based on the Autoscaler component's interface specification. When the data stream entering the fourth-layer proxy establishes a connection with the eBPF kernel-space program, the eBPF kernel-space program is used to make a decision on the forwarding of data packets based on the content recorded in the data structure, and invokes the eBPF user-space program based on the decision. The eBPF user-space program is used to forward the data packets directly to the corresponding workload container, or forward the data packets to the user-space program.
[0071] As a specific implementation of data forwarding, when a data packet reaches the eBPF kernel program of the eBPF program, the eBPF kernel program makes a decision on forwarding the data packet based on the record content of the data structure. If the service load container of the corresponding backend service does not meet the service conditions, the eBPF kernel program modifies the data packet, changes the data packet header to the data packet that will reach the user-space program, and stores the original information in the data packet in the socketbuffer structure. The modified data packet is then forwarded to the user-space program through the eBPF user-space program. The user-space program buffers the received data packets. When the user-space program receives a service load container availability notification from the Autoscaler component, it modifies the data packet header to the service load container that will reach the corresponding backend service and sends the modified data packet to the service load container of its corresponding backend service.
[0072] As a specific implementation of the user-space program, the user-space program is the Envoy program. The data stream monitored by the fourth-layer agent is a TCP / UDP data stream.
[0073] As a specific implementation of the eBPF program, it includes an eBPF kernel-mode program and an eBPF user-mode program. The eBPF kernel-mode program monitors the data flow entering the node's Layer 4 proxy and monitors the current network operating status as monitoring information. It synchronizes the data flow-related information and monitoring information to the Autoscaler component. The eBPF kernel-mode program locally creates a data structure to record the availability status of the service load containers corresponding to each backend service. Based on the records in the local data structure, it determines whether there is a service load container for the backend service corresponding to the data flow. If not, it generates a scaling event notification and calls the eBPF user-mode program. The eBPF user-mode program sends the scaling event notification to the Autoscaler component based on the interface specifications of the Autoscaler component. When the data flow entering the Layer 4 proxy establishes a connection with the eBPF kernel-mode program, the eBPF kernel-mode program makes a decision on packet forwarding based on the content recorded in the data structure and calls the eBPF user-mode program based on the decision. The eBPF user-mode program forwards the data packet directly to the corresponding service load container or forwards the data packet to the user-mode program.
[0074] As a specific implementation of data forwarding, when a data packet reaches the eBPF kernel program of the eBPF program, the eBPF kernel program makes a decision on forwarding the data packet based on the record content of the data structure. If the service load container of the corresponding backend service does not meet the service conditions, the eBPF kernel program modifies the data packet, changes the data packet header to the data packet that will reach the user-space program, and stores the original information in the data packet in the socketbuffer structure. The modified data packet is then forwarded to the user-space program through the eBPF user-space program. The user-space program buffers the received data packets. When the user-space program receives a service load container availability notification from the Autoscaler component, it modifies the data packet header to the service load container that will reach the corresponding backend service and sends the modified data packet to the service load container of its corresponding backend service.
[0075] In this embodiment, the eBPF program runs continuously as a daemon process on the operating system of each Kubernetes (a Kubernetes, open-source container orchestration platform) node. This eBPF program consists of an eBPF kernel-mode program and an eBPF user-mode program. The eBPF kernel-mode program monitors the Layer 4 data streams entering the node, i.e., TCP / UDP data streams, and completes data reporting when the data stream is established. The eBPF user-mode program acts as a man-in-the-middle, recording data and facilitating data synchronization between the eBPF kernel-mode program and the Autoscaler component.
[0076] For eBPF programs, eBPF kernel-mode programs and eBPF user-mode programs have the following functions:
[0077] (1) The eBPF kernel program monitors each newly established Layer 4 data stream and synchronizes and records it with the Autoscaler component. When a service without a load container in the backend is captured by the kernel program, the kernel program will notify the Autoscaler component of the TCP / UDP ack information of the data stream and trigger the container creation process of the Autoscaler component.
[0078] (2) The eBPF kernel-mode program will also output the statistical information of the 4-layer data flow to the Autoscaler component for dynamically adjusting the number of backend load containers.
[0079] (3) eBPF kernel-mode programs can choose to continue sending subsequent data streams to user-mode programs or send them directly to the backend business load container.
[0080] (4) eBPF user-mode programs will notify the Autoscaler component of various events according to the data type from the kernel-mode program and the interface specification of the Autoscaler component.
[0081] The user-space program Envoy exists as a queue-proxy component in the knative design. When a Layer 4 data stream connection TCP / UDP ACK packet arrives at the eBPF kernel program, the eBPF kernel program modifies the packet header to match the data packet destined for Envoy and stores the original information in the kernel's information storage structure, socketbuffer. Envoy temporarily stores the TCP / UDP ACK packet based on notifications from the Autoscaler component and, after meeting certain conditions, modifies the TCP / UDP ACK packet to the correct information before sending it to the appropriate workload container.
[0082] The system in this embodiment can execute the method disclosed in Embodiment 1 to achieve automatic capacity expansion.
[0083] The present invention has been shown and described in detail above with reference to the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art will know that more embodiments of the present invention can be obtained by combining the means in the different embodiments described above, and these embodiments are also within the protection scope of the present invention.
Claims
1. A knative automatic scaling method based on eBPF programs, characterized in that, This implementation uses eBPF programs, the Autoscaler component, and user-space programs to achieve automatic scaling based on the Knative specification. The user-space programs act as Layer 7 proxies for nodes, providing network proxy, load balancing, and service discovery capabilities. The implementation includes the following steps: Data flow monitoring: For Kubernetes cluster nodes, each node's operating system runs an eBPF program as a daemon process. The eBPF program monitors the data flow entering the node's Layer 4 proxy and monitors the current network operating status as monitoring information. The eBPF program also creates a data structure to record the availability status of the business load containers corresponding to each backend service. Data Stream Synchronization: When the eBPF program detects a data stream entering the fourth-layer proxy, it synchronizes the data stream-related information and monitoring information to the Autoscaler component. It also uses the data structure records to determine whether there is a business load container for the backend service corresponding to the data stream. If not, it sends a scaling event notification to the Autoscaler component. Scaling decision: Based on data flow information, monitoring information, scaling event announcements, and the current status of the business-responsible containers of each backend service, the Autoscaler component makes a scaling decision for the business load container and returns a response to the eBPF program. Based on the response, the eBPF program updates its local data structure. Packet forwarding: When a data stream entering the fourth-layer proxy establishes a connection with an eBPF program, the eBPF program makes a decision on packet forwarding based on the content recorded in the data structure. The packet is either forwarded directly to the corresponding workload container, or forwarded to the user-space program and cached by the user-space program. When the Autoscaler component expands the workload container of the backend service related to the data stream and notifies the user-space program that the workload container is available, the user-space program forwards the packet to the workload container of its corresponding backend service.
2. The knative automatic expansion method based on eBPF program according to claim 1, characterized in that, The eBPF program includes an eBPF kernel-mode program and an eBPF user-mode program; The eBPF kernel-mode program is used to monitor the data flow entering the node's fourth-layer agent and monitor the current network operation status as monitoring information. It also synchronizes the data flow-related information and monitoring information to the Autoscaler component. The eBPF kernel-mode program creates a local data structure to record the availability status of the business load containers corresponding to each backend service. Based on the records in the local data structure, it determines whether there is a business load container for the backend service corresponding to the data flow. If not, it generates a scaling event notification and calls the eBPF user-mode program. The eBPF user-mode program is used to send scaling event notifications to the Autoscaler component based on the interface specification of the Autoscaler component. When the data stream entering the fourth-layer agent establishes a connection with the eBPF kernel program, the eBPF kernel program makes decisions on the forwarding of data packets based on the content recorded in the data structure, and calls the eBPF user program based on the decisions. The eBPF user program is used to forward the data packets directly to the corresponding service load container, or to forward the data packets to the user program.
3. The knative automatic expansion method based on eBPF program according to claim 1, characterized in that, When a data packet reaches the eBPF kernel program of the eBPF program, the eBPF kernel program makes a decision on forwarding the data packet based on the record content of the data structure. If the business load container of the backend service corresponding to the data packet does not meet the service conditions, the eBPF kernel program modifies the data packet, changes the data packet header to the data packet that will reach the user-space program, and stores the original information in the data packet in the structure socketbuffer. The modified data packet is then forwarded to the user-space program by the eBPF user program. The user-space program buffers the received data packets. When the user-space program receives a notification from the Autoscaler component that the load balancing container is available, it modifies the data packet header to indicate that the load balancing container for the corresponding backend service has been reached, and then sends the modified data packet to the load balancing container of the corresponding backend service.
4. The knative automatic expansion method based on eBPF program according to claim 1, characterized in that, The user-space program uses the Envoy program, which is an open-source, high-performance proxy.
5. The knative automatic expansion method based on eBPF program according to claim 1, characterized in that, The data stream is a TCP / UDP data stream.
6. A knative automatic expansion system based on eBPF programs, characterized in that, The system is used to implement automatic scaling based on the knative specification through an eBPF program-based knative automatic scaling method as described in any one of claims 1-5, the system comprising an eBPF program component, an Autoscaler component, and a user-space program component. For Kubernetes cluster nodes, each node's operating system runs eBPF program components and user-space program components. The user-space program components act as the node's Layer 7 proxy, providing network proxy, load balancing, and service discovery functions, while the eBPF program components act as the node's Layer 4 proxy. The eBPF program component performs the following actions through the eBPF program: monitoring the data flow entering the fourth-layer agent of the node, monitoring the current network operating status as monitoring information, and creating a data structure in the eBPF program to record the availability status of the business load containers corresponding to each backend service. When the eBPF program detects a data flow entering the fourth-layer proxy, the eBPF program component performs the following actions: Synchronizes data flow-related information and monitoring information to the Autoscaler component, and determines whether a business load container for the corresponding backend service exists based on the data structure records. If not, it sends a scaling event notification to the Autoscaler component. Correspondingly, the Autoscaler component performs the following actions: Based on data flow-related information, monitoring information, scaling event notification, and the current status of the business load containers for each backend service, it makes a scaling decision for the business load container and returns a response to the eBPF program component. Correspondingly, the eBPF program component updates its local data structure based on the response. When a data stream entering the fourth-layer proxy establishes a connection with an eBPF program, the eBPF program component performs the following actions: based on the content recorded in the data structure, it makes a decision on the forwarding of the data packet, either directly forwarding the data packet to the corresponding workload container or forwarding the data packet to the user-space program. Correspondingly, the user-space program component performs the following actions: caches the data packet, and when the Autoscaler component expands the workload container of the backend service related to the data stream and notifies the user-space program that the workload container is available, it forwards the data packet to the workload container of its corresponding backend service.
7. The knative automatic expansion system based on eBPF program according to claim 6, characterized in that, The eBPF program includes an eBPF kernel-mode program and an eBPF user-mode program; The eBPF kernel-mode program is used to monitor the data flow entering the node's fourth-layer agent and monitor the current network operation status as monitoring information. It also synchronizes the data flow-related information and monitoring information to the Autoscaler component. The eBPF kernel-mode program creates a local data structure to record the availability status of the business load containers corresponding to each backend service. Based on the records in the local data structure, it determines whether there is a business load container for the backend service corresponding to the data flow. If not, it generates a scaling event notification and calls the eBPF user-mode program. The eBPF user-mode program is used to send scaling event notifications to the Autoscaler component based on the interface specification of the Autoscaler component. When the data stream entering the fourth-layer agent establishes a connection with the eBPF kernel program, the eBPF kernel program makes decisions on the forwarding of data packets based on the content recorded in the data structure, and calls the eBPF user program based on the decisions. The eBPF user program is used to forward the data packets directly to the corresponding service load container, or to forward the data packets to the user program.
8. The knative automatic expansion system based on eBPF program according to claim 6, characterized in that, When a data packet reaches the eBPF kernel program of the eBPF program, the eBPF kernel program makes a decision on forwarding the data packet based on the record content of the data structure. If the business load container of the backend service corresponding to the data packet does not meet the service conditions, the eBPF kernel program modifies the data packet, changes the data packet header to the data packet that will reach the user-space program, and stores the original information in the data packet in the structure socketbuffer. The modified data packet is then forwarded to the user-space program by the eBPF user program. The user-space program buffers the received data packets. When the user-space program receives a notification from the Autoscaler component that the load balancing container is available, it modifies the data packet header to indicate that the load balancing container for the corresponding backend service has been reached, and then sends the modified data packet to the load balancing container of the corresponding backend service.
9. The knative automatic expansion system based on eBPF program according to claim 6, characterized in that, The user-space program uses the Envoy program, which is an open-source, high-performance proxy.
10. The knative automatic expansion system based on eBPF program according to claim 6, characterized in that, The data stream is a TCP / UDP data stream.
Citation Information
Patent Citations
EBPF-based cloud service topology self-discovery method and system, electronic equipment and storage medium
CN112564967A
Firewall management method and system based on eBPF
CN113949537A