Controller on-demand operation method and related equipment

By implementing modular design and asynchronous management of the controller, the controller can operate on demand, solving the memory consumption problem in resource-scarce scenarios and making it suitable for edge computing environments.

CN119946035BActive Publication Date: 2025-11-14CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411997664.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-11-14
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

Existing technologies lack methods for extending control plane components using WebAssembly. Controllers continuously run and consume memory resources. Reconstructing Kubernetes core components is complex and time-consuming, making it difficult to run on demand in resource-scarce scenarios.

Method used

The controller is designed in a modular fashion, with the parent controller and multiple child controllers working asynchronously. The child controllers are compiled into executable machine code and cached on disk, mapped to memory via files, and unloaded when not used for a preset time. Custom HTTP host functions are introduced for interaction.

Benefits of technology

It enables the cluster controller to run on demand in resource-scarce scenarios, reducing memory usage and resource consumption, improving response speed and flexibility, and is suitable for edge computing environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119946035B_ABST
    Figure CN119946035B_ABST
Patent Text Reader

Abstract

This disclosure provides a method, system, apparatus, device, medium, and computing program for on-demand controller operation, relating to the field of computer technology. The method includes: modularly designing the controller to be executed, obtaining a parent controller and multiple child controllers, wherein the multiple child controllers operate asynchronously, and the parent controller receives asynchronous requests sent by each child controller and returns execution results to each child controller; adding the tasks to be executed by each child controller to a work queue, so that the parent controller executes the tasks of each child controller according to the work queue. This disclosure enables on-demand operation of cluster controllers in resource-scarce scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method, system, apparatus, device, medium, and computing program for controller on-demand operation. Background Technology

[0002] WebAssembly (WASM) is a new code format designed for the web, aiming to achieve portable binary code execution to improve application performance on the network. With technological evolution, WASM has also expanded beyond browsers; for example, with the help of the WebAssembly System Interface (WASI), WASM can run in server and cloud computing environments. This facilitates edge computing and decentralized applications (DApps), bringing new possibilities to modern application development.

[0003] In related technologies, as computing tasks increasingly tend to be executed at the edge, supporting components such as container orchestration systems like Kubernetes are also gradually shifting to the edge. However, current methods have the following problems: a lack of methods to extend control plane components using WebAssembly; the need for the controller to run continuously, constantly consuming memory resources; and the need to refactor core Kubernetes components, 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 background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] This disclosure provides a method, system, apparatus, device, medium, and computing program for controller on-demand operation, which at least to some extent overcomes the problem in related technologies that controllers cannot operate on demand in resource-scarce scenarios.

[0006] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part by practice of this disclosure.

[0007] According to one aspect of this disclosure, a method for on-demand operation of a controller is provided, comprising: modularly designing the controller to be run to obtain a parent controller and multiple child controllers, wherein the multiple child controllers operate asynchronously, and the parent controller is used to receive asynchronous requests sent by each child controller and return execution results to each child controller; adding the tasks to be executed by each child controller to a work queue, so that the parent controller executes the tasks to be executed by each child 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 via file mapping; wherein the parent controller is further configured to unload the executable machine code corresponding to the sub-controller that has not been used for a preset period of time from the disk 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: a custom 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 this disclosure, a control system is also provided, comprising: a control engine, a parent controller, and a plurality of sub-controllers operating asynchronously; wherein the parent controller is configured to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; the control engine is configured to add the pending tasks of each sub-controller to a work queue, so that the parent controller executes the pending tasks of each sub-controller according to the work queue.

[0012] In some embodiments, the parent controller and the plurality of child controllers are modularly designed based on the WebAssembly framework for Kubernetes controllers, 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 this disclosure, a controller on-demand operation device is also provided, comprising: a controller modular design module for modularly designing the controller to be operated, obtaining a parent controller and multiple sub-controllers, wherein the multiple sub-controllers operate asynchronously, and the parent controller is used to receive asynchronous requests sent by each sub-controller and return execution results to each sub-controller; and a task-to-execute addition module for adding tasks to be executed by each sub-controller to a work queue, so that the parent controller executes the tasks to be executed by each sub-controller according to the work queue.

[0014] According to another aspect of this disclosure, an electronic device is also provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the controller-on-demand operation method described in any of the preceding claims by executing the executable instructions.

[0015] According to another aspect of this disclosure, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the controller-on-demand operation method described in any of the preceding claims.

[0016] According to another aspect of this disclosure, a computer program product is also provided, including a computer program that, when executed by a processor, implements a controller-on-demand operation method for any of the above.

[0017] The on-demand controller operation method, system, apparatus, device, medium, and computing program provided in the embodiments of this disclosure modularly design the controller to be run, thereby obtaining a parent controller and multiple child controllers. The tasks to be executed by each child controller are added to a work queue, so that the parent controller executes the tasks of each child controller according to the work queue. The embodiments of this disclosure can achieve on-demand operation of cluster controllers in resource-scarce scenarios.

[0018] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0020] Figure 1 A schematic diagram of an exemplary application system architecture to which the controller on-demand operation method of the embodiments of this disclosure can be applied is shown;

[0021] Figure 2 This illustration shows an interaction diagram between a parent controller and a child controller in an embodiment of this disclosure;

[0022] Figure 3 This diagram illustrates a flowchart of a controller on-demand operation method according to an embodiment of the present disclosure, such as... Figure 3 As shown;

[0023] Figure 4This diagram illustrates an on-demand operation interaction flow of a controller according to an embodiment of the present disclosure.

[0024] Figure 5 This diagram illustrates a controller-on-demand operation system according to an embodiment of the present disclosure.

[0025] Figure 6 This diagram illustrates a controller-on-demand operation device according to an embodiment of the present disclosure;

[0026] Figure 7 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0027] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary 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] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0029] To facilitate understanding, before introducing the embodiments of this disclosure, the following explanations are provided for several terms involved in the embodiments of this disclosure:

[0030] WASI (WebAssembly System Interface) is a standardized interface designed to enable WebAssembly (WASM) to run in any environment, not just a browser. WASI defines a set of system calls and application programming interfaces (APIs) that allow WASM modules to access operating system resources such as the file system, network, and time. 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 applicability and flexibility of WebAssembly.

[0031] DApps: Decentralized applications are software applications that run on a blockchain or other distributed network. Unlike traditional centralized applications, DApps do not rely on a single server or centralized control, but instead operate through multiple nodes in a distributed network. This architecture improves security and transparency because data and operation records are stored on the blockchain, making them difficult to tamper with.

[0032] Serverless: A serverless architecture technology, it's a cloud computing model where developers don't need to manage the setup and maintenance of underlying servers. Instead, they deploy their code to a cloud provider's management platform, which automatically allocates resources and executes the code. The cloud provider dynamically allocates computing resources on demand and bills based on actual usage. This technology simplifies application development and maintenance, and improves scalability and flexibility.

[0033] WASMtime, or WebAssembly Components Time, is a fast, 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 that runs on different platforms, such as local computers, servers, and embedded devices. WASMtime focuses on performance and security, making it suitable for developing efficient and portable applications.

[0034] The specific implementation methods of the embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.

[0035] Figure 1 A schematic diagram of an exemplary application system architecture is shown, illustrating an application of the controller-on-demand operation method described in the embodiments of this disclosure. For example... Figure 1 As shown, the system architecture can include: control plane nodes and worker nodes. The control plane nodes adopt Kubernetes key logic and can include the distributed key-value store etcd and the application programming interface server (API server). These components are responsible for the basic management and state storage of the cluster. The worker nodes adopt WASM controller logic and can include a parent controller and several child controllers. These modules implement the extended logic of the control plane, especially optimized for edge computing environments. The child controllers are WASM instances embedded in the parent controller WASMtime.

[0036] It should be noted that, Figure 1 The number of sub-controllers shown is for illustrative purposes only, and the embodiments disclosed herein do not impose a specific limit on the number of sub-controllers.

[0037] In one embodiment of this disclosure, etcd is a distributed key-value store system for the Kubernetes container orchestration system, used to store cluster state information; the API server is one of the core components of Kubernetes, responsible for handling all requests and responses to cluster state; the parent controller is a master controller responsible for coordinating and managing the work of the child controllers, and is built based on WASM controller logic; the child controllers are lightweight WASM modules that can be started on demand to execute specific tasks or respond to events, and these modules are unloaded after completing their tasks, thereby reducing resource consumption.

[0038] In one embodiment of this disclosure, kernel isolation is achieved between the control plane node and the worker node through physical machines or virtual machines, i.e., isolation based on the underlying hardware or virtualization layer; process isolation is achieved between etcd and the API server in the control plane node, and between the parent controller and the child controller in the worker node, i.e., process isolation based on container technology; functional isolation is achieved between the parent controller and the child controller in the worker node through WASM modules, i.e., functional isolation based on WASM technology, ensuring that each WASM module can run in an independent environment, improving security and resource utilization.

[0039] In one embodiment of this disclosure, the parent controller is primarily responsible for managing the asynchronous operations of several child controllers and offloading child controllers that have been inactive for a long time. The parent controller mainly includes the following three components: the WASM engine, the host functions exposed to the WASM instance, and the work queue.

[0040] In one embodiment of this disclosure, in related technologies, when system memory is insufficient, the operating system can swap some memory data to the disk to free up memory space; however, not all systems enable this swapping function. In this embodiment, the WASM engine extends the original WASM runtime WASMtime by adding custom unloading and disk swapping functions, thereby enabling the unloading and swapping of WASM modules even when the system's swapping function is not enabled.

[0041] In one embodiment of this disclosure, in related technologies, traditional WASMtime may perform just-in-time compilation when loading WASM modules, which can easily lead to additional consumption of memory and CPU resources. In this embodiment, the WASM engine reduces runtime compiler memory consumption by pre-compiling new WASM modules into machine code and caches the compiled modules on 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 this 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 a memory address space. Simultaneously, the engine also provides the 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 aforementioned file mapping technology and communication tools can be determined according to actual circumstances, and this disclosure does not impose specific limitations on them.

[0043] In one embodiment of this disclosure, for a sub-controller in an idle state (e.g., a component or thread in the WASM module), the WASM engine can selectively release its associated memory resources to effectively reduce memory usage. If this memory needs to be accessed again, the kernel will trigger a data reload, reloading the corresponding file into memory.

[0044] In one embodiment of this disclosure, a host function refers to a function exposed by the WASM engine to a WASM instance, and WASI is a standardized set of host functions. However, since the WASI specification does not support Hypertext Transfer Protocol (HTTP) communication between the Kubernetes controller and the Kubernetes API server in related technologies, this disclosure introduces a custom HTTP host function.

[0045] In one embodiment of this disclosure, a work queue is used to manage and schedule pending tasks or jobs, so that these tasks can be queued in a certain order for processing.

[0046] In one embodiment of this disclosure, the sub-controllers are all single-threaded asynchronous WASM instances. The parent controller starts the sub-controller by calling the Start function provided by the WASM module. The Start function initiates the coordination loop of the sub-controller, which sends asynchronous requests to the parent controller and waits for the execution results. Once the request is completed, the parent controller returns the execution results to the sub-controller, enabling it to complete the associated asynchronous request and restart the entire coordination process.

[0047] In one embodiment of this disclosure, Figure 2 This illustration shows an interaction diagram between a parent controller and a child controller in an embodiment of this disclosure, such as... Figure 2As shown, the low-level parts of kube-rs are used to implement Kubernetes host functions, while high-level kube-rs functionality is implemented in suboperators. Furthermore, the added host functions are asynchronous. The kube-rs library is a Kubernetes client library written in Rust that provides functionality for interacting with the Kubernetes API; the standard library std-libs refers to the standard library of programming languages, containing a series of predefined functions, classes, and other resources to support common programming tasks such as input / output, string manipulation, and data structures.

