CN113975815B - Task transfer method, system, device, equipment and storage medium - Google Patents
Task transfer method, system, device, equipment and storage medium Download PDFInfo
- Publication number
- CN113975815B CN113975815B CN202111299936.5A CN202111299936A CN113975815B CN 113975815 B CN113975815 B CN 113975815B CN 202111299936 A CN202111299936 A CN 202111299936A CN 113975815 B CN113975815 B CN 113975815B
- Authority
- CN
- China
- Prior art keywords
- task
- target task
- transfer
- time
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/70—Game security or game management aspects
- A63F13/77—Game security or game management aspects involving data related to game devices or game servers, e.g. configuration data, software version or amount of memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Computer Security & Cryptography (AREA)
- General Business, Economics & Management (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application relates to a task transfer method, a system, a device, equipment and a storage medium. The method comprises the following steps: responding to a transfer instruction of the target task, and acquiring the current remaining execution time and transfer time of the target task; if the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server. By adopting the method, the deviation of the actual execution time of the target task in the local server is reduced, so that the actual execution time of the target task in the execution server is more accurate.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, a system, an apparatus, a device, and a storage medium for task transfer.
Background
With the increasing level of economy, more and more games are being played to meet the mental needs of people. However, as the game is released, the game needs to be adjusted through multiple iterative updates to meet the requirements of the game users.
In the related art, in the existing game iterative update process, there are two transfer modes of the timing task, the first transfer mode is to separate a logically processed server from an actually executed server, and the actually executed server is remotely scheduled by the logically processed server. The second transfer method is to execute the same transfer task simultaneously through multiple execution servers.
However, the task transferring method in the related art may cause the actual execution time to be inaccurate, and cause the jitter of the timing task to be large.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a task transferring method, system, device, apparatus, storage medium, and program product for improving the actual execution time of a timed task and avoiding jitter of the timed task.
In a first aspect, the present application provides a task transferring method, including:
responding to a transfer instruction of the target task, and acquiring the current remaining execution time and transfer time of the target task;
if the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server.
In one embodiment, the transfer conditions include at least one of:
the current residual execution time length and the transfer time length of the target task are in a preset multiple relation;
and the difference value between the current residual execution time length and the transfer time length of the target task is in a preset range.
In one embodiment, the obtaining of the current remaining execution duration and the transfer duration of the target task includes:
determining the current remaining execution duration of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to the task queue, and acquiring response time lengths of the plurality of test requests; and determining the transfer time length of the target task according to the response time length.
In one embodiment, the task information includes at least: the task transfer starting time when the target task is sent to the task queue, the time of the task queue corresponding to the task transfer starting time, the difference between the local time and the time of the task queue, the difference between the task transfer starting time and the next execution time of the target task, and the transfer duration of the target task.
In a second aspect, an embodiment of the present application provides a task transferring method, where the method includes:
acquiring a target task in a task queue and task information corresponding to the target task;
the target task and the task information corresponding to the target task are transferred to a task queue when the current residual execution time and the transfer time of the target task meet a preset transfer condition;
and acquiring the recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
In one embodiment, obtaining recovery information of a target task includes:
and determining a time difference value between the time of the execution server and the time of the task queue, a receiving time and a receiving duration of the execution server for receiving the target task, and the time of the task queue corresponding to the receiving time as the recovery information of the target task.
In one embodiment, calculating the accurate execution time of the target task according to the task information and the recovery information of the target task includes:
and calculating the accurate execution time of the target task through a preset time difference compensation formula according to the task information and the recovery information of the target task.
In a third aspect, an embodiment of the present application provides a task transfer system, where the system includes: the system comprises a local server, a task queue and an execution server;
the local server is used for responding to a transfer instruction of the target task, acquiring the current residual execution time length and the transfer time length of the target task, and transferring the target task and task information corresponding to the target task into the task queue when a preset transfer condition is met between the current residual execution time length and the transfer time length of the target task;
and the execution server is used for acquiring the target task in the task queue and the task information corresponding to the target task, acquiring the recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
In a fourth aspect, the present application further provides an apparatus comprising:
the information acquisition module is used for responding to a transfer instruction of the target task and acquiring the current residual execution time length and the transfer time length of the target task;
the task transferring module is used for transferring the target task and task information corresponding to the target task to the task queue if the current remaining execution time length and the transferring time length of the target task meet a preset transferring condition; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server.
In a fifth aspect, an embodiment of the present application provides a task transferring apparatus, including:
the queue information acquisition module is used for acquiring a target task in the task queue and task information corresponding to the target task; the target task and the task information corresponding to the target task are transferred to a task queue when a preset transfer condition is met between the current residual execution time and the transfer time of the target task;
and the execution time calculation module is used for acquiring the recovery information of the target task and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
In a sixth aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and the processor implements the following steps when executing the computer program:
responding to a transfer instruction of the target task, and acquiring the current remaining execution time and transfer time of the target task;
if the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server.
In a seventh aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program when executed by a processor implements the following steps:
responding to a transfer instruction of the target task, and acquiring the current remaining execution time and transfer time of the target task;
if the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server.
The application provides a task transfer method, a system, a device, equipment and a storage medium.A local server acquires the current residual execution time length and the transfer time length of a target task by responding to a transfer instruction of the target task, and transfers the target task and task information corresponding to the target task to a task queue when the current residual execution time length and the transfer time length of the target task meet a preset transfer condition. In the method, the local server determines whether the target task is transferred to the execution server to be executed or not according to the current residual execution time of the target task and the transfer duration of the target task, and the task information of the target task is transferred during the transfer, so that the deviation between the time for the execution server to acquire the target task from the task queue to execute and the actual execution time of the target task in the local server can be reduced after the target task is transferred to the execution server, the actual execution time of the target task in the execution server is more accurate, and the jitter phenomenon in the execution of the target task is avoided.
Drawings
FIG. 1 is a diagram of an application environment of a task transfer method in one embodiment;
FIG. 2 is a flowchart illustrating a task transfer method according to an embodiment;
FIG. 3 is a flowchart illustrating a task transfer method according to another embodiment;
FIG. 4 is an architecture diagram of a task transfer method in one embodiment;
FIG. 5 is a flowchart illustrating application of the task transfer method to a local server in one embodiment;
FIG. 6 is a flowchart illustrating application of a task transfer method to an execution server in one embodiment;
FIG. 7 is a block diagram showing the construction of a task transfer device according to one embodiment;
FIG. 8 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
The task transferring method provided by the embodiment of the application can be applied to the application environment shown in fig. 1. The local server communicates with the task queue, and the task queue communicates with the execution server. The local server responds to a transfer instruction of the target task and acquires the current remaining execution time and transfer time of the target task; if the local server determines that the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server. The local server and the execution server can be implemented by independent servers or a server cluster composed of a plurality of servers. The task queue can satisfy the storage and management functions of the target task, for example, the task queue is redis or a relational database MySQL.
The task transferring method provided by the embodiment of the application introduces the processes of the task transferring method from the perspective of the local server and the execution server respectively.
First, a method of transferring a task on the side where the execution subject is the local server will be described.
In one embodiment, as shown in fig. 2, a task transferring method is provided, which is described by applying the method to fig. 2, and comprises the following steps:
and 102, responding to the transfer instruction of the target task, and acquiring the current remaining execution time and the transfer time of the target task.
The target task is a task that the user wants to process. A branch instruction, which is an instruction to branch the execution subject of the target task or the position at which the target task is executed. The current remaining execution time length refers to a time period from a moment of responding to a transfer instruction of the target task to a local real execution moment, wherein the local real execution moment of the target task refers to a local original plan execution moment of the target task if the target task is not transferred. The transfer duration refers to the time consumed in the transfer process of the target task.
Specifically, the local server periodically monitors the transfer instruction, and if the local server triggers the transfer instruction of the target task based on the trigger information, the local server responds to the monitored transfer instruction of the target task. The local server acquires the moment of responding to the transfer instruction of the target task, the local real execution moment and the transfer duration, and acquires the current residual execution duration according to the two moments.
Specifically, in the process of game running development, a server needs to execute a large number of timing tasks, and if system updating and other operations which are not suitable for the timing tasks to be continuously executed in a local server need to be executed, a timing task transfer instruction is triggered. The local server periodically monitors the transfer instruction, and when the transfer instruction of the timing task is monitored, the local server responds to the monitored transfer instruction of the timing task. The local server obtains the transfer time length, the time responding to the transfer instruction of the timing task and the local real execution time, and obtains the current residual execution time length according to the two times. The obtained transfer duration of the timing task may be before a transfer instruction of the timing task is monitored.
104, if the current remaining execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server.
The preset transfer condition is a transfer condition of the target task which is set in advance according to the current remaining execution time length and the transfer time length of the target task so as to realize the transfer of the target task. The task information is time information associated with the transfer and execution time of the target task.
The local server judges whether a preset transfer condition is met or not according to the current residual execution time and the transfer time of the timing task, if the preset transfer condition is met between the current residual execution time and the transfer time of the target task, the operation of executing the transfer target task is determined, and the target task and time information corresponding to the target task and associated with the transfer and execution time of the target task are transferred to a task queue. The tasks stored in the task queue are tasks to be processed by the execution server.
Preferably, the task queue is a redis server, the application does not limit the type of the task queue, and the storage and management functions of the target task are satisfied. Optionally, the task queue is a relational database MySQL.
In the specific implementation process, the local server judges whether the current residual execution time is four times longer than the transfer time, if the current residual execution time is longer than the transfer time, the local server executes the operation of transferring the target task, and transfers the target task and the time information associated with the transfer and execution time of the target task to the redis server. The tasks stored in the task queue are tasks to be processed by the execution server. And if the previous residual execution time length is less than or equal to four times of the transfer time length, the operation of transferring the target task is not executed, and the target task is executed in the local server.
According to the task transferring method, the current residual execution time length and the transferring time length of the target task are obtained by responding to the transferring instruction of the target task, and when the current residual execution time length and the transferring time length of the target task meet the preset transferring condition, the target task and the task information corresponding to the target task are transferred to the task queue. In the method, the local server determines whether the target task is transferred to the execution server to be executed or not according to the current residual execution time of the target task and the transfer time for transferring the target task, and the task information of the target task is transferred during the transfer, so that the deviation between the time for the execution server to obtain the target task from the task queue to execute and the actual execution time of the target task in the local server can be reduced after the target task is transferred to the execution server, the actual execution time of the target task in the execution server is more accurate, and the phenomenon of jitter in the execution of the target task is avoided.
In one embodiment, the transfer conditions include at least one of: the current remaining execution time length and the transfer time length of the target task are in a preset multiple relation; the difference value between the current residual execution time length and the transfer time length of the target task is in a preset range.
The preset multiple relationship is the minimum time for executing the target task summarized according to experience, and the specific multiple relationship is not limited in the application, and may be changed along with the progress of the technology.
Preferably, the current remaining execution duration of the target task is greater than 4 times the transfer duration.
The preset range is the minimum time for completing the target task, which is summarized according to experience, and the specific preset range is not limited in the present application, and may be changed along with the progress of the technology.
Preferably, the difference between the current remaining execution time period and the transfer time period of the target task is 10ms.
The task transfer method specifically limits the transfer conditions, increases the transfer success rate of the target task, and reduces the possibility that the transfer process exceeds the accurate execution time of the target task.
In one embodiment, the obtaining of the current remaining execution duration and the transfer duration of the target task includes: determining the current residual execution time of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to the task queue, and acquiring response time lengths of the plurality of test requests; and determining the transfer time length of the target task according to the response time length.
Wherein the current time refers to a time of day in response to a branch instruction of the target task. The next execution time of the target task refers to the original scheduled execution time of the target task in the local server if the target task is not transferred. The test request refers to a sample of a transfer test request sent to the task queue by the local server. The response time of the test request, and the transfer test request time spent by the local server sending the test request sample to the task queue.
Specifically, the terminal determines the current remaining execution time of the target task according to the difference between the time of responding to the transfer instruction of the target task and the original planned execution time of the target task in the local server. Optionally, the terminal sends a plurality of test requests to the task queue before the time of responding to the transfer instruction of the target task, obtains the transfer test request time spent by the local server sending the test request sample to the task queue, and takes the transfer test request time as the transfer duration.
Optionally, the local server sends N test requests to the task queue, and obtains N transfer test request times that the local server spends sending the test request samples to the task queue. Where N is a positive integer of 1 or more, for example, N =100, and ta is a time for each transfer test request, N transfer test request times are: () Then, the average of 100 transfer test request times may be averagedAs the transfer duration. Then, the transition duration may be calculated according to equation (1), where equation (1) is as follows:
in the task transferring method, the current residual execution time of the target task is determined according to the current time and the next execution time of the target task, and the response time of a plurality of test requests is obtained by sending the plurality of test requests to the task queue; and determining the transfer time length of the target task according to the response time length. Therefore, the current residual execution time and the transfer time are obtained, and enough time is ensured to transfer the target task, so that the accurate execution time of the target task is more accurate.
In one embodiment, the task information includes at least: the task transfer starting time of the target task sent to the task queue, the time of the task queue corresponding to the task transfer starting time, the difference value between the local time and the task queue time, the difference value between the task transfer starting time and the next execution time of the target task, and the transfer duration of the target task.
In a specific implementation process, the manner of obtaining the time redisTime1 of the task queue corresponding to the task transfer start time Sendtime is that the local server uses the lua script to obtain the first time redisTime1 of the task queue at the task transfer start time when the target task is sent to the task queue.
In a specific implementation process, the manner of obtaining the difference value of the local time and the task queue time, namely, the local server obtains the current time redisTime of the task queue through the task queue time obtaining program, obtains the start time timestamp of executing the task queue time obtaining program and the end time timeEnd of returning the task queue time obtaining program obtaining result, and calculates the timeseveredis 1 according to the timeStart, the redisTime and the timeEnd. Wherein the difference between the local time and the task queue time may be calculated according to equation (2), equation (2) being as follows:
optionally, the task queue time obtaining program is executed 100 times, corresponding 100 timeSeverRedis1 are calculated, and the smallest storage of the 100 timeSeverRedis1 is taken as the timeSeverRedis1. Optionally, timeSeverRedis1 may be completed before the local server executes the branch instruction in response to the target task.
In a specific implementation, the difference between the task transition start time Sendtime and the next execution time of the target task is represented by delay.
According to the implementation process, the obtaining of the task information at least comprises the following steps: sendtime, redisTime1, timeSeverRedis1, delay, timeAvg1.
According to the task transfer method, the task information related to the target task transfer time is specifically limited, and finer granularity is prepared for the execution server to calculate the accurate execution time of the target task according to the task information, so that the actual execution time is more accurate.
An embodiment relating to a task transfer method in which the execution subject is the execution server side will be described below. It should be noted that, in practical applications, the local server and the execution server are mutually interactive, so that the implementation principle and the process of some features related to the embodiment on the local server side will not be redundantly described in the embodiment on the execution server side, and can be understood by combining the embodiment on the local server side.
In one embodiment, as shown in fig. 3, there is provided a task transferring method for executing a server, including the steps of:
step 202, acquiring a target task in a task queue and task information corresponding to the target task; the target task and the task information corresponding to the target task are transferred to the task queue when the current residual execution time and the transfer time of the target task meet a preset transfer condition.
In the specific game running development process, a server side needs to execute massive timing tasks, and if system updating and other operations which are not suitable for the timing tasks to be continuously executed in a local server need to be executed, a timing task transfer instruction is triggered. The local server periodically monitors the transfer instruction, and when the transfer instruction of the timing task is monitored, the local server responds to the monitored transfer instruction of the timing task. The local server acquires the transfer duration, the moment of responding to the transfer instruction of the timing task and the local real execution moment, and acquires the current residual execution duration according to the two moments. The local server judges whether a preset transfer condition is met or not according to the current residual execution time and the transfer time of the timing task, if the preset transfer condition is met between the current residual execution time and the transfer time of the target task, the operation of executing the transfer target task is determined, and the target task and time information corresponding to the target task and associated with the transfer and execution time of the target task are transferred to a task queue. The execution server periodically accesses the task queue, and when the execution server monitors that the task queue comprises the transfer task and the corresponding task information, the execution server acquires the target task in the task queue and the task information corresponding to the target task.
And step 204, acquiring the recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
Wherein the recovery information refers to associated time information for the transfer of the target task from the task queue to the execution server.
And the execution server calculates the accurate execution time of the target task according to the task information and the recovery information of the target task.
In the task transferring method, the execution server calculates the accurate execution time of the target task according to the task information and the recovery information, and the deviation of the accurate execution time of the target task in the local server is reduced, so that the actual execution time of the target task in the execution server is more accurate.
Acquiring recovery information of a target task, comprising: and determining the time difference between the time of the execution server and the time of the task queue, the picking time and picking duration of the execution server for picking the target task, and the time of the task queue corresponding to the picking time as the recovery information of the target task.
In a specific implementation process, the manner of obtaining the difference value of the time of the execution server and the task queue time, namely, the execution server obtains the current time redisTimeZ of the task queue through the task queue time obtaining program, obtains the start time timeStart2 of the execution task queue time obtaining program and the end time timeEnd2 of the return task queue time obtaining program, and calculates the timeSeverRedis2 according to the timeStart, the redisTime and the timeEnd. Specifically, the timeSeverRedis2 can be calculated according to the following formula (3).
Optionally, the task queue time obtaining program is executed 100 times, corresponding 100 timeSeverRedis2 are calculated, and the smallest storage of the 100 timeSeverRedis2 is taken as the timeSeverRedis2. Optionally, the timeSeverRedis2 may be completed before the execution server performs the step of acquiring the target task and task information corresponding to the target task in the task queue.
In a specific implementation process, the pick-up time when the execution server picks up the target task is recorded as receiveTime.
In a specific implementation process, the obtaining mode of the obtaining time for the execution server to obtain the target task is that the execution server sends a plurality of test requests to the task queue, obtains the transfer test request time spent by the execution server to send the test request sample to the task queue, and takes the transfer test request time as the obtaining time. Optionally, the server sends 100 test requests to the task queue, and obtains 100 transfer test request times (which are taken by the execution server to send the test request samples to the task queue: () The average value of 100 transfer test request times, timeAvg2, is taken as the pickup time length. The pickup duration can be calculated according to a formula (4), wherein the formula (4) is as follows:
in a specific implementation process, the manner of obtaining the time redisTime2 of the task queue corresponding to the getting time of the target task is that the execution server uses the lua script to obtain the first time redisTime2 of the task queue at the getting time of the target task.
According to the implementation process, receiveTime, timeSeverRedis2, timeAvg2, and redisime 2 are determined as the recovery information of the target task.
In the task transferring method, the recovery information related to the target task getting time is specifically limited, and finer granularity preparation is made for the execution server to calculate the accurate execution time of the target task according to the task information and the reply information, so that the actual execution time is more accurate.
In one embodiment, calculating the accurate execution time of the target task according to the task information and the recovery information of the target task comprises: and calculating the accurate execution time of the target task through a preset time difference compensation formula according to the task information and the recovery information of the target task.
Wherein the preset time difference compensation can be calculated according to formula (5), and formula (5) is as follows: (5)
the parameters in formula (5) are obtained according to formulas (6), (7) and (8), and the formulas (6), (7) and (8) are as follows:
the realDelay in the formula is a difference value between a receiving time when the execution server receives the target task and an accurate execution time of the target task in the execution server. Z is the length of time it takes for the target task to transfer from the local server to the task queue. R is the time spent by the target task in the task queue. H is the length of time it takes for the target task to transfer from the task queue to the execution server. The numerical source of each element in the preset moveout compensation formula can be obtained from the above-described embodiment.
According to the task transfer method, the accurate execution time of the target task is calculated through the preset time difference compensation formula according to the task information and the recovery information of the target task, the time difference between the local server and the execution server is reduced, the execution jitter of the target task is reduced, a user cannot feel the execution jitter of the target task, and the game can run more smoothly.
In one embodiment, which is described by taking fig. 4, 5 and 6 as an example, after the server a performs system initialization, the server a locally executes the timing tasks schedule1, schedule2 and schedule3. At a certain moment, the server A monitors the instruction, judges whether the instruction is a timing task transfer instruction, if the instruction is not the timing task transfer instruction, the execution state of the timing task is recovered, and the server A continues to finish the timing task. And if the timing task is the timing task transfer instruction, executing timing task transfer operation. And detecting the tasks in the server A to determine the timing tasks, and acquiring the residual execution time of each timing task in the server A. And calculating the residual execution time of each timing task in the server A according to the difference between the first time when the server A monitors the transfer timing task instruction and the next execution time, namely the second time, of the timing task in the server A. The execution server obtains the transfer duration of the timing task from the server A to the redis server. The method for obtaining the transfer duration includes that the local server sends 100 test requests to the task queue, and obtains 100 transfer test request times (which are spent by the local server sending the test request samples to the task queue) Average of 100 transfer test request timesAs the transfer duration. The calculation formula is consistent with that in the above embodiment, and is not described herein again. The server A judges whether the residual execution time length of each timing task in the server A is greater than four times of the transfer time length, if so, the timing task is transferred to redis, otherwise, the timing task is transferred to the redisThe timed task is run on the local server. In the process of transferring the timing task to redis, task information of the timing task also needs to be calculated, and a specific algorithm of the task information is the same as that in the above embodiment and is not described again here.
The server B periodically acquires the timing task from the redis ordered list, judges whether the timing task exists in the redis ordered list or not, and blocks and waits until the timing task is overtime if the timing task does not exist in the redis ordered list. If the redis ordered list has a timing task, the server B receives the timing task and corresponding task information, acquires corresponding recovery information, and calculates an accurate execution time of the timing task in the server B according to the task information, the corresponding recovery information, and a preset time difference compensation formula, where a specific calculation process is the same as that described in the above embodiment, and is not described herein again. And the server B acquires the timing task, executes the timing task according to the accurate execution time, and then continues to acquire the timing task from the redis ordered list.
In the task transferring method, the execution server calculates the accurate execution time of the target task according to the task information and the recovery information, so that the actual execution time of the target task in the execution server is more accurate, and the deviation from the actual execution time of the target task in the local server is reduced.
It should be understood that, although the steps in the flowcharts related to the embodiments as described above are sequentially displayed as indicated by arrows, the steps are not necessarily performed sequentially as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the embodiments described above may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution order of the steps or stages is not necessarily sequential, but may be rotated or alternated with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the present application further provides a task transferring system for implementing the above related task transferring method. The implementation scheme for solving the problem provided by the system is similar to the implementation scheme described in the above method, so specific limitations in one or more embodiments of the task transfer system provided below can be referred to the above limitations on the task transfer method, and are not described herein again.
In addition, an embodiment of the present application further provides a task transfer system, where the system includes: the system comprises a local server, a task queue and an execution server;
the local server is used for responding to a transfer instruction of the target task, acquiring the current residual execution time length and the transfer time length of the target task, and transferring the target task and task information corresponding to the target task into the task queue when a preset transfer condition is met between the current residual execution time length and the transfer time length of the target task;
and the execution server is used for acquiring the target task in the task queue and the task information corresponding to the target task, acquiring the recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
For specific limitations of the task transferring system in this embodiment, reference may be made to the above limitations on the task transferring method, which is not described herein again.
Based on the same inventive concept, the embodiment of the application also provides a task transferring device for realizing the above related task transferring method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so specific limitations in one or more embodiments of the task transferring device provided below can be referred to the above limitations on the task transferring method, and are not described herein again.
In one embodiment, as shown in fig. 7, there is provided a task transfer apparatus including: the information acquisition module 100 and the task transfer module 200, wherein:
the information acquisition module 100 is configured to respond to a transfer instruction of a target task, and acquire a current remaining execution duration and a transfer duration of the target task;
the task transferring module 200 is configured to transfer the target task and task information corresponding to the target task to a task queue if a preset transfer condition is satisfied between the current remaining execution duration and the transfer duration of the target task; the tasks stored in the task queue are tasks to be processed by the execution server.
In one embodiment, the transfer conditions include at least one of:
the current remaining execution time length and the transfer time length of the target task are in a preset multiple relation;
the difference value between the current residual execution time length and the transfer time length of the target task is in a preset range.
In one embodiment, the information obtaining module 100 includes:
the time length determining submodule is used for determining the current residual execution time length of the target task according to the current time and the next execution time of the target task;
the transfer duration determining module is used for sending a plurality of test requests to the task queue and acquiring the response durations of the test requests; and determining the transfer time length of the target task according to the response time length.
In one embodiment, the task information includes at least: the task transfer starting time when the target task is sent to the task queue, the time of the task queue corresponding to the task transfer starting time, the difference between the local time and the time of the task queue, the difference between the task transfer starting time and the next execution time of the target task, and the transfer duration of the target task.
In one embodiment, the apparatus comprises:
the second information acquisition module is used for acquiring a target task in the task queue and task information corresponding to the target task; the target task is a task queue, wherein the local server responds to a transfer instruction of the target task to acquire the current residual execution time length and the transfer time length of the target task, and when the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, task information corresponding to the target task and the target task is transferred to the task queue;
and the time calculation module is used for acquiring the recovery information of the target task and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
In one embodiment, the second information obtaining module includes:
and determining a time difference value between the time of the execution server and the time of the task queue, a receiving time and a receiving duration of the execution server for receiving the target task, and the time of the task queue corresponding to the receiving time as the recovery information of the target task.
In one embodiment, the time calculation module includes:
and calculating the accurate execution time of the target task through a preset time difference compensation formula according to the task information and the recovery information of the target task.
The various modules in the task transferring apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent of a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure thereof may be as shown in fig. 8. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing the timing tasks and the corresponding data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a task transfer method.
Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
responding to a transfer instruction of the target task, and acquiring the current remaining execution time and transfer time of the target task;
if the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server.
In one embodiment, the transfer conditions include at least one of: the current residual execution time length and the transfer time length of the target task are in a preset multiple relation; and the difference value between the current residual execution time length and the transfer time length of the target task is in a preset range.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
determining the current residual execution time of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to the task queue, and acquiring response time lengths of the plurality of test requests; and determining the transfer time length of the target task according to the response time length.
In one embodiment, the task information includes at least: the task transfer starting time when the target task is sent to the task queue, the time of the task queue corresponding to the task transfer starting time, the difference between the local time and the time of the task queue, the difference between the task transfer starting time and the next execution time of the target task, and the transfer duration of the target task.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring a target task in a task queue and task information corresponding to the target task; the target task is a task queue, wherein the local server responds to a transfer instruction of the target task to acquire the current residual execution time length and the transfer time length of the target task, and when the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, task information corresponding to the target task and the target task is transferred to the task queue; and acquiring the recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and determining a time difference value between the time of the execution server and the time of the task queue, a receiving time and a receiving duration of the execution server for receiving the target task, and the time of the task queue corresponding to the receiving time as the recovery information of the target task.
In one embodiment, the processor when executing the computer program further performs the steps of:
and calculating the accurate execution time of the target task through a preset time difference compensation formula according to the task information and the recovery information of the target task.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
responding to a transfer instruction of the target task, and acquiring the current remaining execution time and transfer time of the target task; if the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to a task queue; and the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server.
In one embodiment, the transfer conditions include at least one of: the current remaining execution time length and the transfer time length of the target task are in a preset multiple relation; the difference value between the current residual execution time length and the transfer time length of the target task is in a preset range.
In one embodiment, the computer program when executed by the processor further performs the steps of:
determining the current remaining execution duration of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to the task queue, and acquiring response time lengths of the plurality of test requests; and determining the transfer time length of the target task according to the response time length.
In one embodiment, the task information includes at least: the task transfer starting time of the target task sent to the task queue, the time of the task queue corresponding to the task transfer starting time, the difference value between the local time and the task queue time, the difference value between the task transfer starting time and the next execution time of the target task, and the transfer duration of the target task.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring a target task in a task queue and task information corresponding to the target task; the target task is a task queue, wherein the local server responds to a transfer instruction of the target task to acquire the current residual execution time length and the transfer time length of the target task, and when the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, task information corresponding to the target task and the target task is transferred to the task queue; and acquiring the recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and determining the time difference between the time of the execution server and the time of the task queue, the picking time and picking duration of the execution server for picking the target task, and the time of the task queue corresponding to the picking time as the recovery information of the target task.
In one embodiment, the computer program when executed by the processor further performs the steps of: and calculating the accurate execution time of the target task through a preset time difference compensation formula according to the task information and the recovery information of the target task.
It should be noted that, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include a Read-Only Memory (ROM), a magnetic tape, a floppy disk, a flash Memory, an optical Memory, a high-density embedded nonvolatile Memory, a resistive Random Access Memory (ReRAM), a Magnetic Random Access Memory (MRAM), a Ferroelectric Random Access Memory (FRAM), a Phase Change Memory (PCM), a graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing based data processing logic devices, etc., without limitation.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims (11)
1. A method of task transfer, the method comprising:
responding to a transfer instruction of a target task, and acquiring the current remaining execution time and transfer time of the target task; the obtaining of the current remaining execution duration and the transfer duration of the target task includes: determining the current residual execution time of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to a task queue, and acquiring response time lengths of the test requests; determining the transfer time length of the target task according to the response time length; the target task is a timing task;
if the current remaining execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task to the task queue; the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server; the task information is time information associated with the transfer and execution time of the target task.
2. The method of claim 1, the transfer condition comprising at least one of:
the current residual execution time length of the target task and the transfer time length are in a preset multiple relation;
and the difference value between the current residual execution time length of the target task and the transfer time length is in a preset range.
3. The method according to claim 1 or 2, the task information comprising at least: the target task is sent to the task transfer starting time of the task queue, the time of the task queue corresponding to the task transfer starting time, the difference between the local time and the task queue time, the difference between the task transfer starting time and the next execution time of the target task, and the transfer duration of the target task.
4. A method of task transfer, the method comprising:
acquiring a target task in a task queue and task information corresponding to the target task;
the target task and task information corresponding to the target task are a transfer instruction of a local server responding to the target task, and the current residual execution time length and the transfer time length of the target task are obtained; the obtaining of the current remaining execution duration and the transfer duration of the target task includes: determining the current remaining execution duration of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to a task queue, and acquiring response time lengths of the test requests; determining the transfer duration of the target task according to the response duration and the transfer process; when the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task into the task queue; the task information is time information associated with the transfer and execution time of the target task; wherein the target task is a timing task;
and acquiring the recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
5. The method of claim 4, the obtaining recovery information for the target task, comprising:
and determining a time difference between the time of the execution server and the time of the task queue, the picking time and picking duration of the target task picked by the execution server, and the time of the task queue corresponding to the picking time as the recovery information of the target task.
6. The method according to claim 4 or 5, wherein the calculating of the accurate execution time of the target task according to the task information and the recovery information of the target task comprises:
and calculating the accurate execution time of the target task through a preset time difference compensation formula according to the task information and the recovery information of the target task.
7. A task transfer system, characterized in that the system comprises: the system comprises a local server, a task queue and an execution server;
the local server is used for responding to a transfer instruction of a target task and acquiring the current residual execution time length and the transfer time length of the target task; the obtaining of the current remaining execution duration and the transfer duration of the target task includes: determining the current residual execution time of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to a task queue, and acquiring response time lengths of the test requests; determining the transfer duration of the target task according to the response duration and the transfer process; when the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task into the task queue; the task information is time information associated with the transfer and execution time of the target task; wherein the target task is a timing task;
the execution server is used for acquiring a target task in the task queue and task information corresponding to the target task, acquiring recovery information of the target task, and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
8. A task transfer apparatus, characterized in that the apparatus comprises:
the information acquisition module is used for responding to a transfer instruction of a target task and acquiring the current residual execution time length and the transfer time length of the target task; the obtaining of the current remaining execution duration and the transfer duration of the target task includes: determining the current remaining execution duration of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to a task queue, and acquiring response time lengths of the plurality of test requests; determining the transfer duration of the target task according to the response duration and the transfer process; wherein the target task is a timing task;
the task transferring module is used for transferring the target task and task information corresponding to the target task to a task queue if the current remaining execution time length and the transferring time length of the target task meet a preset transferring condition; the tasks and the corresponding task information stored in the task queue are tasks to be processed by the execution server; the task information is time information associated with the transfer and execution time of the target task.
9. A task transfer apparatus, characterized in that the apparatus comprises:
the queue information acquisition module is used for acquiring a target task in a task queue and task information corresponding to the target task; the target task and task information corresponding to the target task are transfer instructions of a local server responding to the target task, and the current remaining execution time length and the transfer time length of the target task are obtained; the obtaining of the current remaining execution duration and the transfer duration of the target task includes: determining the current remaining execution duration of the target task according to the current time and the next execution time of the target task; sending a plurality of test requests to a task queue, and acquiring response time lengths of the test requests; determining the transfer duration of the target task according to the response duration and the transfer process; when the current residual execution time length and the transfer time length of the target task meet a preset transfer condition, transferring the target task and task information corresponding to the target task into the task queue; the task information is time information associated with the transfer and execution time of the target task; wherein the target task is a timing task;
and the execution time calculation module is used for acquiring the recovery information of the target task and calculating the accurate execution time of the target task according to the task information and the recovery information of the target task.
10. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 3 or 4 to 6.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 3 or 4 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111299936.5A CN113975815B (en) | 2021-11-04 | 2021-11-04 | Task transfer method, system, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111299936.5A CN113975815B (en) | 2021-11-04 | 2021-11-04 | Task transfer method, system, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113975815A CN113975815A (en) | 2022-01-28 |
CN113975815B true CN113975815B (en) | 2022-12-23 |
Family
ID=79746456
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111299936.5A Active CN113975815B (en) | 2021-11-04 | 2021-11-04 | Task transfer method, system, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113975815B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106357721A (en) * | 2016-08-11 | 2017-01-25 | 北京小米移动软件有限公司 | Timing method and device |
CN107391031A (en) * | 2017-06-27 | 2017-11-24 | 北京邮电大学 | Data migration method and device in a kind of computing system based on mixing storage |
CN109992390A (en) * | 2019-04-23 | 2019-07-09 | 广州裕睿信息科技有限公司 | Timed task dispatching method and timed task processing method |
WO2020019519A1 (en) * | 2018-07-27 | 2020-01-30 | 平安科技(深圳)有限公司 | Task allocation method and apparatus |
CN113448749A (en) * | 2021-06-04 | 2021-09-28 | 山东英信计算机技术有限公司 | Method, system, device and medium for optimizing execution of expected timing task |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103870327A (en) * | 2012-12-18 | 2014-06-18 | 华为技术有限公司 | Real-time multitask scheduling method and device |
CN103473345B (en) * | 2013-09-23 | 2017-03-29 | 融创天下(上海)科技发展有限公司 | A kind of method for estimating duration |
CN110309024B (en) * | 2019-04-23 | 2023-07-18 | 网宿科技股份有限公司 | Data processing system and method for executing data processing task |
CN112214291A (en) * | 2019-07-12 | 2021-01-12 | 杭州海康汽车技术有限公司 | Task scheduling method and device |
-
2021
- 2021-11-04 CN CN202111299936.5A patent/CN113975815B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106357721A (en) * | 2016-08-11 | 2017-01-25 | 北京小米移动软件有限公司 | Timing method and device |
CN107391031A (en) * | 2017-06-27 | 2017-11-24 | 北京邮电大学 | Data migration method and device in a kind of computing system based on mixing storage |
WO2020019519A1 (en) * | 2018-07-27 | 2020-01-30 | 平安科技(深圳)有限公司 | Task allocation method and apparatus |
CN109992390A (en) * | 2019-04-23 | 2019-07-09 | 广州裕睿信息科技有限公司 | Timed task dispatching method and timed task processing method |
CN113448749A (en) * | 2021-06-04 | 2021-09-28 | 山东英信计算机技术有限公司 | Method, system, device and medium for optimizing execution of expected timing task |
Also Published As
Publication number | Publication date |
---|---|
CN113975815A (en) | 2022-01-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9208189B2 (en) | Distributed request processing | |
US8255920B2 (en) | Time management control method for computer system, and computer system | |
CN108809855A (en) | Information management method, device and electronic equipment | |
CN106339493B (en) | A kind of data processing method and relevant apparatus | |
CN114416324A (en) | Task triggering method and device, computer equipment and storage medium | |
CN110474820B (en) | Flow playback method and device and electronic equipment | |
CN109697140B (en) | Data backup method and device, data recovery method and device and storage medium | |
CN113901395B (en) | Data processing method, data processing device, computer equipment and storage medium | |
CN107092628A (en) | The treating method and apparatus of time series data | |
US8868525B2 (en) | Distributed information synchronization | |
WO2017028619A1 (en) | Desktop display method and apparatus for smart television | |
CN112148350A (en) | Remote version management method for works, electronic device and computer storage medium | |
CN113975815B (en) | Task transfer method, system, device, equipment and storage medium | |
US8825603B2 (en) | Ordering volumes and tracks for data transfer based on usage characteristics | |
US10127270B1 (en) | Transaction processing using a key-value store | |
CN113650808A (en) | Task-driven-oriented dynamic emergency method and system for remote sensing satellite | |
CN112711739B (en) | Data processing method and device, server and storage medium | |
US20230281081A1 (en) | Electronic device and method with on-demand accelerator checkpointing | |
US10922190B1 (en) | Updating database records while maintaining accessible temporal history | |
CN114490041A (en) | Array calculation method, device, equipment, medium and computer program product | |
CN112044061A (en) | Game picture processing method and device, electronic equipment and storage medium | |
CN115994267B (en) | Real-time user image depicting method, device, computer equipment and storage medium | |
CN114816710A (en) | Timed task execution method, timed task execution device, timed task execution equipment, timed task storage medium and timed task program product | |
CN114840054B (en) | Time synchronization method, device, system, equipment and storage medium | |
JP6913791B1 (en) | Processing equipment, processing methods and programs |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |