CN117234732A - Shared resource allocation method, device, equipment and medium - Google Patents
Shared resource allocation method, device, equipment and medium Download PDFInfo
- Publication number
- CN117234732A CN117234732A CN202311266555.6A CN202311266555A CN117234732A CN 117234732 A CN117234732 A CN 117234732A CN 202311266555 A CN202311266555 A CN 202311266555A CN 117234732 A CN117234732 A CN 117234732A
- Authority
- CN
- China
- Prior art keywords
- resources
- resource
- allocated
- amount
- resource allocation
- 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.)
- Pending
Links
- 238000013468 resource allocation Methods 0.000 title claims abstract description 136
- 238000000034 method Methods 0.000 title claims abstract description 75
- 238000001514 detection method Methods 0.000 claims abstract description 34
- 230000008569 process Effects 0.000 description 28
- 238000010586 diagram Methods 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 4
- 230000008520 organization Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 125000004122 cyclic group Chemical group 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- OKTJSMMVPCPJKN-UHFFFAOYSA-N Carbon Chemical compound [C] OKTJSMMVPCPJKN-UHFFFAOYSA-N 0.000 description 1
- 238000013475 authorization Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 238000004880 explosion Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 229910021389 graphene Inorganic materials 0.000 description 1
- 238000005192 partition Methods 0.000 description 1
- 238000000638 solvent extraction Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
One or more embodiments of the present disclosure provide a method, an apparatus, a device, and a medium for allocating a shared resource. According to the method and the device, when a resource allocation request of a shared resource of a target system is applied for acquisition by any module, the total amount of allocated resources in the target system is detected based on the preset first resource allocation indication information, so that the amount of resources to be allocated, which are acquired by the resource allocation request application, is detected based on the preset second resource allocation indication information under the condition that the total amount of the allocated resources does not exceed the upper limit of the use of the resources indicated by the first resource allocation indication information, and further the resource allocation is performed based on the detection result of the amount of the resources to be allocated, so that the situation that the total amount of the use of the resources or the use amount of the resources of a single module exceeds the limit is avoided, and more reasonable allocation of the shared resources is realized.
Description
Technical Field
One or more embodiments of the present disclosure relate to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for allocating a shared resource.
Background
With the advancement of technology and the popularity of the global internet, there is an increasing need to efficiently utilize and share limited resources to meet the ever-increasing demands of resource use, and the importance of shared resources in today's rapidly evolving digital era is becoming increasingly prominent. By sharing the resources, the limited resources can be utilized to the greatest extent, so that the resource waste is reduced, and the resource utilization efficiency is improved.
In a computer system, a certain resource can be allocated to a plurality of users for sharing, and when the users use the resource, the users can squeeze each other, so that how to reasonably allocate the shared resource to the plurality of users is a problem to be solved in the resource sharing process.
Disclosure of Invention
In view of this, one or more embodiments of the present disclosure provide a method, apparatus, device, and medium for allocating shared resources
In order to achieve the above object, one or more embodiments of the present disclosure provide the following technical solutions:
according to a first aspect of one or more embodiments of the present disclosure, a method for allocating a shared resource is provided, including:
responding to a resource allocation request of any module for acquiring shared resources of a target system, and detecting the total amount of allocated resources in the target system based on preset first resource allocation indication information, wherein the first resource allocation indication information is used for indicating the upper limit of resource use of the target system;
Detecting the amount of the resources to be allocated acquired by the resource allocation request application based on preset second resource allocation indication information, wherein the second resource allocation indication information is used for indicating the upper limit of the use of the resources of the module in the target system, under the condition that the total amount of the allocated resources does not exceed the upper limit of the use of the resources indicated by the first resource allocation indication information;
and carrying out resource allocation based on the detection result of the amount of the resources to be allocated.
According to a second aspect of one or more embodiments of the present specification, there is provided an allocation apparatus of a shared resource, including:
the detection unit is used for responding to a resource allocation request of any module for acquiring the shared resource of the target system, and detecting the total amount of allocated resources in the target system based on preset first resource allocation indication information, wherein the first resource allocation indication information is used for indicating the upper limit of the use of the resources of the target system;
the detecting unit is further configured to detect, based on preset second resource allocation indication information, an amount of resources to be allocated acquired by the resource allocation request application, where the total amount of allocated resources does not exceed an upper limit of resource usage indicated by the first resource allocation indication information, and the second resource allocation indication information is used to indicate an upper limit of resource usage of the module in the target system;
And the allocation unit is used for carrying out resource allocation based on the detection result of the resource quantity to be allocated.
According to a third aspect of one or more embodiments of the present specification, there is provided a computing device comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method as described in the first aspect above by executing executable instructions.
According to a fourth aspect of one or more embodiments of the present description, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement a method as described in the first aspect above.
According to the method and the device, when a resource allocation request of a shared resource of a target system is applied for acquisition by any module, the total amount of allocated resources in the target system is detected based on the preset first resource allocation indication information, so that the amount of resources to be allocated, which are acquired by the resource allocation request application, is detected based on the preset second resource allocation indication information under the condition that the total amount of the allocated resources does not exceed the upper limit of the use of the resources indicated by the first resource allocation indication information, and further the resource allocation is performed based on the detection result of the amount of the resources to be allocated, so that the situation that the total amount of the use of the resources or the use amount of the resources of a single module exceeds the limit is avoided, and more reasonable allocation of the shared resources is realized.
Drawings
Fig. 1 is a flowchart of a method for allocating shared resources according to an exemplary embodiment.
Fig. 2 is a schematic diagram of an organization architecture of a speed limiting unit according to an exemplary embodiment.
Fig. 3 is a flowchart of a method for allocating shared resources according to an exemplary embodiment.
FIG. 4 is a schematic block diagram of a computing device provided by an exemplary embodiment.
Fig. 5 is a block diagram of a shared resource allocation apparatus according to an exemplary embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the present specification. Rather, they are merely examples of apparatus and methods consistent with aspects of one or more embodiments of the present description as detailed in the accompanying claims.
It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than described in this specification. Furthermore, individual steps described in this specification, in other embodiments, may be described as being split into multiple steps; while various steps described in this specification may be combined into a single step in other embodiments.
User information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in this specification are both information and data authorized by the user or sufficiently authorized by the parties, and the collection, use and processing of relevant data requires compliance with relevant laws and regulations and standards of the relevant country and region, and is provided with corresponding operation portals for the user to choose authorization or denial.
In a computer system (e.g., a software system), a shared resource (e.g., memory) may be shared by multiple users who have some degree of occupation with each other when using the resource, and the resource has a total upper limit, and the sum of the resource usage amounts of all users cannot exceed the upper limit. In addition, in the use process of the shared resource, the consumption process of the shared resource is often required to be limited, that is, on the premise that the total amount of the resource is constant or the generation speed of the resource is constant, the consumption speed of the resource is usually required to be limited to a certain extent before the resource is about to be consumed, so as to ensure that the consumption speed of the resource can drop 0 as smoothly as possible. It can be said that the preemption and allocation control of shared resources is ubiquitous in work and life. It should be noted that, a user sharing a resource may be referred to as a module, and a module referred to hereinafter is a user sharing a resource.
The present disclosure provides a method for allocating a shared resource, which is used for implementing allocation of the shared resource, so as to achieve an automatic balance between resource sharing and speed limiting of multiple modules in a computer system, so as to more reasonably allocate the shared resource.
Optionally, the method for allocating the shared resource provided in the present specification may be used to allocate multiple types of shared resources, for example, the method for allocating the shared resource provided in the present specification may be used to allocate the memory resource; or, the method for allocating the shared resource provided by the specification can also be used for allocating the disk storage resource; alternatively, the method for allocating the shared resource provided in the present specification may also be used for allocating the computing resource, etc., and the specific type of the shared resource is not limited in the present specification.
Taking the shared resource as a memory resource as an example, for a software system, the memory resource as a key resource may be shared by a plurality of modules, which may have a common upper usage limit. Taking a database using a log-structured merge Tree (Log Structure Merge Tree, LSM-Tree) as an example, the memory resources available in a memory table (Memtable) under the LSM-Tree architecture are not infinite, and the allocation of the memory resources is reasonably performed, so that each tenant can be guaranteed to enjoy the memory resources provided by the database.
The above method for allocating the shared resources may be performed by a computing device, where the computing device may be a server, such as a server, a plurality of servers, a server cluster, a cloud computing platform, or other types of devices, and the device types of the computing device are not limited in this specification.
The foregoing is merely exemplary descriptions about application scenarios of the present specification, and does not limit the application scenarios of the present specification, and in more possible implementations, the solution provided in the present specification may be applied to other more scenarios, and the present specification does not limit specific application scenarios.
After the application scenario of the present specification is described, a description is next given of a specific implementation procedure of the present specification.
Referring to fig. 1, fig. 1 is a flowchart of a method for allocating shared resources according to an exemplary embodiment, as shown in fig. 1, the method may include:
step 101, in response to receiving a resource allocation request from any module for obtaining a shared resource of a target system, detecting the total amount of allocated resources in the target system based on preset first resource allocation indication information, where the first resource allocation indication information is used to indicate an upper limit of resource usage of the target system.
The target system may be a shared resource pool of a software system, for example, but not limited to, a database, and may be a shared resource pool of other types of systems, which is not limited in this specification.
Taking the target system as a database, for example, a tenant of the target system may send a resource allocation request to the target system to request use of a resource of a certain module in the target system.
When receiving a resource allocation request from any module to acquire a shared resource of a target system, the module may be allocated the shared resource of the target system, so that a sender of the resource allocation request may use the resource allocated to the module.
Step 102, detecting the amount of resources to be allocated acquired by the resource allocation request application based on preset second resource allocation indication information when the total amount of allocated resources does not exceed the upper limit of the use of resources indicated by the first resource allocation indication information, where the second resource allocation indication information is used for indicating the upper limit of the use of resources in the target system by the module.
It should be noted that, the resource allocation request may carry the amount of resources to be allocated, so that, when the total amount of allocated resources does not exceed the upper limit of use of resources indicated by the first resource allocation indication information, the amount of resources to be allocated acquired by the resource allocation request application may be detected based on the preset second resource allocation indication information.
And 103, performing resource allocation based on the detection result of the amount of the resources to be allocated.
According to the method and the device, when a resource allocation request of a shared resource of a target system is applied for acquisition by any module, the total amount of allocated resources in the target system is detected based on the preset first resource allocation indication information, so that the amount of resources to be allocated, which are acquired by the resource allocation request application, is detected based on the preset second resource allocation indication information under the condition that the total amount of the allocated resources does not exceed the upper limit of the use of the resources indicated by the first resource allocation indication information, and further the resource allocation is performed based on the detection result of the amount of the resources to be allocated, so that the situation that the total amount of the use of the resources or the use amount of the resources of a single module exceeds the limit is avoided, and more reasonable allocation of the shared resources is realized.
The foregoing description is merely illustrative of the basic implementation flow of the present specification, and the method for allocating shared resources provided in the present specification is described in detail below in connection with alternative embodiments of the present specification.
It should be noted that the first resource allocation indication information may include a first resource amount threshold and a second resource amount threshold, where the first resource amount threshold is used to indicate an upper limit of a total amount of resource usage, and the second resource amount threshold may be used to indicate a total amount of resource usage that triggers a speed limit.
In some embodiments, for step 101, when detecting the total amount of allocated resources in the target system based on the preset first resource allocation indication information, the total amount of allocated resources in the target system may be detected based on the first resource amount threshold first, and then the total amount of allocated resources in the target system may be detected based on the second resource amount threshold.
Alternatively, in the case where the total amount of allocated resources exceeds the first resource amount threshold, after waiting for the first preset period of time, the total amount of allocated resources in the target system may be detected again based on the preset first resource allocation indication information, for example, the total amount of allocated resources in the target system may be detected again based on the first resource amount threshold.
It should be noted that, when the total amount of allocated resources exceeds the first resource amount threshold, a cyclic waiting process may be entered, that is, the total amount of allocated resources in the target system may be detected again based on the first resource amount threshold every a first preset period of time, until the total amount of allocated resources does not exceed the first resource amount threshold, and then a subsequent processing process may be entered.
Optionally, in the case that the total amount of allocated resources does not exceed the first resource amount threshold, but the total amount of allocated resources exceeds the second resource amount threshold, after waiting for the first delay allocation duration, the amount of resources to be allocated acquired by the resource allocation request application may be detected based on preset second resource allocation indication information.
The first delay allocation duration may be determined based on the total amount of allocated resources, the first resource allocation indication information, and a preset first speed limit duration. For example, the first delay allocation duration may be determined based on the total amount of allocated resources, the first resource amount threshold, the second resource amount threshold, and the first speed limit duration.
Alternatively, the amount of resources of the first speed limit interval may be determined based on the first amount of resources threshold and the second amount of resources threshold. After the resource amount of the first speed limit interval is obtained, the resource amount of the first speed limit interval can be divided into N equal parts based on a preset first resource dividing step length, so that the first speed limit factor is determined based on the number of divided parts (namely N) of the resource amount of the first speed limit interval and a preset first speed limit duration. After the speed limiting factor is determined, the first delay allocation duration can be determined based on the first speed limiting factor and the total amount of allocated resources.
Alternatively, the difference between the first resource amount threshold and the second resource amount threshold may be determined as the resource amount of the first speed limit interval.
Alternatively, the first speed limiting factor may be determined based on the number of divided parts of the resource amount of the first speed limiting section and the preset first speed limiting duration based on the following formula (1):
T1= DECAY_FACTOR * (1^3 + 2^3 + 3^3 + ..... + N^3) (1)
wherein T1 is the first speed limit duration, DECA_FACTOR is the first speed limit FACTOR, and N is the number of resource amount partitions in the first speed limit interval.
Taking the total amount of resources of the target system (i.e., the first resource amount threshold) as an example, when the usage amount reaches 80%, the speed limit is started (i.e., the second resource amount threshold is 80% of the total amount of resources of the target system), the resource amount of the first speed limit interval is 2GB (10 GB (1-80%), if the first resource partitioning step size is 2 megabytes (megabyte), the resource amount of the first speed limit interval can be partitioned into 1000 (2 GB/2 MB) equal parts, and if the first time period is 2 hours, the first speed limit factor can be calculated according to the above formula (1), so that the first delay allocation time period can be determined based on the first speed limit factor and the total amount of allocated resources.
In some embodiments, after the first speed limiting factor is determined, a mechanism similar to queuing may also be used to implement the delay allocation. For example, when the module a applies for obtaining the shared resource of the target system, the module a may first perform number obtaining, that is, may allocate a number to the user, and the user may wait for the number to be called according to the allocated number, so as to allocate a corresponding resource for the user when the user is called.
Alternatively, when the delay allocation is implemented by the queuing machine as described above, the resource amount of the first speed limit interval may be determined based on the total amount of resources of the target system and the second resource amount threshold. After the resource amount of the first speed limit interval is obtained, the resource amount of the first speed limit interval can be divided into N equal parts based on a preset first resource dividing step length, and then the first speed limit factor is determined based on the number of divided parts (namely N) of the resource amount of the first speed limit interval and a preset first speed limit duration. After the first speed limiting factor is determined, delay allocation can be realized based on the total amount of allocated resources, the time point of last number release, the time point of current number release and the first speed limiting factor.
Optionally, when the delay allocation is implemented based on the total allocated resources, the time point of last number allocation, the time point of current number allocation and the first speed limiting factor, the number of copies corresponding to the total allocated resources may be determined based on the total allocated resources and the first resource dividing step length, so that the delay allocation is implemented based on the number of copies corresponding to the total allocated resources, the time point of last number allocation, the time point of current number allocation and the first speed limiting factor.
For example, when delay allocation is implemented based on the number of copies corresponding to the total amount of allocated resources, the time point of last allocation, the time point of current allocation, and the first speed limiting factor, the number of current allocation may be determined based on the following formula (2):
DECAY_FACTOR * (M^3 + (M+1)^3 + ..... + X^3) = T_current - T_pre (2)
wherein, the DECA_FACTOR is the first speed limiting FACTOR, M is the number corresponding to the total amount of the allocated resources, X is the number of the current number, T_current is the time point of the current number, and T_pre is the time point of the last number.
After determining the number of the current number, all users with numbers smaller than the current number can be allocated to the resource.
In some embodiments, when the total amount of allocated resources does not exceed the first resource amount threshold and the total amount of allocated resources does not exceed the second resource amount threshold, it may be determined that the total amount of allocated resources does not exceed the upper usage limit of resources indicated by the first resource allocation indication information. Thus, for step 102, in the case where the total amount of allocated resources does not exceed the upper limit of resource usage indicated by the first resource allocation indication information, the amount of resources to be allocated acquired by the resource allocation request application is detected based on the preset second resource allocation indication information, that is, in the case where the total amount of allocated resources does not exceed the first resource amount threshold and the total amount of allocated resources does not exceed the second resource amount threshold, the amount of resources to be allocated acquired by the resource allocation request application is detected based on the preset second resource allocation indication information.
It should be noted that the second resource allocation indication information may include a third resource amount threshold and a fourth resource amount threshold, where the third resource amount threshold may be used to indicate an upper limit of a resource usage amount of a module for which resource acquisition is applied, and the fourth resource amount threshold may be used to indicate a resource usage amount for triggering a speed limit of the module.
In some embodiments, for step 102, when detecting the amount of resources to be allocated acquired by the resource allocation request based on the preset second resource allocation indication information, the amount of resources to be allocated may be detected based on the third resource amount threshold first, and then the amount of resources to be allocated may be detected based on the fourth resource amount threshold.
Optionally, when the amount of resources to be allocated exceeds the third threshold of the amount of resources to be allocated, after waiting for a second preset duration, detecting the amount of resources to be allocated acquired by the resource allocation request application based on the preset second resource allocation indication information again.
It should be noted that, when the amount of resources to be allocated exceeds the third amount of resources threshold, a cyclic waiting process may be entered, that is, the amount of resources to be allocated may be detected again based on the third amount of resources threshold every second preset time period until the amount of resources to be allocated does not exceed the third amount of resources threshold, and then a subsequent processing process may be entered.
Alternatively, in the case that the amount of resources to be allocated does not exceed the third threshold of the amount of resources to be allocated but the amount of resources to be allocated exceeds the fourth threshold of the amount of resources to be allocated, the module may be allocated with the shared resources satisfying the amount of resources to be allocated after waiting for the second delay allocation duration.
The second delay allocation duration may be determined based on the allocated resource amount of the module, the second resource allocation indication information, and a preset second speed limit duration. For example, the second delay allocation duration may be determined based on the allocated resource amount of the module, the third resource amount threshold, the fourth resource amount threshold, and the second speed limit duration.
Alternatively, the amount of resources of the second speed limit interval may be determined based on the third and fourth resource amount thresholds. After the resource amount of the second speed limit interval is obtained, the resource amount of the second speed limit interval can be divided into N equal parts based on a preset resource division step length, so that the second speed limit factor is determined based on the number of divided parts (i.e., N) of the resource amount of the second speed limit interval and a preset second speed limit duration. After the second speed limiting factor is determined, a second delay allocation duration can be determined based on the second speed limiting factor and the allocated resource amount of the module.
Alternatively, the difference between the third resource amount threshold and the fourth resource amount threshold may be determined as the resource amount of the second speed limit interval.
Alternatively, the process of determining the second speed limiting factor may refer to the process of determining the first speed limiting factor, which is not described herein.
In some embodiments, after the second speed limiting factor is determined, a mechanism similar to queuing and number fetching may be further used to implement delay allocation, and a specific implementation process may refer to the above embodiment and will not be described herein.
In some embodiments, in a case where the amount of resources to be allocated does not exceed the third amount of resources threshold and the amount of resources to be allocated does not exceed the fourth amount of resources threshold, it may be determined that the amount of resources to be allocated does not exceed the upper limit of resource usage indicated by the second resource allocation indication information. Thus, for step 103, when performing resource allocation based on the detection result of the amount of resources to be allocated, the module may be allocated with the shared resource that satisfies the amount of resources to be allocated in a case where the amount of resources to be allocated does not exceed the upper limit of resource usage indicated by the second resource allocation indication information.
It should be noted that, after the use of the resources is finished, each module may return the corresponding resources to the shared resources, so as to improve the utilization efficiency of the resources.
The method for allocating the shared resources provided in the present specification may divide the detection logic of the resource allocation process into multiple stages, for example, the method for allocating the shared resources provided in the present specification may divide the detection logic of the resource allocation process into two stages, where the first stage detection logic may be used to control the overall usage amount and the usage speed of the shared resources, and the second stage detection logic may be used to control the usage amount and the usage speed of the resources of a single module.
It should be noted that, when any module applies for obtaining resources, it can be judged by the multi-stage detection logic, so as to allocate corresponding resources for the module according to the judgment result.
Alternatively, in the multi-level detection process, whichever level of detection logic is used, the detection logic may be abstracted into a detection unit (or speed limiting unit), and each speed limiting unit may be provided with an upper limit of available resources and a resource usage amount for triggering speed limiting. Taking two stages of detection logic in a resource allocation process as an example, wherein a first-stage speed limiting unit can be used for controlling the overall shared resource usage amount and the usage speed, the upper limit of available resources of the first-stage speed limiting unit can be used as a first resource amount threshold, and the resource usage amount of triggering speed limiting of the first-stage speed limiting unit can be used as a second resource amount threshold; the second-level speed limiting unit can be used for controlling the resource usage amount and the usage speed of a single module, the upper limit of available resources of the second-level speed limiting unit can be used as a third resource amount threshold, and the resource usage amount of triggering speed limiting of the second-level speed limiting unit can be used as a fourth resource amount threshold.
Taking the example of dividing the detection logic of the resource allocation process into two stages, the organization architecture of the plurality of speed limiting units may refer to fig. 2, fig. 2 is a schematic diagram of the organization architecture of a speed limiting unit provided by an exemplary embodiment, as shown in fig. 2, two speed limiting units may be connected in parallel, and a plurality of parallel two speed limiting units may be connected in series with one speed limiting unit to obtain two-stage detection logic.
Based on the two-stage detection logic shown in fig. 2, the flow of the allocation of the shared resource provided in the present disclosure may refer to fig. 3, and fig. 3 is a flow chart of a method for allocating the shared resource provided in an exemplary embodiment, as shown in fig. 3, when any module applies for obtaining the shared resource of the target system, that is, when any module requests for obtaining the amount of the resource to be allocated (or called the amount of the resource to be applied), the resource usage of the primary speed limiting unit and the secondary speed limiting unit may be accumulated to obtain the total amount of the allocated resource of the target system, so that the primary speed limiting unit may be used to perform detection based on the total amount of the allocated resource.
Firstly, the total amount of the allocated resources can be detected based on the upper limit of the first-level speed limiting unit (namely, a first resource amount threshold value), and if the total amount of the allocated resources exceeds the upper limit of the first-level speed limiting unit, namely, if the total amount of the allocated resources exceeds the first resource amount threshold value, a circulation waiting process is entered; if the total amount of the allocated resources does not exceed the upper limit of the first-level speed limiting unit, that is, the total amount of the allocated resources does not exceed the first-level resource amount threshold, a process of detecting the total amount of the allocated resources based on the first-level speed limiting unit speed limiting threshold (that is, the second-level resource amount threshold) can be performed.
If the total amount of the allocated resources exceeds the first-level speed limiting unit speed limiting threshold, that is, if the total amount of the allocated resources exceeds the second-level resource amount threshold, calculating a delay allocation duration (that is, a first delay allocation duration) according to the current speed limiting unit speed limiting threshold and the current service condition, so that delay allocation can be realized based on the delay allocation duration, and a detection process based on the second-level speed limiting unit is performed when the first delay allocation duration is reached; if the total amount of the allocated resources does not exceed the speed limiting threshold of the first-level speed limiting unit, that is, if the total amount of the allocated resources does not exceed the second-level resource amount threshold, the detection process based on the second-level speed limiting unit can be directly entered.
And in the detection process of the secondary speed limiting unit, the detection can be performed based on the resource quantity to be applied through the secondary speed limiting unit. Firstly, detecting the resource quantity to be applied based on the upper limit of a secondary speed limiting unit (namely, a third resource quantity threshold), and entering a circulation waiting process if the resource quantity to be applied exceeds the upper limit of the secondary speed limiting unit (namely, if the resource quantity to be applied exceeds the third resource quantity threshold); if the resource quantity to be applied does not exceed the upper limit of the second-level speed limiting unit, namely, the resource quantity to be applied does not exceed the third resource quantity threshold, a process of detecting the resource quantity to be applied based on the second-level speed limiting unit speed limiting threshold (namely, the fourth resource quantity threshold) can be performed.
If the resource quantity to be applied exceeds the second-level speed limiting unit speed limiting threshold, that is, if the resource quantity to be applied exceeds the fourth resource quantity threshold, calculating a delay allocation duration (that is, a second delay allocation duration) according to the current speed limiting unit speed limiting threshold and the current service condition, so that delay allocation can be realized based on the delay allocation duration, and shared resources can be allocated to the module when the second delay allocation duration is reached; if the resource quantity to be applied does not exceed the speed limiting threshold of the secondary speed limiting unit, that is, if the resource quantity to be applied does not exceed the fourth resource quantity threshold, the shared resource can be directly allocated to the module.
It should be noted that, the embodiments corresponding to fig. 2 and fig. 3 are only described by taking the example that the detection logic of the resource allocation process is divided into two stages as an example, and in more possible implementations, the detection logic of the resource allocation process may be divided into more stages, which is not limited in this specification.
Through the scheme provided by the specification, the whole resource allocation logic can be judged by the multi-stage speed limiting units, each speed limiting unit has own resource upper limit and speed limiting threshold, circulation waiting is needed when no available resources exist, the time for obtaining the resources in a delayed mode is calculated when the available resources are fewer, and the resource application can really obtain the use right of the resources only in the scene that the multi-stage speed limiting is passed.
According to the method for distributing the shared resources, which is provided by the specification, the multi-module resource sharing and the speed limiting can be automatically balanced through multi-stage speed limiting, so that the sum of the multi-module resource use is ensured not to exceed the upper limit, and the problem of total internal memory explosion is avoided. In addition, through the fine control to different speed limiting units, the fine control to the resource usage amount and the use speed of different modules is realized, the speed limiting logic of each module can ensure the resource usage rationality of the module, and the resource upper limit of a single module can be overstocked safely due to the existence of the total upper limit, so that the modules can be automatically squeezed up, and different scenes are better compatible.
Corresponding to the embodiments of the method described above, the present description also provides corresponding device embodiments.
Referring to fig. 4, fig. 4 is a schematic block diagram of a computing device provided by an exemplary embodiment. Referring to FIG. 4, at the hardware level, the computing device includes a processor 402, an internal bus 404, a network interface 406, a memory 408, and a non-volatile storage 410, although other tasks may be performed. One or more embodiments of the present description may be implemented in a software-based manner, such as by the processor 402 reading a corresponding computer program from the non-volatile memory 410 into the memory 408 and then running. Of course, in addition to software implementation, one or more embodiments of the present disclosure do not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
The present disclosure further provides a device for allocating a shared resource, and referring to fig. 5, fig. 5 is a block diagram of a device for allocating a shared resource according to an exemplary embodiment, where the device for allocating a shared resource may be applied to a computing device shown in fig. 4, so as to implement the technical solution of the present disclosure. The allocation device of the shared resource may include:
a detecting unit 501, configured to detect, in response to receiving a resource allocation request from any module for obtaining a shared resource of a target system, a total amount of allocated resources in the target system based on preset first resource allocation indication information, where the first resource allocation indication information is used to indicate an upper resource usage limit of the target system;
the detecting unit 501 is further configured to detect, based on preset second resource allocation indication information, an amount of resources to be allocated acquired by the resource allocation request application, where the total amount of allocated resources does not exceed an upper limit of use of resources indicated by the first resource allocation indication information, where the second resource allocation indication information is used to indicate an upper limit of use of resources in the target system by the module;
An allocation unit 502, configured to allocate resources based on the detection result of the amount of resources to be allocated.
In some embodiments, the first resource allocation indication information includes a first resource amount threshold for indicating an upper limit of a total amount of resource usage, and a second resource amount threshold for indicating a total amount of resource usage that triggers a speed limit;
a detecting unit 501, configured to, when detecting, based on preset second resource allocation indication information, the amount of resources to be allocated acquired by the resource allocation request application, if the total amount of allocated resources does not exceed the upper limit of resource usage indicated by the first resource allocation indication information, perform:
and detecting the resource quantity to be allocated, which is acquired by the resource allocation request application, based on preset second resource allocation indication information under the condition that the total quantity of the allocated resources does not exceed a first resource quantity threshold value and the total quantity of the allocated resources does not exceed a second resource quantity threshold value.
In some embodiments, the detecting unit 501 is further configured to, when the total amount of allocated resources exceeds the first resource amount threshold, detect, after waiting for a first preset duration, the total amount of allocated resources in the target system based on the preset first resource allocation indication information again;
The detecting unit 501 is further configured to detect, when the total amount of allocated resources does not exceed the first resource amount threshold but the total amount of allocated resources exceeds the second resource amount threshold, the amount of resources to be allocated acquired by the resource allocation request application based on the preset second resource allocation indication information after waiting for the first delay allocation duration.
In some embodiments, the apparatus further comprises:
and the first determining unit is used for determining the first delay allocation duration based on the total amount of the allocated resources, the first resource allocation indication information and a preset first speed limit duration.
In some embodiments, the allocation unit 502 is configured to, when configured to perform resource allocation based on the detection result of the amount of resources to be allocated:
and under the condition that the amount of the resources to be allocated does not exceed the upper limit of the use of the resources indicated by the second resource allocation indication information, allocating the shared resources meeting the amount of the resources to be allocated for the module.
In some embodiments, the second resource allocation indication information includes a third resource amount threshold for indicating an upper limit of resource usage by the module, and a fourth resource amount threshold for indicating a resource usage triggering a speed limit by the module;
An allocation unit 502, when the amount of resources to be allocated does not exceed the upper limit of resource usage indicated by the second resource allocation indication information, for allocating, to the module, a shared resource that satisfies the amount of resources to be allocated, the shared resource being configured to:
and if the amount of the resources to be allocated does not exceed the third resource amount threshold and the amount of the resources to be allocated does not exceed the fourth resource amount threshold, allocating the shared resources meeting the amount of the resources to be allocated for the module.
In some embodiments, the detecting unit 501 is further configured to, when the amount of resources to be allocated exceeds the third resource amount threshold, detect, based on the second preset resource allocation indication information again, the amount of resources to be allocated acquired by the resource allocation request application after waiting for a second preset time period;
the allocation unit 502 is further configured to allocate, to the module, a shared resource that satisfies the amount of resources to be allocated after waiting for a second delay allocation duration if the amount of resources to be allocated does not exceed the third amount of resources threshold but the amount of resources to be allocated exceeds the fourth amount of resources threshold.
In some embodiments, the apparatus further comprises:
and the second determining unit is used for determining the second delay allocation duration based on the allocated resource quantity of the module, the second resource allocation indication information and a preset second speed limit duration.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, in which the modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present description. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
In a typical configuration, a computer includes one or more processors (Central Processing Unit, CPU), input/output interfaces, network interfaces, and memory.
The Memory may include non-volatile Memory in a computer readable medium, random access Memory (Random Access Memory, RAM) and/or non-volatile Memory, etc., such as Read-Only Memory (ROM) or flash RAM. Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change Memory (Phase Change Random Access Memory, PRAM), static random access Memory (Static Random Access Memory, SRAM), dynamic random access Memory (Dynamic Random Access Memory, DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically erasable programmable read Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), flash Memory or other Memory technology, read Only optical disk read Only Memory (Compact Disc Read-Only Memory, CD-ROM), digital versatile disks (Digital Video Disc, DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum Memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission media, that can be used to store information that can be accessed by a computing device. Computer-readable Media, as defined herein, does not include Transitory computer-readable Media (transmission Media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of the present description to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The foregoing description of the preferred embodiment(s) is (are) merely intended to illustrate the embodiment(s) of the present invention, and it is not intended to limit the embodiment(s) of the present invention to the particular embodiment(s) described.
Claims (11)
1. A method of allocating shared resources, comprising:
responding to a resource allocation request of any module for acquiring shared resources of a target system, and detecting the total amount of allocated resources in the target system based on preset first resource allocation indication information, wherein the first resource allocation indication information is used for indicating the upper limit of resource use of the target system;
detecting the amount of the resources to be allocated acquired by the resource allocation request application based on preset second resource allocation indication information, wherein the second resource allocation indication information is used for indicating the upper limit of the use of the resources of the module in the target system, under the condition that the total amount of the allocated resources does not exceed the upper limit of the use of the resources indicated by the first resource allocation indication information;
And carrying out resource allocation based on the detection result of the amount of the resources to be allocated.
2. The method of claim 1, the first resource allocation indication information comprising a first resource amount threshold for indicating an upper limit of a total amount of resource usage, and a second resource amount threshold for indicating a total amount of resource usage that triggers a speed limit;
and detecting the amount of resources to be allocated acquired by the resource allocation request application based on preset second resource allocation indication information under the condition that the total amount of allocated resources does not exceed the upper limit of the use of resources indicated by the first resource allocation indication information, including:
and detecting the resource quantity to be allocated, which is acquired by the resource allocation request application, based on preset second resource allocation indication information under the condition that the total quantity of the allocated resources does not exceed a first resource quantity threshold value and the total quantity of the allocated resources does not exceed a second resource quantity threshold value.
3. The method of claim 2, further comprising any of:
when the total amount of the allocated resources exceeds a first resource amount threshold, after waiting for a first preset time period, detecting the total amount of the allocated resources in the target system again based on preset first resource allocation indication information;
And detecting the resource quantity to be allocated, which is acquired by the resource allocation request application, based on preset second resource allocation indication information after waiting for the first delay allocation duration under the condition that the total quantity of the allocated resources does not exceed the first resource quantity threshold value but the total quantity of the allocated resources exceeds the second resource quantity threshold value.
4. A method according to claim 3, further comprising:
and determining the first delay allocation duration based on the total amount of the allocated resources, the first resource allocation indication information and a preset first speed limit duration.
5. The method of claim 1, the allocating resources based on the detection result of the amount of resources to be allocated, comprising:
and under the condition that the amount of the resources to be allocated does not exceed the upper limit of the use of the resources indicated by the second resource allocation indication information, allocating the shared resources meeting the amount of the resources to be allocated for the module.
6. The method of claim 5, the upper resource usage limit indicated by the second resource allocation indication information comprising a third resource amount threshold for indicating an upper resource usage limit for the module and a fourth resource amount threshold for indicating a resource usage amount that triggers the module speed limit;
And if the amount of the resources to be allocated does not exceed the upper limit of the use of the resources indicated by the second resource allocation indication information, allocating the shared resources meeting the amount of the resources to be allocated to the module, including:
and if the amount of the resources to be allocated does not exceed the third resource amount threshold and the amount of the resources to be allocated does not exceed the fourth resource amount threshold, allocating the shared resources meeting the amount of the resources to be allocated for the module.
7. The method of claim 6, further comprising any of:
when the amount of the resources to be allocated exceeds a third resource amount threshold, after waiting for a second preset time period, detecting the amount of the resources to be allocated acquired by the resource allocation request application again based on preset second resource allocation indication information;
and when the amount of the resources to be allocated does not exceed the third resource amount threshold value, but the amount of the resources to be allocated exceeds the fourth resource amount threshold value, after waiting for a second delay allocation duration, allocating the shared resources meeting the amount of the resources to be allocated for the module.
8. The method of claim 7, further comprising:
and determining the second delay allocation duration based on the allocated resource amount of the module, the second resource allocation indication information and a preset second speed limit duration.
9. An apparatus for allocating shared resources, comprising:
the detection unit is used for responding to a resource allocation request of any module for acquiring the shared resource of the target system, and detecting the total amount of allocated resources in the target system based on preset first resource allocation indication information, wherein the first resource allocation indication information is used for indicating the upper limit of the use of the resources of the target system;
the detecting unit is further configured to detect, based on preset second resource allocation indication information, an amount of resources to be allocated acquired by the resource allocation request application, where the total amount of allocated resources does not exceed an upper limit of resource usage indicated by the first resource allocation indication information, and the second resource allocation indication information is used to indicate an upper limit of resource usage of the module in the target system;
and the allocation unit is used for carrying out resource allocation based on the detection result of the resource quantity to be allocated.
10. A computing device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any of claims 1-8 by executing the executable instructions.
11. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method of any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311266555.6A CN117234732A (en) | 2023-09-27 | 2023-09-27 | Shared resource allocation method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311266555.6A CN117234732A (en) | 2023-09-27 | 2023-09-27 | Shared resource allocation method, device, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117234732A true CN117234732A (en) | 2023-12-15 |
Family
ID=89090915
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311266555.6A Pending CN117234732A (en) | 2023-09-27 | 2023-09-27 | Shared resource allocation method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117234732A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118349319A (en) * | 2024-06-18 | 2024-07-16 | 华能信息技术有限公司 | Distributed transaction management method and system |
CN118446442A (en) * | 2024-03-27 | 2024-08-06 | 诚通数字科技有限责任公司 | Shared resource allocation method, apparatus, device and computer readable storage medium |
-
2023
- 2023-09-27 CN CN202311266555.6A patent/CN117234732A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118446442A (en) * | 2024-03-27 | 2024-08-06 | 诚通数字科技有限责任公司 | Shared resource allocation method, apparatus, device and computer readable storage medium |
CN118349319A (en) * | 2024-06-18 | 2024-07-16 | 华能信息技术有限公司 | Distributed transaction management method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106406987B (en) | Task execution method and device in cluster | |
CN117234732A (en) | Shared resource allocation method, device, equipment and medium | |
CN106407207B (en) | Real-time newly-added data updating method and device | |
CN106933534B (en) | Data synchronization method and device | |
US10455003B2 (en) | Method, server, and system for sharing resource data | |
CN106326309B (en) | Data query method and device | |
CN105824705B (en) | A kind of method for allocating tasks and electronic equipment | |
CN110543279B (en) | Data storage and processing method, device and system | |
CN110688223B (en) | Data processing method and related product | |
CN108536759B (en) | Sample playback data access method and device | |
CN110909072B (en) | Data table establishment method, device and equipment | |
CN108664322A (en) | Data processing method and system | |
CN116594734A (en) | Container migration method and device, storage medium and electronic equipment | |
CN116578410A (en) | Resource management method, device, computer equipment and storage medium | |
CN116881003A (en) | Resource allocation method, device, service equipment and storage medium | |
CN108023920B (en) | Data packet transmission method, equipment and application interface | |
CN106557469B (en) | Method and device for processing data in data warehouse | |
CN110681159A (en) | Team forming method, device and equipment | |
CN113849811A (en) | Shared virtual resource analysis method and device | |
CN109246216B (en) | Access request processing method and device | |
CN110875934B (en) | Service grouping method and device based on multi-tenant service | |
CN110874268B (en) | Data processing method, device and equipment | |
CN113296962A (en) | Memory management method, device, equipment and storage medium | |
CN116627789B (en) | Model detection method and device, electronic equipment and storage medium | |
CN111290850A (en) | Data storage method, device and equipment |
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 | ||
REG | Reference to a national code |
Ref country code: HK Ref legal event code: DE Ref document number: 40100578 Country of ref document: HK |