Multi-tenant task management method and apparatus, electronic device, and storage medium
By setting up independent scheduled task modules and business modules in a multi-tenant architecture, and generating startup services and target isolation databases based on task categories, the problem of instance sharing or isolation of scheduled tasks is solved, enabling independent operation and resource optimization among tenants.
Patent Information
- Application Number
- CN202111266008.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2041-10-28
AI Technical Summary
In a multi-tenant architecture, existing technologies cannot effectively solve the problem of instance sharing or isolation of scheduled tasks, resulting in a waste of server resources.
By setting the scheduled task module and business module independently, and generating corresponding startup services and target isolated databases according to the task category when receiving a tenant's task request, data isolation and business code sharing between tenants are achieved, avoiding unnecessary microservice startup.
This allows multiple tenants to have their scheduled tasks independent and isolated from each other, serving their respective tenants without interfering with other tenants, thus solving the problem of wasted server resources.
Smart Images

Figure CN114003360B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud platform multi-tenant deployment technology, and in particular to a multi-tenant task management method, apparatus, electronic device and storage medium. Background Technology
[0002] Multi-tenancy technology, also known as multi-tenancy technology, is a software architecture technology that enables multiple users (generally enterprise users) to share the same system or program components while ensuring data isolation between users.
[0003] Currently, in multi-tenant architectures, there are issues related to instance and data sharing and isolation. In platform deployment, based on actual business conditions, there are three main approaches: (1) full sharing of instances and data; (2) partial sharing of instances and data (instance or data sharing); and (3) complete isolation of instances and data.
[0004] However, without the aid of external frameworks (such as Spring Quartz), instance sharing / isolation cannot perfectly solve the problem of multi-tenant scheduled tasks. The main reason is that instance sharing leads to the scheduled task service not knowing which tenant it belongs to, while isolation requires starting as many microservices as there are tenants, resulting in wasted server resources. This is because, apart from scheduled tasks, other business services do not require isolation, a problem that urgently needs to be addressed. Summary of the Invention
[0005] This application provides a multi-tenant task management method, apparatus, electronic device, and storage medium, which enables multiple tenants' scheduled tasks to be independent and isolated from each other, serving their respective tenants without interfering with other tenants. This solves the problem in related technologies where, when data is isolated, several microservices need to be started for each tenant, leading to a waste of server resources.
[0006] The first aspect of this application provides a multi-tenant task management method, including the following steps:
[0007] Receive task requests from multiple tenants;
[0008] The task category of each tenant's task request is detected, and when the task category is a real-time task, at least one startup service is generated by the startup class corresponding to each of the multiple tenants in the scheduled task module; and
[0009] At least one target isolated database corresponding to the real-time task is started according to the at least one startup service.
[0010] Optionally, starting at least one target isolated database corresponding to the real-time task according to the at least one startup service includes:
[0011] Obtain the startup parameters of at least one target isolated database corresponding to the real-time task;
[0012] Obtain at least one target isolated database corresponding to the identity information of each tenant;
[0013] Based on the correspondence between the real-time task and each tenant, at least one target isolated database corresponding to the real-time task is determined;
[0014] At least one target isolated database corresponding to the real-time task is started according to the startup parameters.
[0015] Optionally, it also includes:
[0016] When the task category is a non-real-time task, a business service is generated based on the unique startup class in the business module to process the non-real-time task.
[0017] Optionally, the scheduled task module and the business module are set up independently.
[0018] A second aspect of this application provides a multi-tenant task management device, comprising:
[0019] The receiving module is used to receive task requests from multiple tenants;
[0020] The first generation module is used to detect the task category of each tenant's task request, and when the task category is a real-time task, to generate at least one startup service from the startup class corresponding to each of the multiple tenants in the scheduled task module; and
[0021] A startup module is used to start at least one target isolated database corresponding to the real-time task according to the at least one startup service.
[0022] Optionally, the startup module is specifically used for:
[0023] Obtain the startup parameters of at least one target isolated database corresponding to the real-time task;
[0024] Obtain at least one target isolated database corresponding to the identity information of each tenant;
[0025] Based on the correspondence between the real-time task and each tenant, at least one target isolated database corresponding to the real-time task is determined;
[0026] At least one target isolated database corresponding to the real-time task is started according to the startup parameters.
[0027] Optionally, it also includes:
[0028] The second generation module is used to generate a business service based on the unique startup class in the business module when the task category is a non-real-time task, so as to process the non-real-time task through the business service.
[0029] Optionally, the scheduled task module and the business module are set up independently.
[0030] A third aspect of this application provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the multi-tenant task management method as described in the above embodiments.
[0031] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the multi-tenant task management method as described in the above embodiments.
[0032] Therefore, it can receive task requests from multiple tenants, detect the task category of each tenant's task request, and when the task category is a real-time task, generate at least one startup service from the startup class corresponding to each of the multiple tenants in the scheduled task module, and start at least one target isolated database corresponding to the real-time task according to the at least one startup service. This allows the scheduled tasks of multiple tenants to be independent and isolated from each other, serving their respective tenants without interfering with other tenants. This solves the problem in related technologies where data isolation requires starting multiple microservices for each tenant, leading to wasted server resources.
[0033] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0034] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0035] Figure 1 This is a flowchart of a multi-tenant task management method provided according to an embodiment of this application;
[0036] Figure 2 This is an example diagram illustrating the deployment of multi-tenant task management according to one embodiment of this application;
[0037] Figure 3 This is an example diagram of a multi-tenant task management device according to an embodiment of this application;
[0038] Figure 4A schematic diagram of the structure of the electronic device provided in the application embodiment. Detailed Implementation
[0039] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0040] The following description, with reference to the accompanying drawings, describes a multi-tenant task management method, apparatus, electronic device, and storage medium according to embodiments of this application. Addressing the problem mentioned in the background section of related technologies where data isolation necessitates the startup of multiple microservices for each tenant, leading to wasted server resources, this application provides a multi-tenant task management method. This method receives task requests from multiple tenants, detects the task category of each tenant's request, and when the task category is a real-time task, generates at least one startup service from a startup class corresponding to each tenant in the scheduled task module. Based on this startup service, at least one target isolated database corresponding to the real-time task is then started. This allows the scheduled tasks of multiple tenants to be independent and isolated from each other, serving their respective tenants without interfering with other tenants, thus solving the problem of wasted server resources caused by the need to start multiple microservices for each tenant during data isolation in related technologies.
[0041] Specifically, Figure 1 This is a flowchart illustrating a multi-tenant task management method provided in an embodiment of this application.
[0042] like Figure 1 As shown, the multi-tenant task management method includes the following steps:
[0043] In step S101, task requests from multiple tenants are received.
[0044] In step S102, the task category of each tenant's task request is detected, and when the task category is a real-time task, at least one startup service is generated by the startup class corresponding to multiple tenants in the timed task module.
[0045] Task requests can include real-time task requests and non-real-time task requests, and task categories can be divided into real-time tasks and non-real-time tasks.
[0046] Specifically, this application embodiment can receive task requests from multiple tenants and analyze the task request category of each tenant. If the task request category of the tenant is a real-time task, at least one startup service can be generated from the startup class corresponding to the tenant whose task request category is a real-time task in the scheduled task module.
[0047] It should be noted that, as Figure 2 As shown, in this embodiment of the application, the scheduled task-related code can be separated from the business code in the microservice and made into an independent module (i.e., the scheduled task module), and a startup class can be added to the scheduled task module.
[0048] In step S103, at least one target isolated database corresponding to the real-time task is started according to at least one startup service.
[0049] Optionally, in some embodiments, starting at least one target isolated database corresponding to a real-time task according to at least one startup service includes: obtaining startup parameters for at least one target isolated database corresponding to a real-time task; obtaining at least one target isolated database corresponding to the identity information of each tenant; determining at least one target isolated database corresponding to a real-time task according to the correspondence between the real-time task and each tenant; and starting at least one target isolated database corresponding to a real-time task according to the startup parameters.
[0050] It should be understood that during project deployment, the above-mentioned scheduled task module can be started as a service. Each tenant starts a service and specifies the startup parameters at startup to indicate which tenant the service belongs to (i.e., which target isolated database the service corresponds to).
[0051] For example, such as Figure 2 As shown, the multiple tenants are tenant 1, tenant 2, tenant 3, ... Then the startup service of tenant 1 can be Micro Service 1 in the scheduled task module, and corresponds to tenant 1 in the target isolation database; the startup service of tenant 2 can be Micro Service 2 in the scheduled task module, and corresponds to tenant 2 in the target isolation database; the startup service of tenant 3 can be Micro Service 3 in the scheduled task module, and corresponds to tenant 3 in the target isolation database, ...
[0052] Optionally, in some embodiments, the method further includes: when the task category is a non-real-time task, generating a business service based on the unique startup class in the business module, so as to process the non-real-time task through the business service.
[0053] It should be understood that, apart from scheduled tasks, other business services do not need to be isolated. Therefore, if the current task category is a non-real-time task, a business service can be generated through a unique startup class in the business module (such as...). Figure 2 The MicroService 0 shown enables the processing of non-real-time tasks.
[0054] Optionally, in some embodiments, the timed task module and the business module are set up independently.
[0055] In other words, in this embodiment of the application, the real-time task module and the business module are set up independently. After the project-related services are started, the business code is shared, that is, multiple tenants correspond to one business service (implemented through the business module), but the scheduled task service is isolated, with one tenant corresponding to one scheduled task service (completed through the scheduled task module).
[0056] Therefore, by adopting methods such as data isolation among multiple tenants, business code sharing, and code isolation for scheduled tasks, multiple tenants can manage scheduled tasks without relying on external frameworks (such as Spring Quartz).
[0057] The multi-tenant task management method proposed in this application can receive task requests from multiple tenants, detect the task category of each tenant's task request, and when the task category is a real-time task, generate at least one startup service from the startup class corresponding to each of the multiple tenants in the scheduled task module, and start at least one target isolated database corresponding to the real-time task according to the at least one startup service. This allows the scheduled tasks of multiple tenants to be independent and isolated from each other, serving their respective tenants without interfering with other tenants. This solves the problem in related technologies where, when data is isolated, several microservices need to be started for each tenant, leading to a waste of server resources.
[0058] Next, a multi-tenant task management apparatus according to an embodiment of this application is described with reference to the accompanying drawings.
[0059] Figure 3 This is a block diagram of a multi-tenant task management device according to an embodiment of this application.
[0060] like Figure 3 As shown, the multi-tenant task management device 10 includes: a receiving module 100, a first generation module 200, and a startup module 300.
[0061] The receiving module 100 is used to receive task requests from multiple tenants;
[0062] The first generation module 200 is used to detect the task category of each tenant's task request, and when the task category is a real-time task, it generates at least one startup service from the startup class corresponding to multiple tenants in the scheduled task module; and
[0063] The startup module 300 is used to start at least one target isolated database corresponding to a real-time task based on at least one startup service.
[0064] Optionally, the startup module 300 is specifically used for:
[0065] Obtain the startup parameters of at least one target isolated database corresponding to the real-time task;
[0066] Obtain at least one target isolated database corresponding to the identity information of each tenant;
[0067] Determine at least one target isolated database corresponding to a real-time task based on the correspondence between the real-time task and each tenant;
[0068] Start at least one target isolated database corresponding to the real-time task based on the startup parameters.
[0069] Optionally, it also includes:
[0070] The second generation module is used to generate a business service based on the unique startup class in the business module when the task category is a non-real-time task, so as to process the non-real-time task through the business service.
[0071] Optionally, the scheduled task module and the business module can be set up independently.
[0072] It should be noted that the foregoing explanation of the multi-tenant task management method embodiment also applies to the multi-tenant task management device of this embodiment, and will not be repeated here.
[0073] The multi-tenant task management device proposed in this application can receive task requests from multiple tenants, detect the task category of each tenant's task request, and when the task category is a real-time task, generate at least one startup service from the startup class corresponding to each of the multiple tenants in the scheduled task module, and start at least one target isolated database corresponding to the real-time task according to the at least one startup service. This allows the scheduled tasks of multiple tenants to be independent and isolated from each other, serving their respective tenants without interfering with other tenants. This solves the problem in related technologies where, when data is isolated, several microservices need to be started for each tenant, leading to a waste of server resources.
[0074] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:
[0075] The memory 401, the processor 402, and the computer program stored on the memory 401 and capable of running on the processor 402.
[0076] When processor 402 executes the program, it implements the multi-tenant task management method provided in the above embodiments.
[0077] Furthermore, electronic devices also include:
[0078] Communication interface 403 is used for communication between memory 401 and processor 402.
[0079] The memory 401 is used to store computer programs that can run on the processor 402.
[0080] The memory 401 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0081] If the memory 401, processor 402, and communication interface 403 are implemented independently, then the communication interface 403, memory 401, and processor 402 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0082] Optionally, in a specific implementation, if the memory 401, processor 402, and communication interface 403 are integrated on a single chip, then the memory 401, processor 402, and communication interface 403 can communicate with each other through an internal interface.
[0083] Processor 402 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0084] This embodiment also provides a computer-readable storage medium storing a computer program thereon, characterized in that the program, when executed by a processor, implements the multi-tenant task management method described above.
[0085] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0086] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0087] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0088] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0089] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
Claims
1. A multi-tenant task management method, characterized by, The method comprises the following steps: receiving task requests of a plurality of tenants; detecting a task category of the task request of each tenant, and generating at least one start service by a start class corresponding to the plurality of tenants in a timing task module when the task category is a real-time task; and starting at least one target isolated database corresponding to the real-time task according to the at least one start service; wherein the starting of the at least one target isolated database corresponding to the real-time task according to the at least one start service comprises: obtaining start parameters of the at least one target isolated database corresponding to the real-time task; obtaining at least one target isolated database corresponding to the identity recognition information of each tenant; determining the at least one target isolated database corresponding to the real-time task according to the correspondence between the real-time task and each tenant; and starting the at least one target isolated database corresponding to the real-time task according to the start parameters; wherein when the task category is a non-real-time task, a business service is generated based on a unique start class in a business module to process the non-real-time task through the business service, and the timing task module and the business module are independently arranged.
2. A multi-tenant task management apparatus, characterized by, It comprises: a receiving module for receiving task requests of a plurality of tenants; a first generation module for detecting a task category of the task request of each tenant, and generating at least one start service by a start class corresponding to the plurality of tenants in a timing task module when the task category is a real-time task; and a starting module for starting at least one target isolated database corresponding to the real-time task according to the at least one start service; wherein the starting module is specifically configured to: obtain start parameters of the at least one target isolated database corresponding to the real-time task; obtain at least one target isolated database corresponding to the identity recognition information of each tenant; determine the at least one target isolated database corresponding to the real-time task according to the correspondence between the real-time task and each tenant; and start the at least one target isolated database corresponding to the real-time task according to the start parameters; The multi-tenant task management device further comprises a second generation module for generating a business service based on a unique start class in a business module to process the non-real-time task through the business service when the task category is a non-real-time task, and the timing task module and the business module are independently arranged.
3. An electronic device, comprising: It comprises: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to implement the multi-tenant task management method of claim 1.
4. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the multi-tenant task management method of claim 1.
Citation Information
Patent Citations
Data management for a multi-tenant identity cloud service
CN108701182A