Service processing method and device
By identifying the main task and subtasks and processing subtasks asynchronously during the execution of the main task, the problem of long wait time caused by serial execution of tasks in the prior art is solved, and the efficiency of service processing is improved.
Patent Information
- Application Number
- CN202411364623.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-01-03
AI Technical Summary
In the prior art, when processing service requests, task execution is serial, resulting in a long wait time and reducing service efficiency.
By determining the main task and subtasks, using a thread pool to load and process subtasks asynchronously, preloading the subtask results for direct use when the subtask execution time arrives, improving the execution efficiency of the main task.
Improve task execution efficiency, reduce waiting time, and improve service processing efficiency.
Smart Images

Figure CN119248497A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to computer technology, and more particularly to a method and device for service processing. Background Art
[0002] After receiving a service processing request sent by a user, the platform will provide the user with corresponding services based on the processing request. When providing services, the platform will often execute multiple tasks in serial to provide the services corresponding to the processing request. That is, the tasks required to provide the service are executed in sequence, and the next task will be executed after the current task is completed. Summary of the invention
[0003] The embodiments of the present application provide a method, device, electronic device, computer-readable storage medium, and computer program product for service processing, which can improve the execution efficiency of tasks.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application provides a method for service processing, the method comprising:
[0006] In response to a first processing request for a target service, determining a main task associated with the target service and at least one subtask associated with the main task;
[0007] Loading a first thread pool corresponding to the first processing request, and executing the main task through a first processing thread in the first thread pool;
[0008] In the process of executing the main task, in response to the preloading condition being satisfied, preloading the subtask and the second processing thread executing the subtask, and performing asynchronous processing on the subtask through the second processing thread to obtain a subtask processing result;
[0009] In response to the execution timing of the subtask arriving, the subtask processing result is called, and the main task is continued to be executed based on the subtask processing result.
[0010] The present application provides a service processing device, including:
[0011] A task determination module, configured to determine, in response to a first processing request for a target service, a main task associated with the target service and at least one subtask associated with the main task;
[0012] A thread pool loading module, used for loading a first thread pool corresponding to the first processing request, and executing the main task through a first processing thread in the first thread pool;
[0013] A task processing module, configured to preload the subtask and execute the second processing thread of the subtask in response to the preloading condition being satisfied during the execution of the main task, and perform asynchronous processing on the subtask through the second processing thread to obtain a subtask processing result;
[0014] The task execution module is used to call the subtask processing result in response to the execution timing of the subtask arriving, and continue to execute the main task based on the subtask processing result.
[0015] In the above scheme, the thread pool loading module is also used to determine the first time period in which the first processing request is located, and obtain the second processing request triggered for the target service within the first time period; load a first number of thread pools, wherein the thread pool includes a first thread pool corresponding to the first processing request and a second thread pool corresponding to the second processing request, and the first number is the total number of requests for the first processing request and the second processing request triggered within the first time period.
[0016] In the above scheme, the task processing module is also used to determine the number of tasks configured for the thread pool; based on the first number and the number of tasks, determine the number of preloaded tasks, and preload the tasks of the preloaded number of tasks, wherein the preloaded tasks include the subtasks.
[0017] In the above scheme, the task processing module is also used to determine that the preloading condition is met in response to the time interval between the execution time of the main task and the execution time of the subtask being greater than a first interval threshold and less than a second interval threshold; or, in response to the historical loading rate of the subtask in the historical target service being higher than a loading rate threshold, determine that the preloading condition is met; in response to the network environment in which the processor processing the target service is located being compatible with the performance of the processor, determine that the preloading condition is met.
[0018] In the above scheme, the task determination module is also used to obtain a second number of thread pools created in a second time period and a total number of requests for processing requests counted in the second time period; based on the second number and the total number of requests, determine a third number of thread pools to be created in a third time period; wherein the third time period is the previous adjacent statistical time period of the first time period in which the first processing request is located, and the second time period is the previous adjacent statistical time period of the third time period; create the third number of thread pools; wherein the third number of thread pools is used for loading in the first time period.
[0019] In the above scheme, the task determination module is also used to obtain a first influence coefficient that affects the number of thread pools to be created in the third time period, and a difference between the total number of requests and the second number; based on the first influence coefficient, the difference and the second number, determine the third number of thread pools to be created in the third time period.
[0020] In the above scheme, the task determination module is also used to obtain a second influence coefficient that affects the number of thread pools to be created in the second time period; based on the total number of requests counted in the second time period, the number of processed requests in the third time period is predicted to obtain a predicted total number; based on the difference and the predicted total number, the second influence coefficient is adjusted to obtain a first influence coefficient that affects the number of thread pools to be created in the third time period.
[0021] In the above scheme, the task processing module is also used to obtain the processing priority of each subtask when the number of the subtasks is the fourth number and the fourth number exceeds the quantity threshold; according to the processing priority of each subtask, the processing order of the fourth number of subtasks is arranged in descending order, and according to the descending order result, the fourth number of subtasks are divided into batches; according to the batch division result, the corresponding batches of subtasks are asynchronously processed in turn through the second processing thread of the subtask to obtain the subtask processing results corresponding to each subtask.
[0022] In the above scheme, the task processing module is also used to obtain influencing parameters for influencing the processing priority of each subtask, and the influencing parameters include at least one of the following: the execution timing of the subtask, the processing time of the subtask, and the number of the second processing threads corresponding to the subtask; based on the influencing parameters, the priority prediction model is called to perform prediction to obtain the processing priority of each subtask.
[0023] In the above solution, the task processing module is further used to determine that the execution timing of the subtask has arrived when the main task executes the process associated with the subtask.
[0024] In the above scheme, the task execution module is also used to, when the subtask is used to request a third-party application to execute the subtask, set the interface input parameter of the third-party application as the processing data of the subtask through the second processing thread; and receive the subtask processing result returned by the third-party application, wherein the subtask processing result is obtained by the third-party application executing the subtask based on the processing data of the subtask.
[0025] In the above solution, the task execution module is further used to determine the main task processing result of the main task based on the subtask processing result; and return the main task processing result to the triggering terminal of the first processing request.
[0026] In the above scheme, the task determination module is also used to determine the execution logic of the main task based on the service attributes of the target service; based on the execution logic, generate at least one subtask on which the main task depends; if there are multiple subtasks, determine the dependency relationship between the subtasks; based on the dependency relationship, determine the execution order of the subtasks, and according to the execution order, perform asynchronous processing on the corresponding subtasks through the second processing threads corresponding to each subtask to obtain the subtask processing results corresponding to each subtask.
[0027] In the above solution, the task determination module is further used to recycle the second processing thread to the first thread pool; or release the processing resources of the second processing thread.
[0028] An embodiment of the present application provides an electronic device, the electronic device comprising:
[0029] A memory for storing computer executable instructions;
[0030] The processor is used to implement the service processing method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.
[0031] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions for implementing the service processing method provided by the embodiment of the present application when executed by a processor.
[0032] An embodiment of the present application provides a computer program product, including computer executable instructions, which, when executed by a processor, implement the service processing method provided in the embodiment of the present application.
[0033] The embodiments of the present application have the following beneficial effects:
[0034] In response to a first processing request for a target service, a main task associated with the target service and at least one subtask associated with the main task are determined, and the tasks associated with the target service are determined as the main task and the subtask, so as to process the main task and the subtask respectively, thereby improving the processing efficiency of the target service. The first thread pool corresponding to the first processing request is loaded, and the main task is executed by the first processing thread in the first thread pool. In the process of executing the main task, in response to the preloading condition being met, the subtask and the second processing thread that executes the subtask are preloaded, and the subtask is asynchronously processed by the second processing thread to obtain the subtask processing result. In response to the execution time of the subtask, the subtask processing result is called, and the main task is continued to be executed based on the subtask processing result, that is, in the process of executing the main task, the subtask is preprocessed to obtain the subtask processing data, and then when the execution time of the subtask arrives, the subtask processing data can be directly used to execute the corresponding subtask, saving the time of executing the subtask to obtain the subtask processing data after the execution time of the subtask arrives, thereby improving the execution efficiency of the task. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a schematic diagram of the architecture of a service processing system 100 provided in an embodiment of the present application;
[0036] Figure 2 is a schematic diagram of the structure of an electronic device 500 provided in an embodiment of the present application;
[0037] Figure 3A It is a first flow chart of the service processing method provided in the embodiment of the present application;
[0038] Figure 3B It is a second flow chart of the service processing method provided in the embodiment of the present application;
[0039] Figure 3C It is a third flow chart of the service processing method provided in the embodiment of the present application;
[0040] Figure 3D It is a fourth flow chart of the service processing method provided in the embodiment of the present application;
[0041] Figure 3E It is a fifth flow chart of the service processing method provided in the embodiment of the present application;
[0042] Figure 4 It is an overall flow chart in actual application scenarios provided by the embodiments of the present application;
[0043] Figure 5 is a flowchart of a loading task loader provided in an embodiment of the present application;
[0044] Figure 6It is a schematic diagram of the management module performing tasks provided in an embodiment of the present application.
[0045] It should be pointed out that the above-mentioned "first" and "second" are only used to distinguish different solutions, and do not represent the degree of superiority or inferiority of the solutions or the priority in the implementation process. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0047] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0048] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0049] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0050] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0051] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.
[0052] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0053] 1) Asynchronous processing: A technique in computer science that can be used to process tasks in concurrent and distributed systems. Asynchronous processing allows other tasks to continue executing while waiting for one or more tasks to complete. The main advantage of asynchronous processing is improved system throughput and responsiveness because asynchronous processing reduces waiting time. Asynchronous processing usually involves submitting tasks to a queue or scheduler that can execute the tasks asynchronously.
[0054] 2) Thread pool: An advanced technology for managing threads, thread pool can improve the performance and responsiveness of applications. In multi-threaded applications, thread pools avoid the overhead of frequently creating and destroying threads by reusing already created threads. The basic idea of thread pool is to create a certain number of threads in advance and store the created threads in a pool. When a task needs to be executed, a thread can be obtained from the pool. After the task is executed, the thread is not destroyed, but returned to the pool to wait for the next use. This can reduce the overhead of thread creation and destruction, and also reduce the overhead of thread context switching.
[0055] After receiving a service processing request from a user, the related technology will serially execute multiple tasks associated with the processing request. In the process of executing multiple tasks, if the current task is not completed, the subsequent tasks can only wait, which results in a large amount of waiting time in the process of providing services to users, reducing the efficiency of providing services to users.
[0056] The embodiments of the present application provide a method, apparatus, device, computer-readable storage medium, and computer program product for service processing, which can improve the execution efficiency of tasks.
[0057] The following describes an exemplary application of the electronic device provided by the embodiment of the present application. The electronic device provided by the embodiment of the present application can be implemented as various types of terminals such as a laptop computer, a tablet computer, a desktop computer, a set-top box, a mobile device, a smart device, a vehicle terminal, an aircraft, etc., and can also be implemented as a server. The following describes an exemplary application when the device is implemented as a server.
[0058] See also Figure 1 , Figure 1 It is a schematic diagram of the architecture of the service processing system 100 provided in the embodiment of the present application. To implement an application supporting a service processing, the terminal is connected to the server 200 via the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.
[0059] The terminal 400 is used to display a service list to the user on the graphical interface 410, so that after the user clicks on a target service in the service list, a first processing request of the target service is sent to the service through the network 300.
[0060] The server 200 is used to, in response to a first processing request for a target service, determine a main task associated with the target service and at least one subtask associated with the main task, load a first thread pool corresponding to the first processing request, and execute the main task through a first processing thread in the first thread pool; in the process of executing the main task, in response to a preloading condition being met, preload a subtask and a second processing thread for executing the subtask, and perform asynchronous processing on the subtask through the second processing thread to obtain a subtask processing result; in response to the execution timing of the subtask arriving, call the subtask processing result, and continue to execute the main task based on the subtask processing result, and transmit the main task processing result to the terminal 400 through the network 300, so that the terminal 400 displays the main task processing result to the user.
[0061] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device 500 provided in an embodiment of the present application, Figure 2 The electronic device 500 shown includes: at least one processor 510, a memory 550, at least one network interface 520 and a user interface 530. The various components in the electronic device 500 are coupled together via a bus system 540. It is understood that the bus system 540 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 540 is not described in detail. Figure 2 Various buses are labeled as bus system 540 .
[0062] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0063] The user interface 530 includes one or more output devices 531 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0064] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 550 may optionally include one or more storage devices that are physically remote from the processor 510.
[0065] The memory 550 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.
[0066] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0067] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0068] A network communication module 552, used to reach other electronic devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB), etc.;
[0069] a presentation module 553 for enabling presentation of information via one or more output devices 531 (e.g., display screen, speaker, etc.) associated with the user interface 530 (e.g., a user interface for operating peripherals and displaying content and information);
[0070] The input processing module 554 is used to detect one or more user inputs or interactions from one of the one or more input devices 532 and translate the detected inputs or interactions.
[0071] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 2The service processing device 555 stored in the memory 550 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: a task determination module 5551, a thread pool loading module 5552, a task processing module 5553 and a task execution module 5554. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0072] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the service processing method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application specific integrated circuits (Application Specific Integrated Circuit, ASIC), digital signal processors (Digital Signal Processor, DSP), programmable logic devices (Programmable Logic Device, PLD), complex programmable logic devices (Complex Programmable Logic Device, CPLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other electronic components.
[0073] The following describes the service processing method provided by the embodiment of the present application. As mentioned above, the service processing electronic device implementing the embodiment of the present application can be a terminal, a server, or a combination of the two. Therefore, the execution subject of each step will not be repeatedly described below.
[0074] See also Figure 3A , Figure 3A This is a first flow chart of the service processing method provided in the embodiment of the present application, which will be combined with Figure 3A Steps 101 to 104 are shown for explanation.
[0075] In step 101 , in response to a first processing request for a target service, a main task associated with the target service and at least one subtask associated with the main task are determined.
[0076] As an example, the target service may be a service that the platform can provide to users, such as loan services, after-sales services, shopping services, etc., and the first processing request may be a processing request sent by the user to the platform, requiring the platform to provide the target service.
[0077] As an example, since a main task associated with providing a service may include multiple subtasks, for example, the main task of the platform providing loan services to users may include the following subtasks: user identity authentication subtask, user credit information query subtask, user personal information query subtask, user compliance assessment subtask, etc.
[0078] As an example, since the execution of the main task and subtasks associated with the target service requires the use of threads maintained in the thread pool, the process of determining the number of thread pools is described below.
[0079] In some embodiments, before executing step 101, the following steps may be performed: Figure 3B Steps 101A to 101C are shown.
[0080] In step 101A, a second number of thread pools created in a second time period and a total number of processing requests counted in the second time period are obtained.
[0081] As an example, in the embodiment of the present application, the first time period is the time period for currently processing the first processing request, the third time period is the previous time period adjacent to the first time period, and the second time period is the previous time period adjacent to the third time period. The length of each time period can be a preset fixed value, or can be the length of the time period dynamically adjusted according to the actual time corresponding to the time period.
[0082] As an example, if the second time period is the first time period after the application providing the service is restarted, or the second time period is the first time period after the application providing the service is first released, the second number of thread pools created in the second time period may be a preset fixed value. If the second time period is neither of the above two situations, the second number of thread pools created in the second time period is determined based on the number of thread pools in the previous time period adjacent to the second time period and the number of requests in the previous time period adjacent to the second time period.
[0083] As an example, the total number of requests processed within the second time period may be counted by obtaining the start time (startTime) of the second time period, obtaining the end time (endTime) of the second time period, and counting the total number of requests within the (startTime, endTime) time range through an atomic operation (incre) in a remote dictionary service (redis) distributed lock.
[0084] In step 101B, based on the second number and the total number of requests, determine the third number of thread pools to be created in the third time period; wherein the third time period is the previous adjacent statistical time period of the first time period in which the first processing request is located, and the second time period is the previous adjacent statistical time period of the third time period.
[0085] In some embodiments, determining the third number of thread pools to be created in the third time period based on the second number and the total number of requests in step 101B can be performed as follows: Figure 3C Steps 101B1 to 101B2 are implemented as shown.
[0086] In step 101B1, a first influence coefficient affecting the number of thread pools to be created in a third time period and a difference between the total number of requests and the second number are obtained.
[0087] As an example, the first influence coefficient may be a parameter for controlling the number of thread pools to be created. The larger the first influence coefficient, the larger the amplitude of adjusting the number of thread pools to be created. At the same time, the difference between the total number of requests and the second number is determined, and the difference represents the difference between the number of existing thread pools and the number of requests. The larger the difference, the larger the amplitude of adjusting the number of thread pools.
[0088] In some embodiments, obtaining the first influence coefficient that affects the number of thread pools to be created in the third time period in step 101B1 can be implemented by the following technical solution: obtaining the second influence coefficient that affects the number of thread pools to be created in the second time period; predicting the number of processed requests in the third time period based on the total number of requests counted in the second time period to obtain a predicted total number; adjusting the second influence coefficient based on the difference and the predicted total number to obtain the first influence coefficient that affects the number of thread pools to be created in the third time period.
[0089] As an example, if the second time period is the first time period after the application providing the service is restarted, or the second time period is the first time period after the application providing the service is first released, the second impact coefficient may be a preset fixed value. If the second time period is neither of the above two situations, the second impact coefficient is based on the impact coefficient of the previous time period adjacent to the second time period, and based on the total number of requests counted in the previous time period adjacent to the second time period, the number of processed requests in the second time period is predicted to obtain the predicted total number, and then based on the difference between the number of thread pools in the previous time period adjacent to the second time period and the number of requests based on the previous time period adjacent to the second time period and the predicted total number, the impact parameter of the previous time period adjacent to the second time period is adjusted to obtain the second impact coefficient.
[0090] As an example, if the predicted total number of processed requests in the third time period is 20, the difference between the second number and the total number of requests in the second time period is 5, and the second number is 10, it can be determined that the difference between the second number and the predicted total number is 10, and the difference between the second number and the total number of requests in the second time period is 5, then the first impact coefficient can be adjusted to 2 (the result obtained by dividing the difference between the second number and the predicted total number by the difference between the second number and the total number of requests in the second time period).
[0091] In step 101B2, based on the first influence coefficient, the difference, and the second number, a third number of thread pools to be created in a third time period is determined.
[0092] As an example, when the difference between the total number of requests and the second number is a positive value, refer to the following formula:
[0093] A=threadCount+incre*rate (1)
[0094] In formula (1), the third number of thread pools to be created in the third time period of A is, threadCount is the second number, incre is the difference between the total number of requests and the second number, and rate is the first impact coefficient. Incre can be obtained according to the following formula (2).
[0095] incre=m–threadCount (2)
[0096] In formula (2), m is the total number of requests, and threadCount is the second number.
[0097] When the difference between the total requested quantity and the second quantity is a negative value, refer to the following formula:
[0098] A=threadCount–decre*rate (3)
[0099] In formula (3), A is the third number of thread pools to be created in the third time period, threadCount is the second number, decre is the difference between the total number of requests and the second number, and rate is the first impact coefficient. Wherein, decre can be obtained according to the following formula (4).
[0100] decre=threadCount–m (4)
[0101] In formula (4), m is the total number of requests, and threadCount is the second number.
[0102] In step 101C, a third number of thread pools are created; wherein the third number of thread pools are used for loading in the first time period.
[0103] As an example, the methods for creating a thread pool mainly include the static methods provided by the ThreadPoolExecutor class and the Executors class. The following introduces two methods for creating a thread pool.
[0104] Create a thread pool through the ThreadPoolExecutor class:
[0105] The ThreadPoolExecutor class is the core class for creating thread pools in Java. The ThreadPoolExecutor class provides a flexible construction method to create a thread pool. The construction method parameters include the number of core threads, the maximum number of threads, the thread survival time, the time unit, the work queue, the thread factory, and the rejection strategy. Through this class, you can create a customized thread pool to meet specific needs.
[0106] Create a thread pool through the static method provided by the Executors class:
[0107] The Executors class provides several ready-made thread pool implementations, including:
[0108] FixedThreadPool: Creates a thread pool of fixed size. When all threads are executing tasks, new tasks will be put into the queue and wait until a thread is available.
[0109] CachedThreadPool: Creates a thread pool that creates new threads as needed, but reuses previously constructed threads when they are available.
[0110] SingleThreadExecutor: Creates a single-threaded thread pool. All tasks are executed sequentially, and there are no parallel tasks.
[0111] ScheduledThreadPool: A thread pool used to delay or periodically execute tasks.
[0112] In step 102, a first thread pool corresponding to a first processing request is loaded, and a main task is executed by a first processing thread in the first thread pool.
[0113] In some embodiments, the first thread pool corresponding to the first processing request in step 102 can be loaded by Figure 3D Steps 1021 to 1022 are implemented as shown.
[0114] In step 1021, a first time period in which the first processing request is located is determined, and a second processing request triggered for a target service within the first time period is obtained.
[0115] As an example, the second processing request may be a processing request initiated again by the current user to the target service, or may be a processing request initiated by other users to the target service, and there may be multiple second processing requests.
[0116] As an example, the target service is loan service A, the first time period is a time period of 10 minutes, and the number of second processing requests can be the number of second processing requests received by loan service A within the 10 minutes corresponding to the first time period. If the first processing request is a request issued by user A, the second processing request can be a processing request issued by user A other than the first processing request, or can be a processing request for loan service A issued by user B, user C, and other users.
[0117] In step 1022, a first number of thread pools are loaded, wherein the thread pools include a first thread pool corresponding to the first processing request and a second thread pool corresponding to the second processing request, and the first number is the total number of requests of the first processing request and the second processing request triggered within the first time period.
[0118] As an example, the number of first thread pools corresponding to the first processing request is 1, and the number of second thread pools corresponding to the second processing request is 10, then 11 pre-created thread pools are loaded.
[0119] In step 103, during the execution of the main task, in response to the preloading condition being met, the subtask is preloaded and the second processing thread of the subtask is executed, and the subtask is asynchronously processed by the second processing thread to obtain the subtask processing result.
[0120] In some embodiments, before executing the preloading subtask in step 103, the following technical solutions may also be executed: in response to the time interval between the execution time of the main task and the execution time of the subtask being greater than the first interval threshold and less than the second interval threshold, determining that the preloading condition is met; or, in response to the historical loading rate of the subtask in the historical target service being higher than the loading rate threshold, determining that the preloading condition is met; in response to the network environment in which the processor processing the target service is located being compatible with the performance of the processor, determining that the preloading condition is met.
[0121] As an example, if the first interval threshold is 1s and the second interval threshold is 3s, the preloading condition can be determined to be satisfied between 1s and 3s before the subtask execution timing arrives. In this way, it is possible to avoid insufficient time to complete the preloading of the subtask when the subtask execution timing arrives, and also avoid completing the preloading of the subtask too early, wasting storage space.
[0122] As an example, if the historical loading rate of a subtask is higher than the loading rate threshold, it indicates that the subtask will be frequently loaded, so the subtask can be preloaded.
[0123] As an example, since the network environment and processor performance of the processor of the target service often affect the preloading speed and the subtask processing result of calling the preloaded subtask when the timing of subtask execution arrives, the preloading condition is determined to be met only when the network environment and processor performance meet the standards, avoiding the failure to call the subtask processing result of the subtask when the timing of subtask execution arrives.
[0124] In some embodiments, the preloading subtasks in step 103 can be implemented by the following technical solution: determining the number of tasks configured in the thread pool; determining the number of preloaded tasks based on the first number and the number of tasks, and preloading the tasks of the preloaded number of tasks, wherein the preloaded tasks include subtasks.
[0125] As an example, the number of tasks may be the number of tasks corresponding to the target service, that is, the number of tasks is the number of tasks that need to be performed to provide the target service.
[0126] As an example, if the first number of the thread pool is 10 and the number of tasks is 5, the number of preloaded tasks is 50.
[0127] Through the above method, multiple tasks can be preloaded through multiple thread pools, thereby improving the efficiency of preloading tasks.
[0128] In some embodiments, the step 103 of asynchronously processing the subtask by the second processing thread to obtain the subtask processing data can be performed as follows: Figure 3E Steps 1031 to 1033 are implemented as shown.
[0129] In step 1031 , when the number of subtasks is the fourth number and the fourth number exceeds the number threshold, the processing priority of each subtask is obtained.
[0130] In some embodiments, obtaining the processing priority of each subtask in step 1023 can be achieved through the following technical solution: obtaining influencing parameters used to influence the processing priority of each subtask, the influencing parameters including at least one of the following: the execution timing of the subtask, the processing time of the subtask, and the number of second processing threads corresponding to the subtask; based on the influencing parameters, calling the priority prediction model for prediction to obtain the processing priority of each subtask.
[0131] As an example, in the process of processing subtasks, there may be a situation where multiple subtasks need to be processed simultaneously. In this case, the order of processing the subtasks may be determined according to the priority of each subtask.
[0132] As an example, factors affecting the priority of each subtask may include the execution timing of the subtask, the processing time of the subtask, and the number of second processing threads corresponding to the subtask. For example, if the execution timing of subtask A is earlier than the execution timing of subtask B, then the priority of subtask A is higher than that of subtask B. For another example, if the processing time of subtask C is shorter than that of subtask D, then the priority of subtask C is higher than that of subtask D. For another example, if the number of first threads corresponding to subtask E is greater than that of subtask F, then the priority of subtask E is higher than that of subtask F.
[0133] As an example, the influencing parameters and priorities may be used as labels to label the historical subtasks to obtain labeled training samples, and then a priority prediction model may be trained based on the labeled training samples.
[0134] As an example, the specific model training process can be to first input the labeled training samples into the priority prediction model to be trained, and obtain the predicted priority of each subtask output by the priority prediction model to be trained. Then, the parameters of the priority prediction model to be trained are updated in reverse with the constraint of minimizing the difference between the predicted priority and the labeled priority calculated by the loss function.
[0135] As an example, the loss function of the training priority prediction model can be mean square error loss, mean absolute error loss, cross entropy loss, etc. The specific loss function can be selected according to the actual situation and is not specifically limited here.
[0136] Through the above method, subtasks with high priority can be processed first, thereby improving the processing efficiency of subtasks.
[0137] In step 1032, the processing order of the fourth number of subtasks is arranged in descending order according to the processing priority of each subtask, and the fourth number of subtasks are divided into batches according to the result of the descending order.
[0138] For example, the priority of subtask A is P1, the priority of subtask B is P3, the priority of subtask C is P2, and the priority of subtask D is P4. The descending order of subtask A, subtask B, subtask C, and subtask D is subtask A, subtask C, subtask B, and subtask D. Afterwards, if each subtask is divided into two batches, subtask A and subtask C can be divided into the first batch, and subtask B and subtask D can be divided into the second batch.
[0139] In step 1033, according to the batch division result, the subtasks of the corresponding batch are asynchronously processed in sequence by the second processing thread of the subtask to obtain the subtask processing result corresponding to each subtask.
[0140] As an example, if the subtasks of the first batch, the subtasks of the second batch, and the subtasks of the third batch are obtained, the subtasks included in the first batch can be processed in parallel by the second processing thread first, then the subtasks included in the second batch, and finally the subtasks included in the third batch. Finally, the subtask processing results of the subtasks included in the first batch, the second batch, and the third batch are obtained.
[0141] In some embodiments, the determination of at least one subtask associated with the main task in the above step 101 can be implemented through the following technical solutions: based on the service attributes of the target service, determine the execution logic of the main task; based on the execution logic, generate at least one subtask on which the main task depends; in step 103, asynchronous processing of the subtasks by the second processing thread to obtain the subtask processing results can be implemented through the following technical solutions: if there are multiple subtasks, determine the dependency relationship between the subtasks; based on the dependency relationship, determine the execution order of the subtasks, and according to the execution order, perform asynchronous processing on the corresponding subtasks through the second processing threads corresponding to the subtasks to obtain the subtask processing results corresponding to the subtasks.
[0142] As an example, if the service attribute of the target service is a loan service, the execution logic of the main task of the target service is to first authenticate the user's identity, then obtain the user's credit record, then determine the user's loan amount based on the credit record, and finally provide the user with a loan service corresponding to the loan amount.
[0143] Continuing with the above example, if the service attribute of the target service is a loan service, at least the user's information query subtask, the user's credit record query subtask, and the user's loan amount assessment subtask can be generated. In the execution of the credit record query subtask, the user's identity needs to be determined first. Therefore, before executing the credit record query subtask, the information query subtask needs to be executed first. Therefore, there is a dependency relationship between the information query subtask and the credit record query subtask. Therefore, in the actual execution of the loan service, the second processing thread will first execute the information query subtask and then execute the credit record query subtask.
[0144] In some embodiments, after executing step 103 in which the second processing thread performs asynchronous processing on the subtask and obtains the subtask processing result, the following technical solution can also be executed: recycling the second processing thread to the first thread pool; or releasing the processing resources of the second processing thread.
[0145] As an example, since the task of the second processing thread is to preload subtasks, after the subtask processing is completed and the subtask processing result is obtained, the second processing thread can be recycled to the first thread pool to execute subsequent main tasks, or the second thread pool can be directly destroyed to release the computing resources of the second processing thread.
[0146] Through the above method, the occupation of computing resources can be reduced.
[0147] In step 104, in response to the execution timing of the subtask arriving, the subtask processing result is called, and the main task is continued to be executed based on the subtask processing result.
[0148] In some embodiments, before executing the calling subtask processing result in step 103 and continuing to execute the main task based on the subtask processing result, the following technical solution can also be executed: when the main task executes the process associated with the subtask, determine that the execution time of the subtask has arrived.
[0149] As an example, the process of the main task includes process node A, process node B and process node C, where the execution timing of subtask D is process node A, and the execution timing of subtask E is process node C. When the main task is executed to process node A, it is determined that the execution timing of subtask D has arrived, and the subtask of subtask D is called to process data to execute subtask D. When the main task is executed to process node C, it is determined that the execution timing of subtask E has arrived, and the subtask of subtask E is called to process data to execute subtask E.
[0150] Through the above method, each subtask can be executed in an orderly manner, thereby improving the efficiency of executing the main task and the subtasks.
[0151] In some embodiments, the asynchronous processing of the subtask by the second processing thread in step 104 to obtain the subtask processing result can be achieved through the following technical solution: when the subtask is used to request a third-party application to execute the subtask, the interface input parameter of the third-party application is set as the processing data of the subtask through the second processing thread; the subtask processing result returned by the third-party application is received, and the subtask processing result is obtained by the third-party application executing the subtask based on the processing data of the subtask.
[0152] As an example, in the process of executing subtasks, some subtasks may need to call third-party applications to be executed. For example, the subtask of querying the credit record of user A needs to call the data in the third-party database. At this time, the address of the credit record of user A in the third-party database can be used as the subtask processing data. Then, the interface input parameter of the third-party database is set as the subtask processing data. After that, after the main task queries the credit record of user A from the third-party database based on the interface input parameter, the obtained credit record of user A is used as the subtask processing result, and the third-party database returns the subtask processing result.
[0153] As an example, when there are multiple subtasks, a third-party application may encapsulate the multiple subtask export results and return them.
[0154] In some embodiments, continuing to execute the main task based on the subtask processing result in step 104 can be achieved through the following technical solutions: determining the main task processing result of the main task based on the subtask processing result; returning the main task processing result to the triggering terminal of the first processing request.
[0155] As an example, when the main task is loan service, the subtasks include the user's identity authentication subtask, the user's credit information query subtask, and the user's personal information query subtask. The subtask processing results of each subtask are: the user's identity authentication passes, the user's credit information meets the loan conditions, and the user's personal information query meets the loan conditions. It can be determined that the user can receive the loan service. Therefore, the user can receive the loan service as the main task processing result and returned to the terminal used by the user.
[0156] Through the above method, the processing results of multiple subtasks can be combined, thereby improving the accuracy of the main task processing result.
[0157] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.
[0158] See also Figure 4 , Figure 4 It is an overall flow chart of the actual application scenario provided by the embodiment of the present application.
[0159] In step 401, the application starts.
[0160] When the application is released for production or restarted, the thread pool loader and task loader are loaded at the same time as the runtime managed objects (springbean).
[0161] In step 402, the thread pool loader is loaded.
[0162] First, the configuration information is read to obtain the number of thread pool configurations (threadCount) as 20, and the first influence coefficient (rate) as 50%.
[0163] Secondly, create a thread pool with a number (threadCount) of 20 and read the configuration information to obtain the statistical time interval (timeInternal) of 1s.
[0164] Afterwards, the total number of requests m within the time range of timeInternal = 1s is obtained (when the application is in the release or restart state, the request cannot be obtained at this time, so m = 0 at this time; when the application is in the release completion or restart completion state, the request can be obtained at this time. When the request enters for the first time, the start time of the count (startTime = System.currentTimeMillis) is obtained, and the end time of the count (endTime = startTime + timeInternal) is obtained. The total number of requests within the time range of (startTime, endTime) is counted through the atomic operation (incre) in the distributed lock of the remote dictionary service (redis)).
[0165] If (m=30)>(threadCount=20), obtain the difference incre=m-threadCount=10, and the number of threads initialized within the next timeInternal=1s time range=threadCount+incre*rate=20+5=25.
[0166] If (m=10)<(threadCount=20), obtain the difference decre=threadCount-m=10, and the number of threads initialized within the next timeInternal=1s time range=threadCount-incre*rate=20-5=15.
[0167] In step 403, the task loader is loaded.
[0168] For details, please refer to Figure 5 , Figure 5 This is a flowchart of the loading task loader provided in an embodiment of the present application.
[0169] In step 501, the time-consuming subtasks are pre-processed.
[0170] When preloading tasks, time-consuming subtasks (such as MySQL database query, JSON string conversion, and permission verification) will be pre-processed in the task.
[0171] In step 502, the number of tasks is obtained.
[0172] Read the configuration information and obtain the number of tasks corresponding to each service (taskCount=3).
[0173] In step 503, the number of preload tasks is determined.
[0174] The number of preloaded tasks = the number of thread pools (threadCount=20)*the number of tasks (taskCount=3)=60.
[0175] In step 404, the third-party interface in the task is replaced.
[0176] When a request comes, the input parameters of the request tripartite interface in the preload task are replaced by the subtask processing data of each preloaded subtask.
[0177] In step 405, the task is executed.
[0178] Execute tasks asynchronously through threads in the thread pool.
[0179] In step 406, the result is returned to the data source interface.
[0180] Then, the results returned by multiple third-party interfaces are obtained, combined and packaged, and returned to the data source interface. After that, the total number of acquisition requests in the above normal end process is cleared.
[0181] Combine the following Figure 6 Describe the tasks performed by the management module in this application. Figure 6 It is a schematic diagram of the management module performing tasks provided in an embodiment of the present application.
[0182] exist Figure 6 In the process, the management module obtains the service requested by the user through the service code, and then loads the thread pool loader to obtain the number of thread pools and the number of core threads in the thread pool. Then, by counting the number of requests within the time interval and the preset first impact coefficient, the number of thread pools in the thread loader is adjusted, and then the task loader is loaded. Through the number of thread pools and the number of tasks corresponding to the service, the number of preloaded tasks is determined to obtain the execution result.
[0183] In the embodiment provided by the present application, by introducing thread pool preloading, the thread pool can be loaded in advance, and there is no need to create a thread pool in a time-consuming manner when a request comes. According to the increase ratio, the optimal number of thread pools is created. And by introducing a task loader, the time-consuming logic can be processed in advance, thereby improving the execution efficiency of the business interface.
[0184] It is understandable that in the embodiments of the present application, related data such as user information is involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards.
[0185] The following continues to describe the exemplary structure of the service processing device 555 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2As shown, the software modules stored in the service processing device 555 of the memory 550 may include:
[0186] The task determination module 5551 is used to determine, in response to a first processing request for a target service, a main task associated with the target service and at least one subtask associated with the main task;
[0187] A thread pool loading module 5552 is used to load a first thread pool corresponding to the first processing request, and execute the main task through a first processing thread in the first thread pool;
[0188] The task processing module 5553 is used for, in the process of executing the main task, in response to the preloading condition being satisfied, preloading the subtask and executing the second processing thread of the subtask, and performing asynchronous processing on the subtask through the second processing thread to obtain the subtask processing result;
[0189] The task execution module 5554 is used to call the subtask processing result in response to the execution timing of the subtask arriving, and continue to execute the main task based on the subtask processing result.
[0190] In some embodiments, the thread pool loading module 5552 is also used to determine a first time period in which the first processing request is located, and obtain a second processing request triggered for the target service within the first time period; load a first number of thread pools, wherein the thread pool includes a first thread pool corresponding to the first processing request and a second thread pool corresponding to the second processing request, and the first number is the total number of requests for the first processing request and the second processing request triggered within the first time period.
[0191] In some embodiments, the task processing module 5553 is also used to determine the number of tasks configured for the thread pool; based on the target number and the number of tasks, determine the number of preloaded tasks, and preload the number of preloaded tasks, wherein the preloaded tasks include the subtasks.
[0192] In the above scheme, the task processing module 5553 is also used to determine that the preloading condition is met in response to the time interval between the execution time of the main task and the execution time of the subtask being greater than the first interval threshold and less than the second interval threshold; or, in response to the historical loading rate of the subtask in the historical target service being higher than the loading rate threshold, determine that the preloading condition is met; in response to the network environment in which the processor processing the target service is located being compatible with the performance of the processor, determine that the preloading condition is met.
[0193] In some embodiments, the task determination module 5551 is also used to obtain a second number of thread pools created in a second time period, and a total number of processing requests counted in the second time period; based on the second number and the total number of requests, determine a third number of thread pools to be created in a third time period; wherein the third time period is the previous adjacent statistical time period of the first time period in which the first processing request is located, and the second time period is the previous adjacent statistical time period of the third time period; create the third number of thread pools; wherein the third number of thread pools is used for loading in the first time period.
[0194] In some embodiments, the task determination module 5551 is also used to obtain a first influence coefficient that affects the number of thread pools to be created in the third time period, and a difference between the total number of requests and the second number; based on the first influence coefficient, the difference and the second number, determine the third number of thread pools to be created in the third time period.
[0195] In some embodiments, the task determination module 5551 is also used to obtain a second influence coefficient that affects the number of thread pools to be created in the second time period; based on the total number of requests counted in the second time period, the number of processed requests in the third time period is predicted to obtain a predicted total number; based on the difference and the predicted total number, the second influence coefficient is adjusted to obtain a first influence coefficient that affects the number of thread pools to be created in the third time period.
[0196] In some embodiments, the task processing module 5553 is also used to obtain the processing priority of each subtask when the number of the subtasks is a fourth number and the fourth number exceeds a quantity threshold; arrange the processing order of the fourth number of subtasks in descending order according to the processing priority of each subtask, and divide the fourth number of subtasks into batches according to the results of the descending order; and according to the batch division results, asynchronously process the corresponding batches of subtasks in turn through the second processing thread of the subtask to obtain the subtask processing results corresponding to each subtask.
[0197] In some embodiments, the task processing module 5552 is also used to obtain influencing parameters for influencing the processing priority of each of the subtasks, and the influencing parameters include at least one of the following: the execution timing of the subtask, the processing time of the subtask, and the number of the second processing threads corresponding to the subtask; based on the influencing parameters, the priority prediction model is called to perform prediction to obtain the processing priority of each of the subtasks.
[0198] In some embodiments, the task processing module 5553 is further used to determine that the execution timing of the subtask has arrived when the main task executes the process associated with the subtask.
[0199] In some embodiments, the task execution module 5554 is also used to, when the subtask is used to request a third-party application to execute the subtask, set the interface input parameter of the third-party application as the processing data of the subtask through the second processing thread; and receive the subtask processing result returned by the third-party application, wherein the subtask processing result is obtained by the third-party application executing the subtask based on the processing data of the subtask.
[0200] In some embodiments, the task execution module 5553 is further used to determine the main task processing result of the main task based on the subtask processing result; and return the main task processing result to the triggering terminal of the first processing request.
[0201] In some embodiments, the task determination module 5551 is also used to determine the execution logic of the main task based on the service attributes of the target service; based on the execution logic, generate at least one subtask on which the main task depends; if there are multiple subtasks, determine the dependency relationship between the subtasks; based on the dependency relationship, determine the execution order of the subtasks, and according to the execution order, perform asynchronous processing on the corresponding subtasks through the second processing threads corresponding to each subtask, to obtain the subtask processing results corresponding to each subtask.
[0202] In some embodiments, the task determination module 5551 is further used to recycle the second processing thread to the first thread pool; or, release the processing resources of the second processing thread.
[0203] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer executable instruction from the computer-readable storage medium, and the processor executes the computer executable instruction, so that the electronic device performs the service processing method described in the embodiment of the present application.
[0204] The present application embodiment provides a computer-readable storage medium in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the processor will execute the service processing method provided by the present application embodiment, for example, Figure 3A Shows the method of service processing.
[0205] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
[0206] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0207] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0208] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.
[0209] In summary, through the embodiments of the present application, the following beneficial effects can be achieved:
[0210] In response to a first processing request for a target service, a main task and at least one subtask associated with the target service are determined, and the tasks associated with the target service are determined as the main task and the subtask, so that the main task and the subtask are processed respectively, thereby improving the processing efficiency of the target service. In the process of executing the main task, the subtask is preloaded, and the subtask is asynchronously processed by the second processing thread corresponding to the subtask to obtain subtask processing data, and in response to the execution timing of the subtask, the subtask processing data is called to execute the subtask. In the process of executing the main task, the subtask is preprocessed to obtain subtask processing data, and then when the execution timing of the subtask arrives, the subtask processing data can be directly used to execute the corresponding subtask, saving the time of executing the subtask to obtain the subtask processing data after the execution timing of the subtask arrives, thereby improving the execution efficiency of the task.
[0211] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A service processing method, characterized in that: The method comprises: In response to a first processing request for a target service, determining a main task associated with the target service and at least one subtask of the main task; Loading a first thread pool corresponding to the first processing request, and executing the main task through a first processing thread in the first thread pool; In the process of executing the main task, in response to the preloading condition being satisfied, preloading the subtask and the second processing thread executing the subtask, and performing asynchronous processing on the subtask through the second processing thread to obtain a subtask processing result; In response to the execution timing of the subtask arriving, the subtask processing result is called, and the main task is continued to be executed based on the subtask processing result.
2. The method according to claim 1, characterized in that The loading of the first thread pool corresponding to the first processing request includes: Determine a first time period in which the first processing request is located, and obtain a second processing request triggered for the target service within the first time period; Load a first number of thread pools, wherein the thread pools include a first thread pool corresponding to the first processing request and a second thread pool corresponding to the second processing request, and the first number is the total number of requests of the first processing request and the second processing request triggered within the first time period.
3. The method according to claim 1, characterized in that The preloading of the subtask includes: Determine the number of tasks configured in the thread pool; Based on the first number and the number of tasks, a preloaded task number is determined, and tasks of the preloaded task number are preloaded, wherein the preloaded tasks include the subtasks.
4. The method according to claim 1, characterized in that Before determining, in response to the first processing request for the target service, a main task associated with the target service and at least one subtask associated with the main task, the method further includes: Obtain a second number of thread pools created within a second time period and a total number of requests processed within the second time period; Based on the second number and the total number of requests, determine a third number of thread pools to be created in a third time period; wherein the third time period is a previous adjacent statistical time period of the first time period in which the first processing request is located, and the second time period is a previous adjacent statistical time period of the third time period; Create the third number of thread pools; wherein the third number of thread pools are used for loading within the first time period.
5. The method according to claim 4, characterized in that The determining, based on the second number and the total number of requests, a third number of thread pools to be created in the third time period includes: Obtain a first influence coefficient affecting the number of thread pools to be created in the third time period, and a difference between the total number of requests and the second number; Based on the first influence coefficient, the difference and the second number, a third number of thread pools to be created in the third time period is determined.
6. The method according to claim 5, characterized in that The obtaining of a first influence coefficient affecting the number of thread pools to be created within the third time period includes: Obtain a second influence coefficient that affects the number of thread pools to be created within the second time period; Based on the total number of requests counted in the second time period, predict the number of processed requests in the third time period to obtain a predicted total number; Based on the difference, the second number and the predicted total number, the second influence coefficient is adjusted to obtain a first influence coefficient that affects the number of thread pools to be created in the third time period.
7. The method according to claim 1, characterized in that The performing asynchronous processing on the subtask by the second processing thread to obtain the subtask processing result includes: When the number of the subtasks is a fourth number and the fourth number exceeds a number threshold, obtaining a processing priority of each of the subtasks; Arrange the processing order of the fourth number of subtasks in descending order according to the processing priority of each subtask, and divide the fourth number of subtasks into batches according to the result of the descending order; According to the batch division result, the subtasks of the corresponding batch are asynchronously processed in turn through the second processing thread of the subtask to obtain the subtask processing results corresponding to each subtask.
8. The method according to claim 7, characterized in that The obtaining of the processing priority of each of the subtasks includes: Acquire an influencing parameter for influencing the processing priority of each of the subtasks, the influencing parameter comprising at least one of the following: an execution timing of the subtask, a processing duration of the subtask, and a number of the second processing threads corresponding to the subtask; Based on the influencing parameters, a priority prediction model is called to perform prediction to obtain the processing priority of each of the subtasks.
9. The method according to claim 1, characterized in that: The determining at least one subtask associated with the main task includes: Determining the execution logic of the main task based on the service attribute of the target service; Based on the execution logic, generating at least one subtask on which the main task depends; The performing asynchronous processing on the subtask by the second processing thread to obtain the subtask processing result includes: If there are multiple subtasks, determine the dependencies between the subtasks; Based on the dependency relationship, the execution order of each subtask is determined, and according to the execution order, the corresponding subtask is asynchronously processed through the second processing thread corresponding to each subtask to obtain the subtask processing results corresponding to each subtask.
10. A service processing device, characterized in that: The device comprises: A task determination module, configured to determine, in response to a first processing request for a target service, a main task associated with the target service and at least one subtask associated with the main task; A thread pool loading module, used for loading a first thread pool corresponding to the first processing request, and executing the main task through a first processing thread in the first thread pool; A task processing module, configured to preload the subtask and execute the second processing thread of the subtask in response to the preloading condition being satisfied during the execution of the main task, and perform asynchronous processing on the subtask through the second processing thread to obtain a subtask processing result; The task execution module is used to call the subtask processing result in response to the execution timing of the subtask arriving, and continue to execute the main task based on the subtask processing result.