[0048] In one embodiment of this 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 indicates a WASI target that uses the standard library std-libs, ensuring that the WASM module can interact with the host environment; the kube-rs high-level library, i.e., the high-level functions of kube-rs implemented in sub-operators, is responsible for more complex business logic and operations; the custom client library is a customized client library for specific client operations and functions; WASI host functions are host functions based on the WASI interface, providing system-level functions such as file operations and network communication; HTTP host functions are host functions implemented through the HTTP protocol, responsible for handling HTTP requests and responses. HTTP host functions are asynchronous to improve response speed and efficiency; the kube-rs low-level library uses the low-level parts of kube-rs to implement Kubernetes host functions, which typically involve low-level resource management and operations; and the network logic is responsible for handling network-related operations, including data transmission and communication.

[0049] In one embodiment of this disclosure, the parent controller is responsible for overall coordination and management, and schedules the child controllers through the WASM engine, thereby sending instructions or data to the child controllers to initiate or schedule them to execute specific tasks. The child controllers receive instructions or data from the parent controller to execute specific tasks or respond to events, and feed back the execution results or status information to the parent controller. Figure 2 As shown, the top-to-bottom arrows indicate the direction from the child controller to the parent controller, typically used to represent the child controller sending data or status information to the parent controller; the bottom-to-top arrows indicate the direction from the parent controller to the child controller, typically used to represent the parent controller sending instructions or data to the child controller. Embodiments of this disclosure ensure efficient resource management and rapid response capabilities, especially in edge computing environments, enabling flexible handling of various asynchronous tasks and environmental interactions.

[0050] Figure 3This diagram illustrates a flowchart of a controller on-demand operation method according to an embodiment of the present disclosure, such as... Figure 3 As shown, the method includes the following steps:

[0051] S302, the controller to be run is modularly designed to obtain a parent controller and multiple child controllers. The multiple child controllers work asynchronously. The parent controller is used to receive asynchronous requests sent by each child controller and return the execution results to each child controller.

[0052] In one embodiment of this disclosure, the controller to be run is modularly designed, which can be designed as a parent controller and several child controllers. The child controllers can all work asynchronously. The parent controller can be used to receive asynchronous requests sent by each child controller and return the execution results to the child controllers.

[0053] S304 adds the tasks to be executed by each sub-controller to the work queue, so that the parent controller can execute the tasks to be executed by each sub-controller according to the work queue.

[0054] In one embodiment of this disclosure, the sub-controller adds tasks to be executed to a work queue, and the parent controller executes the tasks to be executed by each sub-controller according to the order in the work queue. At the same time, the parent controller can return the execution result to the corresponding sub-controller after the task is executed.

[0055] As described above, the embodiments of this disclosure employ a modular design for the controller to be executed, resulting in a parent controller and multiple child controllers. The tasks to be executed by each child controller are added to a work queue, allowing the parent controller to execute these tasks according to the work queue. These embodiments enable on-demand operation of the cluster controller in resource-scarce scenarios.

[0056] In one embodiment of this disclosure, 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 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 a preset period of time from the disk to the hard disk.

[0057] In one embodiment of this disclosure, the WASM engine reduces the need for runtime compilation by pre-compiling each sub-controller (i.e., the new WASM module) into executable machine code, and caches this compiled machine code on disk for subsequent reuse, thus reducing the time and resource consumption of repeated compilation. Simultaneously, through file mapping technology, the executable machine code on disk can be directly mapped to the process's address space, allowing the code to be executed directly from memory without explicitly reading it into a memory buffer.

