Service orchestration method based on multi-tenant micro-service architecture

By adopting a service orchestration method based on a multi-tenant microservice architecture in the SAAS service platform, using thread pools and pipeline processes to handle concurrent tasks, the problem of code redundancy and long response time caused by a single interface to request multiple business parties in serial, and the system is efficient, flexible and scalable.

CN119829255APending Publication Date: 2025-04-15BEIJING BAIJU YIXING TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510029556.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

In the SAAS service platform, a single interface requires multiple business parties to be requested in serial, resulting in code redundancy and long response time. Traditional single software instances are difficult to meet the needs of multiple tenants, resulting in increased system complexity and maintenance costs.

Method used

Using a service orchestration method based on a multi-tenant microservice architecture, a thread pool is created through the ExecutorService interface, a private final pipeline is defined, and a pipeline builder is created through Pipeline.builder(), which specifies each stage in the pipeline, including verification, parallel processing, result assembly and error processing, and creates a parallel processing phase with Fork, supporting asynchronous tasks and exception processing.

Benefits of technology

It realizes the rational utilization and performance optimization of thread pools, defines clear pipeline processes, supports concurrent task processing and timeout management, dynamic configuration and adjustment of business processes, enhances the scalability and flexibility of the system, and improves response speed and concurrent processing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829255A_ABST
    Figure CN119829255A_ABST
Patent Text Reader

Abstract

The invention relates to a service orchestration method based on a multi-tenant micro-service architecture, in particular to the field of distributed systems, comprising the steps of creating a thread pool and defining a private final pipeline, creating a pipeline builder and appointing each stage in the pipeline, generating a pipeline execution class, and initializing a pipeline processing overall business process. The method comprises the following steps: establishing a pipeline object, packaging into different processors, creating a pipeline object, effectively processing concurrent tasks, carrying out reasonable processing under an overtime condition, avoiding waste and blockage of system resources, adding each processor into a pipeline and inserting an interceptor into the pipeline, enhancing expandability and flexibility of a system, and improving system performance. The output results of the processors are combined into a final result, exception handling and rollback operation are carried out, the steps of the whole business process are divided into a plurality of sub-tasks, parallel execution and serial execution sub-task groups are formed, the execution sequence is determined, and the response speed and the concurrent processing capacity of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed systems, and more specifically, to a service orchestration method based on a multi-tenant microservice architecture. Background Art

[0002] Faced with the rapid development of the online car-hailing industry and diversified business needs, as a one-stop SAAS service platform, we have to think about how to better cope with increasingly complex scenarios. In the SAAS background, we face multiple scenarios. One scenario is that a single interface may need to serially request multiple business parties. When more and more business parties are requested, the code becomes redundant and takes a long time to write. Another scenario is that in order to improve the response time of the interface, it is necessary to make concurrent requests to multiple business parties and aggregate the data.

[0003] In today's highly competitive business environment, multi-tenant architecture has become the key for many companies to achieve flexibility and economic benefits. Traditional single software instances are often unable to meet the needs of all customers. Traditional customized development often requires a lot of time and resources, and easily leads to increased system complexity and maintenance costs.

[0004] In the traditional software development process, every time a new function is developed or an existing requirement is iterated, a large amount of similar code needs to be written. The repetitive work not only increases the workload of developers, but also easily introduces errors and reduces development efficiency. Summary of the invention

[0005] In view of the technical problems existing in the prior art, the present invention provides a service orchestration method based on a multi-tenant microservice architecture to solve the problems raised in the above background technology.

[0006] The technical solution of the present invention to solve the above technical problem is as follows: A service orchestration method based on a multi-tenant microservice architecture comprises the following steps:

[0007] S101. Use the ExecutorService interface to create a thread pool, define a private final pipeline, create a pipeline builder, and specify each stage in the pipeline, and execute the pipeline class generated by the build() method;

[0008] S102. Initialize the pipeline to process the steps of the overall business process, encapsulate it into different processors, create a pipeline object, add each processor to the pipeline and insert an interceptor into the pipeline, merge the output results of each processor into the final result, and perform exception handling and rollback operations;

[0009] S103. Split the steps of the overall business process into multiple subtasks, form subtask groups that are executed in parallel or serially, and determine the execution order;

[0010] S104. Parse and verify the transmitted data and status, identify and extract custom parameters, select and execute the steps of the overall business process, and return the execution results to the SaaS system;

