Multi-tenant task processing method and apparatus, storage medium, and electronic device
By identifying idle resources in a multi-tenant environment, acquiring and processing unoccupied task groups, the latency problem caused by resource occupation among tenants is solved, and efficient resource isolation and utilization are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-05
- Publication Date
- 2026-03-20
AI Technical Summary
In a multi-tenant environment, if one tenant continuously consumes a large amount of resources due to high business volume, it will increase the processing latency of other tenants' business and affect the processing efficiency of low-latency business.
By identifying available resources, the system obtains each tenant's unoccupied task groups and uses them as target task groups, thus preventing the reuse of resources in occupied task groups and enhancing resource isolation between tenants.
It reduces the processing latency of shared resources between tenants, enhances the isolation between tenants, and ensures the efficient use of resources.
Smart Images

Figure CN117056036B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, in particular, to a multi-tenant task processing method and device, a storage medium and an electronic device. BACKGROUND
[0002] Multi-tenant technology, also known as multi-rental technology, is a software architecture technology which explores and implements how to share the same system or program component in a multi-user environment and still ensure data isolation and performance isolation of shared resources, effectively saving the cost of developing applications.
[0003] In the related art, the performance isolation of shared resources determines the processing delay of business. Since it is multi-tenant shared resources, if a certain tenant continuously occupies a large amount of resources due to large business volume, it will lead to the business of other tenants cannot be processed in time, thereby increasing the processing delay of business, which has a greater impact on some low-latency business. SUMMARY
[0004] This summary is provided to introduce a selection of concepts, which will be described with greater specificity in the detailed description section. This summary does not intend to identify key or essential features of the claimed technology, nor is it intended for use in determining the scope of the claimed technology.
[0005] In a first aspect, the present disclosure provides a multi-tenant task processing method, comprising:
[0006] In a case where it is determined that there is idle resource, obtaining a to-be-processed task group corresponding to each tenant, wherein each to-be-processed task group of the tenant includes at least one task initiated by the tenant and needing to be processed;
[0007] Determining a target to-be-executed task group from the to-be-processed task groups of all the tenants, wherein the target to-be-executed task group is not in an occupied state, and there is a task in a processing state in the to-be-executed task group in the occupied state;
[0008] Executing the tasks in the target to-be-executed task group.
[0009] In a second aspect, the present disclosure provides a multi-tenant task processing device, comprising:
[0010] A first obtaining module, configured to, in a case where it is determined that there is idle resource, obtain a to-be-processed task group corresponding to each tenant, wherein each to-be-processed task group of the tenant includes at least one task initiated by the tenant and needing to be processed;
[0011] The first determining module is configured to determine a group of to-be-executed tasks in a group of to-be-processed tasks of all the tenants and not in an occupied state as a target group of to-be-executed tasks, and there is a task in an executing state in a group of to-be-executed tasks in an occupied state.
[0012] The executing module is configured to execute the tasks in the target group of to-be-executed tasks.
[0013] In a third aspect, the present disclosure provides a computer readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method in the first aspect.
[0014] In a fourth aspect, the present disclosure provides an electronic device, comprising:
[0015] a storage device having a computer program stored thereon;
[0016] a processing device configured to execute the computer program in the storage device to implement the steps of the method in the first aspect.
[0017] By the above technical solution, in the case that there is an idle resource, a group of to-be-executed tasks in a group of to-be-processed tasks of all the tenants and not in an occupied state is determined as a target group of to-be-executed tasks, and the tasks in the target group of to-be-executed tasks are executed, so that the group of to-be-processed tasks corresponding to a tenant is taken as a scheduling object, and the tasks in the group of to-be-executed tasks in an occupied state are not processed by using the idle resource, but the tasks in the group of to-be-executed tasks not in an occupied state are processed, thereby avoiding the case that a tenant initiates a large number of tasks and affects the processing of tasks of other tenants, enhancing the isolation of the resources shared by the tenants, and reducing the delay in processing the tasks of other tenants.
[0018] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF DRAWINGS
[0019] The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by describing in detail exemplary embodiments thereof with reference to the attached drawings in which:
[0020] Figure 1 is a schematic diagram of an existing processing method of multi-tenant tasks according to an exemplary embodiment of the present disclosure.
[0021] Figure 2 is a flowchart of a multi-tenant task processing method according to an exemplary embodiment of the present disclosure.
[0022] Figure 3is an example diagram of a task group to be processed according to an example embodiment of the present disclosure.
[0023] Figure 4 is a schematic diagram of performing tasks in a task group to be executed by an application instance according to an example embodiment of the present disclosure.
[0024] Figure 5 is another flowchart of a multi-tenant task processing method according to an example embodiment of the present disclosure.
[0025] Figure 6 is a flowchart of adjusting the number of task groups to be executed according to an example embodiment of the present disclosure.
[0026] Figure 7 is a flowchart of adjusting the number of task groups to be executed according to an example embodiment of the present disclosure.
[0027] Figure 8 is a block diagram of a multi-tenant task processing apparatus according to an example embodiment of the present disclosure.
[0028] Figure 9 is a structural schematic diagram of an electronic device according to an example embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] Embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings. While several embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be construed as being limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and fully convey the scope of the present disclosure to those skilled in the art. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of the present disclosure.
[0030] It should be understood that the various steps of the method embodiments of the present disclosure can be performed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit performing the steps shown. The scope of the present disclosure is not limited in this respect.
[0031] The term "comprising" and variations thereof as used herein are open-ended, that is, "including, but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Related definitions are given throughout the description.
[0032] It should be noted that the terms "first", "second", and the like in the present disclosure are only used to distinguish different devices, modules or units, and do not limit the order or interdependence of the functions performed by these devices, modules or units.
[0033] It should be noted that the terms "one", "multiple" in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that "one or more" should be understood unless otherwise explicitly indicated in the context.
[0034] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not used to limit the scope of the messages or information.
[0035] All actions of obtaining signals, information or data in the present disclosure are carried out in accordance with the corresponding data protection regulations and policies of the country where the device is located, and with the authorization given by the corresponding device owner.
[0036] Referring to Figure 1 In the related art, the tasks are usually taken as the scheduling objects, and the initiated tasks are divided into several parts, and each application instance processes one part. If the task quantity of a tenant increases greatly, if this task processing mode is used, the processing of the tasks of the tenant will occupy more resources, and then affect the processing of the newly added tasks of other tenants, resulting in that the isolation between tenants is affected.
[0037] Therefore, the present disclosure provides a multi-tenant task processing method, device, storage medium and electronic equipment, which takes the tenant as the scheduling object, and enhances the isolation between tenants.
[0038] First, the application scenario of the present disclosure is exemplarily described. The present disclosure can be applied to a voice notification scheduling scenario. The target number to be dialed is usually organized in the form of a task, that is, the task is a collection of a plurality of numbers to be dialed, and each task is executed by an application instance. Although the processing of one task takes a short time, when the number of tasks increases to tens of thousands or even hundreds of thousands, the time for one execution increases to tens of seconds or even minutes, and the additional numbers (constituting new tasks) may be dialed out after a few minutes, which has a great impact on some time-sensitive tasks.
[0039] The present disclosure will be further explained and described below in combination with the drawings.
[0040] Figure 2 is a flowchart of a multi-tenant task processing method according to an exemplary embodiment of the present disclosure, referring to Figure 2 The multi-tenant task processing method comprises:
[0041] Step S201, in the case of determining that there is idle resource, obtaining a to-be-processed task group corresponding to each tenant respectively, the to-be-processed task group of each tenant including at least one task initiated by the tenant and needed to be processed.
[0042] It should be noted that the to-be-processed task group is set between the tenant and the task initiated by the tenant, the to-be-processed task group is used to manage the task and is used as a scheduling object when the task is processed, and the to-be-processed task group of each tenant can be set according to actual conditions. For details, refer to Figure 3 In the case of setting the to-be-processed task group 1 and the to-be-processed task group 2 between the tenant A and the task initiated by the tenant A, the to-be-processed task group 1 includes the task 1 and the task 2, the to-be-processed task group 2 includes the task 3 and the task 4, and the task 1, the task 2, the task 2 and the task 4 are all tasks initiated by the tenant A. In the scheduling execution, the to-be-processed task group is used as a scheduling object, and the tasks in the to-be-processed task group scheduled and executed are processed in the scheduling execution.
[0043] In some embodiments, each to-be-processed task group of the tenant can be globally identified by setting a corresponding relationship, for example, each to-be-processed task group of the tenant is identified in the form of <tenant ID, task group serial number>. In some embodiments, a global list can be set to manage the to-be-processed task groups of all tenants.
[0044] In some embodiments, the tasks in the target to-be-executed task group are executed by an application instance. It should be noted that the application instance can be a program component which can process the tasks. In some embodiments, in the case of executing the tasks in the target to-be-executed task group by the application instance, whether there is idle resource can be determined by the following manner: detecting the number of target to-be-executed task groups associated with the tasks being executed by the application instance; in the case that the number of target to-be-executed task groups associated with the tasks being executed by the application instance does not reach the maximum executable task group number, it is determined that there is idle resource, wherein the maximum executable task group number represents the maximum number of target to-be-executed task groups associated with the tasks which can be simultaneously executed by the application instance. It can be understood that the target to-be-executed task group associated with the task can be understood as the target to-be-executed task group to which the task belongs.
[0045] It should be noted that for an application instance, multiple thread resources can be opened, and each thread resource can process the tasks in the target to-be-executed task group. In this case, the maximum executable task group number can also be understood as the number of thread resources opened by the application instance, and in the case that the number of target to-be-executed task groups associated with the tasks being executed in the application instance is lower than the maximum executable task group number, it is considered that there is idle thread resource of the application instance, that is, other target to-be-executed task groups can be allocated to the idle thread resource for processing tasks.
[0046] In some embodiments, a timing thread can be created, and the above process of determining whether there is an idle resource can be implemented by using the timing thread. In some embodiments, the timing thread can be detected at a preset time. For example, the step of detecting the number of target task groups associated with the task being executed by the application instance can be performed every 5 seconds.
[0047] In some embodiments, the maximum number of executable task groups can be pre-set according to actual conditions. In the actual processing of tasks, the maximum number of executable task groups can be dynamically adjusted. Considering that the application instance occupies a certain resource (such as CPU resource and memory resource) in processing tasks, in order to avoid the application instance occupying too much resource and affecting the use of resources in other scenarios except the application scenario (voice notification scheduling scenario) of the present disclosure, the maximum number of executable task groups of the application instance can be dynamically adjusted according to the actual load consumed by the application instance.
[0048] In the case where the application instance includes multiple application instances, the maximum number of executable task groups of the application instance can be updated by: obtaining the load consumed by all application instances; and updating the maximum number of executable task groups of each application instance according to the load and the maximum number of executable task groups of all application instances.
[0049] In some embodiments, the load includes at least one of CPU occupancy and memory occupancy. In the case where the CPU occupancy is greater than a preset CPU occupancy threshold and / or the memory occupancy is greater than a preset memory occupancy threshold, the maximum number of executable task groups of each application instance is reduced.
[0050] In this way, the maximum number of executable task groups of the application instance is dynamically updated according to the load consumed by the application instance in processing tasks, which can reduce the load consumed by the application instance when the load consumed by the application instance is large, thereby avoiding the use of the CPU resource and the memory resource by other systems being affected.
[0051] In some embodiments, in the case where a task in the target task group is executed by the application instance and the application instance includes multiple application instances, whether there is an idle resource can be determined by: detecting whether there is a target application instance, the target application instance being an application instance that has no task to process; and in the case where it is detected that there is a target application instance, determining that there is an idle resource.
[0052] It should be noted that for a service platform, multiple application instances can be opened to process tasks. For an application instance that does not have tasks to process, it can be considered that the application instance still has idle thread resources, i.e., the idle thread resources can be allocated to other target task groups to be executed for task processing. In some embodiments, a timing thread can be created, and the timing thread can be used to implement the process of determining whether there is an idle resource. For example, the step of "detecting whether there is a target application instance" can be performed every 5 seconds.
[0053] In some embodiments, as shown in FIG. 2B, when there are multiple task groups to be processed for a tenant, the tenant-initiated tasks are allocated. A plurality of preset task allocation rules can be set, and for each tenant, at least one task initiated by the tenant that needs to be processed can be allocated to each task group to be processed corresponding to the tenant according to the preset task allocation rule. Figure 3
[0054] For example, the preset task allocation rule can be a quantity difference minimization rule, which can achieve quantity difference minimization by equally dividing the tenant-initiated tasks into each task group to be processed. For example, a tenant initiates 100 tasks, and the tenant corresponds to 2 task groups to be processed, then each task group to be processed is allocated 50 tasks.
[0055] The preset task allocation rule can be a random rule, which randomly allocates the tenant-initiated tasks to each task group to be processed of the tenant.
[0056] The preset task allocation rule can be a specified rule, and the tenant-initiated task can carry a serial number identifier of the task group to be processed, which represents the task group to be processed to which the task wants to be allocated. The task is allocated to the corresponding task group to be processed according to the serial number identifier of the task group to be processed carried by the task.
[0057] The preset task allocation rule can be a time minimization rule, which is used to allocate the tenant-initiated task to the task group to be executed with the shortest execution time.
[0058] In step S202, the task group to be executed that is not in an occupied state in the task group to be processed of all tenants is determined as a target task group to be executed, and the task group to be executed in an occupied state has a task in a processing state.
[0059] It should be noted that for a pending task group that is in an occupied state, it means that an application instance is already processing the task in it. Therefore, other idle resources will not be used to process the tasks in the pending task group that is in an occupied state. Instead, a pending task group that is not currently being executed by any application instance will be selected as the target pending task group (i.e., a pending task group that is not in an occupied state).
[0060] Step S203: Execute the target task group to be executed to process the tasks in the target task group to be executed.
[0061] It should be noted that the target pending task group is executed using idle resources.
[0062] In this way, even if a tenant's task group has a large number of tasks that require significant processing time, only one thread will be available for processing them. Other threads will be used to handle tasks in other task groups, enhancing the isolation of shared resources between tenants. The following example... Figure 4 This disclosure provides an exemplary illustration of how it enhances isolation between tenants.
[0063] like Figure 4 As shown, the global list manages five groups of tasks to be executed, identified by numbers 1-5. These five groups can correspond to different tenants. Application Instance 1 and Application Instance 2 each include two thread resources for executing tasks from the groups; that is, each application instance can execute tasks from a maximum of two groups simultaneously. Figure 4 In the process, every 5 seconds, it checks whether there are any idle resources. If there are idle resources, it executes a task in a task group that is waiting to be executed.
[0064] Depend on Figure 4 It can be seen that the number of tasks in task group 1 is particularly large, and the execution time of its corresponding task group increases significantly. However, other task groups will be processed by other thread resources. Therefore, the execution of one task group does not affect the execution of other task groups. Since the task groups are used as scheduling objects, the same task group will not be executed on two thread resources at the same time. A task group will occupy at most one thread resource. That is, in this embodiment, the tasks of the tenants corresponding to the above 5 task groups will only occupy one thread resource, thereby enhancing the isolation of resources shared by tenants.
[0065] In some embodiments, whether a to-be-executed task group is in an occupied state can be represented by assigning a distributed lock to the to-be-executed task group. For example, a distributed lock is assigned to a to-be-executed task group determined as a target to-be-executed task group, and the distributed lock is used to detect whether the to-be-executed task group is in an occupied state; and the distributed lock assigned to the to-be-executed task group of the target to-be-executed task group is released when the target to-be-executed task group is executed.
[0066] It should be noted that a to-be-executed task group holding a distributed lock represents an occupied state, and a to-be-executed task group not holding a distributed lock represents an unoccupied state. Whether a target to-be-executed task group is determined from each to-be-executed task group can be determined according to whether each to-be-executed task group holds a distributed lock.
[0067] In this way, whether a to-be-executed task group is in an occupied state is marked by assigning or releasing a distributed lock to the to-be-executed task group, so as to determine a target to-be-executed task group.
[0068] Figure 5 is another flowchart of a multi-tenant task processing method according to an example embodiment of the present disclosure. Referring to Figure 5 , the multi-tenant task processing method comprises the following steps:
[0069] Step S501, detecting whether there is an idle resource.
[0070] It should be noted that the implementation process of step S501 can refer to the related embodiments described above, and this embodiment will not be repeated here. And step S501 can be executed at a predetermined time interval, for example, step S501 is executed once every 5 seconds.
[0071] Step S502, selecting a to-be-executed task group to attempt to seize a lock in a global list managing all to-be-executed task groups.
[0072] Step S503, whether the lock is seized successfully.
[0073] It should be noted that steps S502 and S503 are used to determine a target to-be-executed task group. Successful lock seizure indicates that the selected to-be-executed task group is successfully determined as a target to-be-executed task group and is assigned a distributed lock. Failure to seize the lock indicates that the selected to-be-executed task group cannot be determined as a target to-be-executed task group, and the failure to seize the lock is because the selected to-be-executed task group already holds an assigned distributed lock.
[0074] Step S504, executing a task in the to-be-executed task group whose lock is seized successfully.
[0075] Wherein, the implementation process of step S5404 can refer to step S103 shown in Figure 1 , and this embodiment will not be repeated here.
[0076] exist Figure 1 In one embodiment, the number of pending task groups for a tenant can be dynamically set. In actual operation, each pending task group occupies a certain amount of scheduling resources. Considering that the number of tasks each tenant needs to process varies with peaks and troughs, and given that the number of pending task groups for each tenant directly affects the real-time performance of task execution, the number of pending task groups for each tenant can be automatically adjusted to achieve rational resource utilization and improve the timeliness of task execution. The following examples illustrate the automatic adjustment of the number of pending task groups.
[0077] Figure 6 This is a flowchart illustrating an exemplary embodiment of the present disclosure of adjusting the number of task groups to be executed. (Refer to...) Figure 6 This includes the following steps:
[0078] Step S601: Obtain the number of times the pending task groups of all tenants have been executed within the preset time window.
[0079] The preset time window can be set according to actual conditions. This embodiment does not limit it. For example, the preset time window can be 30 minutes.
[0080] It should be noted that each time an application instance's resources are invoked and a task in the pending task group is completed, it signifies that the pending task group has been executed once. (See reference...) Figure 4 Task group 1 was executed once within 10 seconds. Task group 2 was executed twice within 10 seconds.
[0081] Step S602: For each tenant, determine the adjustment strategy corresponding to that tenant based on the number of times all pending task groups of that tenant have been executed and the number of times all pending task groups of all tenants have been executed.
[0082] Step S603: Adjust the number of pending task groups corresponding to the tenant according to the adjustment strategy corresponding to the tenant.
[0083] It should be noted that the adjustment strategy can include three types. For example, for tenant A, the adjustment strategy can be to increase the number of pending task groups (expansion), to decrease the number of pending task groups (shrinkage), or to keep the number of pending task groups unchanged.
[0084] In some embodiments, the adjustment strategy corresponding to a tenant can be determined according to the number of times of execution of all the groups of pending tasks of the tenant and the number of times of execution of all the groups of pending tasks of all the tenants. For example, there are J tenants in total, the J tenants include N groups of pending tasks in total, and the number of times of execution of the N groups of pending tasks is K in total, and the geometric mean number of times of execution of each group of pending tasks is K / N. Taking tenant A as an example, all the groups of pending tasks corresponding to tenant A are M, and the number of times of execution of the M groups of pending tasks of tenant A is L in total, and the geometric mean number of times of execution of each group of pending tasks of tenant A is L / M. If the geometric mean number of times of execution of tenant A is L / M, which is less than (K / N) / 2, it indicates that the number of tasks in tenant A is relatively large, and the geometric mean number of times of execution of each group of pending tasks in a preset time window is small. Therefore, the adjustment strategy of tenant A can be determined as increasing the number of groups of pending tasks, and the specific number can be twice the current number, and the number of groups of pending tasks of tenant A can be adjusted to 2M. If the geometric mean number of times of execution of tenant A is L / M, which is greater than (K / N) / 2, it indicates that the number of tasks in tenant A is relatively small, and the geometric mean number of times of execution of each group of pending tasks in a preset time window is relatively large. Therefore, the adjustment strategy of tenant A can be determined as decreasing the number of groups of pending tasks, and the specific number can be half the current number, and the number of groups of pending tasks of tenant A can be adjusted to M / 2. If the geometric mean number of times of execution of tenant A is L / M, which is equal to (K / N) / 2, the number of groups of pending tasks of tenant A can be kept as M.
[0085] Figure 7 is a flowchart of adjusting the number of groups of pending tasks according to an example embodiment of the present disclosure. Referring to Figure 7 , the method comprises the following steps:
[0086] In step S701, the execution duration of executing tasks in a target group of pending tasks is obtained.
[0087] In step S702, an adjustment strategy is determined according to the execution duration and a preset execution duration.
[0088] In step S703, the number of groups of pending tasks of a tenant corresponding to the target group of pending tasks is adjusted according to the adjustment strategy.
[0089] As shown in the embodiments of Figure 6 , the adjustment strategy in the embodiments shown in Figure 7 may also include the above three kinds, and specific reference can be made to the embodiments related to Figure 6 . This embodiment will not be described here.
[0090] It should be noted that when the execution duration is long, the number of tasks in the to-be-executed task group is large, and therefore the number of to-be-processed task groups of the tenant corresponding to the to-be-executed task group can be increased; when the execution duration is short, the number of tasks in the to-be-executed task group is small, and therefore the number of to-be-processed task groups of the tenant corresponding to the to-be-executed task group can be reduced. Specifically, when the execution duration is greater than the preset execution duration, the number of to-be-processed task groups of the tenant corresponding to the to-be-executed task group is increased; when the execution duration is less than the preset execution duration, the number of to-be-processed task groups of the tenant corresponding to the to-be-executed task group is reduced; and when the execution duration is equal to the preset execution duration, the number of to-be-processed task groups of the tenant corresponding to the to-be-executed task group is kept unchanged.
[0091] The preset execution duration can be set according to actual conditions, which is not limited in the embodiment.
[0092] By Figure 6 and Figure 7 the automatic adjustment of the number of to-be-executed task groups, the number of to-be-executed task groups of a tenant can be increased when there are a large number of tasks of the tenant, and the timeliness of task processing of the tenant can be improved; and the number of to-be-executed task groups of a tenant can be reduced when the number of tasks of the tenant is small, and more spare scheduling resources are provided for other tenants that initiate a large number of tasks, so as to adapt to different task peak and valley situations of tenants and comprehensively improve the performance of task scheduling and processing. In addition, compared with directly expanding the application instance, the expansion granularity is smaller and the expansion is more effective.
[0093] In some embodiments, an upper limit value and a lower limit value of the number of to-be-processed task groups under each tenant can be set. When the number of to-be-processed task groups is adjusted, the number of to-be-processed task groups of each tenant after adjustment is prevented from exceeding the corresponding upper limit value and lower limit value. In this way, the situation that all scheduling resources are monopolized by a certain tenant or the situation that the tasks of a certain tenant cannot be processed due to the absence of to-be-processed task groups is avoided, and the isolation of resources shared by tenants is further affected.
[0094] In some embodiments, in the case of reducing the number of to-be-processed task groups of a tenant, the action of assigning tasks to the to-be-processed task group can be stopped, and the to-be-processed task group can be deleted after all tasks in the to-be-processed task group are processed, so as to avoid the situation that tasks cannot be successfully processed due to the reduction of the number of to-be-processed task groups.
[0095] Figure 8 is a block diagram of a multi-tenant task processing apparatus according to an exemplary embodiment of the present disclosure. Referring to Figure 8 , the apparatus 800 comprises:
[0096] The first obtaining module 801 is configured to, in a case where it is determined that there is idle resource, obtain a to-be-processed task group corresponding to each tenant respectively, wherein the to-be-processed task group of each tenant includes at least one task initiated by the tenant and requiring to be processed;
[0097] The first determining module 802 is configured to determine a target to-be-executed task group from the to-be-processed task groups of all the tenants, wherein the target to-be-executed task group is a to-be-executed task group that is not in an occupied state, and there is a task in a processing state in a to-be-executed task group that is in the occupied state;
[0098] The executing module 803 is configured to execute the tasks in the target to-be-executed task group.
[0099] Optionally, the to-be-processed task group corresponding to each tenant includes multiple to-be-processed task groups, and the apparatus 800 further includes:
[0100] The second obtaining module is configured to obtain the number of times of execution of the to-be-processed task groups of all the tenants within a preset time window;
[0101] The second determining module is configured to, for each tenant, determine an adjustment strategy corresponding to the tenant according to the number of times of execution of all the to-be-processed task groups of the tenant and the number of times of execution of the to-be-processed task groups of all the tenants;
[0102] The first adjustment module is configured to adjust the number of to-be-processed task groups corresponding to the tenant according to the adjustment strategy corresponding to the tenant.
[0103] Optionally, the to-be-processed task group corresponding to each tenant includes multiple to-be-processed task groups, and the apparatus 800 further includes:
[0104] The third obtaining module is configured to obtain an execution duration of executing the tasks in the target to-be-executed task group;
[0105] The third determining module is configured to determine an adjustment strategy according to the execution duration and a preset execution duration;
[0106] The second adjustment module is configured to adjust the number of to-be-processed task groups of a tenant corresponding to the target to-be-executed task group according to the adjustment strategy.
[0107] Optionally, the tasks in the target to-be-executed task group are executed by an application instance, and the apparatus 800 further includes:
[0108] The first detecting module is configured to detect the number of target to-be-executed task groups associated with the tasks being executed by the application instance;
[0109] A fourth determining module is configured to determine that there is an idle resource in a case where a number of the target groups of to-be-executed tasks associated with tasks being executed by the application instance does not reach a maximum number of groups of executable tasks, wherein the maximum number of groups of executable tasks represents a maximum number of the target groups of to-be-executed tasks that can be executed simultaneously by the application instance.
[0110] Optionally, the tasks in the target groups of to-be-executed tasks are executed by application instances, the application instances include a plurality of application instances, and the apparatus 800 further includes:
[0111] A second detecting module is configured to detect whether there is a target application instance, the target application instance being an application instance that has no task to process.
[0112] A fifth determining module is configured to determine that there is an idle resource in a case where it is detected that there is the target application instance.
[0113] Optionally, each of the groups of to-be-processed tasks corresponding to a tenant includes a plurality of groups of to-be-processed tasks, and the apparatus 800 further includes:
[0114] A first allocating module is configured to, for each of the tenants, allocate at least one task initiated by the tenant and requiring to be processed into the groups of to-be-processed tasks corresponding to the tenant according to a preset task allocation rule.
[0115] Optionally, the application instances include a plurality of application instances, and the apparatus 800 further includes:
[0116] A fourth obtaining module is configured to obtain a load consumed by all the application instances.
[0117] An updating module is configured to update the maximum number of groups of executable tasks of each of the application instances according to the load and a maximum number of groups of executable tasks of all the application instances.
[0118] Optionally, the apparatus 800 further includes:
[0119] A second allocating module is configured to allocate a distributed lock to a target group of to-be-executed tasks determined as the target group of to-be-executed tasks, the distributed lock being used to detect whether the target group of to-be-executed tasks is in an occupied state.
[0120] A releasing module is configured to release the distributed lock allocated to the target group of to-be-executed tasks in a case where the target group of to-be-executed tasks is executed completely.
[0121] Reference will be made to the following description of embodiments of the application. Figure 9This document illustrates a structural schematic diagram of an electronic device 900 suitable for implementing embodiments of the present disclosure. The terminal devices in these embodiments may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0122] like Figure 9 As shown, electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 902 or a program loaded from storage device 908 into random access memory (RAM) 903. RAM 903 also stores various programs and data required for the operation of electronic device 900. Processing device 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.
[0123] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 An electronic device 900 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0124] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by a processing device 901, it performs the functions defined in the methods of embodiments of this disclosure.
[0125] It is noted that the aforementioned computer-readable medium of the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium can be, for example and without limitation, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a computer-readable program code transmitted by a computer-readable storage medium or carried by a carrier wave in a baseband or as part of a carrier wave. Such a propagated computer-readable signal medium can take various forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium that can be used to carry or store a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to wire, cable, RF (radio frequency), or the like, or any suitable combination of the foregoing.
[0126] In some embodiments, the electronic device can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communications of any form or medium (e.g., a communications network). Examples of communications networks include local area networks ("LAN"), wide area networks ("WAN"), internetworks (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future developed networks.
[0127] The aforementioned computer-readable medium can be contained in the aforementioned electronic device; or can exist separately without being assembled into the electronic device.
[0128] The computer readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, cause the electronic device to: in a case where it is determined that there is a free resource, acquire a to-be-processed task group corresponding to each tenant respectively, the to-be-processed task group of each tenant including at least one task initiated by the tenant and needing to be processed; determine a to-be-executed task group that is not in an occupied state in the to-be-processed task group of all the tenants as a target to-be-executed task group, there being a task in a processing state in the to-be-executed task group in the occupied state; and execute a task in the target to-be-executed task group.
[0129] Computer program code for carrying out operations of the present disclosure can be written in any of one or more programming languages, including object oriented programming languages such as Java, Smalltalk, C++ or conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0130] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a procedure, or a part of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in a different order than that noted in the figures. For example, two blocks noted in succession can in fact be executed substantially concurrently or in the opposite order, depending on the functionality involved. It will also be noted that each block in the block diagrams and / or flow diagrams, and combinations of blocks in the block diagrams and / or flow diagrams, can be implemented by dedicated hardware-based systems that perform the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0131] The modules described in the embodiments of the present disclosure can be implemented in the form of software, or can be implemented in the form of hardware. In some cases, the name of the module does not constitute a limitation on the module itself, for example, the first obtaining module can also be described as "a module that obtains a to-be-processed task group corresponding to each tenant".
[0132] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, and without limitation, example types of hardware logic components that can be used include field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip systems (SOCs), complex programmable logic devices (CPLDs), etc.
[0133] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the above. More specific examples of machine-readable storage media can include one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
[0134] According to one or more embodiments of the present disclosure, example 1 provides a multi-tenant task processing method, comprising:
[0135] In a case where it is determined that there are idle resources, obtaining a to-be-processed task group corresponding to each tenant, each to-be-processed task group of the tenants including at least one task initiated by the tenant and needing to be processed;
[0136] Determining a target to-be-executed task group from among all to-be-processed task groups of the tenants, the target to-be-executed task group being a to-be-executed task group that is not in an occupied state, and the to-be-executed task group in the occupied state having a task in a processing state;
[0137] Executing a task in the target to-be-executed task group.
[0138] According to one or more embodiments of the present disclosure, example 2 provides the method of example 1, each to-be-processed task group corresponding to each tenant including a plurality, and the method further comprising:
[0139] acquire the executed times of all the groups of to-be-processed tasks of the tenants within a preset time window;
[0140] for each of the tenants, determine an adjustment strategy corresponding to the tenant according to the executed times of all the groups of to-be-processed tasks of the tenant and the executed times of all the groups of to-be-processed tasks of all the tenants;
[0141] adjust the number of groups of to-be-processed tasks corresponding to the tenant according to the adjustment strategy corresponding to the tenant.
[0142] According to one or more embodiments of the present disclosure, example 3 provides the method of example 1, the groups of to-be-processed tasks corresponding to each of the tenants include multiple, and the method further includes:
[0143] acquire an execution duration of executing tasks in the target group of to-be-executed tasks;
[0144] determine an adjustment strategy according to the execution duration and a preset execution duration;
[0145] adjust the number of groups of to-be-processed tasks of the tenant corresponding to the target group of to-be-executed tasks according to the adjustment strategy.
[0146] According to one or more embodiments of the present disclosure, example 4 provides the method of example 1, the tasks in the target group of to-be-executed tasks are executed by an application instance, and the method further includes:
[0147] detect the number of target groups of to-be-executed tasks associated with the tasks being executed by the application instance;
[0148] in a case where the number of target groups of to-be-executed tasks associated with the tasks being executed by the application instance does not reach a maximum executable group number, it is determined that there is an idle resource, wherein the maximum executable group number represents a maximum number of target groups of to-be-executed tasks associated with tasks that can be executed simultaneously by the application instance.
[0149] According to one or more embodiments of the present disclosure, example 5 provides the method of example 1, the tasks in the target group of to-be-executed tasks are executed by an application instance, and the application instance includes multiple, and the method further includes:
[0150] detect whether there is a target application instance, the target application instance being an application instance that has no task to process;
[0151] in a case where it is detected that there is the target application instance, it is determined that there is an idle resource.
[0152] According to one or more embodiments of the present disclosure, example 6 provides the method of example 1, each of the pending task groups corresponding to a tenant comprises a plurality, and the method further comprises:
[0153] According to a preset task allocation rule, allocating at least one task initiated by the tenant and needed to be processed into each of the pending task groups corresponding to the tenant.
[0154] According to one or more embodiments of the present disclosure, example 7 provides the method of example 4, the application instances comprise a plurality, and the method further comprises:
[0155] Obtaining a load consumed by all the application instances;
[0156] According to the load and a maximum number of executable task groups of all the application instances, updating the maximum number of executable task groups of each of the application instances.
[0157] According to one or more embodiments of the present disclosure, example 8 provides the method of example 1, and the method further comprises:
[0158] Allocating a distributed lock to the to-be-executed task group determined as the target to-be-executed task group, the distributed lock being used to detect whether the to-be-executed task group is in an occupied state;
[0159] Releasing the distributed lock allocated to the to-be-executed task group of the target to-be-executed task group in a case where the target to-be-executed task group is executed completely.
[0160] According to one or more embodiments of the present disclosure, example 9 provides a multi-tenant task processing apparatus, comprising:
[0161] A first obtaining module, configured to, in a case where it is determined that there is an idle resource, obtain a pending task group corresponding to each tenant, each of the pending task groups of the tenants comprising at least one task initiated by the tenant and needed to be processed;
[0162] A first determining module, configured to determine a to-be-executed task group not in an occupied state in all the pending task groups of the tenants as a target to-be-executed task group, the to-be-executed task group in the occupied state comprising a task in a processing state;
[0163] An executing module, configured to execute a task in the target to-be-executed task group.
[0164] According to one or more embodiments of the present disclosure, example 10 provides a computer readable medium, having stored thereon a computer program, the program being executed by a processing apparatus to implement the steps of the method of any one of examples 1-8.
[0165] According to one or more embodiments of the present disclosure, example 11 provides an electronic device comprising:
[0166] a storage device having stored thereon a computer program;
[0167] a processing device configured to execute the computer program in the storage device to implement steps of the method of any one of examples 1-8.
[0168] The above description is only preferred embodiments of the present disclosure and a description of the principles of technology used. It should be understood by those skilled in the art that the disclosed scope of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by the combinations of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the technical solutions formed by the mutual replacement of the above features and the technical features disclosed in the present disclosure (but not limited to) having similar functions.
[0169] In addition, although each operation is described in a particular order, this should not be understood as requiring the operations to be performed in the specific order shown or in sequential order. In certain circumstances, multitasking and parallel processing can be advantageous. Similarly, although several implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments can also be combined in a single embodiment. Conversely, various features described in the context of a single embodiment can also be separated and implemented in multiple embodiments.
[0170] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With respect to the devices in the above-described embodiments, the specific manner in which the various modules perform operations has been described in detail in the embodiments related to the method, and will not be described in detail here.
Claims
1. A multi-tenant task processing method, characterized in that, include: If it is determined that there are idle resources, obtain the task group to be processed corresponding to each tenant, and the task group to be processed for each tenant includes at least one task initiated by the tenant that needs to be processed. The unoccupied pending task groups of all the tenants are identified as the target pending task groups. Among the pending task groups that are occupied, there are tasks that are being processed. Execute the tasks in the target task group; Each tenant corresponds to multiple pending task groups, and the method further includes: obtaining the number of times the pending task groups of all tenants have been executed within a preset time window; for each tenant, determining an adjustment strategy corresponding to that tenant based on the number of times all pending task groups of that tenant have been executed and the total number of times all pending task groups of all tenants have been executed; and adjusting the number of pending task groups corresponding to that tenant based on the adjustment strategy corresponding to that tenant. The method further includes: obtaining the execution time of tasks in the target task group to be executed; determining an adjustment strategy based on the execution time and a preset execution time; and adjusting the number of task groups to be processed for the tenant corresponding to the target task group to be executed based on the adjustment strategy.
2. The method according to claim 1, characterized in that, The method further includes executing tasks in the target task group by using an application instance: Detect the number of target task groups associated with the task currently being executed by the application instance; If the number of target task groups associated with the task being executed by the application instance does not reach the maximum number of executable task groups, it is determined that there are idle resources, wherein the maximum number of executable task groups represents the maximum number of target task groups associated with the tasks that the application instance can execute simultaneously.
3. The method according to claim 1, characterized in that, The method further includes executing tasks in the target task group by means of application instances, wherein the application instances include multiple instances. Detect whether a target application instance exists, wherein the target application instance is an application instance for which no task can be processed; If the existence of the target application instance is detected, it is determined that there are idle resources.
4. The method according to claim 1, characterized in that, Each tenant corresponds to multiple groups of tasks to be processed, and the method further includes: For each tenant, according to the preset task allocation rules, at least one task initiated by the tenant that needs to be processed is allocated to the corresponding task groups to be processed.
5. The method according to claim 2, characterized in that, The application instances include multiple examples, and the method further includes: Get the load consumed by all the application instances mentioned; Update the maximum number of executable task groups for each application instance based on the load and the maximum number of executable task groups for all application instances.
6. The method according to claim 1, characterized in that, The method further includes: A distributed lock is allocated to the task group to be executed, which is identified as the target task group to be executed. The distributed lock is used to detect whether the task group to be executed is in an occupied state. Once the target task group has been completed, the distributed lock allocated to the target task group is released.
7. A multi-tenant task processing device, characterized in that, include: The first acquisition module is used to acquire, when it is determined that there are idle resources, a group of tasks to be processed corresponding to each tenant, wherein each tenant's group of tasks to be processed includes at least one task initiated by the tenant that needs to be processed. The first determining module is used to determine the unoccupied pending task groups among all the pending task groups of the tenants as the target pending task groups, and to determine the pending task groups that are occupied as having tasks that are being processed. An execution module is used to execute the target task group to process the tasks in the target task group. Each tenant corresponds to multiple pending task groups, and the device further includes: a second acquisition module, configured to acquire the number of times the pending task groups of all tenants have been executed within a preset time window; a second determination module, configured to determine an adjustment strategy corresponding to each tenant based on the number of times all pending task groups of that tenant have been executed and the total number of times all pending task groups of all tenants have been executed; and a first adjustment module, configured to adjust the number of pending task groups corresponding to the tenant according to the adjustment strategy corresponding to the tenant. The device further includes: a third acquisition module, used to acquire the execution duration of tasks in the target task group to be executed; a third determination module, used to determine an adjustment strategy based on the execution duration and a preset execution duration; and a second adjustment module, used to adjust the number of task groups to be processed for the tenant corresponding to the target task group to be executed based on the adjustment strategy.
8. A computer-readable medium having a computer program stored thereon, characterized in that, When executed by the processing device, the program implements the steps of the method described in any one of claims 1-6.
9. An electronic device, characterized in that, include: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
Task queuing method and device, computer equipment and storage medium
CN113806049A
Distributed scheduling method and device under micro-service architecture and medium
CN114138435A