On-demand operation method of controller and related equipment
By combining modular design of the controller and asynchronous working mode, on-demand operation in the scenario of resource scarcity is achieved, the problems of high resource occupation and complex reconstruction tasks in the existing technology are solved, and resource utilization and management efficiency are improved.
Patent Information
- Application Number
- CN202411997664.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2044-12-31
AI Technical Summary
In the prior art, in the scenario of resource scarcity, the controller cannot operate on demand, resulting in high resource utilization, complex and time-consuming reconstruction tasks that are difficult to bear.
By modularly designing the controller to be run, the parent controller and multiple child controllers are obtained, and the child controller is allowed to work asynchronously. The parent controller receives the asynchronous request of the child controller and returns the execution result, adding the child controller's tasks to the work queue, so that the parent controller can execute tasks according to the queue. In addition, the child controller is compiled into executable machine code, caches it to disk, and maps the code to memory through file mapping, and the parent controller is responsible for uninstalling the child controller code that has not been used for a long time.
It realizes on-demand operation of cluster controllers in resource scarcity scenarios, reduces resource usage, simplifies the expansion and management of control plane components, and reduces complexity and time-consuming.
Smart Images

Figure CN119946035A_ABST
Abstract
Description
Background Art
[0002] WebAssembly (WASM for short) is a new code format created for the web, designed to enable portable binary code execution to improve the performance of applications on the web. With the evolution of technology, WASM has also begun to expand beyond browsers. For example, with the help of the WebAssembly system interface WASI, WASM can run on servers and cloud computing environments. This has promoted the implementation of edge computing and decentralized applications (DApps), bringing new possibilities to modern application development.
[0003] In related technologies, as computing tasks tend to be performed at the edge, supporting components such as the container orchestration system Kubernetes are also gradually moving to the edge. However, current methods have the following problems: lack of methods to extend control plane components using WebAssembly; need the controller to run continuously and occupy memory resources continuously; need to reconstruct Kubernetes core components, which is a complex and time-consuming task that not all organizations can afford and is difficult to apply.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present disclosure provides a controller on-demand operation method, system, device, equipment, medium and computing program, which at least to a certain extent overcomes the problem in the related art that the controller cannot be operated on-demand in resource-scarce scenarios.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] According to one aspect of the present disclosure, a controller on-demand operation method is provided, comprising: modularly designing a controller to be operated to obtain a parent controller and multiple sub-controllers, wherein the multiple sub-controllers work in an asynchronous manner, and the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; adding the tasks to be executed of each sub-controller to a work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue.
[0008] In some embodiments, the method further includes: compiling each sub-controller into executable machine code and caching it on a disk; mapping the executable machine code on the disk to memory by means of file mapping; wherein the parent controller is also used to unload the executable machine code corresponding to the sub-controller on the disk that has not been used for more than a preset time to the hard disk.
[0009] In some embodiments, the controller to be run is a Kubernetes controller; wherein, the controller to be run is modularly designed to obtain a parent controller and multiple child controllers, including: modularly designing the Kubernetes controller based on the WebAssembly framework to obtain a parent controller and multiple child controllers corresponding to the Kubernetes controller, wherein each child controller corresponds to a WASM instance, and the parent controller starts the corresponding child controller by calling the Start function provided by each WASM instance.
[0010] In some embodiments, the method further includes: customizing an HTTP host function, wherein the HTTP host function is used for the parent controller to interact with each child controller.
[0011] According to another aspect of the present disclosure, a control system is also provided, including: a control engine, a parent controller and multiple sub-controllers working in an asynchronous manner; wherein the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; the control engine is used to add the to-be-executed tasks of each sub-controller to a work queue, so that the parent controller executes the to-be-executed tasks of each sub-controller according to the work queue.
[0012] In some embodiments, the parent controller and the multiple child controllers are obtained by modularly designing the Kubernetes controller based on the WebAssembly framework, wherein each child controller corresponds to a WASM instance, and the parent controller starts the corresponding child controller by calling the Start function provided by each WASM instance.
[0013] According to another aspect of the present disclosure, a controller on-demand operation device is also provided, including: a controller modular design module, used to perform modular design on the controller to be operated, to obtain a parent controller and multiple sub-controllers, wherein the multiple sub-controllers work in an asynchronous manner, and the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; a to-be-executed task adding module, used to add the to-be-executed tasks of each sub-controller to a work queue, so that the parent controller executes the to-be-executed tasks of each sub-controller according to the work queue.
[0014] According to another aspect of the present disclosure, an electronic device is also provided, which includes: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the controller on-demand operation methods described above by executing the executable instructions.
[0015] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the controller on-demand operation method described in any one of the above is implemented.
[0016] According to another aspect of the present disclosure, a computer program product is also provided, including a computer program, wherein when the computer program is executed by a processor, the controller on-demand operation method described above is implemented.
[0017] The controller on-demand operation method, system, device, equipment, medium and computing program provided in the embodiments of the present disclosure perform modular design on the controller to be operated, thereby obtaining a parent controller and multiple sub-controllers, and adding the tasks to be executed of each sub-controller to a work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue. The embodiments of the present disclosure can realize the on-demand operation of the cluster controller in a scenario with scarce resources.
[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0020] Figure 1 A schematic diagram of an exemplary application system architecture to which the controller on-demand operation method in an embodiment of the present disclosure can be applied is shown;
[0021] Figure 2 A schematic diagram of interaction between a parent controller and a child controller in an embodiment of the present disclosure is shown;
[0022] Figure 3 A flow chart of a controller on-demand operation method in an embodiment of the present disclosure is shown as follows: Figure 3 As shown;
[0023] Figure 4A schematic diagram of an on-demand operation interaction process of a controller in an embodiment of the present disclosure is shown;
[0024] Figure 5 A schematic diagram of a controller on-demand operation system in an embodiment of the present disclosure is shown;
[0025] Figure 6 A schematic diagram of a controller on-demand operation device in an embodiment of the present disclosure is shown;
[0026] Figure 7 A structural block diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0027] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0028] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0029] For ease of understanding, before introducing the embodiments of the present disclosure, several terms involved in the embodiments of the present disclosure are first explained as follows:
[0030] WASI: WebAssembly System Interface, a standardized interface designed to enable WebAssembly (WASM) to run in any environment, not just in browsers. WASI defines a set of system calls and application program interface APIs that enable WASM modules to access operating system resources such as the file system, network, and time. The existence of this interface allows developers to write code once and run it on different platforms and environments, such as servers, IoT devices, and embedded systems, thereby increasing the scope and flexibility of WebAssembly.
[0031] DApps: Decentralized applications are software applications that run on blockchain or other distributed networks. Unlike traditional centralized applications, DApps do not rely on a single server or centralized control, but operate through multiple nodes in a distributed network. This architecture improves security and transparency because data and operation records are stored on the blockchain and are difficult to tamper with.
[0032] Serverless: Serverless architecture technology is a cloud computing model where developers do not need to manage the setup and maintenance of underlying servers. Instead, they deploy the code to the cloud provider's management platform, which automatically allocates resources and executes the code. The cloud provider dynamically allocates computing resources on demand and charges based on actual usage. This technology simplifies application development and operation and improves scalability and flexibility.
[0033] WASMtime: Web Assembly Time is a fast and lightweight WebAssembly runtime designed to enable WebAssembly modules to run efficiently in a variety of environments. It supports WASI, allowing developers to write WebAssembly code to run on different platforms, such as local computers, servers, and embedded devices. WASMtime focuses on performance and security, and is suitable for developing efficient and portable applications.
[0034] The specific implementation of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0035] Figure 1 FIG. 1 shows an exemplary application system architecture diagram to which the controller on-demand operation method in the embodiment of the present disclosure can be applied. Figure 1 As shown, the system architecture may include: control plane nodes and worker nodes, wherein the control plane nodes adopt Kubernetes key logic, which may include distributed key-value storage etcd and application programming interface server API server, which are responsible for the basic management and state storage of the cluster; the worker nodes adopt WASM controller logic, which may include a parent controller and several child controllers, which implement the extended logic of the control plane, especially for the optimization of edge computing environment, wherein the child controller is a WASM instance embedded in the parent controller WASMtime.
[0036] It should be noted that Figure 1 The number of sub-controllers shown in the figure is for exemplary purposes only, and the embodiments of the present disclosure do not specifically limit the number of sub-controllers.
[0037] In one embodiment of the present disclosure, specifically, etcd is a distributed key-value storage system of the container orchestration system Kubernetes, which is used to store cluster status information; the API server is one of the core components of Kubernetes, responsible for processing all requests and responses to cluster status; the parent controller is a main controller, responsible for coordinating and managing the work of the sub-controllers, and is built based on the controller logic of WASM; the sub-controllers are lightweight WASM modules that can be started on demand to perform specific tasks or respond to events. These modules will be uninstalled after completing the task, thereby reducing resource usage.
[0038] In one embodiment of the present disclosure, kernel isolation is performed between the control plane node and the working node through a physical machine or a virtual machine, that is, isolation based on the underlying hardware or virtualization layer; process isolation is performed between etcd and the API server in the control plane node and between the parent controller and the child controller as a whole in the working node through containers, that is, process isolation implemented based on container technology; functional isolation is performed between the parent controller and the child controller in the working node through a WASM module, that is, functional isolation implemented based on WASM technology, ensuring that each WASM module can run in an independent environment, thereby improving security and resource utilization.
[0039] In one embodiment of the present disclosure, the parent controller is mainly responsible for managing the asynchronous operations of several child controllers and uninstalling child controllers that have been inactive for a long time. The parent controller mainly includes the following three components: a WASM engine, a host function exposed to a WASM instance, and a work queue.
[0040] In one embodiment of the present disclosure, in the related art, when the system memory is insufficient, the operating system can swap part of the memory data to the disk to free up memory space, but not all systems enable this swap function. In the embodiment of the present disclosure, the WASM engine expands the original WASM runtime WASMtime and adds a customized unloading and disk swapping function, thereby enabling the unloading and swapping operations of the WASM module even when the system does not enable the swapping function.
[0041] In one embodiment of the present disclosure, in the related art, traditional WASMtime may perform just-in-time compilation when loading WASM modules, which may easily cause additional consumption of memory and CPU resources. In the embodiment of the present disclosure, the WASM engine compiles the new WASM module into machine code in advance to reduce the memory consumption of the runtime compiler, and caches the compiled module to the disk. When the same WASM module is needed again, the compiled version can be loaded directly from the disk without repeating the compilation process, further improving efficiency.
[0042] In one embodiment of the present disclosure, the WASM module can be initialized and started by mapping files to memory and providing necessary communication tools. File mapping technology is a method of mapping files or other objects to memory address space. At the same time, the engine also provides necessary communication tools to ensure that the WASM module can interact correctly with the host environment. It should be noted that the specific types of the above-mentioned file mapping technology and communication tools can be determined according to actual conditions, and the embodiments of the present disclosure do not specifically limit this.
[0043] In one embodiment of the present disclosure, for a sub-controller in an idle state (for example, a component or thread in a WASM module), the WASM engine can selectively release its related memory resources to effectively reduce memory usage. If this part of the memory needs to be accessed again, the kernel will trigger data reloading and reload the corresponding file into the memory.
[0044] In one embodiment of the present disclosure, a host function refers to a function exposed by a WASM engine to a WASM instance, and WASI is a standardized set of host functions. However, since the WASI specification in the related art does not support Hypertext Transfer Protocol (HTTP) communication between a Kubernetes controller and a Kubernetes API server, a custom HTTP host function is introduced in an embodiment of the present disclosure.
[0045] In one embodiment of the present disclosure, a work queue is used to manage and schedule tasks or jobs to be processed, so that these tasks can be queued in a certain order and wait for processing.
[0046] In one embodiment of the present disclosure, each sub-controller is a single-threaded asynchronous WASM instance, and the parent controller starts the sub-controller by calling the Start function provided by the WASM module. The startup function Start function will start the coordination loop of the sub-controller, which sends an asynchronous request to the parent controller and waits for the execution result. Once the request is completed, the parent controller returns the execution result to the sub-controller, so that it can complete the associated asynchronous request and restart the entire coordination process.
[0047] In one embodiment of the present disclosure, Figure 2 A schematic diagram of interaction between a parent controller and a child controller in an embodiment of the present disclosure is shown. Figure 2As shown in the figure, the low-level part of kube-rs is used to implement the Kubernetes host function, while the high-level kube-rs functions are implemented in the child operator. In addition, the added host function is an asynchronous function. Among them, the kube-rs library is a Kubernetes client library written in Rust language, which provides the function of interacting with the Kubernetes API; the standard library std-libs refers to the standard library of the programming language, which contains a series of predefined functions, classes and other resources to support common programming tasks, such as input and output, string processing, data structures, etc.
[0048] In one embodiment of the present disclosure, the operation logic is the top layer of the entire WASM-based Kubernetes control plane architecture, responsible for coordinating and managing all operations; the WASI target with std-libs represents the WASI target that uses the standard library std-libs to ensure that the WASM module can interact with the host environment; the kube-rs high-level library, that is, the high-level functions of kube-rs implemented in the sub-operator, is responsible for more complex business logic and operations; the custom client library is a customized client library for specific client operations and functions; the WASI host function is a host function based on the WASI interface, which provides system-level functions such as file operations, network communications, etc.; the HTTP host function is a host function implemented through the HTTP protocol, which is responsible for processing HTTP requests and responses, and the HTTP host function is asynchronous to improve response speed and efficiency; the kube-rs low-level library uses the low-level part of kube-rs to implement Kubernetes host functions, which usually involve underlying resource management and operations; the network logic is responsible for processing network-related operations, including data transmission and communication.
[0049] In one embodiment of the present disclosure, the parent controller is responsible for overall coordination and management, and schedules the sub-controller through the WASM engine, and then sends instructions or data to the sub-controller to start or schedule the sub-controller to perform specific tasks; the sub-controller receives the instructions or data from the parent controller to perform specific tasks or respond to events, and feeds back the execution results or status information to the parent controller. Figure 2 As shown, the arrow from top to bottom may refer to the direction from the child controller to the parent controller, which can usually be used to indicate that the child controller sends data or status information to the parent controller; the arrow from bottom to top may refer to the direction from the parent controller to the child controller, which can usually be used to indicate that the parent controller sends instructions or data to the child controller. The disclosed embodiments ensure efficient resource management and fast response capabilities, especially in edge computing environments, and can flexibly handle various asynchronous tasks and environmental interactions.
[0050] Figure 3A flow chart of a controller on-demand operation method in an embodiment of the present disclosure is shown as follows: Figure 3 As shown, the method comprises the following steps:
[0051] S302, modular design is performed on the controller to be run to obtain a parent controller and multiple sub-controllers, wherein the multiple sub-controllers work in an asynchronous manner, and the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller.
[0052] In one embodiment of the present disclosure, a modular design is performed on the controller to be run currently, and it can be designed as a parent controller and several sub-controllers. The sub-controllers can all work in an asynchronous manner. The parent controller can be used to receive asynchronous requests sent by each sub-controller and return the execution results to the sub-controllers.
[0053] S304, adding the tasks to be executed of each sub-controller to the work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue.
[0054] In one embodiment of the present disclosure, the sub-controller adds the tasks to be executed to the work queue, and the parent controller executes the tasks to be executed of each sub-controller according to the order in the work queue. At the same time, the execution result can be returned to the corresponding sub-controller after the task execution is completed.
[0055] As can be seen from the above, the disclosed embodiment performs modular design on the controller to be run, thereby obtaining a parent controller and multiple sub-controllers, and adding the tasks to be executed of each sub-controller to a work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue. The disclosed embodiment can realize the on-demand operation of the cluster controller in a scenario with scarce resources.
[0056] In one embodiment of the present disclosure, the method also includes: compiling each sub-controller into executable machine code and caching it on the disk; mapping the executable machine code on the disk to the memory by means of file mapping; wherein the parent controller is also used to unload the executable machine code corresponding to the sub-controller on the disk that has not been used for more than a preset time to the hard disk.
[0057] In one embodiment of the present disclosure, the WASM engine compiles each sub-controller (i.e., a new WASM module) into executable machine code in advance to reduce the need for runtime compilation, and caches the compiled machine code on disk for subsequent reuse, thereby reducing the time and resource consumption of repeated compilation. At the same time, through file mapping technology, the executable machine code on disk can be directly mapped to the address space of the process, so that the code can be executed directly from the memory without explicitly reading it into the memory buffer.
[0058] It should be noted that file mapping is an efficient I / O operation mode, which allows the operating system to directly map file content to virtual memory, so that the application can directly operate the file data by accessing the memory. The appropriate file mapping technology can be selected according to the actual situation, and the embodiment of the present disclosure does not specifically limit the type of file mapping technology used.
[0059] In one embodiment of the present disclosure, the controller to be run is a Kubernetes controller; wherein, the controller to be run is modularly designed to obtain a parent controller and multiple child controllers, including: modularly designing the Kubernetes controller based on the WebAssembly framework to obtain a parent controller and multiple child controllers corresponding to the Kubernetes controller, wherein each child controller corresponds to a WASM instance, and the parent controller starts the corresponding child controller by calling the Start function provided by each WASM instance.
[0060] In one embodiment of the present disclosure, the traditional Kubernetes controller is an integrated component responsible for managing changes in cluster state. Through modular design, the Kubernetes controller can be split into multiple smaller and more independent sub-controllers. After the modular design of the Kubernetes controller based on the WebAssembly framework, each sub-controller is designed as an independent WASM instance, which means that they can be quickly loaded and executed when needed, and can be unloaded immediately after completing the task, thereby saving resources; the parent controller starts the corresponding sub-controller by calling the Start function provided by each WASM instance. This method allows the parent controller to programmatically precisely control when to start which sub-controller, increasing flexibility and responsiveness. The efficiency and isolation of WASM make this design very suitable for resource-constrained environments, significantly reducing the resource usage of the control plane, allowing Kubernetes to be deployed in resource-constrained environments such as edge and fog computing.
[0061] In one embodiment of the present disclosure, by separating different control logics into independent WASM instances, the corresponding functions can be dynamically adjusted according to actual needs to be activated or deactivated. At the same time, since the sub-controller is started on demand and can be uninstalled immediately after the task is completed, it is possible to add and delete sub-controllers without interfering with other active sub-controllers, reducing memory usage and other resource consumption. In addition, WASM provides a sandbox environment, that is, isolation is provided based on the WASM engine, which enhances security, prevents potential conflicts between different sub-controllers, and eliminates the overhead caused by container isolation.
[0062] In one embodiment of the present disclosure, the method further includes: customizing an HTTP host function, wherein the HTTP host function is used to enable the parent controller to interact with each child controller.
[0063] In one embodiment of the present disclosure, the HTTP host function is a host function implemented by the HTTP protocol, which is responsible for processing HTTP requests and responses. The HTTP host function is asynchronous to improve response speed and efficiency. Through the HTTP host function, a new sub-controller can be integrated into an existing system by simply adding a new HTTP endpoint without modifying the parent controller or other sub-controllers. At the same time, the parent controller can efficiently interact with multiple sub-controllers to maintain good performance and security.
[0064] Figure 4 A schematic diagram of a controller on-demand operation interaction process in an embodiment of the present disclosure is shown. Figure 4 As shown in the figure, in this process, the parent controller manages the asynchronous operations of the child controller and unloads it to the hard disk when the child controller is inactive for a long time. Among them, the WASM engine is responsible for managing and scheduling the execution of the child controller, the event loop is responsible for processing asynchronous operations and coordinating task execution, the work queue is used to store pending asynchronous operations, and the host function provides an interface for interacting with the host environment.
[0065] In one embodiment of the present disclosure, the process includes the following steps:
[0066] Step ① The WASM engine starts and calls the main function of the sub-controller, that is, executes the main function of the sub-controller through the entry point of the WASM engine. The main function can usually be a function for initialization or execution of a specific task.
[0067] Step ② The sub-controller interacts with the host environment by calling the host functions provided by the WASM engine, such as reading files, sending network requests, etc.
[0068] Step ③ The sub-controller starts asynchronous operations and adds them to the work queue. These operations may include file I / O, network requests, etc.
[0069] Step ④ The sub-controller returns control to the WASM engine and waits for further processing.
[0070] Step ⑤ After the WASM engine has executed all synchronization logic, it stops executing and returns control to the event loop. Synchronous logic refers to operations that do not need to wait for external resources.
[0071] Step ⑥ The event loop checks whether the asynchronous operation in the work queue has been completed. If the operation has been completed, step ⑦ is executed.
[0072] In one embodiment of the present disclosure, the event loop is a core concept in the serverless architecture. The event loop continuously detects whether there are operations completed in the work queue and passes the results to the WASM engine.
[0073] Step 7: The event loop passes the completed operation results to the WASM engine.
[0074] Step ⑧ The WASM engine checks whether the sub-controller has been uninstalled. If it has been uninstalled, the sub-controller is reloaded and a new set of synchronization operations is performed.
[0075] In one embodiment of the present disclosure, the execution subject of the above steps is a parent controller, and the parent controller will continuously repeat the above process to ensure that the child controller can continuously execute tasks and respond to environmental changes.
[0076] Figure 5 A schematic diagram of a controller on-demand operation system in an embodiment of the present disclosure is shown. Figure 5 As shown, the system may include: a control engine, a parent controller, and multiple child controllers working in an asynchronous manner.
[0077] Among them, the parent controller is used to receive asynchronous requests sent by each child controller and return execution results to each child controller; the control engine is used to add the pending tasks of each child controller to the work queue, so that the parent controller executes the pending tasks of each child controller according to the work queue.
[0078] As can be seen from the above, the disclosed embodiment can modularly design the controller to be run, thereby obtaining a parent controller and multiple sub-controllers, and adding the tasks to be executed of each sub-controller to a work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue. The disclosed embodiment can realize the on-demand operation of the cluster controller in a scenario with scarce resources.
[0079] In one embodiment of the present disclosure, a parent controller and multiple sub-controllers are obtained by modularly designing a Kubernetes controller based on a WebAssembly framework, wherein each sub-controller corresponds to a WASM instance, and the parent controller starts the corresponding sub-controller by calling a Start function provided by each WASM instance.
[0080] Based on the same inventive concept, the embodiment of the present disclosure also provides a controller on-demand operation device, as described in the following embodiment. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0081] Figure 6A schematic diagram of a controller on-demand operation device in an embodiment of the present disclosure is shown. Figure 6 As shown, the device includes: a controller modular design module 601 and a to-be-executed task adding module 602.
[0082] Among them, the controller modular design module 601 is used to perform modular design on the running controller to obtain a parent controller and multiple sub-controllers, wherein the multiple sub-controllers work in an asynchronous manner, and the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; the to-be-executed task adding module 602 is used to add the to-be-executed tasks of each sub-controller to the work queue, so that the parent controller executes the to-be-executed tasks of each sub-controller according to the work queue.
[0083] As can be seen from the above, the disclosed embodiment can modularly design the controller to be run, thereby obtaining a parent controller and multiple sub-controllers, and adding the tasks to be executed of each sub-controller to a work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue. The disclosed embodiment can realize the on-demand operation of the cluster controller in a scenario with scarce resources.
[0084] In one embodiment of the present disclosure, the device also includes: a machine code mapping module 603, which is used to compile each sub-controller into executable machine code and cache it to the disk; map the executable machine code in the disk to the memory through file mapping; wherein the parent controller is also used to unload the executable machine code corresponding to the sub-controller that has not been used for more than a preset time in the disk to the hard disk.
[0085] In one embodiment of the present disclosure, the WASM engine compiles each sub-controller (i.e., a new WASM module) into executable machine code in advance to reduce the need for runtime compilation, and caches the compiled machine code on disk for subsequent reuse, thereby reducing the time and resource consumption of repeated compilation. At the same time, through file mapping technology, the executable machine code on disk can be directly mapped to the address space of the process, so that the code can be executed directly from the memory without explicitly reading it into the memory buffer.
[0086] It should be noted that file mapping is an efficient I / O operation mode, which allows the operating system to directly map file content to virtual memory, so that the application can directly operate the file data by accessing the memory. The appropriate file mapping technology can be selected according to the actual situation, and the embodiment of the present disclosure does not specifically limit the type of file mapping technology used.
[0087] In one embodiment of the present disclosure, the controller to be run is a Kubernetes controller; wherein, the controller to be run is modularly designed to obtain a parent controller and multiple child controllers, including: modularly designing the Kubernetes controller based on the WebAssembly framework to obtain a parent controller and multiple child controllers corresponding to the Kubernetes controller, wherein each child controller corresponds to a WASM instance, and the parent controller starts the corresponding child controller by calling the Start function provided by each WASM instance.
[0088] In one embodiment of the present disclosure, the traditional Kubernetes controller is an integrated component responsible for managing changes in cluster state. Through modular design, the Kubernetes controller can be split into multiple smaller and more independent sub-controllers. After the modular design of the Kubernetes controller based on the WebAssembly framework, each sub-controller is designed as an independent WASM instance, which means that they can be quickly loaded and executed when needed, and can be unloaded immediately after completing the task, thereby saving resources; the parent controller starts the corresponding sub-controller by calling the Start function provided by each WASM instance. This method allows the parent controller to programmatically precisely control when to start which sub-controller, increasing flexibility and responsiveness. The efficiency and isolation of WASM make this design very suitable for resource-constrained environments, enabling Kubernetes to be deployed in resource-constrained environments such as edge and fog computing.
[0089] In one embodiment of the present disclosure, by separating different control logics into independent WASM instances, it is possible to dynamically adjust which functions should be activated or deactivated according to actual needs. At the same time, since the sub-controller is started on demand and can be uninstalled immediately after the task is completed, memory usage and other resource consumption are reduced. In addition, WASM provides a sandbox environment to enhance security and prevent potential conflicts between different sub-controllers.
[0090] In one embodiment of the present disclosure, the device further includes: a host function customization module 604, which is used to customize the HTTP host function, wherein the HTTP host function is used to enable the parent controller to interact with each child controller.
[0091] In one embodiment of the present disclosure, the HTTP host function is a host function implemented by the HTTP protocol, which is responsible for processing HTTP requests and responses. The HTTP host function is asynchronous to improve response speed and efficiency. Through the HTTP host function, a new sub-controller can be integrated into an existing system by simply adding a new HTTP endpoint without modifying the parent controller or other sub-controllers. At the same time, the parent controller can efficiently interact with multiple sub-controllers to maintain good performance and security.
[0092] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0093] Refer to the following Figure 7 An electronic device 700 according to this embodiment of the present disclosure is described. Figure 7 The electronic device 700 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0094] like Figure 7 As shown, the electronic device 700 is in the form of a general computing device. The components of the electronic device 700 may include but are not limited to: at least one processing unit 710, at least one storage unit 720, and a bus 730 connecting different system components (including the storage unit 720 and the processing unit 710).
[0095] The storage unit stores a program code, and the program code can be executed by the processing unit 710, so that the processing unit 710 executes the steps described in the above "Exemplary Method" section of this specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 710 can execute the following steps of the above method embodiment: modularly design the controller to be run to obtain a parent controller and multiple sub-controllers, wherein the multiple sub-controllers work in an asynchronous manner, and the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; add the tasks to be executed of each sub-controller to the work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue.
[0096] The storage unit 720 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 7201 and / or a cache storage unit 7202 , and may further include a read-only storage unit (ROM) 7203 .
[0097] The storage unit 720 may also include a program / utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0098] Bus 730 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0099] The electronic device 700 may also communicate with one or more external devices 740 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 760. As shown, the network adapter 760 communicates with other modules of the electronic device 700 via a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0100] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0101] Based on the same inventive concept, a computer-readable storage medium is also provided in the embodiment of the present disclosure, on which a computer program is stored, and when the computer program is executed by a processor, any of the above-mentioned controller on-demand operation methods is implemented. Since the principle of solving the problem in the embodiment of the computer-readable storage medium is similar to that in the above-mentioned method embodiment, the implementation of the embodiment of the computer-readable storage medium can refer to the implementation of the above-mentioned method embodiment, and the repeated parts will not be repeated.
[0102] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, 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), 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.
[0103] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0104] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0105] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0106] Based on the same inventive concept, a computer program product is also provided in the embodiment of the present disclosure, including a computer program product, including: a computer program or an instruction, wherein when the computer program or the instruction is executed by a processor, the controller on-demand operation method of any one of the above method embodiments is implemented. Since the principle of solving the problem in the computer program product embodiment is similar to that in the above method embodiment, the implementation of the computer program product embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0107] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0108] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0109] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0110] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. A controller on-demand operation method, characterized in that: include: Modular design is performed on the controller to be run to obtain a parent controller and multiple sub-controllers, wherein the multiple sub-controllers work in an asynchronous manner, and the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; The tasks to be executed of each sub-controller are added to the work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue.
2. The controller on-demand operation method according to claim 1, characterized in that: The method further comprises: Compile each sub-controller into executable machine code and cache it to disk; Mapping the executable machine code in the disk to the memory by means of file mapping; The parent controller is further used to unload the executable machine code corresponding to the sub-controller in the disk that has not been used for a preset period of time to the hard disk.
3. The controller on-demand operation method according to claim 1 or 2, characterized in that: The controller to be run is a Kubernetes controller; The controller to be run is modularly designed to obtain a parent controller and multiple child controllers, including: modularly designing the Kubernetes controller based on the WebAssembly framework to obtain a parent controller and multiple child controllers corresponding to the Kubernetes controller, wherein each child controller corresponds to a WASM instance, and the parent controller starts the corresponding child controller by calling the Start function provided by each WASM instance.
4. The controller on-demand operation method according to claim 2, characterized in that: The method further comprises: A custom HTTP host function is used for the parent controller to interact with each child controller.
5. A control system, characterized in that: include: Control engine, parent controller and multiple child controllers working in asynchronous manner; The parent controller is used to receive asynchronous requests sent by each child controller and return execution results to each child controller; The control engine is used to add the tasks to be executed of each sub-controller to the work queue, so that the parent controller executes the tasks to be executed of each sub-controller according to the work queue.
6. The control system according to claim 5, characterized in that: The parent controller and the multiple sub-controllers are obtained by modularly designing the Kubernetes controller based on the WebAssembly framework, wherein each sub-controller corresponds to a WASM instance, and the parent controller starts the corresponding sub-controller by calling the Start function provided by each WASM instance.
7. A controller on-demand operation device, characterized in that: include: A controller modular design module, used for modular design of the controller to be run, to obtain a parent controller and a plurality of sub-controllers, wherein the plurality of sub-controllers work in an asynchronous manner, and the parent controller is used for receiving asynchronous requests sent by each sub-controller and returning execution results to each sub-controller; The to-be-executed tasks adding module is used to add the to-be-executed tasks of each sub-controller to the work queue, so that the parent controller executes the to-be-executed tasks of each sub-controller according to the work queue.
8. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the controller on-demand operation method according to any one of claims 1 to 4 by executing the executable instructions.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the controller on-demand operation method described in any one of claims 1 to 4 is implemented.
10. A computer program product comprising: A computer program or instruction, characterized in that when the computer program or instruction is executed by a processor, the controller on-demand operation method described in any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
KUBERNETES application program interface in extension process
CN113971095A
Vehicle traction converter control system, data transmission protocol and protocol synchronization method
CN114825634A
Container editing method and device, storage medium and program product
CN116166373A
Resource scheduling method and device, cluster, equipment and readable storage medium
CN116775222A
System and method for virtual devices using a plurality of processors
CN1601512A