Task processing method and device, server and storage medium
Patent Information
- Application Number
- CN202110914677.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-10
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2041-08-10
AI Technical Summary
[0003]处理任务的过程需要耗费处理资源,而如何提高处理资源的利用率成为亟待解决的问题
Smart Images

Figure CN115941796B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a task processing method, apparatus, server, and storage medium. Background Technology
[0002] In the field of internet technology, tasks can be divided into online tasks and offline tasks. Online tasks are those with high real-time requirements, while offline tasks are those with lower real-time requirements. Related technologies typically use online servers to process online tasks and offline servers to process offline tasks.
[0003] Processing tasks requires processing resources, and how to improve the utilization rate of these resources has become an urgent problem to be solved. Summary of the Invention
[0004] This application provides a task processing method, apparatus, server, and storage medium, which can improve the utilization rate of processing resources. The technical solution is as follows:
[0005] On the one hand, a task processing method is provided, the method comprising:
[0006] A first target time period is determined, during which the resource usage of online tasks is less than a first threshold.
[0007] Send a task scheduling request carrying the first target time period to the scheduling server. The scheduling server is used to receive the task scheduling request and return an offline task during the first target time period.
[0008] During the first target time period, the offline task sent by the scheduling server is received, and the online task and the offline task are executed.
[0009] Optionally, stopping the execution of the offline task when the total resource usage exceeds a second threshold includes:
[0010] If the total resource usage exceeds the second threshold, at least one offline task is stopped based on the resource usage of each offline task. The resource usage of the stopped offline task is greater than the resource usage of the remaining offline tasks that are not stopped, so that the total resource usage of the online task and the remaining offline task does not exceed the second threshold.
[0011] On the other hand, a task processing method is provided, the method comprising:
[0012] Receive a task scheduling request sent by a first online server, the task scheduling request carrying a first target time period, during which the resource usage of online tasks of the first online server is less than a first threshold;
[0013] During the first target time period, an offline task is sent to the first online server. The first online server is used to receive the offline task and execute the online task and the offline task during the first target time period.
[0014] Optionally, the method further includes:
[0015] Send a third offline task to the offline server, wherein the maximum allowed delay of the third offline task is no greater than the first delay.
[0016] On the other hand, a task processing system is provided, the task processing system including a first online server and a scheduling server;
[0017] The first online server is used to determine a first target time period, during which the resource usage of online tasks is less than a first threshold.
[0018] The first online server is also used to send a task scheduling request carrying the first target time period to the scheduling server;
[0019] The scheduling server is used to receive the task scheduling request and send an offline task to the first online server during the first target time period;
[0020] The first online server is further configured to receive the offline task sent by the scheduling server during the first target time period, and execute the online task and the offline task.
[0021] Optionally, the system further includes an offline server;
[0022] The scheduling server is also used to send a third offline task to the offline server, wherein the maximum allowable delay of the third offline task is not greater than the first delay;
[0023] The offline server is used to receive the third offline task and execute the third offline task.
[0024] On the other hand, a task processing apparatus is provided, the apparatus comprising:
[0025] The time period determination module is used to determine a first target time period, in which the resource usage of online tasks is less than a first threshold.
[0026] The scheduling request sending module is used to send a task scheduling request carrying the first target time period to the scheduling server. The scheduling server is used to receive the task scheduling request and return an offline task during the first target time period.
[0027] The task execution module is used to receive the offline task sent by the scheduling server during the first target time period, and to execute the online task and the offline task.
[0028] Optionally, the time period determination module includes:
[0029] The data collection unit is used to collect the resource usage of the online task at multiple time points;
[0030] A time point determination unit is used to determine multiple consecutive target time points among the plurality of time points, wherein the resource usage corresponding to the target time points is less than the first threshold.
[0031] The first determining unit is used to determine the time period consisting of the multiple target time points as the second target time period;
[0032] The second determining unit is used to determine the same time period in the subsequent period of the second target time period as the first target time period.
[0033] Optionally, the device further includes:
[0034] The resource availability determination module is used to determine the resource availability of the offline task based on the resource usage of the online task in the first target time period.
[0035] The first allocation module is used to allocate the first processing resources corresponding to the available resources to the offline task;
[0036] The second allocation module is used to allocate other processing resources besides the first processing resource to the online task.
[0037] Optionally, the resource availability determination module includes:
[0038] The resource remaining amount determination unit is used to determine the difference between the total resources of the first online server and the resource usage of the online task as the resource remaining amount;
[0039] The resource availability determination unit is used to determine the difference between the remaining resource amount and the reserved resource amount as the resource availability of the offline task.
[0040] Optionally, the device further includes:
[0041] The resource usage total determination module is used to determine the total resource usage of the online task and the offline task during the execution of the online task and the offline task;
[0042] The task execution module is also used to stop executing the offline task when the total resource usage exceeds the second threshold.
[0043] Optionally, the task execution module includes:
[0044] The task execution unit is configured to, when the total resource usage exceeds the second threshold, stop executing at least one offline task based on the resource usage of each offline task, wherein the resource usage of the stopped offline task is greater than the resource usage of the remaining offline tasks that have not been stopped, so that the total resource usage of the online task and the remaining offline task does not exceed the second threshold.
[0045] On the other hand, a task processing apparatus is provided, the apparatus comprising:
[0046] The scheduling request receiving module is used to receive a task scheduling request sent by a first online server. The task scheduling request carries a first target time period, during which the resource usage of the online tasks of the first online server is less than a first threshold.
[0047] The task sending module is used to send offline tasks to the first online server during the first target time period. The first online server is used to receive the offline tasks and execute the online tasks and the offline tasks during the first target time period.
[0048] Optionally, the task sending module includes:
[0049] The cutoff time point determination unit is used to determine the cutoff time point in the target time period, and the duration between the cutoff time point and the end time point of the target time period is the target duration.
[0050] The task sending unit is used to stop sending the offline task to the first online server starting from the cutoff sending time.
[0051] Optionally, the first online server is an online server that is in operation; the task sending module includes:
[0052] The first offline task sending unit is used to send a first offline task to the first online server during the first target time period. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay, and the second delay is greater than the first delay.
[0053] The device further includes:
[0054] The second offline task sending module is used to send a second offline task to a second online server. The maximum allowable delay of the second offline task is greater than the second delay. The second online server is an online server in an idle state.
[0055] Optionally, the device further includes:
[0056] The third offline task sending module is used to send a third offline task to the offline server, wherein the maximum allowable delay of the third offline task is not greater than the first delay.
[0057] On the other hand, a server is provided, the server including a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to perform the operations performed in the task processing method described above.
[0058] On the other hand, a computer-readable storage medium is provided that stores at least one computer program, which is loaded and executed by a processor to perform the operations performed in the task processing method described above.
[0059] On the other hand, a computer program product or computer program is provided, the computer program product or computer program including computer program code stored in a computer-readable storage medium, wherein a server processor reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code, causing the server to perform the operations performed in the task processing method described above.
[0060] The method, apparatus, server, and storage medium provided in this application embodiment determine a first target time period with low resource usage for online tasks. Since the resource usage is low, the utilization rate of processing resources is also low during this first target time period. Therefore, by scheduling the server, offline tasks are scheduled during this first target time period, thereby executing both online and offline tasks simultaneously to fully utilize the processing resources within this period. Thus, by employing a hybrid deployment approach for online and offline tasks, the utilization rate of processing resources can be improved. Attached Figure Description
[0061] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0062] Figure 1 This is a system architecture diagram of a task processing system provided in an embodiment of this application.
[0063] Figure 2 This is a system architecture diagram of another task processing system provided in the embodiments of this application.
[0064] Figure 3 This is a schematic diagram of an online server flow provided in an embodiment of this application.
[0065] Figure 4 This is a flowchart of a task processing method provided in an embodiment of this application.
[0066] Figure 5 This is a schematic diagram of a task processing method provided in an embodiment of this application.
[0067] Figure 6 This is a flowchart of a task processing method provided in an embodiment of this application.
[0068] Figure 7 This is a schematic diagram of a task processing method provided in an embodiment of this application.
[0069] Figure 8 This is a flowchart of another task processing method provided in the embodiments of this application.
[0070] Figure 9 This is a flowchart of another task processing method provided in the embodiments of this application.
[0071] Figure 10 This is a flowchart of another task processing method provided in the embodiments of this application.
[0072] Figure 11 This is a schematic diagram of the structure of a task processing device provided in an embodiment of this application.
[0073] Figure 12 This is a schematic diagram of another task processing device provided in the embodiments of this application.
[0074] Figure 13 This is a schematic diagram of another task processing device provided in the embodiments of this application.
[0075] Figure 14This is a schematic diagram of another task processing device provided in the embodiments of this application.
[0076] Figure 15 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0077] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0078] It is understood that the terms "first," "second," etc., used in this application may be used to describe various concepts herein, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of this application, a first online server may be referred to as a second online server, and similarly, a second online server may be referred to as a first online server.
[0079] "At least one" refers to one or more online servers. For example, at least one online server can be one, two, three, or any integer number of online servers greater than or equal to one. "Multiple" refers to two or more online servers. For example, multiple online servers can be two, three, or any integer number of online servers greater than or equal to two. "Each" refers to each of the at least one online server. For example, each online server refers to each of the multiple online servers. If the multiple online servers are three online servers, then each online server refers to each of the three online servers.
[0080] Figure 1 This is a system architecture diagram of a task processing system provided in an embodiment of this application. See also... Figure 1 The task processing system includes: a first online server 101 and a scheduling server 102.
[0081] The first online server 101 is used to determine a first target time period, during which the resource usage of online tasks is less than a first threshold.
[0082] The first online server 101 is also used to send a task scheduling request carrying a first target time period to the scheduling server 102;
[0083] The scheduling server 102 is used to receive task scheduling requests and send offline tasks to the first online server 101 during the first target time period.
[0084] The first online server 101 is also used to receive offline tasks sent by the scheduling server 102 and execute online and offline tasks during the first target time period.
[0085] In one possible implementation, such as Figure 2 As shown, the task processing system also includes a second online server 103. The first online server 101 is an online server in a running state, and the second online server 103 is an online server in an idle state.
[0086] The scheduling server 102 is used to receive task scheduling requests and send a first offline task to the first online server 101 in a first target time period. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay, and the second delay is greater than the first delay.
[0087] The first online server 101 is used to receive the first offline task sent by the scheduling server 102 during the first target time period, and to execute the online task and the first offline task.
[0088] The scheduling server 102 is also used to send a second offline task to the second online server 103, wherein the maximum allowable delay of the second offline task is greater than the second delay;
[0089] The second online server 103 is used to receive and execute the second offline task.
[0090] In one possible implementation, such as Figure 2 As shown, the task processing system also includes an offline server 104. The scheduling server 102 is also used to send a third offline task to the offline server 104, wherein the maximum allowable delay of the third offline task is no greater than the first delay;
[0091] Offline server 1104 is used to receive and execute the third offline task.
[0092] The above Figure 2 In the task processing system shown, the first online server 101, the second online server 103, and the offline server 104 are directly or indirectly connected to the scheduling server 102 via wired or wireless communication. All four types of servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0093] The first online server 101 is an online server in a running state, and the second online server 103 is an online server in an idle state. An online server is a server used to execute online tasks; the running state refers to the state where online tasks have been deployed, and the idle state refers to the state where no online tasks have been deployed. The offline server 104 is a server used to execute offline tasks.
[0094] The set of first online servers that are in operation is called the online pool, and the set of second online servers that are in idle state is called the resource pool. The switching between the running state and the idle state can be called the flow between servers. Figure 3 This is a schematic diagram of an online server workflow provided in an embodiment of this application. See also... Figure 3 Based on the status of the online servers, they can be divided into a procurement pool 301, a delivery pool 302, a resource pool 303, an online pool 304, and a return pool 305. The procurement pool 301 represents online servers that have been procured but not yet delivered; the delivery pool 302 represents online servers that have been delivered; the resource pool 303 represents initialized online servers, which are the second online servers in this embodiment. The second online servers in resource pool 303 do not have any online tasks deployed and are a set of backup servers for online pool 304. Online pool 304 represents online servers with deployed online tasks, which are the first online servers in this embodiment. The return pool 305 represents online servers that have expired warranty or have been decommissioned.
[0095] After initialization, online servers in delivery pool 302 are transferred to resource pool 303. When the number of online tasks suddenly increases and the processing resources of the first online server in online pool 304 are insufficient, the second online server in resource pool 303 is transferred to online pool 304, that is, the second online server is switched from an idle state to a running state. When the first online server in online pool 304 is under low load or has no load, it is transferred to resource pool 303, that is, the first online server is switched from a running state to an idle state. When the second online server in resource pool 303 fails, it will be transferred back to resource pool 303 after repair, and when the first online server in online pool 304 fails, it will be transferred back to online pool 304 after repair. When an online server in resource pool 303 or online pool 304 fails, expires its warranty, or is decommissioned, the online server will be transferred to return pool 305. The online server in return pool 305 will be returned to the pool, and a new budget will be allocated to purchase a new online server.
[0096] Figure 4 This is a flowchart illustrating a task processing method provided in an embodiment of this application. The execution entity in this embodiment is a first online server. (See also...) Figure 4 The method includes:
[0097] 401. The first online server determines the first target time period.
[0098] In the field of internet technology, tasks are divided into online tasks and offline tasks. Online tasks are those with high real-time requirements and are sensitive to latency, while offline tasks are those with lower real-time requirements. The first online server is the server used to execute online tasks.
[0099] The first online server determines a first target time period, during which the resource usage of online tasks is less than a first threshold. The resource usage of an online task refers to the amount of resources used to execute the online task. It should be noted that this first target time period is a time period that has not yet arrived, i.e., a time period after the current moment. The resource usage of online tasks within this first target time period is the predicted resource usage; that is, when online tasks are executed subsequently within this first target time period, the resource usage of the online tasks is expected to be less than the first threshold.
[0100] The first threshold is a standard for measuring the resource usage of online tasks. If the resource usage of an online task is less than the first threshold, it means that the resource usage of the online task is relatively small. Therefore, it can be understood that the first target time period is a time period in which the processing resources of the first online server are relatively idle.
[0101] 402. The first online server sends a task scheduling request carrying the first target time period to the scheduling server.
[0102] Since the resource usage of online tasks during the first target time period is less than the first threshold, the processing resources of the first online server are relatively idle during the first target time period. In order to improve the resource utilization of the first online server, the processing resources during the first target time period can be utilized. Therefore, the first online server generates a task scheduling request carrying the first target time period and sends the task scheduling request to the scheduling server. This task scheduling request is used to request the scheduling of offline tasks during the first target time period.
[0103] The scheduling server manages offline tasks and can schedule them to other devices for execution. Upon receiving a task scheduling request from the first online server, the scheduling server determines the first target time period carried in the request and returns the offline task within that time period, thus scheduling the offline task to the first online server.
[0104] 403. During the first target time period, the first online server receives offline tasks sent by the scheduling server and executes both online and offline tasks.
[0105] During the first target time period, the first online server receives and executes offline tasks sent by the scheduling server. In addition, since the first online server is also used to execute online tasks, it will also receive online tasks during the first target time period and execute them as usual. Therefore, during the first target time period, the first online server will execute both online and offline tasks simultaneously.
[0106] The method provided in this application identifies a first target time period with low resource usage for online tasks. Since resource usage is low, the utilization rate of processing resources is also low during this first target time period. Therefore, an offline task is scheduled during this first target time period via a scheduling server, allowing both online and offline tasks to be executed simultaneously, thus fully utilizing the processing resources within this period. Therefore, by employing a hybrid deployment approach for online and offline tasks, the utilization rate of processing resources can be improved.
[0107] Figure 5 This is a flowchart illustrating a task processing method provided in an embodiment of this application. The execution entity in this embodiment is a scheduling server. (See also...) Figure 5 The method includes:
[0108] 501. The scheduling server receives a task scheduling request sent by the first online server.
[0109] The scheduling server manages offline tasks and can schedule them to other devices for execution. The primary online server is used to execute online tasks.
[0110] In this embodiment of the application, the first online server sends a task scheduling request to the scheduling server, which receives the task scheduling request. The task scheduling request carries a first target time period and is used to request the scheduling of offline tasks within the first target time period. During the first target time period, the resource usage of the online tasks of the first online server is less than a first threshold.
[0111] The first threshold is a standard for measuring the resource usage of online tasks. If the resource usage of an online task is less than the first threshold, it is considered that the resource usage of the online task is relatively small. This can be understood as a period of time when the processing resources of the first online server are relatively idle. Therefore, the first online server will request to schedule offline tasks within the first target time period.
[0112] 502. During the first target time period, the scheduling server sends offline tasks to the first online server.
[0113] The scheduling server determines the first target time period carried in the task scheduling request. Within the first target time period, it sends offline tasks to the first online server, thereby scheduling the offline tasks to the first online server. The first online server is used to receive offline tasks and execute both online and offline tasks within the first target time period.
[0114] Since the first online server is used to execute online tasks, in addition to receiving offline tasks returned by the scheduling server, the first online server will also receive online tasks in the first target time period. Therefore, in the first target time period, the first online server will execute online tasks and offline tasks simultaneously.
[0115] The method provided in this application embodiment addresses a situation where the resource usage of online tasks on a first online server is low during a first target time period. Because the resource usage is low, the utilization rate of processing resources is also low during this first target time period. Therefore, the scheduling server sends offline tasks to the first online server during the first target time period, allowing the first online server to execute both online and offline tasks simultaneously, thus fully utilizing the processing resources during this period. Therefore, by employing a mixed deployment of online and offline tasks, the utilization rate of processing resources on the first online server can be improved.
[0116] Figure 6 This is a flowchart illustrating a task processing method provided in an embodiment of this application. The execution entity of this embodiment is the aforementioned... Figure 1 The first online server and scheduling server in the implementation environment, see Figure 6 The method includes:
[0117] 601. The first online server determines the first target time period.
[0118] In the field of internet technology, tasks are divided into online tasks and offline tasks. Online tasks are those with high real-time requirements and are relatively sensitive to latency. Offline tasks are those with lower real-time requirements and are relatively less sensitive to latency. Optionally, online tasks have latency requirements on the order of seconds or milliseconds, while offline tasks have latency requirements on the order of minutes or hours. Some offline tasks can even have a maximum allowable latency of more than a day. The latency referred to here is the time spent executing the task and returning the result.
[0119] For example, in the field of push advertising, an ad summary can be pushed to a user's terminal. If the user is interested in the ad summary, they can click on it. In response to the click, the user's terminal sends an ad viewing request to the server, requesting the server to return the ad details corresponding to the ad summary. In this case, the ad details need to be returned in real time to display the ad to the user as quickly as possible. This ad query request has high real-time requirements; therefore, it is an online task.
[0120] For example, in the field of ad delivery, a user terminal can collect data on a user's ad browsing activity over a week and send an ad delivery request containing this data to a server. The server then determines the user's preferences based on this data and returns an ad summary that matches those preferences to the user terminal, which can then subsequently display the ad summary to the user. In this case, there is no need to push ad summaries to the user in real time; the real-time requirement of this ad delivery request is low, therefore it is an offline task.
[0121] The first online server is used to execute online tasks. It determines a first target time period during which the resource usage of online tasks is less than a first threshold. It should be noted that this first target time period is a period that has not yet arrived, and the resource usage of online tasks during this period is predicted. Subsequent execution of online tasks within this first target time period will ensure that the resource usage of those tasks is less than the first threshold.
[0122] The first threshold is a standard for measuring the resource usage of online tasks. If the resource usage of an online task is not less than the first threshold, it indicates that the resource usage of the online task is relatively high, the current resource utilization of the first online server is high, and there are few idle processing resources in the first online server. If the resource usage of an online task is less than the first threshold, it indicates that the resource usage of the online task is relatively low, the current resource utilization of the first online server is low, and there are many idle processing resources in the first online server. Therefore, the first target time period can be understood as a time period in which the processing resources of the first online server are relatively idle. Optionally, the first threshold is a threshold preset by the first online server.
[0123] In one possible implementation, the first online server determines a first target time period by: collecting resource usage data of online tasks at multiple time points; identifying multiple consecutive target time points among these time points; defining the time period formed by the multiple target time points as a second target time period; and defining identical time periods within subsequent cycles of the second target time period as the first target time period. The resource usage corresponding to each target time point is less than a first threshold.
[0124] The first online server receives and executes online tasks. At any given time, the first online server can execute multiple online tasks in parallel. The number of online tasks executed by the first online server at each time point is not fixed, therefore, the resource usage of online tasks at different times is also not fixed. However, within a period, the distribution pattern of resource usage of online tasks on the first online server is consistent within each period. For example, the period is 1 day or 1 week. It can be considered that the resource usage of online tasks is approximate within the same time period in different periods.
[0125] During the execution of an online task, the first online server collects resource usage data at multiple points within a cycle. Then, it identifies consecutive target time points where resource usage is less than a first threshold. Since the resource usage at these consecutive target time points is less than the first threshold, the resource usage within the time period formed by these target time points is considered to be less than the first threshold. Therefore, the first online server designates this time period as the second target time period. This second target time period is the time period that has already passed within the cycle. Because the resource usage of the online task is approximately the same within the same time period in different cycles, it can be assumed that the resource usage within the same time period in subsequent cycles is also less than the first threshold. Therefore, the first online server designates the same time period within subsequent cycles of the second target time period as the first target time period, which is the time period preceding the current moment.
[0126] Optionally, the first online server collects the resource usage of online tasks every reference duration, thereby obtaining the resource usage at multiple time points. For example, the first online server collects the resource usage of online tasks every 1 minute. Optionally, the first online server determines a first target time point and a last target time point among multiple target time points, and defines the time period between the first target time point and the last target time point as a second target time period.
[0127] Optionally, the first online server determines a resource profile based on the resource usage collected at multiple time points. This resource profile characterizes the changes in resource usage of online tasks over time. Based on this resource profile, multiple consecutive target time points with corresponding resource usage below a first threshold are determined. For example, the resource profile can be represented by a curve or line graph to show the changes in resource usage.
[0128] For example, if the online task is related to user behavior, the first online server uses a 24-hour cycle to obtain resource usage data at multiple points within that 24-hour period. From these multiple points, it identifies several consecutive target time points and defines the time period corresponding to these target time points as the second target time period. For example, if the second target time period is 1:00 AM to 5:00 AM, then the first target time period is 1:00 AM to 5:00 AM every day thereafter.
[0129] 602. The first online server sends a task scheduling request carrying the first target time period to the scheduling server.
[0130] Since the resource usage of online tasks during the first target time period is less than the first threshold, the resource utilization rate is relatively low. Therefore, the processing resources of the first online server are relatively idle during this period. To improve the resource utilization rate of the first online server, these processing resources can be utilized. Thus, the first online server generates a task scheduling request carrying the first target time period and sends it to the scheduling server. This task scheduling request requests that offline tasks be scheduled during the first target time period so that idle resources can be used to execute offline tasks later during that period.
[0131] 603. The scheduling server receives the task scheduling request sent by the first online server.
[0132] 604. During the first target time period, the scheduling server sends offline tasks to the first online server.
[0133] The scheduling server continuously receives offline tasks, such as those sent by user terminals. The server stores these offline tasks in an offline task pool and, based on the latency requirements of each task, promptly schedules them to other devices for execution.
[0134] In this embodiment, after receiving a task scheduling request from a first online server, the scheduling server obtains a first target time period carried in the task scheduling request and sends offline tasks from the offline task pool to the first online server within the first target time period. Optionally, the scheduling server receives the task scheduling request at a time earlier than the first target time period. Therefore, the scheduling server monitors the time in real time. When the time reaches the start time of the first target time period, it starts sending offline tasks to the first online server, and when the time reaches the end time of the first target time period, it stops sending offline tasks to the first online server.
[0135] Within the first time period, the scheduling server can send one or more offline tasks to the first online server. The scheduling server can send offline tasks to the first online server at any point within the first target time period. For example, if at a certain point in time there are offline tasks to be executed in the scheduling server's offline task pool, and that point in time belongs to the first target time period, then the scheduling server will send that offline task to the first online server. If a point in time belongs to the first target time period, but there are no offline tasks to be executed in the offline task pool at that point in time, then the scheduling server will not send any offline tasks to the first online server.
[0136] In one possible implementation, the scheduling server determines a cutoff time point within the target time period, and stops sending offline tasks to the online server from this cutoff time point. The duration between this cutoff time point and the end time of the target time period is the target duration.
[0137] In this embodiment, the first online server executes offline tasks only within a first target time period. When the time reaches the end point of the first target time period, the first online server stops executing offline tasks. If there are offline tasks being executed at the end point, those tasks will also be stopped, affecting the stability of offline task execution and consuming the processing resources of the first online server without completing the task. To ensure stable execution of offline tasks, the scheduling server can stop sending offline tasks in advance. The scheduling server determines the time between the end point and the target time as the cutoff sending time for the target duration. From this cutoff sending time, the scheduling server stops sending offline tasks to the first online server. Therefore, within the target duration between the cutoff sending time and the end point, the first online server will not receive new offline tasks and will not execute any new offline tasks. Offline tasks that start executing before the cutoff sending time have a higher probability of completing at the end point, thereby reducing the number of offline tasks being executed at the end point, which reduces the number of offline tasks that are stopped midway and improves the stability of offline task execution.
[0138] For example, statistics show that 52% of offline tasks take less than 5 minutes to execute, 17% take between 5 and 10 minutes, 21% take between 10 and 30 minutes, and 10% take more than 30 minutes. Therefore, setting the target duration to 10 minutes will ensure that at least 69% of offline tasks can be executed stably.
[0139] 605. During the first target time period, the first online server receives offline tasks sent by the scheduling server and executes both online and offline tasks.
[0140] During the first target time period, the first online server receives and executes offline tasks sent by the scheduling server. In addition, since the first online server is also used to execute online tasks, it will also receive online tasks during the first target time period and execute them as usual. Therefore, during the first target time period, the first online server will execute both online and offline tasks simultaneously.
[0141] Since the resource usage of online tasks is relatively low during the first target time period, the first online server only executes offline tasks during this period. Outside of this period, the resource usage of online tasks is higher, so the processing resources on the first online server need to be reserved for them. Therefore, starting from the end of the first target time period, the first online server stops executing offline tasks. If any offline tasks are still running at the end of the time period, they will also stop executing. Furthermore, the first online server will return any incomplete offline tasks to the scheduling server, which will then resend them to other devices for execution.
[0142] In this embodiment, the first online server is a server used to execute online tasks. Executing offline tasks on the first online server disrupts its original execution environment. While executing offline tasks, it is necessary to ensure that the online tasks on the first online server are not affected. Therefore, the first online server employs at least one of the following isolation strategies or fallback strategies to ensure that online tasks are not affected.
[0143] (i) Isolation strategy: Before executing online and offline tasks, the first online server determines the available resources for offline tasks based on the resource usage of online tasks in the first target time period, allocates the first processing resources corresponding to the available resources to offline tasks, and allocates other processing resources other than the first processing resources to online tasks.
[0144] The first online server determines the available resources for offline tasks. From its processing resources, it identifies the first processing resource corresponding to that available resource. This process divides the processing resources into the first processing resource and other processing resources. The first processing resource is used to execute offline tasks, while the other processing resources are used to execute online tasks. In scenarios where offline and online tasks are deployed in a mixed manner, isolating the processing resources for online and offline tasks ensures that they do not interfere with each other, preventing offline tasks from affecting online tasks.
[0145] The available resource amount refers to the maximum resource usage of offline tasks. When the resource usage of the first online server executing offline tasks reaches this maximum, the first online server will no longer execute new offline tasks, thereby preventing offline tasks from preempting the processing resources of online tasks and ensuring the stable execution of online tasks.
[0146] Optionally, the first online server determines the difference between the total resources of the first online server and the resource usage of the online task as the remaining resources, and determines the difference between the remaining resources and the reserved resources as the available resources for the offline task.
[0147] Resource usage refers to the amount of resources required to execute online tasks. The difference between the total resources and the resource usage is the remaining available resources. However, since this resource usage is a predicted resource usage for online tasks within the first target time period, and this usage may fluctuate, to further ensure sufficient processing resources for executing online tasks, the first online server determines a resource reservation. The processing resources corresponding to this reservation are reserved for online tasks. Therefore, the first online server determines the available resources for offline tasks based on the difference between the remaining resources and the reserved resources. That is, the processing resources corresponding to the available resources are allocated to offline tasks, while the processing resources corresponding to the resource usage and the reserved resources are allocated to online tasks. Optionally, this resource reservation is pre-set by the first online server.
[0148] In this embodiment, the processing resources corresponding to the resource utilization are allocated to online tasks. The idle remaining resources in the total resources, excluding the resource utilization, are determined, and the processing resources corresponding to the resource reservation in the idle remaining resources are also allocated to online tasks. This ensures that there are sufficient processing resources to execute online tasks and further avoids the situation where offline tasks preempt the processing resources of online tasks.
[0149] For example, expressing the amount of processing resources as a percentage, if the total resources in the first online server are 100%, and the resource usage of online tasks is 30%, then the remaining resources are 70%. If the resource reservation set for the first online server is 30%, then the available resources for offline tasks are 40%. Therefore, the first online server allocates 60% of its processing resources to online tasks and 40% to offline tasks.
[0150] (ii) fallback strategy: During the execution of online and offline tasks, the first online server determines the total resource usage of online and offline tasks. If the total resource usage exceeds the second threshold, the execution of offline tasks is stopped.
[0151] The total resource usage refers to the sum of the resource usage of at least one online task and at least one offline task currently in use. If the total resource usage of the first online server is too high, it may negatively impact online tasks. To avoid this, an upper limit can be set for the total resource usage of the first online server, for example, a second threshold. During the execution of online and offline tasks in the first target time period, the first online server monitors the total resource usage of both tasks in real time. If the total resource usage exceeds the second threshold, the execution of offline tasks is stopped, thereby reducing the total resource usage on the first online server and preventing any impact on online tasks, further ensuring the stability of online tasks. Optionally, the second threshold is preset by the first online server; for example, the first online server determines the maximum historical total resource usage and sets this maximum value as the second threshold.
[0152] Optionally, if the total resource usage exceeds the second threshold, the first online server stops executing at least one offline task based on the resource usage of each offline task. The resource usage of the stopped offline task is greater than the resource usage of the remaining offline tasks that have not been stopped, so that the total resource usage of the online tasks and the remaining offline tasks does not exceed the second threshold.
[0153] The first online server determines the resource usage of each offline task. If the total resource usage exceeds a second threshold, the first few offline tasks with the highest resource usage are stopped to ensure that the total resource usage does not exceed the second threshold. Optionally, the first online server sorts the offline tasks in descending order of resource usage. It first stops the execution of the first offline task and determines whether the total resource usage of the online tasks and the remaining offline tasks exceeds the second threshold. If it still exceeds the second threshold, the second offline task is stopped, and the total resource usage is checked again until the total resource usage does not exceed the second threshold. Alternatively, the first online server determines a target number and directly stops the execution of the target number of offline tasks to ensure that the total resource usage does not exceed the second threshold. In this embodiment, when the total resource usage of the offline tasks and online tasks exceeds the second threshold, the first online server stops the execution of some offline tasks based only on the resource usage of each offline task, while allowing the remaining offline tasks to continue execution. This reduces the total resource usage while ensuring the stable execution of some offline tasks.
[0154] Figure 7 This is a schematic diagram of a task processing method provided in an embodiment of this application, such as... Figure 7As shown, the first online server includes a management module 701 and a monitoring module 702. The management module 701 manages the mixed deployment of online and offline tasks, while the monitoring module 702 monitors the usage of processing resources. During the execution of online tasks, the management module 701 reports the resource utilization of the online tasks to the monitoring module 702. The monitoring module 702 determines a resource profile based on the resource utilization of the online tasks. This resource profile characterizes the changes in resource utilization of the online tasks over time. Based on the resource profile, resource prediction is performed to determine the first target time period for executing offline tasks and the available resources allocated to the offline tasks. The monitoring module 702 notifies the management module 701 of the first target time period and the available resources so that the management module 701 can allocate the processing resources corresponding to the available resources to the offline tasks during the first target time period. Optionally, the management module 701 and the monitoring module 702 can be deployed on the same first online server or on different first online servers.
[0155] like Figure 7 As shown, the scheduling server 703 deploys an offline task pool, which includes offline tasks. The scheduling server 703 can also determine the server status and task status. The server status indicates whether the online or offline server connected to the scheduling server is working properly, and the task status indicates the status of the offline task, including unexecuted, executing, and completed execution. The scheduling server 703 can schedule the offline tasks in the offline task pool according to the server status and task status. Specifically, the first online server sends a task scheduling request carrying a first target time period to the scheduling server 703 through the management module 701. After receiving the task scheduling request, the scheduling server 703 sends the offline tasks in the offline task pool to the first online server during the first target time period.
[0156] In related technologies, online tasks are executed by an online server, and offline tasks are executed by an offline server. When the processing resources of the offline server are insufficient, the only solution is to expand the offline server to supplement processing resources. Therefore, the consumption of processing resources on the offline server is relatively large, the processing cost of the offline server is relatively high, and the utilization rate of the processing resources of the online server is relatively low. However, the method provided in this application deploys online and offline tasks together on a first online server, allocating the processing resources of the online server during off-peak periods to offline tasks. This not only improves the utilization rate of the processing resources of the online server but also reduces the processing cost of the offline server, alleviating the problem of insufficient processing resources on the offline server.
[0157] The method provided in this application identifies a first target time period with low resource usage for online tasks. Since resource usage is low, the utilization rate of processing resources is also low during this first target time period. Therefore, an offline task is scheduled during this first target time period via a scheduling server, allowing both online and offline tasks to be executed simultaneously, thus fully utilizing the processing resources within this period. Therefore, by employing a hybrid deployment approach for online and offline tasks, the utilization rate of processing resources can be improved.
[0158] Furthermore, starting from the cutoff sending time, the scheduling server stops sending offline tasks to the first online server. During the target duration between the cutoff sending time and the end time, the first online server will not receive any new offline tasks, thereby reducing the number of offline tasks being executed at the end time. In other words, it reduces the number of offline tasks that are stopped midway and improves the stability of offline task execution.
[0159] Furthermore, in scenarios where offline and online tasks are deployed in a mixed manner, by isolating the processing resources for executing online tasks from those for executing offline tasks, the processing resources for offline tasks and online tasks do not interfere with each other, thus preventing offline tasks from affecting online tasks.
[0160] Furthermore, the processing resources corresponding to the resource utilization are allocated to online tasks. The remaining idle resources in the total resource pool are determined, and the processing resources corresponding to the reserved resources in the remaining idle resources are also allocated to online tasks. This ensures that there are sufficient processing resources to execute online tasks and further avoids the situation where offline tasks preempt the processing resources of online tasks.
[0161] Furthermore, during the execution of online and offline tasks, the total resource usage of online and offline tasks is determined. If the total resource usage exceeds a second threshold, the execution of offline tasks is stopped, thereby reducing the total resource usage in the first online server. This prevents excessive resource usage from affecting online tasks and further ensures the stability of online tasks.
[0162] Figure 8 This is a flowchart of another task processing method provided in this application embodiment. The execution subject of this application embodiment is the above-mentioned... Figure 2 The first online server, scheduling server, second online server, and offline server in the implementation environment are described in the following document. Figure 8 The method includes:
[0163] 801. The scheduling server divides offline tasks into the first offline task, the second offline task, and the third offline task.
[0164] The scheduling server receives and stores offline tasks. To facilitate the management and scheduling of offline tasks, the scheduling server categorizes them into three types based on latency requirements: first offline tasks, second offline tasks, and third offline tasks. The scheduling server determines the maximum allowable latency for each offline task. Tasks with a maximum allowable latency no greater than the first latency are designated as third offline tasks; tasks with a maximum allowable latency greater than the first latency but no greater than the second latency are designated as first offline tasks; and tasks with a maximum allowable latency greater than the second latency are designated as second offline tasks. The second latency is greater than the first latency. Optionally, the first and second latencies are determined by the scheduling server based on operator actions.
[0165] Offline tasks can be categorized into real-time and non-real-time tasks based on their latency sensitivity. This application uses a first latency level as the standard for measuring latency sensitivity. Offline tasks with a maximum permissible latency not exceeding the first latency are defined as real-time offline tasks, i.e., the aforementioned third offline task. Offline tasks with a maximum permissible latency exceeding the first latency are defined as non-real-time offline tasks. Real-time offline tasks are more sensitive to latency and have higher real-time requirements; for example, real-time offline tasks are required to complete within minutes. Non-real-time offline tasks are less sensitive to latency and have lower real-time requirements; for example, non-real-time offline tasks are required to complete within hours.
[0166] Among them, non-real-time offline tasks can be further divided into first offline tasks and second offline tasks based on their sensitivity to latency. In this embodiment, the second latency is used as the standard for measuring the latency sensitivity of non-real-time offline tasks. Offline tasks with a maximum allowable latency not greater than the second latency are determined as first offline tasks, and offline tasks with a maximum allowable latency greater than the second latency are determined as second offline tasks.
[0167] For example, the first type of offline task includes routine tasks, which are tasks that perform periodic data analysis, triggered at a certain point in the current cycle or when the data is ready. Routine tasks have certain time requirements for execution. For example, an offline task that processes data from one day must be completed before 8 a.m. the next day so that operations personnel can study the results of the data processing.
[0168] For example, the second offline task includes a test task, which is a task to test data. For example, after developing a target application, it is necessary to run the target application to test it and obtain test results. The requirements for execution time of the test task are relatively lenient, and the test task can be re-executed, so even if the test task fails, it will not have an impact.
[0169] For example, the second offline task includes a historical data supplementation task. This task involves performing the same processing on historical data when the data processing results meet expectations. Since the offline task needs to process historical data, such as data from the past week, quarter, or even year, the execution time requirements for historical data supplementation tasks are relatively lenient.
[0170] 802. The first online server determines the first target time period and sends a task scheduling request carrying the first target time period to the scheduling server.
[0171] 803. The scheduling server receives the task scheduling request sent by the first online server and sends the first offline task to the first online server within the first target time period.
[0172] The scheduling server receives a task scheduling request from the first online server, determines the first target time period carried in the task scheduling request, and sends a first offline task to the first online server within the first target time period. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay.
[0173] 804. During the first target time period, the first online server receives the first offline task and executes both the online task and the first offline task.
[0174] The process of steps 802-804 is the same as that of steps 401-405 above, and will not be repeated here. The only difference is that the offline task sent by the scheduling server to the first online server is the first offline task.
[0175] 805. The scheduling server sends the second offline task to the second online server.
[0176] The scheduling server retrieves the second offline task from the offline task pool. The maximum allowed latency of the second offline task is greater than the second latency, and then sends the second offline task to the second online server.
[0177] 806. The second online server receives the second offline task and executes it.
[0178] If the second online server has no online tasks deployed and is in an idle state, it does not need to execute any online tasks. In this case, the second online server receives the second offline task sent by the scheduling server and executes the second offline task.
[0179] In one possible implementation, the second online server can switch from an idle state to a running state. For example, when the processing resources of the first online server are insufficient, it is necessary to switch the second online server from an idle state to a running state, thereby deploying online tasks on the second online server and enabling it to execute these tasks. In response to a state switch notification, the second online server stops executing the second offline task; this state switch notification is used to notify the server to switch from an idle state to a running state.
[0180] Optionally, the status transition notification is triggered by operators, sent by a scheduling server, or sent by a management server that manages the status of online servers, for example, the management server can manage the aforementioned... Figure 7 The status of online servers in the resource pool and online pool. This application embodiment does not limit the method of obtaining the status transition notification.
[0181] 807. The scheduling server sends the third offline task to the offline server.
[0182] The scheduling server retrieves the third offline task from the offline task pool. The maximum allowed latency of the third offline task is no greater than the first latency. The scheduling server then sends the third offline task to the offline server.
[0183] 808. The offline server receives the third offline task and executes it.
[0184] In this embodiment, the first online server executes online and offline tasks during a first target time period. Starting from the end of the first target time period, the first online server stops executing offline tasks. Furthermore, if the total resource usage on the first online server reaches a second threshold, it also stops executing offline tasks. In this embodiment, the second online server is an idle online server. If the second online server switches from an idle state to a running state while executing offline tasks, it stops executing the offline tasks. Therefore, both the first and second online servers are susceptible to interruptions in their offline tasks. If an offline task is interrupted, it needs to be rescheduled to another server for re-execution.
[0185] For offline tasks that are sensitive to latency, interruption has a significant impact, while for offline tasks that are less sensitive to latency, interruption has a smaller impact. Considering that offline tasks on the offline server are uninterrupted and have the highest stability, the scheduling server sends the third offline task (the most latency-sensitive among the first, second, and third offline tasks) to the offline server for execution.
[0186] Since the second online server is a backup server for the first online server, the second online server switches from idle to running state more frequently, which is as described above. Figure 7 The online servers in the resource pool are frequently transferred to servers in the online pool. Therefore, the probability of offline tasks on the second online server being interrupted is higher than that on the first online server. Offline tasks on the first online server are also more stable than those on the second online server. Therefore, the scheduling server, in the case of the first and second offline tasks, sends the latency-sensitive first offline task to the first online server for execution, and the latency-insensitive second offline task to the second online server for execution.
[0187] Figure 9 This is a flowchart of a task processing method provided in an embodiment of this application, such as... Figure 9 As shown, the method includes:
[0188] 901. Classify offline tasks: Divide offline tasks into real-time offline tasks and non-real-time offline tasks. Assign real-time offline tasks to offline servers and non-real-time offline tasks to online servers. The real-time offline task is the third type of offline task.
[0189] 902. Classify online servers: Deploy the first online server to the online pool cluster, and deploy the second online server to the resource pool cluster.
[0190] 903. Classify non-real-time offline tasks: Divide non-real-time offline tasks into first offline tasks and second offline tasks.
[0191] 904. Matching offline tasks with online servers: Assign the first offline task with high stability requirements to the online pool cluster, and assign the second offline task with low stability requirements to the resource pool cluster.
[0192] Using the method provided in this application embodiment, the average maximum resource utilization of the online server is increased by 11.4%, the average resource utilization of the online server is increased by 5.8%, and the low load rate of the online server is reduced by 16%.
[0193] It should be noted that the embodiments of this application take the example of the scheduling server dividing the offline tasks into the first offline task, the second offline task, and the third offline task in advance. In another embodiment, when the scheduling server receives an offline task, it determines what kind of offline task the offline task is. That is, the scheduling server may not perform the above step 801.
[0194] The method provided in this application, based on the stability of offline tasks in the first online server, second online server, and offline server, and the sensitivity of the first offline task, second offline task, and third offline task to latency, schedules the first offline task to the first online server, the second offline task to the second online server, and the third offline task to the offline server, thereby reducing the impact on each offline task as a whole and improving the overall stability.
[0195] The above embodiments can be applied to any scenario that requires the execution of online and offline tasks. For example, in the field of advertising push, tasks are divided into online advertising push tasks and offline advertising push tasks. Online push tasks require the real-time return of the pushed advertisements, while offline push tasks do not require the real-time return of the pushed advertisements. Figure 10 This is a flowchart of a task processing method provided in an embodiment of this application. See also... Figure 10 The method includes:
[0196] 1001. User terminals periodically send offline push tasks to the scheduling server. These offline push tasks are used to request advertisements to be pushed to users in the next cycle.
[0197] 1002. The first online server sends a task scheduling request carrying the first target time period to the scheduling server.
[0198] 1003. The scheduling server receives the task scheduling request and, within the first target time period, sends the offline push task sent by the user terminal to the first online server.
[0199] 1004. In the first target time period, the user terminal responds to the advertisement push request by sending an online push task to the first online server. This advertisement push request is triggered by the user.
[0200] 1005. During the first target time period, the first online server receives the offline push task sent by the scheduling server and the online push task sent by the user terminal, and executes the online push task and the offline push task.
[0201] In addition to the aforementioned advertising push field, online and offline tasks can also be deployed together on the first online server in other scenarios, such as multimedia data playback, online shopping, and online social networking. This application embodiment does not limit the application scenarios of the task processing method.
[0202] Figure 11 This is a schematic diagram of the structure of a task processing device provided in an embodiment of this application. See also... Figure 11 The device includes:
[0203] The time period determination module 1101 is used to determine a first target time period, in which the resource usage of online tasks is less than a first threshold.
[0204] The scheduling request sending module 1102 is used to send a task scheduling request carrying a first target time period to the scheduling server. The scheduling server is used to receive the task scheduling request and return the offline task in the first target time period.
[0205] The task execution module 1103 is used to receive offline tasks sent by the scheduling server and execute online and offline tasks during the first target time period.
[0206] The task processing apparatus provided in this application embodiment determines a first target time period where the resource usage of online tasks is relatively low. Since the resource usage is low, the utilization rate of processing resources is also low during this first target time period. Therefore, an offline task is scheduled during this first target time period via a scheduling server, allowing both online and offline tasks to be executed simultaneously, thus fully utilizing the processing resources within this first target time period. Therefore, by adopting a mixed deployment approach for online and offline tasks, the utilization rate of processing resources can be improved.
[0207] Optionally, see Figure 12 The time period determination module 1101 includes:
[0208] Data collection unit 1111 is used to collect the resource usage of online tasks at multiple time points;
[0209] The time point determination unit 1121 is used to determine multiple consecutive target time points among multiple time points, wherein the resource usage corresponding to the target time point is less than a first threshold.
[0210] The first determining unit 1131 is used to determine the time period consisting of multiple target time points as the second target time period;
[0211] The second determining unit 1141 is used to determine the same time period in the subsequent period of the second target time period as the first target time period.
[0212] Optionally, see Figure 12 The device also includes:
[0213] The resource availability determination module 1104 is used to determine the resource availability of offline tasks based on the resource usage of online tasks in the first target time period.
[0214] The first allocation module 1105 is used to allocate the first processing resources corresponding to the available resources to offline tasks;
[0215] The second allocation module 1106 is used to allocate processing resources other than the first processing resource to online tasks.
[0216] Optionally, see Figure 12 The resource availability determination module 1104 includes:
[0217] The resource remaining amount determination unit 1114 is used to determine the resource remaining amount as the difference between the total amount of resources of the first online server and the resource usage of the online task;
[0218] The resource availability determination unit 1124 is used to determine the difference between the remaining resource amount and the reserved resource amount as the resource availability of the offline task.
[0219] Optionally, see Figure 12 The device also includes:
[0220] The resource usage total determination module 1107 is used to determine the total resource usage of online and offline tasks during the execution of online and offline tasks.
[0221] The task execution module 1103 is also used to stop executing offline tasks when the total resource usage exceeds the second threshold.
[0222] Optionally, see Figure 12 Task execution module 1103 includes:
[0223] The task execution unit 1113 is used to stop executing at least one offline task based on the resource usage of each offline task when the total resource usage exceeds a second threshold. The resource usage of the stopped offline task is greater than the resource usage of the remaining offline tasks that have not been stopped, so that the total resource usage of online tasks and remaining offline tasks does not exceed the second threshold.
[0224] It should be noted that the task processing device provided in the above embodiments is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the server can be divided into different functional modules to complete all or part of the functions described above. In addition, the task processing device and the task processing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0225] Figure 13 This is a schematic diagram of the structure of a task processing device provided in an embodiment of this application. See also... Figure 13 The device includes:
[0226] The scheduling request receiving module 1301 is used to receive a task scheduling request sent by the first online server. The task scheduling request carries a first target time period, during which the resource usage of the online tasks of the first online server is less than a first threshold.
[0227] The task sending module 1302 is used to send offline tasks to the first online server during the first target time period. The first online server is used to receive offline tasks and execute online and offline tasks during the first target time period.
[0228] The task processing apparatus provided in this application embodiment has a low resource usage for online tasks on the first online server during a first target time period. Because the resource usage is low, the utilization rate of processing resources is also low during this first target time period. Therefore, the scheduling server sends offline tasks to the first online server during the first target time period, allowing the first online server to execute both online and offline tasks simultaneously, thus fully utilizing the processing resources during the first target time period. Therefore, by adopting a mixed deployment approach for online and offline tasks, the utilization rate of processing resources on the first online server can be improved.
[0229] Optionally, see Figure 14 The task sending module 1302 includes:
[0230] The cutoff transmission time determination unit 1312 is used to determine the cutoff transmission time in the target time period. The duration between the cutoff transmission time and the end time of the target time period is the target duration.
[0231] The task sending unit 1322 is used to stop sending offline tasks to the first online server starting from the deadline for sending.
[0232] Optionally, see Figure 14 The first online server is an online server that is in operation; the task sending module 1302 includes:
[0233] The first offline task sending unit 1332 is used to send a first offline task to the first online server during a first target time period. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay, and the second delay is greater than the first delay.
[0234] The device also includes:
[0235] The second offline task sending module 1303 is used to send the second offline task to the second online server. The maximum allowable delay of the second offline task is greater than the second delay. The second online server is an online server in an idle state.
[0236] Optionally, see Figure 14 The device also includes:
[0237] The third offline task sending module 1304 is used to send the third offline task to the offline server. The maximum allowable delay of the third offline task is no greater than the first delay.
[0238] It should be noted that the task processing device provided in the above embodiments is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the server can be divided into different functional modules to complete all or part of the functions described above. In addition, the task processing device and the task processing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0239] This application also provides a server, which includes a processor and a memory. The memory stores at least one computer program, which is loaded and executed by the processor to perform the operations performed in the task processing method of the above embodiments.
[0240] Figure 15 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 1500 can vary significantly due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 1501 and one or more memories 1502. The memories 1502 store at least one computer program, which is loaded and executed by the processor 1501 to implement the methods provided in the various method embodiments described above. Of course, the server may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which will not be elaborated upon here.
[0241] This application also provides a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to perform the operations performed in the task processing method of the above embodiments.
[0242] This application also provides a computer program product or computer program, which includes computer program code stored in a computer-readable storage medium. A server's processor reads the computer program code from the computer-readable storage medium and executes the computer program code, causing the server to perform the operations described in the task processing method of the above embodiments. In some embodiments, the computer program involved in this application can be deployed and executed on a single server, or on multiple servers located in one location, or on multiple servers distributed across multiple locations and interconnected via a communication network. These multiple servers distributed across multiple locations and interconnected via a communication network can form a blockchain system.
[0243] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0244] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present application should be included within the protection scope of the present application.
Claims
1. A task processing method, characterized in that, The method is executed by a first online server that is in a running state, where the running state refers to the state in which online tasks have been deployed; the method includes: A first target time period is determined, during which the resource usage of the online tasks is less than a first threshold; a task scheduling request carrying the first target time period is sent to the scheduling server, the scheduling server is used to receive the task scheduling request, return a first offline task during the first target time period, and from the cutoff sending time point in the first target time period, the scheduling server stops sending the first offline task to the first online server, the maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay, and the duration between the cutoff sending time point and the end time point of the first target time period is the target duration; Subtract the resource usage and resource reservation of the online task from the total resources of the first online server to obtain the available resources of the first offline task; allocate the first processing resources corresponding to the available resources to the first offline task; allocate other processing resources besides the first processing resources to the online task; during the first target time period, receive the first offline task sent by the scheduling server, use the other processing resources to execute the online task, and use the first processing resources to execute the first offline task; During the execution of the online task and the first offline task, if the total resource usage of the online task and the first offline task exceeds the second threshold, at least one first offline task is stopped based on the resource usage of each first offline task. The resource usage of the stopped first offline task is greater than the resource usage of the remaining first offline tasks that have not been stopped, so that the total resource usage of the online task and the remaining first offline tasks does not exceed the second threshold. The scheduling server is further configured to send a second offline task to a second online server, wherein the maximum allowable delay of the second offline task is greater than the second delay, and the second online server is an online server in an idle state, wherein the idle state refers to a state in which no online task has been deployed; the second online server is configured to stop executing the second offline task in response to a state switching notification, wherein the state switching notification is further configured to notify the server to switch from an idle state to a running state; The scheduling server is also used to send a third offline task to the offline server, wherein the maximum allowed delay of the third offline task is not greater than the first delay.
2. The method according to claim 1, characterized in that, Determining the first target time period includes: Collect the resource usage of the online task at multiple points in time; Among the plurality of time points, a plurality of consecutive target time points are determined, wherein the resource usage corresponding to the target time points is less than the first threshold. The time period formed by the multiple target time points is defined as the second target time period; The same time period in the subsequent cycle of the second target time period is determined as the first target time period.
3. The method according to claim 1, characterized in that, The method further includes: If the total resource usage exceeds the second threshold, the first offline task will be stopped.
4. A task processing method, characterized in that, The method includes: Receive a task scheduling request sent by a first online server. The task scheduling request carries a first target time period. During the first target time period, the resource usage of the online tasks of the first online server is less than a first threshold. The first online server is in a state where online tasks have been deployed. During the first target time period, a first offline task is sent to the first online server. Starting from the cutoff time point in the first target time period, the sending of the first offline task is stopped. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay. The duration between the cutoff time point and the end time point of the first target time period is the target duration. Send a second offline task to a second online server. The maximum allowable delay of the second offline task is greater than the second delay. The second online server is an online server in an idle state, which means that no online task has been deployed. The second online server is used to stop executing the second offline task in response to a state switching notification. The state switching notification is also used to notify the server to switch from an idle state to a running state. Send a third offline task to the offline server, wherein the maximum allowable delay of the third offline task is no greater than the first delay; The first online server is used to subtract the resource usage and resource reservation of the online task from the total resources of the first online server to obtain the available resources of the first offline task; allocate the first processing resources corresponding to the available resources to the first offline task; allocate other processing resources besides the first processing resources to the online task; during the first target time period, receive the first offline task, execute the online task using the other processing resources besides the first processing resources, and execute the first offline task using the first processing resources; during the execution of the online task and the first offline task, if the total resource usage of the online task and the first offline task is greater than a second threshold, based on the resource usage of each first offline task, stop executing at least one first offline task, the resource usage of the stopped first offline task is greater than the resource usage of the remaining first offline tasks that have not been stopped, so that the total resource usage of the online task and the remaining first offline tasks is not greater than the second threshold.
5. A task processing system, characterized in that, The task processing system includes a first online server, a second online server, an offline server, and a scheduling server. The first online server is in a running state, which means that online tasks have been deployed. The second online server is in an idle state, which means that no online tasks have been deployed. The first online server is configured to determine a first target time period, during which the resource usage of the online tasks is less than a first threshold. The first online server is also used to send a task scheduling request carrying the first target time period to the scheduling server; The scheduling server is configured to receive the task scheduling request, send a first offline task to the first online server during the first target time period, and stop sending the first offline task from the cutoff sending time point in the first target time period. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay. The duration between the cutoff sending time point and the end time point of the first target time period is the target duration. The first online server is further configured to subtract the resource usage and resource reservation of the online task from the total resources of the first online server to obtain the available resources of the first offline task; Allocate the first processing resource corresponding to the available resource quantity to the first offline task; allocate the other processing resources besides the first processing resource to the online task; The first online server is further configured to receive the first offline task sent by the scheduling server during the first target time period, execute the online task using the processing resources other than the first processing resource, and execute the first offline task using the first processing resource; The first online server is further configured to, during the execution of the online task and the first offline task, if the total resource usage of the online task and the first offline task exceeds a second threshold, stop executing at least one first offline task based on the resource usage of each first offline task, wherein the resource usage of the stopped first offline task is greater than the resource usage of the remaining first offline tasks that have not been stopped, so that the total resource usage of the online task and the remaining first offline tasks does not exceed the second threshold; The scheduling server is also used to send a second offline task to a second online server, wherein the maximum allowable delay of the second offline task is greater than the second delay; The second online server is configured to receive the second offline task, execute the second offline task, and stop executing the second offline task in response to a state switching notification. The state switching notification is also configured to notify the user to switch from an idle state to a running state. The scheduling server is also used to send a third offline task to the offline server, wherein the maximum allowed delay of the third offline task is not greater than the first delay.
6. A task processing device, characterized in that, The device includes: The time period determination module is used to determine a first target time period, in which the resource usage of online tasks is less than a first threshold. The scheduling request sending module is used to send a task scheduling request carrying the first target time period to the scheduling server. The scheduling server is used to receive the task scheduling request, return the first offline task in the first target time period, and stop sending the first offline task to the first online server from the cutoff sending time point in the first target time period. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay. The duration between the cutoff sending time point and the end time point of the first target time period is the target duration. The resource availability determination module is used to subtract the resource usage and resource reservation of the online task from the total resources of the first online server to obtain the resource availability of the first offline task. The first allocation module is used to allocate the first processing resources corresponding to the available resources to the first offline task; The second allocation module is used to allocate other processing resources besides the first processing resource to the online task; The task execution module is configured to receive the first offline task sent by the scheduling server during the first target time period, execute the online task using the other processing resources, and execute the first offline task using the first processing resources. The task execution module is further configured to, during the execution of the online task and the first offline task, if the total resource usage of the online task and the first offline task is greater than the second threshold, stop executing at least one first offline task based on the resource usage of each first offline task, wherein the resource usage of the stopped first offline task is greater than the resource usage of the remaining first offline tasks that have not been stopped, so that the total resource usage of the online task and the remaining first offline task is not greater than the second threshold. The scheduling server is further configured to send a second offline task to a second online server, wherein the maximum allowable delay of the second offline task is greater than the second delay, and the second online server is an online server in an idle state, wherein the idle state refers to a state in which no online task has been deployed; the second online server is configured to stop executing the second offline task in response to a state switching notification, wherein the state switching notification is further configured to notify the server to switch from an idle state to a running state; The scheduling server is also used to send a third offline task to the offline server, wherein the maximum allowed delay of the third offline task is not greater than the first delay.
7. The apparatus according to claim 6, characterized in that, The time period determination module includes: The data collection unit is used to collect the resource usage of the online task at multiple time points; A time point determination unit is used to determine multiple consecutive target time points among the plurality of time points, wherein the resource usage corresponding to the target time points is less than the first threshold. The first determining unit is used to determine the time period consisting of the multiple target time points as the second target time period; The second determining unit is used to determine the same time period in the subsequent period of the second target time period as the first target time period.
8. The apparatus according to claim 6, characterized in that, The task execution module is also used for: If the total resource usage exceeds the second threshold, the offline task will be stopped.
9. A task processing device, characterized in that, The device includes: The scheduling request receiving module is used to receive a task scheduling request sent by a first online server. The task scheduling request carries a first target time period. During the first target time period, the resource usage of the online tasks of the first online server is less than a first threshold, and the first online server is in a state where online tasks have been deployed. The task sending module is used to send a first offline task to the first online server during the first target time period, and to stop sending the first offline task from the cutoff sending time point in the first target time period. The maximum allowable delay of the first offline task is greater than the first delay and not greater than the second delay. The duration between the cutoff sending time point and the end time point of the first target time period is the target duration. The task sending module is further configured to send a second offline task to a second online server, wherein the maximum allowable delay of the second offline task is greater than the second delay, and the second online server is an online server in an idle state, wherein the idle state refers to a state in which no online task has been deployed; the second online server is configured to stop executing the second offline task in response to a state switching notification, wherein the state switching notification is further configured to notify the server to switch from an idle state to a running state; The task sending module is also used to send a third offline task to the offline server, wherein the maximum allowable delay of the third offline task is not greater than the first delay; The first online server is used to subtract the resource usage and resource reservation of the online task from the total resources of the first online server to obtain the available resources of the first offline task; allocate the first processing resources corresponding to the available resources to the first offline task; allocate other processing resources besides the first processing resources to the online task; during the first target time period, receive the first offline task, execute the online task using the other processing resources besides the first processing resources, and execute the first offline task using the first processing resources; during the execution of the online task and the first offline task, if the total resource usage of the online task and the first offline task is greater than a second threshold, based on the resource usage of each first offline task, stop executing at least one first offline task, the resource usage of the stopped first offline task is greater than the resource usage of the remaining first offline tasks that have not been stopped, so that the total resource usage of the online task and the remaining first offline tasks is not greater than the second threshold.
10. A server, characterized in that, The server includes a processor and a memory, the memory storing at least one computer program, which is loaded and executed by the processor to perform the operations performed in the task processing method as described in any one of claims 1 to 3, or to perform the operations performed in the task processing method as described in claim 4.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to implement the operations performed in the task processing method as described in any one of claims 1 to 3, or to implement the operations performed in the task processing method as described in claim 4.
12. A computer program product, characterized in that, The computer program product includes computer program code stored in a computer-readable storage medium. The server's processor reads the computer program code from the computer-readable storage medium and executes the computer program code, causing the server to perform the operations performed in the task processing method as described in any one of claims 1 to 3, or to perform the operations performed in the task processing method as described in claim 4.
Citation Information
Patent Citations
Resource scheduling method, device and system for server cluster
CN107968810A