[0058] It should be noted that file mapping is an efficient I / O operation method that allows the operating system to directly map file content into virtual memory, enabling applications to directly manipulate file data by accessing memory. Appropriate file mapping technologies can be selected based on actual needs, and this disclosure does not specifically limit the type of file mapping technology used.

[0059] In one embodiment of this 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 this disclosure, a traditional Kubernetes controller is a monolithic component responsible for managing cluster state changes. Through modular design, the Kubernetes controller can be broken down into multiple smaller, more independent sub-controllers. After modularizing the Kubernetes controller using the WebAssembly framework, each sub-controller is designed as an independent WASM instance. This means they can be quickly loaded and executed when needed and immediately unloaded after completing their tasks, thus saving resources. The parent controller starts the corresponding sub-controller by calling the Start function provided by each WASM instance. This approach allows the parent controller to programmatically control when and which sub-controller is started, increasing flexibility and responsiveness. The efficiency and isolation of WASM make this design well-suited for resource-constrained environments, significantly reducing control plane resource consumption and enabling Kubernetes to be deployed in resource-constrained environments such as edge computing and fog computing.

[0061] In one embodiment of this disclosure, by separating different control logic into independent WASM instances, the corresponding functions can be dynamically adjusted according to actual needs, making them active or deactivated. Simultaneously, since sub-controllers are started on demand and can be unloaded immediately after a task is completed, adding and removing sub-controllers without interfering with other active sub-controllers reduces memory usage and other resource consumption. Furthermore, WASM provides a sandbox environment, i.e., isolation based on the WASM engine, enhancing security, preventing potential conflicts between different sub-controllers, and eliminating the overhead of container isolation.

[0062] In one embodiment of this disclosure, the method further includes: a custom HTTP host function, wherein the HTTP host function is used to enable the parent controller to interact with the various child controllers.

[0063] In one embodiment of this disclosure, the HTTP host function is a host function implemented using the HTTP protocol, responsible for handling HTTP requests and responses. The HTTP host function is asynchronous to improve response speed and efficiency. Through the HTTP host function, new sub-controllers can be integrated into the existing system by simply adding new HTTP endpoints without modifying the parent controller or other sub-controllers. Simultaneously, the parent controller can efficiently interact with multiple sub-controllers, maintaining good performance and security.

[0064] Figure 4 This diagram illustrates an on-demand operation interaction flow of a controller according to an embodiment of the present disclosure, such as... Figure 4 As shown, in this process, the parent controller manages the asynchronous operations of the child controllers and unloads them to disk when a child controller is inactive for an extended period. The WASM engine manages and schedules the execution of the child controllers, the event loop handles asynchronous operations and coordinates task execution, the work queue stores pending asynchronous operations, and the host functions provide the interface for interacting with the host environment.

[0065] In one embodiment of this disclosure, the process includes the following steps:

[0066] Step 1: The WASM engine starts and calls the main function of the sub-controller. That is, the main function of the sub-controller is executed through the entry point of the WASM engine. This main function can usually be a function that initializes or performs a specific task.

[0067] Step 2: The sub-controller interacts with the host environment by calling host functions provided by the WASM engine, such as reading files and sending network requests.

[0068] Step 3: The sub-controller initiates asynchronous operations and adds them to the work queue. These operations may include file I / O, network requests, etc.

[0069] Step 4: The sub-controller returns control to the WASM engine, awaiting further processing.

[0070] Step 5: After the WASM engine has executed all synchronization logic, it stops execution and returns control to the event loop. Synchronization logic refers to operations that do not require waiting for external resources.

[0071] Step 6: The event loop checks whether the asynchronous operations in the work queue have been completed. If the operations have been completed, proceed to step 7.

[0072] In one embodiment of this disclosure, the event loop is a core concept in a serverless architecture. The event loop continuously checks whether any operations have been completed in the work queue and passes the results to the WASM engine.

[0073] Step 7: The event loop passes the results of the completed operations to the WASM engine.

[0074] Step 8: The WASM engine checks if the sub-controller has been unloaded. If it has, the sub-controller is reloaded, and a new set of synchronization operations is executed.