[0011] In a preferred embodiment, in S101, the fixed size of the thread pool is determined to be 2 based on the load of the multi-tenant online car-hailing system, the number of CPU cores, memory conditions, and the expected number of concurrent tasks, and the thread pool is created using Java's ExecutorService interface, and the thread pool parameters are configured as required.

[0012] Furthermore, a private final pipeline getResourceByTokenPipeline is defined, and a parameter of type GetResourceByTokenContext is received. A pipeline builder is created using Pipeline.builder(), and each stage in the pipeline is specified, including:

[0013] Step 1. Verify the administrator user token parameters;

[0014] Step 2. Parameter converter and RpcService1 invoker;

[0015] Step 3. Use Fork to create a parallel processing stage and set the maximum waiting time to 500 milliseconds;

[0016] Step 4. Result assembler;

[0017] Step 5. In the error handling phase, packErrorResponse packs the error response;

[0018] The pipeline execution class is generated by the build() method, where the only input parameter of execute is PipeContext, and the final execution result is saved in PipeContext and returned.

[0019] In a preferred embodiment, in S102, the steps of the overall business process of the pipeline processing multi-tenant online car-hailing system are initialized and encapsulated into different processors, each of which is responsible for performing a specific task, and a pipeline object is created, wherein the pipeline object contains a processor list that provides methods to add, remove and execute processors, each processor is added to the pipeline and an interceptor is inserted into the pipeline, and the processors are arranged in the order of steps, and the interceptor is used to perform additional operations before and after the execution of the processor, call the execution method of the pipeline object and trigger the execution of the steps, call the processing method of each processor in the order of adding the processors, and pass data and status through the context object, merge the output results of each processor into the final result, and perform exception handling and rollback operations.

[0020] In a preferred embodiment, in S103, the steps of the overall business process are split into multiple subtasks according to the dependencies and execution order between the steps of the overall business process, the subtasks to be executed in parallel are marked to form a subtask group to be executed in parallel, the subtask combinations with dependencies are marked to form a subtask group to be executed in serial, the subtask group to be executed in serial is determined to be executed after the task group to be executed in parallel, and the subtask groups to be executed in parallel are merged and processed in a manner of asynchronous tasks.

[0021] In a preferred embodiment, in S104, when the interface request called by the SaaS system is received, the execution of the overall business process parses and verifies the transmitted data and status, identifies and extracts custom parameters, selects and executes the steps of the overall business process through the logical mapping relationship defined in the code, and returns the execution result to the SaaS system, wherein the execution result identifies success, failure and error information, and implements customized functions in the overall business process through conditional judgment and function calling, and optimizes the execution efficiency of the business process.

[0022] The beneficial effects of the present invention are as follows: by creating a thread pool and describing the parameters of the thread pool in detail, the reasonable use and performance optimization of the thread pool are ensured; a private final pipeline is defined and parameters are received; a clear description of the functions and tasks of each stage is given, so that the entire pipeline process is clear and controllable; by creating a pipeline builder to specify the functions of the customized pipeline at different stages, the functions of the pipeline can be conveniently expanded and modified to meet the changes in system requirements and the increase in functions; by using Fork to create a parallel processing stage, concurrent tasks can be effectively processed, and reasonable processing can be performed in the case of timeout to avoid waste and blocking of system resources; by organizing and managing processors through pipeline objects, the execution order between processors is flexible and controllable; at the same time, methods for adding, removing and executing processors are provided to realize dynamic configuration and adjustment of business processes; and inserting an interceptor into the pipeline can be performed during processor execution. Additional operations are performed before and after the execution, which enhances the scalability and flexibility of the system. Data and status are passed through context objects, so that information can be shared between processors, while ensuring decoupling between processors. Exception handling and regression operations are used to ensure the stability and reliability of the system. By further splitting the overall business process into multiple subtasks, the dependencies and execution order between each step are more clearly described, and the subtask groups executed in parallel are marked to fully utilize system resources, improve processing efficiency and shorten the overall processing time. The subtask groups executed in parallel are processed in the form of asynchronous tasks, which fully utilizes the advantages of multi-core processors and speeds up task processing. It supports setting the maximum waiting time for asynchronous tasks to prevent long-term blocking of tasks from causing system performance degradation. The system's response speed and concurrent processing capabilities are improved by supporting full background execution. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 is a flow chart of the method of the present invention; DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0025] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0026] In the description of the present application, the term "for example" is used to mean "used as an example, illustration or description". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid unnecessary details to obscure the description of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.

[0027] This embodiment provides Figure 1 A service orchestration method based on a multi-tenant microservice architecture is shown, which specifically includes the following steps:

[0028] S101. Use the ExecutorService interface to create a thread pool, define a private final pipeline, create a pipeline builder, and specify each stage in the pipeline, and execute the pipeline class generated by the build() method;

[0029] Furthermore, according to the load situation of the multi-tenant online car-hailing system, the number of CPU cores, memory situation and the expected number of concurrent tasks, the fixed size of the thread pool is determined to be 2, and the thread pool is created using Java's ExecutorService interface. The thread pool parameters are configured according to demand, including the number of core threads, the maximum number of threads, the thread idle time and the task queue type. The core thread requirement is the minimum number of threads that remain active in the thread pool, and the number is configured according to the concurrent load and expected response time of the multi-tenant online car-hailing system. The maximum thread requirement is the maximum number of threads allowed in the thread pool, and new threads are created in the thread pool to handle concurrent tasks. The thread idle time requirement is the time that a non-core thread remains alive when there is no task to execute, which is configured according to the request mode and response requirements. The task queue type requirement is to save the different task characteristics waiting to be executed, and is configured according to the task processing speed and memory consumption.

[0030] Furthermore, a private final pipeline getResourceByTokenPipeline is defined, and a parameter of the GetResourceByTokenContext type is received. The final pipeline is defined outside the request method, that is, each request method only defines one pipeline instance, not a new pipeline instance for each execution. A pipeline builder is created using Pipeline.builder(), and each stage in the pipeline is specified, including:

[0031] Step 1. Verify the administrator user token parameters;

[0032] Step 2. Parameter converter and RpcService1 invoker;

[0033] Step 3. Use Fork to create a parallel processing stage, including RpcService2 caller, asyncNoResult asynchronous processing, asyncWithResult asynchronous processing and writing back results, AsyncTaskCommand call and AsyncTaskWriteBack call, and set the maximum waiting time to 500 milliseconds;

[0034] Step 4. Result assembler;

[0035] Step 5. In the error handling phase, packErrorResponse packs the error response;

[0036] The pipeline execution class is generated by the build() method, where the only input parameter of execute is PipeContext, and the final execution result is saved in PipeContext and returned.

[0037] S102. Initialize the pipeline to process the steps of the overall business process, encapsulate it into different processors, create a pipeline object, add each processor to the pipeline and insert an interceptor into the pipeline, merge the output results of each processor into the final result, and perform exception handling and rollback operations;

[0038] Furthermore, the steps of the overall business process of the multi-tenant online car-hailing system are initialized and encapsulated into different processors, where each processor is responsible for performing specific tasks, including parameter verification, business logic processing, and data persistence. A pipeline object is created to organize and manage each processor, where the pipeline object contains a processor list that provides methods to add, remove, and execute processors. Each processor is added to the pipeline and an interceptor is inserted into the pipeline, and the processors are arranged in the order of steps. The interceptor is used to perform additional operations before and after the execution of the processor, including logging and permission verification. The execution method of the pipeline object is called and the execution of the steps is triggered. The processing method of each processor is called in turn in the order in which the processors are added, and data and status are passed through the context object. The output results of each processor are merged into the final result, and exception handling and rollback operations are performed.

[0039] S103. Split the steps of the overall business process into multiple subtasks, form subtask groups that are executed in parallel or serially, and determine the execution order;

[0040] Furthermore, according to the dependency relationship and execution order between the steps of the overall business process, the steps of the overall business process are split into multiple subtasks, the subtasks executed in parallel are marked, and a subtask group executed in parallel is formed, and the subtask combinations with dependencies are marked to form a subtask group executed in serial, and the subtask group executed in serial is determined to be executed after the task group executed in parallel. The subtask group executed in parallel is merged and processed by asynchronous tasks, wherein the core methods of asynchronous tasks are divided into two categories, one is to add asynchronous tasks, which are divided into run method and call method, wherein the run method does not return the execution result, and when the return result exists, it is implemented by saving it in PipeContext, wherein the call method is processed by the main thread to return the execution result, and the other is to set the maximum waiting time, which supports specifying the time in milliseconds and complete background execution, wherein the main thread does not need to wait for the execution result.

[0041] S104. Parse and verify the transmitted data and status, identify and extract custom parameters, select and execute the steps of the overall business process, and return the execution results to the SaaS system;

[0042] Furthermore, in a preferred embodiment, in S104, when the interface request called by the SaaS system is received, the execution of the overall business process parses and verifies the transmitted data and status, and identifies and extracts custom parameters to support the execution of different logics according to the custom parameters, and selects and executes the steps of the overall business process through the logical mapping relationship defined in the code, and returns the execution result to the SaaS system, wherein the execution result is marked with success, failure and error information, and the customized function is implemented in the overall business process through conditional judgment and function calling, and the execution efficiency of the business process is optimized, including reducing the number of database queries, rationally using cache, and executing tasks in parallel.

[0043] It should be noted that in the above embodiments, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0044] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0045] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0046] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0047] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0048] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0049] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A service orchestration method based on a multi-tenant microservice architecture, characterized in that: The specific steps include: S101. Use the ExecutorService interface to create a thread pool, define a private final pipeline, create a pipeline builder, and specify each stage in the pipeline, and execute the pipeline class generated by the build() method; S102. Initialize the pipeline to process the steps of the overall business process, encapsulate it into different processors, create a pipeline object, add each processor to the pipeline and insert an interceptor into the pipeline, merge the output results of each processor into the final result, and perform exception handling and rollback operations; S103. Split the steps of the overall business process into multiple subtasks, form subtask groups that are executed in parallel or serially, and determine the execution order; S104. Parse and verify the transmitted data and status, identify and extract custom parameters, select the steps of the overall business process and execute them, and return the execution results to the SaaS system.

2. A service orchestration method based on a multi-tenant microservice architecture according to claim 1, characterized in that: In S101, a thread pool is created, thread pool parameters are configured according to requirements, a private final pipeline getResourceByTokenPipeline is defined, a pipeline builder is created using Pipeline.builder(), and each stage in the pipeline is specified. The pipeline execution class generated by the build() method, and the final execution result is saved in PipeContext and returned.

3. A service orchestration method based on a multi-tenant microservice architecture according to claim 2, characterized in that: The various stages in the specified pipeline include: Step 1. Verify the administrator user token parameters; Step 2. Parameter converter and RpcService1 invoker; Step 3. Use Fork to create a parallel processing stage and set the maximum waiting time to 500 milliseconds; Step 4. Result assembler; Step 5. In the error handling phase, packErrorResponse packages the error response.

4. The service orchestration method based on a multi-tenant microservice architecture according to claim 1, characterized in that: In S102, the steps of the overall business process of the multi-tenant online car-hailing system are initialized and encapsulated into different processors, a pipeline object is created, each processor is added to the pipeline and an interceptor is inserted into the pipeline, and the processors are arranged in the order of the steps, the execution method of the pipeline object is called and the execution of the steps is triggered, the processing method of each processor is called in turn according to the order in which the processors are added, and data and status are passed through the context object, the output results of each processor are merged into the final result, and exception handling and rollback operations are performed.

5. A service orchestration method based on a multi-tenant microservice architecture according to claim 4, characterized in that: The processor is responsible for executing specific tasks, the pipeline object contains a processor list that provides methods to add, remove and execute processors, and the interceptor is used to perform additional operations before and after the processor is executed.

6. A service orchestration method based on a multi-tenant microservice architecture according to claim 1, characterized in that: In S103, according to the dependency relationship and execution order between the steps of the overall business process, the steps of the overall business process are divided into multiple subtasks, the subtasks to be executed in parallel are marked to form a subtask group to be executed in parallel, the subtask combinations with dependencies are marked to form a subtask group to be executed serially, and it is determined that the subtask group to be executed serially is executed after the task group to be executed in parallel.

7. The service orchestration method based on a multi-tenant microservice architecture according to claim 1, characterized in that: In S104, when the interface request called by the SaaS system is received, the execution of the overall business process parses and verifies the transmitted data and status, identifies and extracts custom parameters, selects and executes the steps of the overall business process through the logical mapping relationship defined in the code, and returns the execution result to the SaaS system. The overall business process implements customized functions through conditional judgment and function calling, and optimizes the execution efficiency of the business process.

8. A service orchestration method based on a multi-tenant microservice architecture according to claim 7, characterized in that: The execution results are marked with success, failure and error information, and the subtask groups executed in parallel are merged and processed in an asynchronous task manner.

9. A service orchestration method based on a multi-tenant microservice architecture according to claim 8, characterized in that: The core methods of the asynchronous task are divided into two categories. One category is adding an asynchronous task, which is divided into a run method and a call method.

Citation Information

Cited By

  • Micro-service elastic telescopic arrangement method and arrangement device

    CN121078133A

  • A micro-service elasticity scaling method and orchestrator

    CN121078133B