Container-based resource allocation method, device, equipment and storage medium
Patent Information
- Application Number
- CN202210540648.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2042-05-17
AI Technical Summary
[0003]然而,在一些容器化部署服务场景下,尤其在一个节点机器(Node)上部署多个容器服务时,当某个容器服务进行端口绑定、使用节点机器资源时,极易与其他容器服务产生端口冲突,从而带来极大的系统风险
Smart Images

Figure CN117118977B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computers, and more particularly to a container-based resource allocation method, apparatus, device, and storage medium. Background Technology
[0002] With the development of virtualization technology, many applications can be deployed online using Docker containers. Docker is an open-source application container engine that enables virtualization by allowing developers to package their applications and dependencies into a portable image, which can then be deployed to any Linux operating system machine.
[0003] However, in some containerized deployment scenarios, especially when multiple container services are deployed on a single node machine, when a container service binds to a port and uses the node machine's resources, it is very easy to cause port conflicts with other container services, which can lead to significant system risks. Summary of the Invention
[0004] This disclosure provides a container-based resource allocation method, apparatus, device, and storage medium to solve at least one technical problem in the prior art.
[0005] On the one hand, this disclosure provides a container-based resource allocation method applied to a first device node, including:
[0006] In response to the fulfillment of the resource allocation trigger condition, obtain the container identifier and corresponding resource demand information of each container in multiple containers;
[0007] Based on the device node information to which the demand resource information belongs, multiple containers are aggregated to obtain at least one container set.
[0008] For each container set in the at least one container set, the runtime environment information of the container set and the container identifier of each container in the container set are sent to the second device node; the second device node allocates resource identifiers based on the runtime environment information and the container identifiers to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated;
[0009] Based on the obtained initial resource identifier, the resources pointed to by the required resource information corresponding to the multiple containers are allocated respectively to obtain resource allocation results.
[0010] On the other hand, a container-based resource allocation method is also provided, applied to the second device node, including:
[0011] The system obtains runtime environment information of each container set in at least one container set and container identifiers of each container in the container set; the at least one container set is obtained by a first device node in response to a resource allocation trigger condition, by obtaining container identifiers of multiple containers and resource demand information of multiple containers; and by aggregating multiple containers based on the device node information to which the resource demand information belongs.
[0012] Based on the runtime environment information and the container identifier, resource identifiers are allocated to determine the initial resource identifier for each container in the multiple containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated;
[0013] The initial resource identifier is sent to the first device node. Based on the obtained initial resource identifier, the first device node allocates resources to the resources pointed to by the required resource information of the multiple containers respectively, and obtains the resource allocation result.
[0014] On the other hand, a container-based resource allocation device is also provided, applied to a first device node, the device comprising:
[0015] The first acquisition module is used to acquire the container identifier and corresponding resource demand information of each container in multiple containers in response to the triggering condition of resource allocation being met.
[0016] The second acquisition module is used to aggregate multiple containers based on the device node information to which the demand resource information belongs, and obtain at least one container set;
[0017] The first sending module is configured to send the runtime environment information of the container set and the container identifier of each container in the container set to the second device node for each container set in the at least one container set; the second device node performs resource identifier allocation based on the runtime environment information and the container identifier to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated;
[0018] The allocation module is used to allocate resources pointed to by the required resource information corresponding to the multiple containers based on the obtained initial resource identifier, and obtain resource allocation results.
[0019] On the other hand, a container-based resource allocation device is also provided, applied to a second device node, the device comprising:
[0020] The third acquisition module is used to acquire the runtime environment information of each container set in at least one container set and the container identifier of each container in the container set; the at least one container set is obtained by the first device node in response to the triggering condition of resource allocation, acquiring the container identifiers of multiple containers and the resource demand information of multiple containers; and based on the device node information to which the resource demand information belongs, the multiple containers are aggregated.
[0021] The identifier determination module is used to allocate resource identifiers based on the runtime environment information and the container identifier, and to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated;
[0022] The second sending module is used to send the initial resource identifier to the first device node. Based on the obtained initial resource identifier, the first device node allocates resources to the resources pointed to by the demand resource information corresponding to the multiple containers respectively, and obtains resource allocation results.
[0023] On the other hand, an electronic device is also provided, the electronic device including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement any of the methods described above.
[0024] On the other hand, a computer-readable storage medium is also provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or the at least one program being loaded and executed by a processor to implement any of the methods described above.
[0025] On the other hand, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the methods described above.
[0026] The present disclosure provides a container-based resource allocation method, apparatus, device, and storage medium, which have the following technical advantages:
[0027] This embodiment of the disclosure, in response to a resource allocation trigger condition, obtains the container identifier and corresponding resource requirement information of each container in multiple containers; based on the device node information to which the resource requirement information belongs, aggregates the multiple containers to obtain at least one container set; for each container set in the at least one container set, sends the runtime environment information of the container set and the container identifier of each container in the container set to a second device node; the second device node allocates resource identifiers based on the runtime environment information and the container identifiers to determine the initial resource identifier of each container in the multiple containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated; based on the obtained initial resource identifiers, the resources pointed to by the resource requirement information corresponding to the multiple containers are allocated respectively to obtain the resource allocation result. Thus, by aggregating multiple containers and using the second device node to allocate initial resource identifiers to each container in the aggregated container set, and then allocating resources based on these initial resource identifiers, the problem of port conflicts and resource conflicts that easily occur when deploying multiple containers on the same device node is solved, improving the security and stability of the system. Attached Figure Description
[0028] To more clearly illustrate the technical solutions and advantages in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a schematic diagram of an application environment for a container-based resource allocation method provided in an embodiment of this disclosure;
[0030] Figure 2 This is a partial flowchart illustrating a container-based resource allocation method provided in an embodiment of this disclosure;
[0031] Figure 3 This is a partial flowchart illustrating a container-based resource allocation method provided in an embodiment of this disclosure;
[0032] Figure 4 This is a schematic diagram of a portion of the process of a container-based resource allocation method provided in an embodiment of this disclosure;
[0033] Figure 5 This is a schematic flowchart of another container-based resource allocation method provided in this embodiment of the disclosure;
[0034] Figure 6 This is a partial flowchart illustrating a container-based resource allocation method provided in an embodiment of this disclosure;
[0035] Figure 7 This is a schematic diagram of a portion of the process of another container-based resource allocation method provided in an embodiment of this disclosure;
[0036] Figure 8 This is a schematic diagram of a portion of the process of another container-based resource allocation method provided in an embodiment of this disclosure;
[0037] Figure 9a and 9b These are schematic diagrams illustrating application scenarios of a container-based resource allocation method provided in this disclosure embodiment;
[0038] Figure 10 This is a structural block diagram of a container-based resource allocation device provided in an embodiment of this disclosure;
[0039] Figure 11 This is a structural block diagram of another container-based resource allocation device provided in an embodiment of this disclosure;
[0040] Figure 12 This is a schematic diagram of the hardware structure of a device for implementing the method provided in the embodiments of this disclosure. Detailed Implementation
[0041] To enable those skilled in the art to better understand the present disclosure, the technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present disclosure.
[0042] To make the objectives, technical solutions, and advantages of this disclosure clearer, the embodiments of this disclosure will be described in further detail below with reference to the accompanying drawings.
[0043] To facilitate understanding of the technical solutions described above and their resulting technical effects in the embodiments of this disclosure, the terms used in the embodiments of this disclosure are briefly introduced as follows:
[0044] Docker is an open-source application container engine that allows developers to package their applications and dependencies into a portable container and then deploy it on any popular Linux machine. It can also achieve virtualization. Containers use a sandbox mechanism and have no interface with each other.
[0045] A container refers to Docker's virtualization environment technology on Linux, which can create an independent runtime environment on Linux. Each container can run its own application service, and the normal operation of an application can be achieved through communication between multiple application services.
[0046] Host mode (or hostNetwork mode) refers to using Docker virtualization where containers are added to the network stack of the host machine (node machine) without being assigned virtual IP addresses (also known as private IP addresses). Instead, they communicate with the outside world using the host machine's IP address. If multiple Docker containers are virtualized on a single node machine and all use the host machine's IP address, they cannot monitor the same port.
[0047] Kubernetes (K8S) is an open-source, portable container orchestration and management tool designed for container services. It manages containerized applications across multiple hosts on a cloud platform, making application deployment simple and efficient, and providing a mechanism for application deployment, planning, updating, and maintenance.
[0048] Cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Based on the cloud computing business model, cloud technology encompasses network technology, information technology, integration technology, management platform technology, and application technology. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will require robust system support, which can be achieved through cloud computing.
[0049] Cloud computing is a computing model that distributes computing tasks across a large pool of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, resources in the "cloud" appear infinitely scalable, readily available, on-demand, and expandable, with payment based on usage.
[0050] As a provider of fundamental cloud computing capabilities, a cloud resource pool (referred to as a cloud platform, generally called an IaaS (Infrastructure as a Service) platform) is established. Various types of virtual resources are deployed in the resource pool for external customers to choose from. The cloud resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, and network devices.
[0051] Based on logical functional division, a PaaS (Platform as a Service) layer can be deployed on top of the IaaS (Infrastructure as a Service) layer, and a SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, SaaS can be directly deployed on IaaS. PaaS is a platform for running software, such as databases and web containers. SaaS refers to various types of business software, such as web portals and bulk SMS senders. Generally, SaaS and PaaS are upper layers relative to IaaS. The solutions provided in this disclosure involve technologies such as cloud technology, which will be specifically described through the following embodiments.
[0052] The container-based resource allocation method disclosed herein can be applied to, for example... Figure 1 In the hardware environment shown. For example... Figure 1 As shown, the hardware environment can be based on a container orchestration and management architecture (such as Kubernetes architecture), which includes at least a master node 110, a service node 120, and a second device node 130.
[0053] In this architecture, the master node 110 serves as the master node, i.e., the cluster control node, used to manage and control the entire cluster. Service nodes 120 serve as node nodes, and there can be multiple service nodes 120. Each service node 120 is connected to the master node 110 and receives workloads from it. Multiple containers can be deployed on each service node 120, and each container can run a unique application service. The normal operation of an application is achieved through communication between these application services. For example, taking a game application as an example, the application services could include page generation services, login services, and game messaging services. The second device node 130 serves as a resource allocation service node, providing resource allocation management services for the containers deployed on each service node.
[0054] As an example only, the master node 110, service node 120, and second device node 130 mentioned above can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing cloud computing services. The master node 110, service node 120, and second device node 130 can be directly or indirectly connected through wired or wireless communication, and this disclosure does not impose any restrictions.
[0055] In some embodiments, the master node 110, service node 120, and second device node 130 can also be implemented as nodes in a blockchain system. Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0056] It should be noted that, in practical applications, the container-based resource allocation method provided in this disclosure can be implemented in the first device node or the second device node, or jointly implemented by the first device node and the second device node. The first device node can be a service node and / or a master node in the above-mentioned hardware environment.
[0057] Of course, the methods provided in this disclosure are not limited to... Figure 1 The hardware environment shown can also be used in other possible hardware environments, and this disclosure does not limit the scope of the embodiments. Figure 1 The functions that each device in the hardware environment shown can perform will be described in subsequent method embodiments, and will not be elaborated on here.
[0058] Figure 2 This is a flowchart illustrating a container-based resource allocation method provided in an embodiment of this disclosure. This disclosure provides the operational steps of the method described in the embodiments or flowchart, but based on conventional or non-inventive methods, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many steps and does not represent a unique execution order. The executing entity of this container-based resource allocation method can be a first device node, which can be one of the aforementioned... Figure 1 The service nodes and / or master nodes in the system, taking the first device node as the service node as an example, are explained here. Figure 2 As shown, the method may include:
[0059] S201: In response to the fulfillment of the resource allocation triggering condition, obtain the container identifier and corresponding required resource information of each container in multiple containers.
[0060] During the containerized deployment of services, multiple containers can be created on the first device node. Each container can generate an independent runtime environment for deploying the corresponding application services. Each container has a corresponding container identifier and resource requirements information.
[0061] The container identifier is used to reflect the uniqueness of the container created in the first device node. This container identifier may include, but is not limited to, the container name and container ID.
[0062] Resource requirement information refers to the information about the target resource that the container needs to acquire. This target resource can include, but is not limited to, at least one resource such as a port, IP address, directory, file, memory, or service process identifier (busid). This resource requirement information can vary depending on the type of the target resource. Similarly, resource requirement information can include, but is not limited to, at least one of the following: port information, IP information, directory information, memory information, or service process identifier information.
[0063] It should be understood that the required resource information may include more granular resource information. For example, when the target resource is a port resource, the container's required resource information may include a first type of port information and a second type of port information. Here, the first type of port information and the second type of port information can refer to port numbers in port ranges corresponding to different container services. For example, the port number range corresponding to the first type of port information can be 1-10000, and the port number range corresponding to the second type of port information can be 10000-20000.
[0064] The triggering condition for resource allocation can refer to the conditions under which resource allocation is required. For example, during the startup or operation of some containers, these containers need to acquire resources such as ports to execute corresponding services, which requires resource allocation management for the containers, i.e., determining whether the triggering condition for resource allocation is met. Specifically, the corresponding thread in the first device node can be invoked to monitor the status of the containers deployed on it. If at least two containers are detected to be running, it can be determined that the triggering condition for resource allocation has been met.
[0065] In practical applications, the corresponding thread in the first device node can be called to monitor the status of the deployed containers. If at least two containers are detected to be running, it can be determined that the triggering conditions for resource allocation are met.
[0066] S203: Based on the device node information to which the demand resource information belongs, aggregate the multiple containers to obtain at least one container set.
[0067] The associated device node information indicates the location of the device node that hosts the resources required by the container. This associated device node information can be the container's host node information or other device node information. The associated device node information may include, but is not limited to, the device node's IP address and device node name.
[0068] Having determined the device node information to which the resource requirements of each container belong, multiple containers can be aggregated based on this device node information to construct at least one container set. Aggregation here refers to grouping at least one container with the same device node information together. Each device node information can correspond to a unique container set, and each container set can contain one or more containers.
[0069] In one optional implementation, the step of aggregating multiple containers based on the device node information to which the container's demand resource information belongs to obtain at least one container set includes: aggregating multiple containers based on the resource category and device node information to which the container's demand resource information belongs to obtain at least one container set.
[0070] During the aggregation process, in addition to considering the device node information to which the container's resource requirements belong, the resource category to which the container's resource requirements belong is also considered. Based on these two pieces of information, multiple containers are aggregated to construct at least one container set. This container set can simultaneously carry both its resource category and its device node information.
[0071] The resource category to which the requested resource information belongs reflects the resource contention object in the container's request. For example, the resource category to which the requested resource information belongs may include, but is not limited to, at least one primary resource category such as port, IP address, directory, file, memory, and service process identifier (busid). Of course, the resource category to which the requested resource information belongs may include more granular secondary resource categories, such as first-class ports, second-class ports, etc., with different port categories corresponding to different port number ranges. For example, the port number range corresponding to the first-class ports may be 1-10000, and the port number range corresponding to the second-class ports may be 10000-20000.
[0072] Having determined the device node information and resource category to which each container in a set of containers belongs, we can aggregate these containers based on their resource categories to construct at least one container set. Aggregation here refers to grouping together at least one container with the same resource requirements and the same device node information. Each resource category and device node information can correspond to a unique container set, and each container set can contain at least one container.
[0073] The above embodiments aggregate multiple containers by using the resource category and device node information of the container's required resources. The resulting container set carries both resource category and device node information, making resource allocation for the container set more accurate and improving resource utilization.
[0074] S205: For each container set in the at least one container set, the runtime environment information of the container set and the container identifier of each container in the container set are sent to the second device node; the second device node allocates resource identifiers based on the runtime environment information and the container identifiers to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated.
[0075] The runtime environment information of the container set reflects the environment shared by all containers within the set. This runtime environment information may include the IP address of the host node, and at least one of the following: the environment name, process name, or service name of the container set. This runtime environment information uniquely identifies different container sets, allowing for the determination of resource identifier information for each container within each container set, at least once. The second device node may be a device used to implement the initial resource identifier allocation service.
[0076] Optionally, when a container starts, runtime environment information such as the node IP and other key information (e.g., environment name) can be obtained through environment variables. This runtime environment information is then concatenated into a set name for each container set. Using the system-assigned container identifier as the key, an application is made to a unified second device node to allocate initial resource identifiers for each container in the container set. The second device node allocates initial resource identifiers based on a resource allocation list. This resource allocation list can record historical allocation information of initial resource identifiers already allocated in the second device node.
[0077] In practical applications, for each container set within at least one container set, a first device node can generate an identifier generation request corresponding to that container set based on the container set's runtime environment information and the container identifiers of each container within the container set. This identifier generation request is then sent to a second device node, which uses the runtime environment information and container identifiers of the container set carried in the identifier generation request as an allocation primary key. Based on the allocation primary key corresponding to each container among multiple containers, resource identifiers are allocated in the resource allocation list corresponding to the container set, determining the initial resource identifier for each container corresponding to each allocation primary key. This initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated. For example, the initial resource identifier can be a number (e.g., 1 to N, where N is a positive integer), a letter, or a string, with each different string corresponding to a different allocation sequence number (ID number) of the resource that the container needs to obtain. Different container sets can correspond to different resource allocation lists. In actual allocation requests, the initial resource identifier can be allocated based on a preset allocation strategy. This is just an example; the preset allocation strategy can be, but is not limited to, allocating initial resource identifiers in ascending order.
[0078] S207: Based on the obtained initial resource identifier, allocate the resources pointed to by the required resource information corresponding to the multiple containers respectively, and obtain the resource allocation result.
[0079] Optionally, the first device node can allocate target resources to each container based on the initial resource identifier of each container and according to the mapping relationship between the initial resource identifier and the resources pointed to by the required resource information. If the container successfully obtains the corresponding resource information, the allocation result of successful resource allocation can be obtained; if the container fails to obtain the corresponding resource information, the allocation result of failed resource allocation can be obtained.
[0080] In one optional implementation, the step of allocating resources corresponding to the required resource information of the multiple containers based on the obtained initial resource identifier, and obtaining resource allocation results, includes:
[0081] S2071: Based on the obtained initial resource identifier and the resource configuration information corresponding to each container in the plurality of containers, determine the target resource identifier for each container in the plurality of containers; the target resource identifier includes location information for pointing to the resource to be allocated;
[0082] S2073: Based on the target resource identifier, allocate the resources pointed to by the demand resource information corresponding to the multiple containers respectively to obtain the resource allocation result.
[0083] Optionally, after obtaining the initial resource identifier, the first device node can invoke a resource allocation script to determine the target resource identifier for each container based on the initial resource identifier and the resource configuration information corresponding to each container in the multiple containers. This resource configuration information can be at least one of the following: a resource range allocated to the device node, a preset allocation strategy, or resource allocation constraints. Different container sets' runtime environment information and the container identifiers of each container in the container set can correspond to different resource configuration information. This resource configuration information can be flexibly configured according to resource allocation requirements and container information. The target resource identifier can uniquely identify the corresponding resource. Then, based on the target resource identifier, the target resource is allocated to each container. If the container successfully acquires the corresponding target resource, a successful resource allocation result is obtained; if the container fails to acquire the corresponding target resource, a failed resource allocation result is obtained.
[0084] For example, taking an initial resource identifier as a number and the required resource as a port resource, for container set A = {container 1, container 2, container 3, ...}, the port range allocated to the nodes in container set A is 10001 to 11000. Before resource allocation, a resource partitioning strategy can be determined, such as sequential allocation according to the size of the initial resource identifier. In this case, if the initial resource identifier of container 1 is 1, the corresponding target resource identifier is calculated as port 10001 according to the preset allocation strategy; if the initial resource identifier of container 2 is 2, the corresponding target resource identifier is calculated as port 10002 according to the same strategy; if the initial resource identifier of container 3 is 5, the corresponding target resource identifier is calculated as port 10005, and so on. The same method can be used for allocating specific directories on a machine, allocating a certain memory range, allocating service process identifiers, etc. Each resource can have its own corresponding preset allocation strategy, and different container sets corresponding to the same resource can also have their own corresponding preset allocation strategies. After determining the target resource identifier for each container in container set A, the target resource corresponding to the target resource identifier can be quickly identified, improving resource allocation efficiency. Furthermore, the target resource identifier is determined based on resource configuration information, enabling flexible resource allocation across multiple dimensions, supporting resources such as ports, IP addresses, directories, files, and service process identifiers.
[0085] It should be noted that when deploying containers in hostNetwork mode in this embodiment of the present disclosure, when multiple container services are launched on a single device node, after the container starts the service using the node's IP address, it can bind different resources (such as ports) according to the unique initial resource identifier allocated to avoid resource conflicts with other containers.
[0086] In the above embodiment, in response to the fulfillment of a resource allocation trigger condition, the container identifier and corresponding resource requirement information of each container in multiple containers are obtained; based on the device node information to which the resource requirement information belongs, the multiple containers are aggregated to obtain at least one container set; for each container set in the at least one container set, the runtime environment information of the container set and the container identifier of each container in the container set are sent to a second device node; the second device node allocates resource identifiers based on the runtime environment information and the container identifiers to determine the initial resource identifier of each container in the multiple containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated; based on the obtained initial resource identifiers, the resources pointed to by the resource requirement information corresponding to the multiple containers are allocated respectively to obtain the resource allocation result. Thus, by aggregating multiple containers and using the second device node to allocate initial resource identifiers to each container in the aggregated container set, and then allocating resources based on these initial resource identifiers, the problem of port conflicts and resource conflicts that easily occur when deploying multiple containers on the same device node is solved, improving the security and stability of the system.
[0087] Furthermore, this disclosure resolves resource conflicts and other issues inherent in hostNetwork deployment by adopting a unified resource allocation method that avoids relying on existing containerized deployments. Instead, it allows containers to be deployed using a hostNetwork approach, automatically allocating resources via scripts. Resource configuration information only needs to be set up in advance, and then the allocation can be handled by the second device node. Specifically, various resources such as ports and busids can be managed using allocation sequence numbers corresponding to initial resource identifiers. This approach eliminates the limitations of existing container platform-supported resource allocation functions, enabling flexible resource allocation across multiple dimensions.
[0088] In an alternative implementation, such as Figure 3 and Figure 4 As shown, after the step of obtaining the resource allocation result, the method further includes:
[0089] S301: Upon detecting the container process corresponding to the target container, an update request is generated for the initial resource identifier corresponding to the target container. The update request is used to instruct the second device node to refresh the registration information corresponding to the allocated initial resource identifier.
[0090] S303: Upon detecting the trigger condition that the target container exits the container process, a release request is generated for the initial resource identifier corresponding to the target container. The release request is used to instruct the second device node to perform a release operation on the allocated initial resource identifier.
[0091] The target container is at least one of the plurality of containers.
[0092] Furthermore, upon detecting the container process corresponding to the target container (i.e., during container runtime), to ensure that the initial resource identifier is continuously occupied, update requests can be sent periodically to refresh the container's registration information on the second device node, updating the lifespan of the original initial resource identifier. This ensures the relationship between the running container and the refreshed initial resource identifier, preventing the initial resource identifier from being occupied by other container services and causing resource conflicts again. For example, this can be done by periodically reporting updates, or by using methods such as persistent TCP connections for initial resource identifier lifespan detection.
[0093] Upon detecting the trigger condition for the target container's exit process, i.e., when the target container exits, after determining all related processes exiting the target container, information is submitted to the second device node to release the use of the initial resource identifier. Simultaneously, upon detecting the release of the initial resource identifier, the target resources allocated based on that released initial resource identifier can be reclaimed.
[0094] The above-mentioned approach monitors the operational status of containers and dynamically adjusts the initial resource identifier information corresponding to containers in different states based on their lifecycle, further avoiding resource conflicts and improving resource allocation efficiency and utilization. Simultaneously, when a target container is detected to be exiting, the initial resource identifier is released, and the target resource corresponding to the released initial resource identifier is promptly reclaimed, improving the effective utilization of resources and reducing waste.
[0095] Figure 5 This is a flowchart illustrating a container-based resource allocation method provided in an embodiment of this disclosure. This disclosure provides the operational steps of the method described in the embodiments or flowchart, but based on conventional or non-inventive methods, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many steps and does not represent a unique execution order. The execution entity of this container-based resource allocation method is the aforementioned... Figure 1 Taking the second device node in the example, as an example, Figure 5 As shown, the method may include:
[0096] S501: Obtain the runtime environment information of each container set in at least one container set and the container identifier of each container in the container set; the at least one container set is obtained by the first device node in response to the triggering condition of resource allocation, obtaining the container identifiers of multiple containers and the resource demand information of multiple containers; and based on the device node information to which the resource demand information belongs, aggregating the multiple containers.
[0097] S503: Based on the operating environment information and the container identifier, resource identifier allocation is performed to determine the initial resource identifier of each container in the multiple containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated.
[0098] In an alternative implementation, such as Figure 6 As shown, the process of allocating resource identifiers based on the runtime environment information and the container identifier, and determining the initial resource identifier for each container among the multiple containers, includes:
[0099] S5031: For each container set in the at least one container set, after determining that at least one first container in the container set has a resource identifier allocation record, detect whether there is an expired resource identifier;
[0100] S5033: Upon detecting an expired resource identifier, based on the first identifier allocation strategy, the runtime environment information, and the container identifier, at least one of the expired resource identifiers is used as the initial resource identifier of at least one of the first containers.
[0101] S5035: Upon detecting that no expired resource identifier exists, based on the second identifier allocation strategy, the operating environment information, and the container identifier, at least one unoccupied resource identifier is used as the initial resource identifier of at least one of the first containers.
[0102] S5037: If it is determined that there is no resource identifier allocation record for the first container in the container set, register at least one of the first containers and allocate a corresponding initial resource identifier.
[0103] Optionally, continue as follows Figure 6As shown, for each container set in the at least one container set, after the container is launched, the second device node is accessed through the set name and container identifier of the container set. The second device node can be an allocation server that provides, for example, MySQL query functionality. When the second device node determines that at least one first container in each container set does not have a resource identifier allocation record, that is, the first container has not been registered with the second device node, it registers at least one of the first containers and allocates a corresponding initial resource identifier. When the second device node determines that at least one first container in each container set has a resource identifier allocation record, that is, the first container has been registered with the second device node, it can first query whether there are any expired initial resource identifiers in the resource identifier allocation record. If so, it is determined that there are expired resource identifiers, and according to the first identifier allocation strategy, the runtime environment information, and the container identifier, at least one resource identifier from the expired resource identifiers is used as the initial resource identifier of the first container. The first identifier allocation strategy can be an allocation in ascending order. If no expired resource identifier is found, it is determined that there are expired resource identifiers, and according to the second identifier allocation strategy, the runtime environment information, and the container identifier, at least one resource identifier from the unoccupied resource identifiers is used as the initial resource identifier of the first container. Specifically, the second identifier allocation strategy can apply for container registration after obtaining the latest initial resource identifier vid' based on the unoccupied resource identifier vid corresponding to the current container identifier and the identifier increment n. Here, the identifier increment n can be a positive integer. The second device node determines at least one of the following in each container set:
[0104] For example, taking an increment of n of 1 as an example, first query the maximum initial resource identifier vid. max and in the largest initial resource identifier vid max Based on this, add an increment n to the identifier, that is, vid max +1 serves as the initial resource identifier vid' for the first container making the latest request to register the container. After the first container obtains the allocated initial resource identifier vid', it retrieves the resource configuration corresponding to the allocation sequence number of the initial resource identifier vid' from the resource configuration information and then uses it. During the container's lifespan, it can periodically report the initial resource identifier information to the second device node to refresh the initial resource identifier information.
[0105] S505: The initial resource identifier is sent to the first device node. Based on the obtained initial resource identifier, the first device node allocates resources to the resources pointed to by the required resource information of the multiple containers respectively, and obtains resource allocation results.
[0106] Optionally, continuing the example above, after the first container obtains the allocated initial resource identifier vid', it sends the initial resource identifier vid' to the first device node. The first device node retrieves the allocated resource corresponding to the allocation sequence number of the initial resource identifier vid' from the resource configuration information based on the initial resource identifier vid', and then allocates and uses the resource. During the lifetime of the first container, it periodically reports the initial resource identifier information vid' to the second device node to refresh the initial resource identifier information.
[0107] The above embodiments, by aggregating multiple containers and using a second device node to assign initial resource identifiers to each container in the aggregated container set, and then allocating resources based on these initial resource identifiers, solve the problem of resource conflicts that easily occur when deploying multiple containers on the same device node, thereby improving the security and stability of the system.
[0108] It should be understood that any details and beneficial effects not disclosed in the above steps can be found in the above embodiments, and will not be repeated here.
[0109] In an alternative implementation, such as Figure 7 As shown, the method further includes:
[0110] S701: For each container set in the at least one container set, if it is determined that at least one second container in the container set has a resource identifier allocation record, obtain the historical resource identifier of at least one second container; the historical resource identifier is the initial resource identifier that has been allocated.
[0111] S703: Use the historical resource identifier as the initial resource identifier of at least one of the second containers.
[0112] Optionally, during the initial resource allocation process, the required registration name is a unique value. Each registration name uniquely represents the client requesting the service. Therefore, if the service encounters an anomaly or a registration is submitted repeatedly, the second device node will first check whether the second container has a previously allocated initial resource identifier record (including expired but unused initial resource identifiers) in the current resource identifier allocation record. If a previously used historical resource identifier can still be registered, it can be reused as the initial resource identifier for the second container. This method ensures consistency in logical usage after the service recovers from an anomaly.
[0113] In practical applications, if the second device node exits abnormally and all operation records are lost, the update heartbeat reported by the client service corresponding to the second container upon reconnection will contain the currently allocated historical resource identifier. When the second device node receives an update request (not a registration request), it will also prioritize registering the same historical resource identifier with the client corresponding to the second container as the initial resource identifier for that second container, avoiding logical anomalies caused by reallocating the initial resource identifier. This ensures the automatic recovery capability of the second device node in abnormal situations, reduces the risk of anomalies, and further improves system stability.
[0114] In an alternative implementation, such as Figure 8 As shown, the method further includes:
[0115] S801: In response to a request to release the initial resource identifier corresponding to the target container, a release operation is performed on the allocated initial resource identifier; the target container is at least one of the plurality of containers;
[0116] S803: Adjust the current marking time of the initial resource identifier after release to the first marking time, where the first marking time is a first time difference earlier than the current marking time;
[0117] S805: Adjust the current marking time of the initial resource identifier after release to the second marking time, where the second marking time is a second time difference later than the current marking time.
[0118] Optionally, after the target container uses the initial resource identifier and is deregistered, in order to avoid time discrepancies between machines, the time of the second device node is uniformly used. After the target container releases the initial resource identifier, the current marked time of the released initial resource identifier is adjusted to the first marked time, which is the time difference earlier than the current marked time. In other words, the time is marked as the time difference before the current marked time (e.g., five minutes). This ensures that the initial resource identifier can be put into use immediately after release, avoids idle waste of resources, and improves the response efficiency of the system's container service.
[0119] Alternatively, when some services of the target container stop, some functions may not be completely cleaned up. To avoid conflicts between the reused initial resource identifier and the old service, after the target container releases the initial resource identifier, the current marking time of the released initial resource identifier can be adjusted to a second marking time, which is a second time difference later than the current marking time. In other words, the release time is increased by a second time difference lock time (e.g., five minutes). Then, the initial resource identifier under this container set can only be reused after five minutes. During this period, when this container set requests an initial resource identifier, if there is no reusable initial resource identifier, a new initial resource identifier can be pulled for use. In this way, service conflicts caused by the old and new services are avoided, and the stability of the system is improved.
[0120] To facilitate understanding, the method disclosed herein will be described in detail with reference to some specific application scenarios:
[0121] 1) In a game application scenario, the game service module includes dozens of types of service modules such as lobby, chat, store, team, etc. Each service module can be deployed in containers on different first device nodes in the game service cluster based on hostNetwork mode. The same game service can be deployed in multiple containers on different first device nodes.
[0122] like Figure 9a As shown, the container-based resource allocation method disclosed herein aggregates containers corresponding to multiple game services based on the device node information of each first device node, obtaining container set a and container set b. Then, the second device node allocates resource identifiers based on the runtime environment information of these two container sets and the container identifiers of the containers in each container set. The initial resource identifier for each game service's container is determined in the initial resource set corresponding to each container set. This initial resource identifier can be an allocation sequence number. This initial resource identifier can be understood as the nth game service started on the first device node. Taking port resources as an example, after obtaining the initial resource identifier of container 11, an unallocated starting port value (e.g., 7000) is selected from the resource set corresponding to container set a. The sum of this starting port value and the initial resource identifier (e.g., 20) (i.e., port value 7020) is used as the monitoring port for the service process corresponding to container 11. After obtaining the initial resource identifier of container k2, select an unallocated starting port value (e.g., 8000) from the resource set corresponding to container set b, and use the sum of the starting port value and the initial resource identifier (e.g., 50) (i.e., the port value is 8050) as the monitoring port of the service process corresponding to container k2.
[0123] In this way, based on this monitoring port, the local IP address and port of the first device node can be reported to a unified management server. The management server will broadcast the information of this service process to other game service processes that are also connected, enabling dynamic discovery and communication between processes. Processes can connect and access each other within the game service cluster based on each other's IP address and port. Thus, through the above resource allocation method, it can be ensured that any number of hostNetwork containers started on the first device node will not interfere with each other's communication, avoiding port conflicts within the game service cluster.
[0124] It should be understood that if a container other than the hostNetwork is deployed, the virtual IP can be replaced with the node IP mentioned above, and the same good resource allocation effect can be achieved.
[0125] 2) In another gaming application scenario, for a large-scale game application, for example, if a battlefield has 10 players, one battlefield service can run 350 battlefields simultaneously. Therefore, if millions of players are online, more than 300 battlefield services are needed. Each battlefield service needs to be allocated a port and obtain an open IP address on the external network for external devices (such as game clients) to connect to, thus enabling external devices to connect to the game service and experience its functions. In this scenario requiring large-scale resource allocation to achieve open service, traditional Kubernetes solutions cannot handle such large-scale resource management and allocation.
[0126] In this game application scenario, such as Figure 9b As shown, the game gateway needs to open firewalls for these addresses and ports, or configure a cloud service's cluster load balancer (Clb), and the game service itself needs to obtain an external access point for distribution to external devices (such as game clients). When deploying such game services in containers, in addition to resolving the aforementioned port conflict issues, it is also necessary to ensure that they are only assigned to ports that are already open to the external network, and that the game service itself can obtain an external access point.
[0127] Continue as Figure 9bAs shown, the container-based resource allocation method disclosed herein aggregates multiple service containers corresponding to the game service based on the device node information (e.g., node IP) and the resource category of the required resource information, obtaining container sets 1 to 4. Then, the second device node allocates resource identifiers based on the runtime environment information (e.g., service name) of these four container sets and the container identifiers of the containers in each container set. Initial resource identifiers are determined for each container in the initial resource sets corresponding to different container sets. These initial resource identifiers can be allocation sequence numbers (e.g., ID numbers). These initial resource identifiers can be understood as indicating which type of container service is started on the first device node, enabling individual identification of this type of container service. Next, a configuration file for the first device node is generated from the IP ports that have already applied for external network access, such as those opened in firewalls or bound to Clb. Based on this configuration file, all open port information is obtained, and the corresponding ports are retrieved according to the initial resource identifiers. Simultaneously, the corresponding external network entry connections can be stored in the configuration file, achieving large-scale resource management and allocation while avoiding port conflicts for external access of the game service cluster.
[0128] 3) In another game application scenario, taking the resource requirement as the service process identifier as an example, each game service will use a service process identifier (busid) as the unique identifier of the service process. The service process identifier can be an int 32 bits, and its data format can be: Region ID (255).Service Type (255).Instance ID (65535).
[0129] The resource allocation method disclosed herein aggregates multiple service containers corresponding to the game service based on the resource category of the required resource information to obtain at least one container set. Then, a second device node allocates resource identifiers based on the runtime environment information (e.g., environment name) of the container set and the container identifiers of the containers in each container set, determining the initial resource identifier for each container among the multiple containers. This initial resource identifier can be an allocation sequence number (e.g., ID number), which can be understood as the nth container service of this type of service in the game service cluster environment. Using this initial resource identifier as the instance ID in the busid, a unique service process identifier under the game service cluster can be generated.
[0130] It should be understood that the application scenarios used in this disclosure are not limited to those listed above, and may also be applicable to other applicable scenarios.
[0131] It should be noted that this disclosure is designed based on the container lifecycle and is decoupled from various container orchestration and management technologies currently used in the industry. Therefore, it is applicable to all container orchestration and management technologies. Corresponding extension plugins can be developed based on Kubernetes to support this functionality, enabling flexible resource allocation.
[0132] For technical details not described in detail in the methods provided in the above embodiments, please refer to the methods provided in any of the above embodiments of this disclosure, which will not be repeated here.
[0133] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein. For details not disclosed in the apparatus embodiments of this disclosure, please refer to the embodiments of the method disclosed herein.
[0134] Please refer to Figure 10 This diagram illustrates a structural block diagram of a container-based resource allocation device according to an embodiment of this disclosure. The device implements the functions described in the method example above; these functions can be implemented in hardware or by hardware executing corresponding software. The container-based resource allocation device, applied to a first device node, may include:
[0135] The first acquisition module 1001 is used to acquire the container identifier and corresponding resource demand information of each container in multiple containers in response to the triggering condition of resource allocation being met.
[0136] The second acquisition module 1002 is used to aggregate multiple containers based on the device node information to which the demand resource information belongs, and obtain at least one container set;
[0137] The first sending module 1003 is used to send the runtime environment information of the container set and the container identifier of each container in the container set to the second device node for each container set in the at least one container set; the second device node performs resource identifier allocation based on the runtime environment information and the container identifier to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated;
[0138] The allocation module 1004 is used to allocate resources pointed to by the required resource information corresponding to the multiple containers based on the obtained initial resource identifier, and obtain resource allocation results.
[0139] In an optional implementation, the allocation module is specifically used for:
[0140] Based on the obtained initial resource identifier and the resource configuration information corresponding to each container in the plurality of containers, a target resource identifier for each container in the plurality of containers is determined; the target resource identifier is used to point to the location information of the resource to be allocated.
[0141] Based on the target resource identifier, the resources pointed to by the demand resource information corresponding to the multiple containers are allocated respectively to obtain the resource allocation result.
[0142] In one optional implementation, the second acquisition module is specifically used for:
[0143] Based on the resource category and device node information of the container's required resources, multiple containers are aggregated to obtain at least one container set.
[0144] In an alternative embodiment, the apparatus further includes:
[0145] The update module is used to generate an update request for the initial resource identifier corresponding to the target container when the container process corresponding to the target container is detected. The update request is used to instruct the second device node to refresh the registration information corresponding to the allocated initial resource identifier.
[0146] The release module is used to generate a release request for the initial resource identifier corresponding to the target container when the trigger condition of the target container exiting the container process is detected. The release request is used to instruct the second device node to perform a release operation on the allocated initial resource identifier.
[0147] The target container is at least one of the plurality of containers.
[0148] The apparatus provided in the above embodiments can execute the corresponding methods in the embodiments of this disclosure, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the methods provided in any embodiment of this application.
[0149] Please refer to Figure 11 This diagram illustrates a structural block diagram of another container-based resource allocation device provided in an embodiment of this disclosure. The device has the functions described in the method examples above, which can be implemented in hardware or by hardware executing corresponding software. The container-based resource allocation device is applied to a second device node and may include:
[0150] The third acquisition module 1101 is used to acquire the runtime environment information of each container set in at least one container set and the container identifier of each container in the container set; the at least one container set is obtained by the first device node in response to the triggering condition of resource allocation, acquiring the container identifiers of multiple containers and the resource demand information of multiple containers; and aggregating multiple containers based on the resource category to which the resource demand information belongs.
[0151] The identifier determination module 1102 is used to allocate resource identifiers based on the operating environment information and the container identifier, and to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated;
[0152] The second sending module 1103 is used to send the initial resource identifier to the first device node. Based on the obtained initial resource identifier, the first device node allocates resources pointed to by the demand resource information corresponding to the multiple containers respectively, and obtains resource allocation results.
[0153] In an optional implementation, the identifier determination module is specifically used for:
[0154] For each container set in the at least one container set, if it is determined that at least one first container in the container set has a resource identifier allocation record, it is detected whether there is an expired resource identifier.
[0155] Upon detecting an expired resource identifier, based on the first identifier allocation policy, the runtime environment information, and the container identifier, at least one of the expired resource identifiers is used as the initial resource identifier for at least one of the first containers.
[0156] If no expired resource identifier is detected, at least one resource identifier among the unoccupied resource identifiers is used as the initial resource identifier of at least one of the first containers, according to the second identifier allocation strategy, the runtime environment information and the container identifier.
[0157] In an optional implementation where it is determined that the first container in the container set does not have a resource identifier allocation record, the apparatus further includes:
[0158] For each container set in the at least one container set, if it is determined that at least one second container in the container set has a resource identifier allocation record, the historical resource identifier of at least one second container is obtained; the historical resource identifier is the initial resource identifier that has been allocated.
[0159] The historical resource identifier is used as the initial resource identifier for at least one of the second containers.
[0160] In an alternative embodiment, the apparatus further includes:
[0161] In response to a request to release the initial resource identifier corresponding to the target container, a release operation is performed on the allocated initial resource identifier; the target container is at least one of the plurality of containers;
[0162] The current marking time of the released initial resource identifier is adjusted to a first marking time, which is a first time difference earlier than the current marking time; or, the current marking time of the released initial resource identifier is adjusted to a second marking time, which is a second time difference later than the current marking time.
[0163] The apparatus provided in the above embodiments can execute the corresponding methods in the embodiments of this disclosure, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the methods provided in any embodiment of this application.
[0164] This disclosure provides a computer device that may include a processor and a memory. The memory stores at least one instruction, at least one program, a code set, or an instruction set. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the method described in any of the above method embodiments.
[0165] This disclosure also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded by a processor and executed by any of the methods described in the above method embodiments.
[0166] This disclosure also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the methods described in this embodiment.
[0167] Furthermore, Figure 12 A schematic diagram of a hardware structure for implementing the methods provided in the embodiments of this disclosure is shown. The device may be a computer terminal, a mobile terminal, or other device, and may also participate in or include the apparatus provided in the embodiments of this disclosure. Figure 12As shown, the computer terminal 12 may include one or more processors 122 (shown as 122a, 122b, ..., 122n in the figure) 122 (processor 122 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 124 for storing data, and a transmission device 126 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 12 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 12 may also include... Figure 12 The more or fewer components shown, or having the same Figure 12 The different configurations shown.
[0168] It should be noted that the aforementioned one or more processors 122 and / or other data processing circuitry are generally referred to herein as "data processing circuitry". This data processing circuitry may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 12 (or mobile device). As per the embodiments of this disclosure, the data processing circuitry serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0169] The memory 124 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method described in this embodiment. The processor 122 executes various functional applications and data processing by running the software programs and modules stored in the memory 124, thereby implementing the aforementioned neural network processing method. The memory 124 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 124 may further include memory remotely located relative to the processor 122, and these remote memories can be connected to the computer terminal 12 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0170] The transmission device 126 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 12. In one example, the transmission device 126 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 126 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0171] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 12 (or mobile device).
[0172] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments of this disclosure have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.
[0173] The various embodiments in this disclosure are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and server embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0174] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0175] The above description is only a preferred embodiment of this disclosure and is not intended to limit this disclosure. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the protection scope of this disclosure.
Claims
1. A container-based resource allocation method, characterized in that, Applied to multiple first device nodes, including: In response to the fulfillment of the resource allocation trigger condition, the container identifier and corresponding resource requirement information of each container in the multiple containers are obtained; the trigger condition is when at least two containers are detected to be starting. Based on the resource category and device node information of the demand resource information, multiple containers are aggregated to obtain at least one container set; the resource category of the demand resource information is used to reflect the resource contention object of the container request; each container in each container set has the same device node and resource category; For each container set in the at least one container set, the runtime environment information of the container set and the container identifier of each container in the container set are sent to the second device node; the second device node allocates resource identifiers based on the runtime environment information and the container identifiers to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated; Based on the obtained initial resource identifier, the resources pointed to by the demand resource information corresponding to the multiple containers are allocated respectively to obtain resource allocation results; The step of allocating resources corresponding to the demand resource information of multiple containers based on the obtained initial resource identifier to obtain resource allocation results includes: determining the target resource identifier of each container in the multiple containers based on the obtained initial resource identifier and the resource configuration information corresponding to each container in the multiple containers; the target resource identifier includes location information for pointing to the resource to be allocated; the resource configuration information includes at least one of the resource range allocated to the device node, a preset allocation strategy, and resource allocation constraints; and allocating resources corresponding to the demand resource information of multiple containers based on the target resource identifier to obtain resource allocation results. Upon detecting the container process corresponding to the target container, an update request is generated for the initial resource identifier corresponding to the target container. The update request is used to instruct the second device node to refresh the registration information corresponding to the allocated initial resource identifier. Upon detecting the trigger condition that the target container exits the container process, a release request is generated for the initial resource identifier corresponding to the target container. The release request is used to instruct the second device node to perform a release operation on the allocated initial resource identifier. The target container is at least one of the multiple containers.
2. A container-based resource allocation method, characterized in that, Applied to the second device node, including: The system acquires runtime environment information of each container set in at least one container set and container identifiers of each container in the container set; the at least one container set is obtained by a first device node in response to a resource allocation trigger condition, acquiring container identifiers of multiple containers and resource demand information of multiple containers; and aggregates the multiple containers based on the resource category and device node information to which the resource demand information belongs; the resource category to which the resource demand information belongs is used to reflect the resource contention object requested by the container; the trigger condition is when at least two containers are detected to start. Based on the runtime environment information and the container identifier, resource identifiers are allocated to determine the initial resource identifier for each container in the multiple containers. The initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated. Each container in each container set belongs to the same device node and resource category. The initial resource identifier is sent to the first device node. Based on the obtained initial resource identifier, the first device node allocates resources to the resources pointed to by the required resource information of the multiple containers respectively, and obtains resource allocation results. Based on the obtained initial resource identifier, the resources pointed to by the demand resource information corresponding to the multiple containers are allocated respectively, and the resource allocation results are obtained as follows: Based on the obtained initial resource identifier and the resource configuration information corresponding to each container in the plurality of containers, a target resource identifier for each container in the plurality of containers is determined; the target resource identifier includes location information for pointing to the resource to be allocated; the resource configuration information includes at least one of the resource range allocated to the device node, a preset allocation strategy, and resource allocation constraints. Based on the target resource identifier, the resources pointed to by the demand resource information corresponding to the multiple containers are allocated respectively to obtain the resource allocation result; In response to a request to release the initial resource identifier corresponding to the target container, a release operation is performed on the allocated initial resource identifier; the target container is at least one of the plurality of containers; In response to the update request sent by the first device node, the registration information corresponding to the allocated initial resource identifier is refreshed.
3. The method according to claim 2, characterized in that, The process of allocating resource identifiers based on the runtime environment information and the container identifier, and determining the initial resource identifier for each container among the multiple containers, includes: For each container set in the at least one container set, if it is determined that at least one first container in the container set has a resource identifier allocation record, it is detected whether there is an expired resource identifier. Upon detecting an expired resource identifier, based on the first identifier allocation policy, the runtime environment information, and the container identifier, at least one of the expired resource identifiers is used as the initial resource identifier for at least one of the first containers. If no expired resource identifier is detected, at least one resource identifier among the unoccupied resource identifiers is used as the initial resource identifier of at least one of the first containers, according to the second identifier allocation strategy, the runtime environment information and the container identifier. If it is determined that there is no resource identifier allocation record for the first container in the container set, at least one of the first containers is registered and a corresponding initial resource identifier is assigned.
4. The method according to claim 2, characterized in that, The method further includes: For each container set in the at least one container set, if it is determined that at least one second container in the container set has a resource identifier allocation record, the historical resource identifier of at least one second container is obtained; the historical resource identifier is the initial resource identifier that has been allocated. The historical resource identifier is used as the initial resource identifier for at least one of the second containers.
5. The method according to any one of claims 2-4, characterized in that, The method further includes: The current marking time of the released initial resource identifier is adjusted to a first marking time, which is a first time difference earlier than the current marking time; or, the current marking time of the released initial resource identifier is adjusted to a second marking time, which is a second time difference later than the current marking time.
6. A container-based resource allocation device, characterized in that, The device is applied to multiple first device nodes and includes: The first acquisition module is used to acquire the container identifier and corresponding resource demand information of each container in multiple containers in response to the triggering condition of resource allocation being met; the triggering condition is when at least two containers are detected to be starting. The second acquisition module is used to aggregate multiple containers based on the resource category and device node information of the demand resource information to obtain at least one container set; the resource category of the demand resource information is used to reflect the resource contention object of the container request; each container in each container set has the same device node and resource category; The first sending module is configured to send the runtime environment information of the container set and the container identifier of each container in the container set to the second device node for each container set in the at least one container set; the second device node performs resource identifier allocation based on the runtime environment information and the container identifier to determine the initial resource identifier of each container in the plurality of containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated; The allocation module is used to allocate resources pointed to by the required resource information corresponding to the multiple containers based on the obtained initial resource identifier, and obtain resource allocation results; The update module is used to generate an update request for the initial resource identifier corresponding to the target container when the container process corresponding to the target container is detected. The update request is used to instruct the second device node to refresh the registration information corresponding to the allocated initial resource identifier. The process of allocating resources based on the obtained initial resource identifier to the resources pointed to by the demand resource information corresponding to the multiple containers, and obtaining resource allocation results, includes: Based on the obtained initial resource identifier and the resource configuration information corresponding to each container in the plurality of containers, a target resource identifier for each container in the plurality of containers is determined; the target resource identifier includes location information for pointing to the resource to be allocated; the resource configuration information includes at least one of the resource range allocated to the device node, a preset allocation strategy, and resource allocation constraints. Based on the target resource identifier, the resources pointed to by the demand resource information corresponding to the multiple containers are allocated respectively to obtain the resource allocation result; The release module is used to generate a release request for the initial resource identifier corresponding to the target container when the trigger condition of the target container exiting the container process is detected. The release request is used to instruct the second device node to perform a release operation on the allocated initial resource identifier. The target container is at least one of the multiple containers.
7. A container-based resource allocation device, characterized in that, Applied to a second device node, the device includes: The third acquisition module is used to acquire the runtime environment information of each container set in at least one container set and the container identifier of each container in the container set; the at least one container set is obtained by the first device node in response to a resource allocation trigger condition, acquiring the container identifiers of multiple containers and the resource demand information of multiple containers; and aggregating the multiple containers based on the resource category and device node information to which the resource demand information belongs; the resource category to which the resource demand information belongs is used to reflect the resource contention object requested by the container; the trigger condition is when at least two containers are detected to be starting; The identifier determination module is used to allocate resource identifiers based on the runtime environment information and the container identifier, and to determine the initial resource identifier of each container in the multiple containers; the initial resource identifier is used to characterize the allocation sequence number of each container in each container set for the resource to be allocated; the device node and resource category to which each container in each container set belongs are the same; The second sending module is used to send the initial resource identifier to the first device node. The first device node allocates resources pointed to by the required resource information of the multiple containers based on the obtained initial resource identifier, and obtains resource allocation results. The update module is used to refresh the registration information corresponding to the allocated initial resource identifier in response to the update request sent by the first device node. The process of allocating resources based on the obtained initial resource identifier to the resources pointed to by the demand resource information corresponding to the multiple containers, and obtaining resource allocation results, includes: Based on the obtained initial resource identifier and the resource configuration information corresponding to each container in the plurality of containers, a target resource identifier for each container in the plurality of containers is determined; the target resource identifier includes location information for pointing to the resource to be allocated; the resource configuration information includes at least one of the resource range allocated to the device node, a preset allocation strategy, and resource allocation constraints. Based on the target resource identifier, the resources pointed to by the demand resource information corresponding to the multiple containers are allocated respectively to obtain the resource allocation result; The release module is used to release the allocated initial resource identifier in response to a release request for the initial resource identifier corresponding to the target container; the target container is at least one of the plurality of containers.
8. The resource allocation device according to claim 7, characterized in that, The identifier determination module is used for: For each container set in the at least one container set, if it is determined that at least one first container in the container set has a resource identifier allocation record, it is detected whether there is an expired resource identifier. Upon detecting an expired resource identifier, based on the first identifier allocation policy, the runtime environment information, and the container identifier, at least one of the expired resource identifiers is used as the initial resource identifier for at least one of the first containers. If no expired resource identifier is detected, at least one resource identifier among the unoccupied resource identifiers is used as the initial resource identifier of at least one of the first containers, according to the second identifier allocation strategy, the runtime environment information and the container identifier. If it is determined that there is no resource identifier allocation record for the first container in the container set, at least one of the first containers is registered and a corresponding initial resource identifier is assigned.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the container-based resource allocation method as described in claim 1, or the container-based resource allocation method as described in any one of claims 2-5.
10. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the container-based resource allocation method as described in claim 1, or the container-based resource allocation method as described in any one of claims 2-5.
11. A computer program product, characterized in that, The computer program product includes at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the container-based resource allocation method as described in claim 1, or the container-based resource allocation method as described in any one of claims 2-5.
Citation Information
Patent Citations
Container processing method and device, main body server, system and storage medium
CN109992354A
Container creation method, server and storage medium
CN111787126A
Port distribution method and system based on container
CN114138464A