[0075] In one embodiment of this disclosure, the parent controller is responsible for executing the above steps. The parent controller will continuously repeat the above process to ensure that the child controller can continuously perform tasks and respond to environmental changes.

[0076] Figure 5 This diagram illustrates a controller-on-demand operation system according to an embodiment of the present disclosure, such as... Figure 5 As shown, the system may include: a control engine, a parent controller, and multiple child controllers that operate asynchronously.

[0077] The parent controller receives asynchronous requests from each child controller and returns execution results to each child controller. The control engine adds the tasks to be executed by each child controller to the work queue, so that the parent controller can execute the tasks to be executed by each child controller according to the work queue.

[0078] As described above, the embodiments of this disclosure can modularly design the controller to be run, thereby obtaining a parent controller and multiple child controllers, and adding the tasks to be executed by each child controller to a work queue, so that the parent controller can execute the tasks to be executed by each child controller according to the work queue. The embodiments of this disclosure can realize the on-demand operation of the cluster controller in resource-scarce scenarios.

[0079] In one embodiment of this disclosure, the parent controller and multiple child controllers are modularly designed based on the WebAssembly framework for Kubernetes controllers. 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.

[0080] Based on the same inventive concept, this disclosure also provides a controller on-demand operation device, as described in the following embodiments. Since the principle by which this device embodiment solves the problem is similar to that of the above-described method embodiments, the implementation of this device embodiment can refer to the implementation of the above-described method embodiments, and repeated details will not be elaborated further.

[0081] Figure 6This diagram illustrates a controller-on-demand operation device according to an embodiment of the present disclosure, such as... Figure 6 As shown, the device includes: a controller modular design module 601 and a task addition module 602.

[0082] The controller modular design module 601 is used to perform modular design on the controller to be run, resulting in a parent controller and multiple child controllers. The multiple child controllers work asynchronously. The parent controller is used to receive asynchronous requests sent by each child controller and return the execution results to each child controller. The task to be executed addition module 602 is used to add the tasks to be executed by each child controller to the work queue, so that the parent controller can execute the tasks to be executed by each child controller according to the work queue.

[0083] As described above, the embodiments of this disclosure can modularly design the controller to be run, thereby obtaining a parent controller and multiple child controllers, and adding the tasks to be executed by each child controller to a work queue, so that the parent controller can execute the tasks to be executed by each child controller according to the work queue. The embodiments of this disclosure can realize the on-demand operation of the cluster controller in resource-scarce scenarios.

[0084] In one embodiment of this disclosure, the device further includes: a machine code mapping module 603, used to compile each sub-controller into executable machine code and cache it in a disk; and to map the executable machine code in the disk to 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 a preset period of time from the disk to the hard disk.

[0085] In one embodiment of this disclosure, the WASM engine reduces the need for runtime compilation by pre-compiling each sub-controller (i.e., the new WASM module) into executable machine code, and caches this compiled machine code on disk for subsequent reuse, thus reducing the time and resource consumption of repeated compilation. Simultaneously, through file mapping technology, the executable machine code on disk can be directly mapped to the process's address space, allowing the code to be executed directly from memory without explicitly reading it into a memory buffer.

[0086] It should be noted that file mapping is an efficient I / O operation method that allows the operating system to directly map file content into virtual memory, enabling applications to directly manipulate file data by accessing memory. Appropriate file mapping technologies can be selected based on actual needs, and this disclosure does not specifically limit the type of file mapping technology used.

[0087] In one embodiment of this 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 this disclosure, a traditional Kubernetes controller is a monolithic component responsible for managing cluster state changes. Through modular design, the Kubernetes controller can be broken down into multiple smaller, more independent sub-controllers. By modularizing the Kubernetes controller using the WebAssembly framework, each sub-controller is designed as an independent WASM instance. This means they can be quickly loaded and executed when needed and immediately unloaded after completing their tasks, thus saving resources. The parent controller starts the corresponding sub-controller by calling the Start function provided by each WASM instance. This approach allows the parent controller to programmatically control when and which sub-controller is started, increasing flexibility and responsiveness. The efficiency and isolation of WASM make this design well-suited for resource-constrained environments, enabling Kubernetes to be deployed in resource-constrained environments such as edge computing and fog computing.

