[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN107783836B - Method and device for controlling Web application resources based on Linux container - Google Patents

Method and device for controlling Web application resources based on Linux container Download PDF

Info

Publication number
CN107783836B
CN107783836B CN201610790693.8A CN201610790693A CN107783836B CN 107783836 B CN107783836 B CN 107783836B CN 201610790693 A CN201610790693 A CN 201610790693A CN 107783836 B CN107783836 B CN 107783836B
Authority
CN
China
Prior art keywords
application
thread
resource control
control group
application resource
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610790693.8A
Other languages
Chinese (zh)
Other versions
CN107783836A (en
Inventor
何震苇
杨新章
陆钢
严丽云
梁柏青
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN201610790693.8A priority Critical patent/CN107783836B/en
Publication of CN107783836A publication Critical patent/CN107783836A/en
Application granted granted Critical
Publication of CN107783836B publication Critical patent/CN107783836B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5044Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering hardware capabilities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/504Resource capping

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method and a device for controlling Web application resources based on a Linux container, and relates to the field of cloud computing. The method comprises the following steps: creating an application resource control group; setting a mapping relation between a Web application ID and an application resource control group ID; setting a mapping relation among a Web application ID, a user thread ID and a kernel thread ID; calling an interface of an application resource control group according to the Web application ID, and writing the kernel thread ID into a task control list of the corresponding application resource control group; and when the kernel thread is scheduled, executing the resource control strategy of the application resource control group according to the kernel thread ID, thereby realizing the fine control of each Web application resource quota by taking the thread as granularity.

Description

Method and device for controlling Web application resources based on Linux container
Technical Field
The invention relates to the field of cloud computing, in particular to a method and a device for controlling Web application resources based on a Linux container.
Background
The lightweight Web application is managed and operated based on a Web application engine, the Web application engine provides a common class library and a runtime environment required by application operation, a large number of lightweight Web applications can be managed and operated on one Web application engine at the same time, and as all applications on the application engine share the same host resources, the resources of the whole host are exhausted when an abnormal condition (such as a dead cycle) occurs in a specific application, so that the resource quota of the Web application needs to be controlled.
As shown in fig. 1, a Web application engine generally uses a language-level sandbox technology (such as a custom class loader, an interface security policy, etc.) to control application resources, and provides a dedicated thread and an I/O interface for an application, so that the Web application is tightly bound to the application engine, which affects the portability of the application, and the application engine operates in an operating system user mode and cannot control kernel-mode resources (such as a kernel thread, a CPU physical core, etc.).
In addition, currently, the mainstream Linux container technology (e.g., LXC, Docker, etc.) mainly controls resources by taking a process as a granularity, and as shown in fig. 2, a container technology can be used to package a Web application and an application engine integrally and run in an isolated manner in the form of a process container, however, the application engine usually occupies hundreds of megabytes, which increases the overhead of deployment and running of a lightweight Web application.
Disclosure of Invention
The technical problem to be solved by the invention is to provide a scheme capable of finely controlling lightweight Web application resource quotas by taking threads as granularity.
According to one aspect of the invention, a method for controlling Web application resources based on a Linux container is provided, which comprises the following steps: creating an application resource control group; setting a mapping relation between a Web application ID and an application resource control group ID; setting a mapping relation among a Web application ID, a user thread ID and a kernel thread ID; calling an interface of an application resource control group according to the Web application ID, and writing the kernel thread ID into a task control list of the corresponding application resource control group; and executing the resource control strategy of the application resource control group according to the kernel thread ID when the kernel thread is scheduled.
Further, creating the application resource control group includes: an application resource control group is created according to the type and priority of the Web application.
Further, setting a mapping relationship among the Web application ID, the user thread ID, and the kernel thread ID includes: setting a mapping relation between a user thread ID and a kernel thread ID in a thread library; and calling an interface of a bottom layer language or an operating system thread library by an application engine corresponding to the Web application ID to acquire the kernel thread ID corresponding to the user thread ID, so as to establish the mapping relation between the Web application ID and the user thread ID and the mapping relation between the Web application ID and the kernel thread ID.
Further, executing the resource control policy of the application resource control group according to the kernel thread ID includes: acquiring a corresponding application resource control group according to the kernel thread ID; and resource control kernel threads configured according to the application resource control groups.
Further, the resource control kernel thread configured according to the application resource control group includes: the CPU, memory, and I/O configured according to the application resource control group controls the upper limit of the CPU time slice, stack size, Swap size, and/or I/O rate that each kernel thread can use.
Further, the method further comprises: the corresponding Web applications in the application resource control group have the same resource priority.
According to another aspect of the present invention, there is further provided an apparatus for controlling Web application resources based on a Linux container, including: the control group creation module is used for creating an application resource control group; the application deployment management module is used for setting the mapping relation between the Web application ID and the application resource control group ID; the thread manager module is used for setting the mapping relation among the Web application ID, the user thread ID and the kernel thread ID; and the application resource management module is used for calling an interface of the application resource control group according to the Web application ID and writing the kernel thread ID into the task control list of the corresponding application resource control group so as to execute the resource control strategy of the application resource control group according to the kernel thread ID when the kernel thread is scheduled.
Further, the control group creation module is configured to create the application resource control group according to the type and priority of the Web application.
Further, the thread manager module is configured to obtain a mapping relationship between the user thread ID and the kernel thread ID from the thread library, and store the mapping relationship between the Web application ID and the user thread ID and the mapping relationship between the Web application ID and the kernel ID.
Further, the application resource management module is configured to obtain a corresponding application resource control group according to the kernel thread ID, and control the kernel thread according to the resource configured by the application resource control group.
Further, the application resource management module is used for controlling the CPU time slice, the stack size, the Swap size and/or the upper limit of the I/O rate which can be used by each kernel thread according to the CPU, the memory and the I/O configured by the application resource control group.
Further, the corresponding Web applications in the application resource control group have the same resource priority.
Compared with the prior art, the method and the device have the advantages that the application resource control group is created, the mapping relation between the Web application ID and the application resource control group ID and the mapping relation between the Web application ID, the user thread ID and the kernel thread ID are set, the interface of the application resource control group is called according to the Web application ID, the kernel thread ID is written into the corresponding task control list of the application resource control group, and when the kernel thread is scheduled, the resource control strategy of the application resource control group is executed according to the kernel thread ID, so that the fine control of each Web application resource quota by taking the thread as granularity is realized.
Other features of the present invention and advantages thereof will become apparent from the following detailed description of exemplary embodiments thereof, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description, serve to explain the principles of the invention.
The invention will be more clearly understood from the following detailed description, taken with reference to the accompanying drawings, in which:
fig. 1 is a schematic diagram of a conventional language-level application resource control method based on an application sandbox.
Fig. 2 is a schematic diagram of a conventional container-based process-level application resource control method.
Fig. 3 is a flowchart illustrating an embodiment of a method for controlling Web application resources based on a Linux container according to the present invention.
Fig. 4 is a flowchart illustrating another embodiment of the method for controlling Web application resources based on a Linux container according to the present invention.
Fig. 5 is a schematic structural diagram of an embodiment of the apparatus for controlling Web application resources based on a Linux container according to the present invention.
FIG. 6 is a diagram illustrating an embodiment of controlling Web application resources based on a Linux container according to the present invention.
Detailed Description
Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that: the relative arrangement of the components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description.
The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate.
In all examples shown and discussed herein, any particular value should be construed as merely illustrative, and not limiting. Thus, other examples of the exemplary embodiments may have different values.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to specific embodiments and the accompanying drawings.
Fig. 3 is a flowchart illustrating an embodiment of a method for controlling Web application resources based on a Linux container according to the present invention. The method comprises the following steps:
at step 310, an application resource control group is created. I.e., defining several thread-level resource control groups. For example, n groups of application resource Control groups are defined according to a performance model or priority of an application, a CGroup (Control Group) is created for each application resource Control Group, and the upper limit of CPU, memory and I/O resources of each CGroup is configured.
At step 320, the mapping relationship between the Web application ID and the application resource control group ID is set. When the application is deployed, namely the Web application is deployed on the application engine, the application ID and the application resource control group ID are bound.
In step 330, a mapping relationship between the Web application ID, the user thread ID, and the kernel thread ID is set. For example, an application engine corresponding to the Web application ID invokes an interface of a thread library (e.g., posix) to create a user thread, which binds the user thread to a kernel thread. The application engine calls the thread library interface again to obtain the mapping relation between the user thread ID and the kernel thread ID, so that the corresponding relation between the Web application ID and the user thread ID and the mapping relation between the Web application ID and the kernel thread ID are established.
In step 340, the interface of the application resource control group is called according to the Web application ID, and the kernel thread ID is written into the task control list of the corresponding application resource control group.
In step 350, when the kernel thread is scheduled, the resource control policy of the application resource control group is executed according to the kernel thread ID. When the operating system schedules the kernel thread, the operating system executes the resource control strategy of the CGroup control group associated with the kernel thread, and realizes the resource control of a CPU, a memory and an I/O (input/output), namely, the control of a CPU time slice, a stack size, a Swap size and an upper limit of an I/O rate which can be used by each thread of application.
In the embodiment, by creating an application resource control group, setting a mapping relationship between a Web application ID and an application resource control group ID and a mapping relationship between the Web application ID, a user thread ID and a kernel thread ID, calling an interface of the application resource control group according to the Web application ID, writing the kernel thread ID into a task control list of the corresponding application resource control group, and executing a resource control policy of the application resource control group according to the kernel thread ID when scheduling the kernel thread, fine control of each Web application resource quota with the thread as granularity is realized.
Fig. 4 is a flowchart illustrating another embodiment of the method for controlling Web application resources based on a Linux container according to the present invention. The method comprises the following steps:
at step 410, application resource control groups are created according to the type and priority of the Web application, one CGroup for each application resource control group. The CPU, memory and I/O resource upper limit of each CGroup may be configured, and the corresponding Web application in each application resource control group has the same resource priority. For example, each process or kernel thread in the same application resource control group can obtain the same proportion of resources, and the processes or threads in the application resource control group with higher priority can obtain more resources.
Assume that the system has two CPU control groups, CPU _ g1, CPU _ g 2. Wherein the weight of the CPU _ g1 is 100 and the weight of the CPU _ g2 is 200, that is, the CPU _ g2 can obtain twice more CPU time slices than the CPU _ g 1. If there are two applications, app1 and app2, and assuming that the number of threads of each application is the same, the threads of app1 are all added to cpu _ g1, and the threads of app2 are all added to cpu _ g2, then app1 can obtain a cpu time of 100/100+200, and app2 can obtain a cpu time of 200/100+ 200. If there is now one app3 added to cpu _ g2, then the time slices available to app1 are 100/100+200 x 2, and the time slices available to both app2 and app3 are 200/100+200 x 2.
At step 420, when the Web application is deployed on the application engine, the application ID is bound to the application resource control group ID. The Web applications and the application resource control groups are in a one-to-many relationship, that is, each Web application can only bind one application resource control group, and one application resource control group can bind a plurality of applications.
In step 430, the application engine calls an interface of the underlying language or the operating system thread library to learn the corresponding relationship between the Web application ID and the user thread ID and the mapping relationship between the Web application ID and the kernel thread ID. The application ID and the user thread ID are in a 1: n relationship, the current mainstream Web application engines all adopt a 1:1 thread model, namely one user thread corresponds to one kernel thread, and for example, a Java-based full-series Web server adopts a 1:1 thread model. The Web application engine may also be an n:1 threading model, such as a script-based Web engine, e.g., ruby, Python, etc., or an n: m threading model, which is rarely used in Web engines, but is usually used by xen, kvm, etc. virtual machines.
The Web application engine generally adopts a multi-thread Web application model, when the application engine receives a Web request of a certain Web application, the application engine acquires an idle thread from a common thread pool and executes the Web request of the application, and in the process of executing the Web request, the Web application can also create a new thread as required and asynchronously process time-consuming tasks, such as database operation, file I/O operation and the like. The Web application engine and the Web application are both language-level Thread-class-provided methods for triggering the start Thread, for example, the Java application engine starts the Java Thread through a start () method of Java.
In step 440, the interface of the application resource control group is called according to the Web application ID, and the kernel thread ID is written into the task control list of the corresponding application resource control group. The task control list of the application resource control group is controlled by a Tasks file of the CGroup, and a kernel thread ID or a process ID to be controlled can be written into the Tasks file of the corresponding CGroup directory. Taking Ubuntu as an example, the tasks file is placed in the directory of/sys/fs/cgroup/cpu/groupname/tasks.
When the Web application engine adopts the n:1 and n: m thread models, a condition that one kernel thread corresponds to a plurality of user threads exists, that is, a condition that one kernel thread corresponds to a plurality of applications exists, and at this time, the mapping relationship between the kernel thread and the application resource control group can adopt the mode that the kernel thread is added into the application resource control group corresponding to the application with the highest resource quota.
In step 450, the operating system executes the resource control policy of the application resource control group associated with the kernel thread when scheduling the kernel thread, thereby implementing resource control of the CPU, the memory, and the I/O.
In the embodiment, an application resource control group is defined for each type of Web application, the applications in the same application resource control group have the same resource priority, a CGroup is allocated to each application resource control group, managed application resources of an application engine are controlled through a Linux CGroup mechanism, the applications and the resource control groups are bound when the Web application is deployed, threads allocated to the Web application are mapped into kernel threads, and kernel thread IDs are added to a task control list of the CGroup, so that when the kernel threads are scheduled, a resource control strategy of the corresponding application resource control group is executed according to the kernel thread IDs. The embodiment can enhance and realize the resource isolation of the lightweight Web application, provides a thread-level resource isolation means for the lightweight Web application, and also improves the deployment density and efficiency of the Web application, can deploy a large number of lightweight Web applications on a single application engine, and can adjust the resource quota of the application on line according to the change of the application load.
Fig. 5 is a schematic structural diagram of an embodiment of the apparatus for controlling Web application resources based on a Linux container according to the present invention. The apparatus includes a control group creation module 510, an application deployment management module 520, a thread manager module 530, and an application resource management module 540, wherein:
the control group creation module 510 is used to create application resource control groups. I.e., defining several thread-level resource control groups. For example, n groups of application resource control groups are defined according to the performance model or priority of the application, one CGroup is created for each application resource control group, and the upper limit of the CPU, memory and I/O resources of each CGroup is configured.
The application deployment management module 520 is configured to set a mapping relationship between the Web application ID and the application resource control group ID. When the application is deployed, namely the Web application is deployed on the application engine, the application ID and the application resource control group ID are bound.
The thread manager module 530 is used to set a mapping relationship between the Web application ID, the user thread ID, and the kernel thread ID. In the one-to-one and many-to-one thread models, the same user thread binds the same kernel thread ID in the whole life cycle, and in the many-to-many thread model, the user thread may bind different kernel threads in the life cycle, so that the kernel thread ID corresponding to the user thread ID needs to be polled periodically or a thread binding relationship change event is monitored.
The application resource management module 540 is configured to invoke an interface of an application resource control group according to the Web application ID, and write the kernel thread ID into the task control list of the corresponding application resource control group, so that when the kernel thread is scheduled, a resource control policy of the application resource control group is executed according to the kernel thread ID. When the operating system schedules the kernel thread, the operating system executes the resource control strategy of the CGroup control group associated with the kernel thread, and realizes the resource control of a CPU, a memory and an I/O (input/output), namely, the control of a CPU time slice, a stack size, a Swap size and an upper limit of an I/O rate which can be used by each thread of application.
In the embodiment, by creating an application resource control group, setting a mapping relationship between a Web application ID and an application resource control group ID and a mapping relationship between the Web application ID, a user thread ID and a kernel thread ID, calling an interface of the application resource control group according to the Web application ID, writing the kernel thread ID into a task control list of the corresponding application resource control group, and executing a resource control policy of the application resource control group according to the kernel thread ID when scheduling the kernel thread, fine control of each Web application resource quota with the thread as granularity is realized.
In another embodiment of the present invention, the control group creation module 510 is configured to create application resource control groups according to the type and priority of the Web application, and create a CGroup for each application resource control group. The CPU, memory and I/O resource upper limit of each CGroup may be configured, and the corresponding Web application in each application resource control group has the same resource priority. Taking a CPU as an example, a CPU subsystem of an operating system schedules CPU resources through a CFS scheduler, adds all active processes or kernel threads to a red-black tree, and uses a virtual running time of the CPU as a sorting basis for nodes of the red-black tree, and preferentially schedules nodes with smaller virtual running times, where the virtual running time is determined by an actual running time of the process/thread and a CPU weight of a control group, and the weight is inversely proportional to the virtual running time, i.e., the larger the weight is, the smaller the virtual running time is, and the higher the probability of being scheduled is.
The application deployment management module 520 is configured to bind the application ID and the application resource control group ID when the Web application is deployed to the application engine. The Web applications and the application resource control groups are in a one-to-many relationship, that is, each Web application can only bind one application resource control group, and one application resource control group can bind a plurality of applications.
The thread manager module 530 is configured to obtain a mapping relationship between a user thread ID and a kernel thread ID from a thread library, and store a mapping relationship between a Web application ID and the user thread ID and a mapping relationship between the Web application ID and the kernel ID.
The application resource management module 540 is configured to invoke an interface of an application resource control group according to the Web application ID, and write the kernel thread ID into the task control list of the corresponding application resource control group, so that when the operating system schedules the kernel thread, the operating system executes a resource control policy of the application resource control group associated with the kernel thread, thereby implementing resource control on the CPU, the memory, and the I/O.
The task control list of the application resource control group is controlled by a Tasks file of the CGroup, and a kernel thread ID or a process ID to be controlled can be written into the Tasks file of the corresponding CGroup directory.
In the embodiment, an application resource control group is defined for each type of Web application, the applications in the same application resource control group have the same resource priority, a CGroup is allocated to each application resource control group, managed application resources of an application engine are controlled through a Linux CGroup mechanism, the applications and the resource control groups are bound when the Web application is deployed, threads allocated to the Web application are mapped into kernel threads, and kernel thread IDs are added to a task control list of the CGroup, so that when the kernel threads are scheduled, a resource control strategy of the corresponding application resource control group is executed according to the kernel thread IDs. The embodiment can enhance and realize the resource isolation of the lightweight Web application, provides a thread-level resource isolation means for the lightweight Web application, and also improves the deployment density and efficiency of the Web application, can deploy a large number of lightweight Web applications on a single application engine, and can adjust the resource quota of the application on line according to the change of the application load.
FIG. 6 is a diagram illustrating an embodiment of controlling Web application resources based on a Linux container according to the present invention.
First, two groups of application resource control groups are defined, and a CGroup is created for each application resource control group, such as CGroup app1 and CGroup app2, and CPU, memory and I/O resource upper limits are configured for CGroup app1 and CGroup app2, respectively.
In this embodiment, the container engine is extended, and the extended container engine includes an application deployment management module, an application resource management module, and a container resource management module. When the Web application is deployed on the application engine, the application deployment management module manages the relationship between the Web application and the application thread resource control group, namely, the Java application 1 and the Ruby application 1 are respectively bound to the CGroupAPP1, and the Java application 2 and the Ruby application 2 are respectively bound to the CGroupAPP 2. In addition, the cgroupaae 1 and cgroupaae 2 are control groups oriented to the application engine, control is the main process resource of the application engine, the application engine is deployed in the container, and management of the application engine and control of the main process resource are realized through the mechanism of the container. Wherein each CGroup is managed by a CGroups manager. In addition, the application resource management module manages the corresponding relation between the thread tasks of the application and the application resource control group, the container resource management module controls the resources at the level of the application engine, and the container resources are isolated and controlled.
In addition, the same application engine only needs to be deployed once on the same host, that is, each application engine has only one instance at most on each host. The application engine is deployed in a container mirror mode, the application is deployed in an application package (such as WAR) mode, the application deployment module is deployed in the application engine of a specified host, and a plurality of applications can be deployed on one application engine, so that the deployment and running expenses of the light Web application are reduced.
In this embodiment, a thread manager module is further added to the application engine, and the thread manager module is responsible for mapping the user thread allocated to the application to a kernel thread and binding the relationship between the kernel thread and the application thread. The thread manager module packages the original thread manager of the Web application engine for the second time and provides a thread operation interface the same as that of the original thread manager. The Web application engine generally loads a thread manager at startup, and the loaded thread manager can be provided by an underlying language environment (such as JRE), or can be provided by the application engine after secondary packaging based on the thread manager or an operating system thread library of the underlying language environment.
In this embodiment, for the problem that resources of a lightweight Web application hosted at high density are difficult to be effectively isolated and controlled currently, a plurality of thread-level resource control groups are defined first, the application is associated with the thread-level resource control groups when the application is deployed, a corresponding kernel thread ID is written into the thread-resource control group associated with the application when a thread is created or allocated for the application, and an operating system executes a resource quota of the corresponding control group when the kernel thread is scheduled, thereby implementing fine control of resource quotas of each Web application. In addition, the application in the embodiment still uses the original thread interface, the control process of the resource is realized by the thread manager module, the resource control mechanism is transparent to the application, the application code does not need to be modified, and the portability of the application is ensured.
Thus far, the present invention has been described in detail. Some details well known in the art have not been described in order to avoid obscuring the concepts of the present invention. It will be fully apparent to those skilled in the art from the foregoing description how to practice the presently disclosed embodiments.
The method and apparatus of the present invention may be implemented in a number of ways. For example, the methods and apparatus of the present invention may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order for the steps of the method is for illustrative purposes only, and the steps of the method of the present invention are not limited to the order specifically described above unless specifically indicated otherwise. Furthermore, in some embodiments, the present invention may also be embodied as a program recorded in a recording medium, the program including machine-readable instructions for implementing a method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
Although some specific embodiments of the present invention have been described in detail by way of illustration, it should be understood by those skilled in the art that the above illustration is only for the purpose of illustration and is not intended to limit the scope of the invention. It will be appreciated by those skilled in the art that modifications may be made to the above embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.

Claims (12)

1. A method for controlling Web application resources based on a Linux container is characterized by comprising the following steps:
creating an application resource control group and defining a thread-level application resource control group;
setting a mapping relation between a Web application ID and an application resource control group ID;
setting a mapping relation among the Web application ID, the user thread ID and the kernel thread ID;
calling an interface of an application resource control group according to the Web application ID, and writing the kernel thread ID into a corresponding task control list of the application resource control group;
and executing the resource control strategy of the application resource control group according to the kernel thread ID when the kernel thread is scheduled.
2. The method of claim 1, wherein creating the application resource control group comprises:
and creating the application resource control group according to the type and the priority of the Web application.
3. The method of claim 1, wherein setting the mapping relationship between the Web application ID, the user thread ID and the kernel thread ID comprises:
setting a mapping relation between the user thread ID and the kernel thread ID in a thread library;
and the application engine corresponding to the Web application ID calls an interface of the thread library to acquire the kernel thread ID corresponding to the user thread ID, so that the mapping relation between the Web application ID and the user thread ID and the mapping relation between the Web application ID and the kernel thread ID are established.
4. The method according to any of claims 1-3, wherein said enforcing the resource control policy of the application resource control group according to the kernel thread ID comprises:
acquiring the corresponding application resource control group according to the kernel thread ID;
and controlling the kernel thread according to the resources configured by the application resource control group.
5. The method of claim 4, wherein the controlling the kernel thread according to the resource control group configuration comprises:
and controlling the CPU time slice, the stack size, the Swap size and/or the upper limit of the I/O rate which can be used by each kernel thread according to the CPU, the memory and the I/O configured by the application resource control group.
6. The method of any of claims 1-3, further comprising:
and the corresponding Web applications in the application resource control group have the same resource priority.
7. An apparatus for controlling Web application resources based on a Linux container, comprising:
the control group creation module is used for creating an application resource control group and defining a thread-level application resource control group;
the application deployment management module is used for setting the mapping relation between the Web application ID and the application resource control group ID;
the thread manager module is used for setting the mapping relation among the Web application ID, the user thread ID and the kernel thread ID;
and the application resource management module is used for calling an interface of an application resource control group according to the Web application ID and writing the kernel thread ID into a corresponding task control list of the application resource control group so as to execute a resource control strategy of the application resource control group according to the kernel thread ID when the kernel thread is scheduled.
8. The apparatus of claim 7 wherein the control group creation module is configured to create the application resource control group based on a type and priority of the Web application.
9. The apparatus of claim 7, wherein the thread manager module is configured to obtain a mapping relationship between the user thread ID and the kernel thread ID from a thread library, and store the mapping relationship between the Web application ID and the user thread ID and the mapping relationship between the Web application ID and the kernel thread ID.
10. The apparatus according to any one of claims 7 to 9, wherein the application resource management module is configured to obtain the corresponding application resource control group according to the kernel thread ID, and control the kernel thread according to the resource configured in the application resource control group.
11. The apparatus as claimed in claim 10, wherein the application resource management module is configured to control the upper limit of the CPU time slice, stack size, Swap size and/or I/O rate that each kernel thread can use according to the configured CPU, memory and I/O of the application resource control group.
12. The apparatus according to any of claims 7-9, wherein the corresponding Web applications in the application resource control group have the same resource priority.
CN201610790693.8A 2016-08-31 2016-08-31 Method and device for controlling Web application resources based on Linux container Active CN107783836B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610790693.8A CN107783836B (en) 2016-08-31 2016-08-31 Method and device for controlling Web application resources based on Linux container

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610790693.8A CN107783836B (en) 2016-08-31 2016-08-31 Method and device for controlling Web application resources based on Linux container

Publications (2)

Publication Number Publication Date
CN107783836A CN107783836A (en) 2018-03-09
CN107783836B true CN107783836B (en) 2020-10-09

Family

ID=61451510

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610790693.8A Active CN107783836B (en) 2016-08-31 2016-08-31 Method and device for controlling Web application resources based on Linux container

Country Status (1)

Country Link
CN (1) CN107783836B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111290858B (en) * 2020-05-11 2020-08-11 腾讯科技(深圳)有限公司 Input/output resource management method, device, computer equipment and storage medium
CN113806011B (en) * 2021-08-17 2023-12-19 曙光信息产业股份有限公司 Cluster resource control method and device, cluster and computer readable storage medium
CN116431335B (en) * 2023-03-21 2024-06-07 哈尔滨工业大学 Control group-based container message queue resource quota control method
CN117290116B (en) * 2023-11-27 2024-02-23 和创(北京)科技股份有限公司 Dynamic code running method, device, equipment and system for controllable resources

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001265609A (en) * 2000-03-16 2001-09-28 Omron Corp Arithmetic processor
JP2005251184A (en) * 2004-03-04 2005-09-15 Internatl Business Mach Corp <Ibm> Device, method and program for managing resource in multi-node computer system
CN102831015A (en) * 2012-08-01 2012-12-19 华为技术有限公司 Method and equipment for scheduling multi-core processor
CN104407924A (en) * 2014-10-31 2015-03-11 小米科技有限责任公司 Method and device for optimizing internal memory
WO2015191358A1 (en) * 2014-06-10 2015-12-17 Qualcomm Incorporated Systems and methods of managing processor device power consumption

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001265609A (en) * 2000-03-16 2001-09-28 Omron Corp Arithmetic processor
JP2005251184A (en) * 2004-03-04 2005-09-15 Internatl Business Mach Corp <Ibm> Device, method and program for managing resource in multi-node computer system
CN102831015A (en) * 2012-08-01 2012-12-19 华为技术有限公司 Method and equipment for scheduling multi-core processor
WO2015191358A1 (en) * 2014-06-10 2015-12-17 Qualcomm Incorporated Systems and methods of managing processor device power consumption
CN104407924A (en) * 2014-10-31 2015-03-11 小米科技有限责任公司 Method and device for optimizing internal memory

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
GPUVerify: a verifier for GPU kernels;Adam Betts 等;《Proceedings of the ACM international conference on Object oriented programming systems languages and applications》;20121231;113-131 *
基于WEB的系统组态;刁勇;《中国优秀硕士学位论文全文数据库 信息科技辑》;20060415;I138-190 *
电信运营商对容器技术的探索和思考;陆钢 等;《电信科学》;20160820(第8期);159-163 *

Also Published As

Publication number Publication date
CN107783836A (en) 2018-03-09

Similar Documents

Publication Publication Date Title
Gadepalli et al. Sledge: A serverless-first, light-weight wasm runtime for the edge
JP6646114B2 (en) Dynamic virtual machine sizing
CN110888743B (en) GPU resource using method, device and storage medium
US9996401B2 (en) Task processing method and virtual machine
US9417912B2 (en) Ordering tasks scheduled for execution based on priority and event type triggering the task, selecting schedulers for tasks using a weight table and scheduler priority
EP3332321B1 (en) Process and thread launch features
US8549524B2 (en) Task scheduler for cooperative tasks and threads for multiprocessors and multicore systems
US8161453B2 (en) Method and apparatus for implementing task management of computer operations
US20230393879A1 (en) Coordinated Container Scheduling For Improved Resource Allocation In Virtual Computing Environment
CN107783836B (en) Method and device for controlling Web application resources based on Linux container
Allen Effective Akka: Patterns and Best Practices
US11061729B2 (en) Throttling logging processes
KR20100073980A (en) System and method for shifting workloads across platform in a hybrid system
CN111880891B (en) Extensible virtual machine monitor based on microkernel and embedded system
WO2019214608A1 (en) User space pre-emptive real-time task scheduler
CN106250217A (en) Synchronous dispatching method between a kind of many virtual processors and dispatching patcher thereof
CN115686805A (en) GPU resource sharing method and device, and GPU resource sharing scheduling method and device
Chen et al. Pufferfish: Container-driven elastic memory management for data-intensive applications
Chen et al. Preemptive and low latency datacenter scheduling via lightweight containers
JP2007280397A (en) Method for loading program by computer system including a plurality of processing nodes, computer readable medium including program, and parallel computer system
US9619277B2 (en) Computer with plurality of processors sharing process queue, and process dispatch processing method
US8010963B2 (en) Method, apparatus and program storage device for providing light weight system calls to improve user mode performance
Lufei et al. vStarCloud: An operating system architecture for Cloud computing
McBride SledgeEDF: deadline-driven serverless for the edge
KR102708907B1 (en) External exception handling

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20180309

Assignee: Tianyiyun Technology Co.,Ltd.

Assignor: CHINA TELECOM Corp.,Ltd.

Contract record no.: X2024110000040

Denomination of invention: Method and device for controlling web application resources based on Linux containers

Granted publication date: 20201009

License type: Common License

Record date: 20240914