Container resource scheduling method and device, electronic equipment and storage medium
By calculating the proportion of free paths of the container and the proportion of used time slices, the container priority is determined, and the rationality of container resource scheduling is solved, and resource utilization and load balancing are improved.
Patent Information
- Application Number
- CN202510324840.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2045-03-19
AI Technical Summary
How to reasonably schedule container resource in the prior art is an urgent problem, especially when the resources consumed by code submitted by different users are completely different and difficult to predict.
By calculating the proportion of free paths of each container and the proportion of used time slices of sandbox in each container, the priority information of each container is determined, so as to perform container resource scheduling for code run requests.
It realizes dynamic selection of containers with sufficient resources, improves resource utilization, solves the problem of local overload or idleness caused by static resource allocation, and uses time slice weight adjustment to ensure long-term fairness and reasonably balance container load.
Smart Images

Figure CN119829221A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a container resource scheduling method, device, electronic device and storage medium. Background Art
[0002] With the continuous development of computer technology, it is becoming more and more common in modern computing systems to allow users to submit and execute custom code, or code generated by large models to the cloud for fast execution. However, malicious users may trigger large models to generate unsafe execution paths by submitting fuzzy code, thereby affecting system stability.
[0003] In related technologies, container technology is usually used to isolate the execution environment to prevent system damage caused by malicious code. However, the resources consumed by the codes submitted by different users are completely different and difficult to predict. How to reasonably schedule container resources has become a problem that needs to be solved urgently in the industry. Summary of the invention
[0004] The present invention provides a container resource scheduling method, device, electronic device and storage medium, which are used to solve the problem of how to reasonably perform container resource scheduling in the prior art.
[0005] The present invention provides a container resource scheduling method, comprising: When receiving a code execution request, the idle path ratio and the used time slice ratio of the sandbox of each container are calculated according to the idle path number and the used time slice information of the sandbox of each container; wherein each of the containers includes multiple sandboxes; Priority information of each container is determined according to the percentage of idle paths in the sandbox of each container and the percentage of used time slices in the sandbox, so as to schedule container resources for the code execution request according to the priority information.
[0006] According to a container resource scheduling method provided by the present invention, the priority information of each container is determined according to the proportion of idle paths of the sandbox of each container and the proportion of used time slices of the sandbox, including: Obtaining path weight information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient; Obtaining time slice weight information of each container according to the product of the sandbox used time slice ratio of the container and the time slice coefficient; The priority information of each container is obtained based on the sum of the path weight information and the time slice weight information of each container; The path coefficient is associated with the path number used by the sandbox of each container, and the time slice coefficient is associated with the used time slice information of the sandbox of each container.
[0007] According to a container resource scheduling method provided by the present invention, before the step of obtaining the priority information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient, and the sum of the product of the sandbox used time slice ratio of the container and the time slice coefficient, the method further includes: Determine the path coefficient according to the ratio of the sum of the number of paths used by the sandboxes of each container to the sum of the maximum number of paths available for the sandboxes of each container; The time slice coefficient is determined according to the ratio of the sum of the sandbox used time slice information of each container to the sum of the maximum time slice information of each container.
[0008] According to a container resource scheduling method provided by the present invention, the calculation of the proportion of the number of idle paths and the proportion of the used time slice of the sandbox of each container according to the number of idle paths and the used time slice information of the sandbox of each container includes: Determine the proportion of the number of free sandbox paths of each container according to the ratio of the number of free sandbox paths of each container to the total number of free sandbox paths; the total number of free sandbox paths is obtained by summing the number of free sandbox paths of each container; The proportion of the sandbox used time slice information of each container is determined according to the ratio of the sandbox used time slice information of each container to the total sandbox used time slice information; wherein the total sandbox used time slice information is obtained by summing the sandbox used time slice information of each container.
[0009] According to a container resource scheduling method provided by the present invention, container resource scheduling of the code execution request is performed according to the priority information, including: The target priority information corresponds to any idle sandbox in the container, and is dispatched to the code execution request to execute the code; The target priority information is the maximum value among the priority information.
[0010] According to a container resource scheduling method provided by the present invention, before the step of scheduling any idle sandbox in the container corresponding to the target priority information to the code execution request to execute the code, the method further includes: When there are multiple target priority information, the target priority information with the largest number of sandbox idle paths is used as the final target priority information.
[0011] According to a container resource scheduling method provided by the present invention, the sandbox in the container uses a Linux user isolation mechanism to achieve mutual isolation between different sandboxes in the same container.
[0012] The present invention also provides a container resource scheduling device, comprising: A calculation module, configured to calculate the percentage of the number of free paths in the sandbox and the percentage of the used time slice of the sandbox of each container according to the number of free paths in the sandbox and the used time slice information of the sandbox of each container when receiving a code execution request; wherein each of the containers includes a plurality of sandboxes; The scheduling module is used to determine the priority information of each container according to the proportion of idle paths in the sandbox of each container and the proportion of used time slices in the sandbox, so as to schedule the container resources of the code execution request according to the priority information.
[0013] According to a container resource scheduling device provided by the present invention, the device is also used for: Obtaining path weight information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient; Obtaining time slice weight information of each container according to the product of the sandbox used time slice ratio of the container and the time slice coefficient; The priority information of each container is obtained based on the sum of the path weight information and the time slice weight information of each container; The path coefficient is associated with the path number used by the sandbox of each container, and the time slice coefficient is associated with the used time slice information of the sandbox of each container.
[0014] According to a container resource scheduling device provided by the present invention, the device is also used for: Determine the path coefficient according to the ratio of the sum of the number of paths used by the sandboxes of each container to the sum of the maximum number of paths available for the sandboxes of each container; The time slice coefficient is determined according to the ratio of the sum of the sandbox used time slice information of each container to the sum of the maximum time slice information of each container.
[0015] According to a container resource scheduling device provided by the present invention, the device is also used for: Determine the proportion of the number of free sandbox paths of each container according to the ratio of the number of free sandbox paths of each container to the total number of free sandbox paths; the total number of free sandbox paths is obtained by summing the number of free sandbox paths of each container; The proportion of the sandbox used time slice information of each container is determined according to the ratio of the sandbox used time slice information of each container to the total sandbox used time slice information; wherein the total sandbox used time slice information is obtained by summing the sandbox used time slice information of each container.
[0016] According to a container resource scheduling device provided by the present invention, the device is also used for: The target priority information corresponds to any idle sandbox in the container, and is dispatched to the code execution request to execute the code; The target priority information is the maximum value among the priority information.
[0017] According to a container resource scheduling device provided by the present invention, the device is also used for: When there are multiple target priority information, the target priority information with the largest number of sandbox idle paths is used as the final target priority information.
[0018] According to a container resource scheduling device provided by the present invention, the device is also used for: the sandbox in the container uses the Linux user isolation mechanism to achieve mutual isolation between different sandboxes in the same container.
[0019] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any of the container resource scheduling methods described above is implemented.
[0020] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the container resource scheduling method described in any one of the above is implemented.
[0021] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the container resource scheduling method described above is implemented.
[0022] The container resource scheduling method, device, electronic device and storage medium provided by the present invention can solve the problem of local overload or idleness caused by static resource allocation by calculating the proportion of idle paths in the sandbox, realize dynamic selection of containers with sufficient resources, and improve resource utilization. By calculating the proportion of used time slices in the sandbox, the starvation problem caused by historical load imbalance can be solved. By adjusting the time slice weight, long-term fairness can be guaranteed. Combined with the priority information calculated by the proportion of idle paths in the sandbox and the proportion of used time slices in the sandbox, the container load can be reasonably balanced to avoid some containers from exhausting resources prematurely or being idle for a long time, thereby effectively scheduling container resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 It is a flowchart of the container resource scheduling method provided by the present invention; Figure 2The overall architecture of the distributed code execution sandbox provided by the embodiment of the present invention; Figure 3 A schematic diagram of the system scheduling process provided by the present invention; Figure 4 A schematic diagram of the structure of the container resource scheduling device provided by the present invention; Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] In the related art, when scheduling container resources, user requests User are scheduled to relatively idle containers Container. There are enough idle sandboxes CodeBox in the Container to allocate to user requests. The Container is required to have sufficient computing power to run the code to prevent the occurrence of hungry containers.
[0027] First, the Scheduler will traverse the Containers and select the idle Container with Idle(i)>0; = filter ( ,i => >0); traverse Select Smallest Assigned to User; = Min( , i => ).
[0028] After the above steps, you can select an idle sandbox ( ) and have enough time slices to run the user's code. However, this method may lead to a scenario where the CodeBox of a container is fully allocated, but its time slice is still idle. A new user may be scheduled to a container with idle paths but few remaining time slices, resulting in increased time consumption. Therefore, the algorithm needs to be optimized.
[0029] The Scheduler cannot know how many time slices are needed for the code to run. It can only record the time consumption of the code that is already running. Therefore, it can also combine the sandbox used time slice information and number of free paths in the sandbox Let’s choose together.
[0030] Figure 1 is a flow chart of the container resource scheduling method provided by the present invention, such as Figure 1 As shown, the method includes the following: Step 110, when receiving a code execution request, calculating the percentage of the number of free paths in the sandbox and the percentage of the used time slice of the sandbox of each container according to the information of the number of free paths in the sandbox and the used time slice of the sandbox of each container; wherein each of the containers includes multiple sandboxes; In the present invention, the code execution request may specifically refer to a code execution request uploaded by a user, or may be a code execution request for automatically generating code from a large model.
[0031] In the present invention, the number of sandbox idle paths refers to the number of sandbox execution paths that are not currently used to execute code in the container.
[0032] Each container contains multiple sandboxes, and the system counts the number of running code (occupied) and unrunning code (idle) in these sandboxes periodically or in real time. For example, if a container has 10 sandboxes, 3 of which are executing code and 7 are not in use, then the number of idle sandboxes is 7.
[0033] In the present invention, the time slice information used by the sandbox represents the time resources consumed by the code running in the sandbox. The time slice is a time unit used for task scheduling in the operating system. The system divides the CPU time into several time slices and allocates them to the code execution in each sandbox in turn. Each sandbox will allocate a certain time slice each time it runs a code. When the code execution time exceeds this time slice, the system will suspend the execution of the code and run other codes instead.
[0034] In the present invention, the system records the total number of time slices consumed by each sandbox since its creation. For example, a sandbox has run the code 5 times since its creation, and each run uses 10ms, 15ms, 5ms, 20ms, and 8ms time slices respectively, then the total time slices used by the sandbox is 10+15+5+20+8=58ms.
[0035] In the present invention, by calculating the percentage of idle sandbox paths and the percentage of used sandbox time slices, the current resource usage and load level of each container can be understood. A high percentage of idle sandbox paths indicates that there are more available sandbox resources in the container, which can handle more code execution requests at the same time; while a high percentage of used sandbox time slices indicates that the sandbox resources of the container are already busy, and a large number of time slices have been consumed within a certain period of time, and it may take some time to process new code tasks. These data provide an important basis for subsequent container resource scheduling, help to reasonably allocate code execution requests, and improve the overall resource utilization and performance of the system.
[0036] Step 120: Determine the priority information of each container according to the percentage of idle paths in the sandbox of each container and the percentage of used time slices in the sandbox, so as to schedule container resources for the code execution request according to the priority information.
[0037] In the present invention, by calculating the priority information of each container, the scheduling system is helped to better understand the resource status and load conditions of each container, thereby optimizing the scheduling strategy and improving the overall performance and response speed of the system.
[0038] In the present invention, the scheduling system selects a container with a high priority to execute the code execution request based on the calculated priority information. Containers with a high priority usually have a higher percentage of sandbox idle paths and a lower percentage of sandbox used time slices, which means that they have more available resources and lower load, and can respond to code execution requests faster.
[0039] Therefore, containers with higher priorities will be selected first to execute code running requests, thereby achieving efficient resource utilization and load balancing.
[0040] In the present invention, by calculating the percentage of idle paths in the sandbox, the problem of local overload or idleness caused by static allocation of resources can be solved, and dynamic selection of containers with sufficient resources can be achieved to improve resource utilization. By calculating the percentage of used time slices in the sandbox, the starvation problem caused by historical load imbalance can be solved. By adjusting the time slice weight, long-term fairness can be guaranteed. Combined with the priority information calculated based on the percentage of idle paths in the sandbox and the percentage of used time slices in the sandbox, the container load can be reasonably balanced to avoid some containers from exhausting resources prematurely or being idle for a long time, thereby effectively scheduling container resources.
[0041] Optionally, determining the priority information of each container according to the percentage of idle paths in the sandbox and the percentage of used time slices in the sandbox of each container includes: Obtaining path weight information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient; Obtaining time slice weight information of each container according to the product of the sandbox used time slice ratio of the container and the time slice coefficient; The priority information of each container is obtained based on the sum of the path weight information and the time slice weight information of each container; The path coefficient is associated with the path number used by the sandbox of each container, and the time slice coefficient is associated with the used time slice information of the sandbox of each container.
[0042] In the present invention, the path coefficient is associated with the sandbox usage path of each container, and is used to adjust the weight of the sandbox idle path ratio in the priority calculation. For example, when the sandbox usage paths of some containers in the system are large, the path coefficient can be adjusted to balance the resource allocation between different containers.
[0043] In the present invention, the time slice coefficient is associated with the sandbox used time slice information of each container, and is used to adjust the weight of the sandbox used time slice ratio in the priority calculation. For example, if a container has a large number of sandbox used time slices, it may mean that the tasks of the container are more urgent or take longer to execute. The time slice coefficient can help the system better prioritize these tasks.
[0044] More specifically, computing containers Priority information .
[0045] - b
[0046] Among them, combined with the proportion of idle roads and time slice consumption ratio The weights are calculated comprehensively, among which, is the number of idle paths, The sandbox used time slice information. i is the container number, n is the total number of containers in the system, is the path coefficient, and b is the time slice coefficient.
[0047] In the present invention, the path coefficient and the time slice coefficient can be set to fixed values, for example, both are set to 1, or can be dynamically adjusted according to the device conditions.
[0048] In the present invention, by comprehensively considering the proportion of idle paths in the sandbox and the proportion of used time slices in the sandbox, and combining the path coefficient and the time slice coefficient to determine the priority, resources can be allocated more reasonably and the utilization of resources can be improved. The determination of priority information can help the scheduling system better understand the resource status and load conditions of each container, thereby optimizing the scheduling strategy and improving the overall performance and response speed of the system.
[0049] Optionally, before the step of obtaining the priority information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient, and the sum of the product of the sandbox used time slice ratio of the container and the time slice coefficient, the step further includes: Determine the path coefficient according to the ratio of the sum of the number of paths used by the sandboxes of each container to the sum of the maximum number of paths available for the sandboxes of each container; The time slice coefficient is determined according to the ratio of the sum of the sandbox used time slice information of each container to the sum of the maximum time slice information of each container.
[0050] In the present invention, the total number of sandbox usage paths of all containers is counted , and the total number of available paths in the sandbox of all containers , calculate the path coefficient, specifically: = 1+
[0051] In the present invention, the total time slices used by the sandbox of all containers are counted , and the maximum time slice sum of all containers , calculate the time slice coefficient, specifically: b = 1+
[0052] In the present invention, through these two coefficients, the system can more accurately measure the resource usage of each container, so that when calculating the priority, the idle resources and load status of the container can be comprehensively considered to achieve more intelligent resource scheduling.
[0053] Optionally, the calculating, according to the number of sandbox idle paths and the sandbox used time slice information of each container, the sandbox idle path ratio and the sandbox used time slice ratio of each container includes: Determine the proportion of the number of free sandbox paths of each container according to the ratio of the number of free sandbox paths of each container to the total number of free sandbox paths; the total number of free sandbox paths is obtained by summing the number of free sandbox paths of each container; The proportion of the sandbox used time slice information of each container is determined according to the ratio of the sandbox used time slice information of each container to the total sandbox used time slice information; wherein the total sandbox used time slice information is obtained by summing the sandbox used time slice information of each container.
[0054] In the present invention, the number of free sandboxes in each container refers to the number of sandboxes that are currently not in use in each container. For example, container A has 10 sandboxes, 3 of which are running code, then its number of free sandboxes is 7. For example, there are containers A, B, and C, and their number of free sandboxes is 7, 5, and 3 respectively, then the total number of free sandboxes is 7+5+3=15.
[0055] In the present invention, the number of free sandbox paths of each container is divided by the total number of free sandbox paths to obtain the percentage of free sandbox paths of each container. For example, the percentage of free sandbox paths of container A is 7 / 15, that of container B is 5 / 15, and that of container C is 3 / 15.
[0056] In the present invention, the sandbox used time slice information of each container refers to the number of time slices used by the sandbox in each container. For example, the sandbox used time slice of container A is 100ms, container B is 80ms, and container C is 50ms.
[0057] The total time slice information used is the sum of the sandbox time slice information used for all containers. For example, the total sandbox time slice information used for containers A, B, and C is 100+80+50=230ms. Divide the sandbox time slice information used for each container by the total sandbox time slice information used to get the sandbox time slice information ratio for each container. For example, the sandbox time slice information ratio for container A is 100 / 230, the ratio for container B is 80 / 230, and the ratio for container C is 50 / 230.
[0058] In the present invention, by calculating the percentage of idle paths in the sandbox of each container and the percentage of used time slices in the sandbox, the relative usage of each container in the overall resources can be understood, providing a basis for subsequent resource scheduling.
[0059] Optionally, scheduling container resources for the code execution request according to the priority information includes: The target priority information corresponds to any idle sandbox in the container, and is dispatched to the code execution request to execute the code; The target priority information is the maximum value among the priority information.
[0060] In the present invention, the system selects the maximum value from the priority information of all containers as the target priority information. For example, if there are three containers with priorities of 80, 90, and 75 respectively, the target priority information is 90.
[0061] In the present invention, the system assigns the code execution request to the container with the target priority information. Assuming that the priority of container B is 90, the system will select container B to process the code execution request.
[0062] There are multiple sandboxes in container B, some of which are idle. The scheduling system selects one of these idle sandboxes to allocate to the code running request. For example, container B has sandbox 1, sandbox 2, and sandbox 3, and sandbox 2 is idle. The system will schedule sandbox 2 to the code running request.
[0063] In the present invention, the code execution request is executed in the scheduled sandbox. For example, the code submitted by the user is executed in sandbox 2.
[0064] In the present invention, by allocating code execution requests to the container with the highest priority, it is ensured that the code can be executed as quickly as possible, thereby improving the response speed of the system. The priority scheduling mechanism can make reasonable allocations based on the resource usage and load status of the container, thereby avoiding resource waste and task accumulation.
[0065] Optionally, before the step of scheduling any idle sandbox in the container corresponding to the target priority information to the code execution request to execute the code, the method further includes: When there are multiple target priority information, the target priority information with the largest number of sandbox idle paths is used as the final target priority information.
[0066] In the present invention, for containers with the same priority information, their current sandbox idle paths are counted respectively. The sandbox idle paths of these containers are compared to find the container with the largest sandbox idle path. The priority information of the container with the largest sandbox idle path is used as the final target priority information for scheduling code execution requests.
[0067] A container with more free paths in the sandbox means that there are more free sandbox resources available for code execution. Selecting such a container can more efficiently utilize system resources and avoid resource waste.
[0068] For example, there are three containers A, B, and C in the system, and their priority information is all 90. The number of free sandbox paths of container A is 5, the number of free sandbox paths of container B is 8, and the number of free sandbox paths of container C is 3. According to the above steps, container B has the largest number of free sandbox paths, so its priority information is used as the final target priority information, and the code execution request is scheduled to container B.
[0069] In the present invention, by reasonably allocating resources, the overall stability and reliability of the system can be improved, ensuring that code execution requests can be processed in a timely manner.
[0070] Optionally, the sandbox in the container uses a Linux user isolation mechanism to achieve mutual isolation between different sandboxes in the same container.
[0071] Figure 2The overall architecture of the distributed code execution sandbox provided by the embodiment of the present invention is as follows: Figure 2 As shown in the figure, each container contains multiple "code sandboxes". Code sandboxes are isolated environments for executing user code. They are isolated from each other through the Linux user isolation mechanism, ensuring that the code running in each sandbox does not interfere with each other and does not affect the security of the container or physical machine.
[0072] In the present invention, the Linux user isolation mechanism: the code running in the sandbox is executed as a specific Linux user, who has lower permissions in the system and cannot perform key operations on the host machine. In addition, different sandboxes are isolated from each other using Linux user identities, ensuring that the code execution environment in each sandbox is relatively independent, further strengthening the security of user data and code execution in a multi-tenant environment, and preventing malicious code from escalating permissions or interfering with each other through user identities.
[0073] Multiple environments are isolated in each container, and each environment is only available to one user at a time to ensure the isolation of user environments. Containers run on physical machines and are scheduled by K8s.
[0074] Figure 3 The system scheduling flow diagram provided by the present invention is as follows: Figure 3 As shown, it includes: the user submits a code running request to the system, the scheduler receives the user's code running request, and schedules the request to a suitable container according to the system's resource status.
[0075] In addition, the scheduler will receive the status report of the container periodically or in real time, including the number of idle paths of the sandbox in the container, the used time slice, etc. Based on the received status report, the scheduler decides to which sandbox in the container the user's code execution request should be assigned.
[0076] Each container contains multiple code sandboxes, which are used to execute user code. Each container has multiple code sandboxes and can handle multiple code running requests at the same time.
[0077] More specifically, user User1 submits a code execution request to the scheduler, and the scheduler receives the user's request and queries the container's status information. The container periodically reports to the scheduler information such as the number of idle paths and used time slices in its internal sandbox.
[0078] The scheduler calculates the priority of each container based on the container's status information and assigns the user's code execution request to an idle sandbox in the container with the highest priority; the selected sandbox receives the code execution request and executes the user's code.
[0079] In the present invention, through the intelligent scheduling of the scheduler, code execution requests can be allocated to the most appropriate containers and sandboxes, thereby improving the resource utilization and response speed of the system.
[0080] The container resource scheduling device provided by the present invention is described below. The container resource scheduling device described below and the container resource scheduling method described above can be referred to each other.
[0081] Figure 4 A schematic diagram of the structure of the container resource scheduling device provided by the present invention is shown in FIG. Figure 4 As shown, including: The calculation module 410 is used to calculate the percentage of the number of free paths and the percentage of the used time slice of the sandbox of each container according to the number of free paths and the used time slice information of the sandbox of each container when receiving the code execution request; wherein each of the containers includes multiple sandboxes; The scheduling module 420 is used to determine the priority information of each container according to the proportion of idle paths in the sandbox of each container and the proportion of used time slices in the sandbox, so as to schedule the container resources of the code execution request according to the priority information.
[0082] According to a container resource scheduling device provided by the present invention, the device is also used for: Obtaining path weight information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient; Obtaining time slice weight information of each container according to the product of the sandbox used time slice ratio of the container and the time slice coefficient; The priority information of each container is obtained based on the sum of the path weight information and the time slice weight information of each container; The path coefficient is associated with the path number used by the sandbox of each container, and the time slice coefficient is associated with the used time slice information of the sandbox of each container.
[0083] According to a container resource scheduling device provided by the present invention, the device is also used for: Determine the path coefficient according to the ratio of the sum of the number of paths used by the sandboxes of each container to the sum of the maximum number of paths available for the sandboxes of each container; The time slice coefficient is determined according to the ratio of the sum of the sandbox used time slice information of each container to the sum of the maximum time slice information of each container.
[0084] According to a container resource scheduling device provided by the present invention, the device is also used for: Determine the proportion of the number of free sandbox paths of each container according to the ratio of the number of free sandbox paths of each container to the total number of free sandbox paths; the total number of free sandbox paths is obtained by summing the number of free sandbox paths of each container; The proportion of the sandbox used time slice information of each container is determined according to the ratio of the sandbox used time slice information of each container to the total sandbox used time slice information; wherein the total sandbox used time slice information is obtained by summing the sandbox used time slice information of each container.
[0085] According to a container resource scheduling device provided by the present invention, the device is also used for: The target priority information corresponds to any idle sandbox in the container, and is dispatched to the code execution request to execute the code; The target priority information is the maximum value among the priority information.
[0086] According to a container resource scheduling device provided by the present invention, the device is also used for: When there are multiple target priority information, the target priority information with the largest number of sandbox idle paths is used as the final target priority information.
[0087] According to a container resource scheduling device provided by the present invention, the device is also used for: the sandbox in the container uses the Linux user isolation mechanism to achieve mutual isolation between different sandboxes in the same container.
[0088] In the present invention, by calculating the percentage of idle paths in the sandbox, the problem of local overload or idleness caused by static allocation of resources can be solved, and dynamic selection of containers with sufficient resources can be achieved to improve resource utilization. By calculating the percentage of used time slices in the sandbox, the starvation problem caused by historical load imbalance can be solved. By adjusting the time slice weight, long-term fairness can be guaranteed. Combined with the priority information calculated based on the percentage of idle paths in the sandbox and the percentage of used time slices in the sandbox, the container load can be reasonably balanced to avoid some containers from exhausting resources prematurely or being idle for a long time, thereby effectively scheduling container resources.
[0089] Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the container resource scheduling method, the method comprising: upon receiving a code execution request, calculating the proportion of the number of free paths and the proportion of the used time slice of the sandbox of each container according to the number of free paths and the used time slice information of the sandbox of each container; wherein each of the containers includes multiple sandboxes; Priority information of each container is determined according to the percentage of idle paths in the sandbox of each container and the percentage of used time slices in the sandbox, so as to schedule container resources for the code execution request according to the priority information.
[0090] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0091] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the container resource scheduling method provided by the above methods, the method comprising: when receiving a code execution request, according to the number of sandbox idle paths and the sandbox used time slice information of each container, calculating the sandbox idle path ratio and the sandbox used time slice ratio of each container; wherein each of the containers includes multiple sandboxes; Priority information of each container is determined according to the percentage of idle paths in the sandbox of each container and the percentage of used time slices in the sandbox, so as to schedule container resources for the code execution request according to the priority information.
[0092] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the container resource scheduling method provided by the above methods, the method comprising: upon receiving a code execution request, calculating the sandbox idle path ratio and the sandbox used time slice ratio of each container according to the sandbox idle path number and sandbox used time slice information of each container; wherein each of the containers includes multiple sandboxes; Priority information of each container is determined according to the percentage of idle paths in the sandbox of each container and the percentage of used time slices in the sandbox, so as to schedule container resources for the code execution request according to the priority information.
[0093] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0094] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A container resource scheduling method, characterized in that: include: When receiving a code execution request, the idle path ratio and the used time slice ratio of the sandbox of each container are calculated according to the idle path number and the used time slice information of the sandbox of each container; wherein each of the containers includes multiple sandboxes; Priority information of each container is determined according to the percentage of idle paths in the sandbox of each container and the percentage of used time slices in the sandbox, so as to schedule container resources for the code execution request according to the priority information.
2. The container resource scheduling method according to claim 1, characterized in that: Determining the priority information of each container according to the proportion of idle paths in the sandbox and the proportion of used time slices in the sandbox of each container, including: Obtaining path weight information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient; Obtaining time slice weight information of each container according to the product of the sandbox used time slice ratio of the container and the time slice coefficient; The priority information of each container is obtained based on the sum of the path weight information and the time slice weight information of each container; The path coefficient is associated with the path number used by the sandbox of each container, and the time slice coefficient is associated with the used time slice information of the sandbox of each container.
3. The container resource scheduling method according to claim 2, characterized in that: Before the step of obtaining the priority information of each container according to the product of the sandbox idle path ratio of the container and the path coefficient, and the sum of the product of the sandbox used time slice ratio of the container and the time slice coefficient, the step further includes: Determine the path coefficient according to the ratio of the sum of the number of paths used by the sandboxes of each container to the sum of the maximum number of paths available for the sandboxes of each container; The time slice coefficient is determined according to the ratio of the sum of the sandbox used time slice information of each container to the sum of the maximum time slice information of each container.
4. The container resource scheduling method according to claim 1, characterized in that: The calculating, according to the number of sandbox idle paths and the sandbox used time slice information of each container, the proportion of the number of sandbox idle paths and the proportion of the sandbox used time slice of each container includes: Determine the proportion of the number of free sandbox paths of each container according to the ratio of the number of free sandbox paths of each container to the total number of free sandbox paths; the total number of free sandbox paths is obtained by summing the number of free sandbox paths of each container; The proportion of the sandbox used time slice information of each container is determined according to the ratio of the sandbox used time slice information of each container to the total sandbox used time slice information; wherein the total sandbox used time slice information is obtained by summing the sandbox used time slice information of each container.
5. The container resource scheduling method according to claim 1, characterized in that: Scheduling container resources for the code execution request according to the priority information includes: The target priority information corresponds to any idle sandbox in the container, and is dispatched to the code execution request to execute the code; The target priority information is the maximum value among the priority information.
6. The container resource scheduling method according to claim 5, characterized in that: Before the step of scheduling any idle sandbox in the container corresponding to the target priority information to the code execution request for executing the code, the method further includes: When there are multiple target priority information, the target priority information with the largest number of sandbox idle paths is used as the final target priority information.
7. The container resource scheduling method according to claim 1, characterized in that: The sandbox in the container uses the Linux user isolation mechanism to achieve mutual isolation between different sandboxes in the same container.
8. A container resource scheduling device, characterized in that: include: A calculation module, configured to calculate the percentage of the number of free paths in the sandbox and the percentage of the used time slice of the sandbox of each container according to the number of free paths in the sandbox and the used time slice information of the sandbox of each container when receiving a code execution request; wherein each of the containers includes a plurality of sandboxes; The scheduling module is used to determine the priority information of each container according to the proportion of idle paths in the sandbox of each container and the proportion of used time slices in the sandbox, so as to schedule the container resources of the code execution request according to the priority information.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the container resource scheduling method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the container resource scheduling method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Resource scheduling method and device in clustering management system based on containers
CN108519911A
A method and apparatus for scheduling system resources between multi-container systems
CN109298913A
Sandbox-based resource processing method and device, storage medium and processor
CN112131001A
Method and device for restarting cluster in cloud platform, electronic equipment and storage medium
CN115525478A
Resource scheduling method and device, electronic equipment and readable storage medium
CN116185606A
Cited By
Code analysis method, system and equipment based on multi-programming language sandbox and medium
CN120893033A