[0089] In one embodiment of this disclosure, by separating different control logic into independent WASM instances, it is possible to dynamically adjust which functions should be activated or deactivated according to actual needs. Furthermore, since the sub-controllers are started on demand and can be unloaded immediately after a task is completed, memory usage and other resource consumption are reduced. In addition, WASM provides a sandbox environment, enhancing security and preventing potential conflicts between different sub-controllers.

[0090] In one embodiment of this disclosure, the apparatus further includes a host function customization module 604 for customizing HTTP host functions, wherein the HTTP host functions are used to enable the parent controller to interact with each child controller.

[0091] In one embodiment of this disclosure, the HTTP host function is a host function implemented using the HTTP protocol, responsible for handling HTTP requests and responses. The HTTP host function is asynchronous to improve response speed and efficiency. Through the HTTP host function, new sub-controllers can be integrated into the existing system by simply adding new HTTP endpoints without modifying the parent controller or other sub-controllers. Simultaneously, the parent controller can efficiently interact with multiple sub-controllers, maintaining good performance and security.

[0092] Those skilled in the art will understand that various aspects of this disclosure can be implemented as a system, method, or program product. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."

[0093] The following reference Figure 7 To describe an electronic device 700 according to such an embodiment of the present disclosure. Figure 7 The electronic device 700 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0094] like Figure 7 As shown, the electronic device 700 is manifested in the form of a general-purpose 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 storage unit 720 and processing unit 710).

[0095] The storage unit stores program code that can be executed by the processing unit 710, causing the processing unit 710 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 710 can perform the following steps of the above method embodiments: modularly design the controller to be run to obtain a parent controller and multiple child controllers, wherein the multiple child controllers work asynchronously, the parent controller receives asynchronous requests sent by each child controller and returns execution results to each child controller; add the tasks to be executed by each child controller to a work queue, so that the parent controller executes the tasks to be executed by each child controller according to the work queue.

[0096] Storage unit 720 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 7201 and / or cache memory 7202, and may further include a read-only memory (ROM) 7203.

[0097] The storage unit 720 may also include a program / utility 7204 having a set (at least one) program module 7205, such program module 7205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0098] Bus 730 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0099] Electronic device 700 can also communicate with one or more external devices 740 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 700, and / or with any device that enables electronic device 700 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 750. Furthermore, electronic device 700 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 760. As shown, network adapter 760 communicates with other modules of electronic device 700 via bus 730. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with 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.

[0100] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0101] Based on the same inventive concept, this disclosure also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the controller-on-demand execution method described above. Since the principle by which this computer-readable storage medium embodiment solves the problem is similar to that of the above method embodiments, the implementation of this computer-readable storage medium embodiment can refer to the implementation of the above method embodiments, and repeated details will not be elaborated further.

[0102] More specific examples of computer-readable storage media in this disclosure may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0103] In this disclosure, a computer-readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting a program for use by or in connection with an instruction execution system, apparatus, or device.

[0104] Optionally, the program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0105] In practical implementation, program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0106] Based on the same inventive concept, this disclosure also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the controller on-demand execution method of any one of the above method embodiments. Since the principle by which this computer program product embodiment solves the problem is similar to that of the above method embodiments, the implementation of this computer program product embodiment can refer to the implementation of the above method embodiments, and repeated details will not be elaborated further.

[0107] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0108] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0109] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0110] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A method for on-demand operation of a controller, characterized in that, include: The controller to be run is modularly designed to obtain a parent controller and multiple child controllers. The multiple child controllers work asynchronously. The parent controller is used to receive asynchronous requests sent by each child controller and return the execution results to each child controller. The tasks to be executed by each sub-controller are added to the work queue, so that the parent controller executes the tasks to be executed by each sub-controller according to the work queue; The parent controller includes: the WASM engine; The WASM engine is used to start and call the main function of the sub-controller; The sub-controller is used to: interact with the host environment by calling host functions provided by the WASM engine; initiate asynchronous operations, add the asynchronous operations to the work queue, and return control to the WASM engine; The WASM engine is also used to: after executing all synchronous logic, stop execution and return control to the event loop, so that the event loop checks whether the asynchronous operations in the work queue have been completed and passes the results of the completed operations to the WASM engine. The WASM engine is also used to: check whether the sub-controller has been unloaded; if it has been unloaded, reload the sub-controller and execute a new set of synchronization operations.

2. The controller on-demand operation method according to claim 1, characterized in that, The method further includes: Each sub-controller is compiled into executable machine code and cached on disk; The executable machine code on the disk is mapped into memory through file mapping. The parent controller is also used to unload the executable machine code corresponding to the child controller that has not been used for a preset period of time from the disk 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 process involves modularizing the controller to be run, resulting in a parent controller and multiple child controllers. This includes modularizing the Kubernetes controller based on the WebAssembly framework, resulting in a parent controller and multiple child controllers corresponding to the Kubernetes controller. 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 includes: A custom HTTP host function is provided, wherein the HTTP host function is used for the parent controller to interact with each child controller.

5. A control system, characterized in that, include: The control engine, the parent controller, and multiple child controllers that operate asynchronously; The parent controller is used to receive asynchronous requests sent by each child controller and return the execution results to each child controller. The control engine is used to add the tasks to be executed by each sub-controller to the work queue, so that the parent controller can execute the tasks to be executed by each sub-controller according to the work queue. The parent controller includes: the WASM engine; The WASM engine is used to start and call the main function of the sub-controller; The sub-controller is used to: interact with the host environment by calling host functions provided by the WASM engine; initiate asynchronous operations, add the asynchronous operations to the work queue, and return control to the WASM engine; The WASM engine is also used to: after executing all synchronous logic, stop execution and return control to the event loop, so that the event loop checks whether the asynchronous operations in the work queue have been completed and passes the results of the completed operations to the WASM engine. The WASM engine is also used to: check whether the sub-controller has been unloaded; if it has been unloaded, reload the sub-controller and execute a new set of synchronization operations.

6. The control system according to claim 5, characterized in that, The parent controller and the multiple child controllers are modularly designed based on the WebAssembly framework for Kubernetes controllers. 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.

7. A controller-on-demand operation device, characterized in that, include: The controller modular design module is used to perform modular design on the controller to be run, resulting in a parent controller and multiple child controllers. The multiple child controllers work asynchronously. The parent controller is used to receive asynchronous requests sent by each child controller and return the execution results to each child controller. The pending task addition module is used to add pending tasks of each sub-controller to the work queue, so that the parent controller can execute the pending tasks of each sub-controller according to the work queue; The parent controller includes: the WASM engine; The WASM engine is used to start and call the main function of the sub-controller; The sub-controller is used to: interact with the host environment by calling host functions provided by the WASM engine; initiate asynchronous operations, add the asynchronous operations to the work queue, and return control to the WASM engine; The WASM engine is also used to: after executing all synchronous logic, stop execution and return control to the event loop, so that the event loop checks whether the asynchronous operations in the work queue have been completed and passes the results of the completed operations to the WASM engine. The WASM engine is also used to: check whether the sub-controller has been unloaded; if it has been unloaded, reload the sub-controller and execute a new set of synchronization operations.

8. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; 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 the processor, it implements the controller on-demand operation method according to any one of claims 1 to 4.

10. A computer program product comprising: A computer program or instruction, characterized in that, when executed by a processor, the computer program or instruction implements the controller on-demand operation method according to any one of claims 1 to 4.

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