CN114237851A - Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium - Google Patents

Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium Download PDF

Info

Publication number
CN114237851A
CN114237851A CN202111562377.2A CN202111562377A CN114237851A CN 114237851 A CN114237851 A CN 114237851A CN 202111562377 A CN202111562377 A CN 202111562377A CN 114237851 A CN114237851 A CN 114237851A
Authority
CN
China
Prior art keywords
task
timing task
timing
execution
server
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.)
Pending
Application number
CN202111562377.2A
Other languages
Chinese (zh)
Inventor
金丽娜
宋增芳
刘素园
朴春光
王睿
文静
黄翀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sunshine Life Insurance Co ltd
Original Assignee
Sunshine Life Insurance Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Sunshine Life Insurance Co ltd filed Critical Sunshine Life Insurance Co ltd
Priority to CN202111562377.2A priority Critical patent/CN114237851A/en
Publication of CN114237851A publication Critical patent/CN114237851A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • G06F9/4887Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues involving deadlines, e.g. rate based, periodic

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The method comprises the steps of receiving a timing task execution instruction which is distributed by a task scheduling center aiming at least one timing task, wherein the timing task execution instruction is distributed when the task scheduling center determines that the at least one timing task reaches the corresponding execution time; based on the timing task execution instruction, acquiring task data corresponding to at least one timing task from a database; executing at least one timing task based on task data by adopting a coroutine mode to obtain an execution result of the at least one timing task; and storing the execution result of the at least one timing task to a database. Thus, when the timing task is executed, the execution efficiency of the timing task can be improved.

Description

Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for executing a timing task.
Background
With the rapid development of internet technology, more and more timing tasks need to be processed in a server, and usually, in the execution process of the timing tasks, read-write operations need to be performed on a database.
In the prior art, when a timing task is executed, a large amount of read-write interaction with a database is usually required.
However, in the process of interacting with the database, the resource of the database is occupied greatly, the pressure of the database is increased, the interaction time is too frequent, and the execution efficiency of the timing task is low.
Therefore, how to improve the execution efficiency of the timing task when the timing task is executed is a technical problem to be solved.
Disclosure of Invention
An embodiment of the present application provides a method, an apparatus, a device, and a storage medium for executing a timing task, so as to improve the execution efficiency of the timing task when the timing task is executed.
In one aspect, a method for executing a timing task is provided, including:
receiving a timing task execution instruction distributed by a task scheduling center aiming at least one timing task, wherein the timing task execution instruction is distributed when the task scheduling center determines that the at least one timing task reaches corresponding execution time;
based on the timing task execution instruction, acquiring task data corresponding to at least one timing task from a database;
executing at least one timing task based on task data by adopting a coroutine mode to obtain an execution result of the at least one timing task;
and storing the execution result of the at least one timing task to a database.
In the implementation process, the server acquires the task data corresponding to the timing task from the database, adopts a multi-protocol mode, and concurrently executes the timing task, thereby greatly improving the execution efficiency of the timing task.
In one embodiment, a coroutine method is adopted to execute at least one timing task based on task data and obtain an execution result of the at least one timing task, and the method includes:
for each of the at least one timing task, respectively, performing the following steps:
splitting a timing task to obtain a plurality of subtasks of the timing task;
respectively creating at least one coroutine for each subtask;
and respectively executing each subtask by adopting each coroutine based on task data corresponding to one timing task.
In the implementation process, the server divides the timing task into a plurality of subtasks, and creates a coroutine for each subtask, and the coroutines are executed concurrently, so that the execution efficiency of the timing task is improved.
In one embodiment, before executing each subtask respectively based on task data corresponding to one timed task by using each coroutine, the method further includes:
respectively aiming at task data corresponding to each timing task in at least one timing task, creating a task data array;
acquiring an array address of a task data array corresponding to at least one timing task;
based on task data corresponding to a timing task, adopting each coroutine to respectively execute each subtask, wherein the task data comprises the following steps:
and calling task data corresponding to one timing task by adopting each coroutine according to an array address corresponding to the timing task, and executing each subtask respectively, wherein data transmission is carried out between different subtasks through a pipeline.
In the implementation process, when the server executes the timing task, the server creates a task data array aiming at task data corresponding to the timing task, obtains the task data according to the data address, and concurrently executes each subtask.
In one aspect, a method for executing a timing task is provided, including:
respectively acquiring the execution time of each timing task;
when at least one timing task reaches corresponding execution time, generating a timing task execution instruction aiming at the at least one timing task;
sending a timed task execution instruction to at least one server, so that the server executes the following steps: based on the timing task execution instruction, acquiring task data corresponding to at least one timing task from a database; executing at least one timing task based on the task data to obtain an execution result of the at least one timing task; and storing the execution result of the at least one timing task to a database.
In the implementation process, the task scheduling center sends a timing task execution instruction to the server, and the scheduling server executes the timing task based on the timing task execution instruction.
In one aspect, an apparatus for executing a timed task is provided, including:
the system comprises a receiving unit, a task scheduling center and a processing unit, wherein the receiving unit is used for receiving a timing task execution instruction distributed by the task scheduling center aiming at least one timing task, and the timing task execution instruction is distributed when the task scheduling center determines that the at least one timing task reaches the corresponding execution time;
the acquisition unit is used for acquiring task data corresponding to at least one timing task from a database based on a timing task execution instruction;
the execution unit is used for executing at least one timing task based on the task data in a coroutine mode to obtain an execution result of the at least one timing task;
and the storage unit is used for storing the execution result of at least one timing task to the database.
In one embodiment, the execution unit is specifically configured to:
for each of the at least one timing task, respectively, performing the following steps:
splitting a timing task to obtain a plurality of subtasks of the timing task;
respectively establishing a coroutine aiming at each subtask;
and respectively executing each subtask by adopting each coroutine based on task data corresponding to one timing task.
In one embodiment, the execution unit is further configured to:
respectively aiming at task data corresponding to each timing task in at least one timing task, creating a task data array;
acquiring an array address of a task data array corresponding to at least one timing task;
based on task data corresponding to a timing task, adopting each coroutine to respectively execute each subtask, wherein the task data comprises the following steps:
and calling task data corresponding to one timing task by adopting each coroutine according to an array address corresponding to the timing task, and executing each subtask respectively, wherein data transmission is carried out between different subtasks through a pipeline.
In one aspect, an apparatus for executing a timed task is provided, including:
the acquisition unit is used for respectively acquiring the execution time of each timing task;
the generating unit is used for generating a timing task execution instruction aiming at least one timing task when the at least one timing task reaches the corresponding execution time;
a sending unit, configured to send a timed task execution instruction to one server of the at least one server, so that the one server performs the following steps: based on the timing task execution instruction, acquiring task data corresponding to at least one timing task from a database; executing at least one timing task based on the task data to obtain an execution result of the at least one timing task; and storing the execution result of the at least one timing task to a database.
In one aspect, an electronic device is provided, comprising a processor and a memory, the memory storing computer readable instructions which, when executed by the processor, perform the steps of the method provided in any of the various alternative implementations of the timing task described above.
In one aspect, a readable storage medium is provided, on which a computer program is stored, which when executed by a processor performs the steps of the method as provided in any of the various alternative implementations described above for the timed task.
In one aspect, a computer program product is provided which, when run on a computer, causes the computer to perform the steps of the method provided in the various alternative implementations of performing any of the timing tasks described above.
In the method, the device, the equipment and the storage medium for executing the timing task, a timing task execution instruction which is distributed by a task scheduling center aiming at least one timing task is received, wherein the timing task execution instruction is distributed when the task scheduling center determines that the at least one timing task reaches the corresponding execution time; based on the timing task execution instruction, acquiring task data corresponding to at least one timing task from a database; executing at least one timing task based on task data by adopting a coroutine mode to obtain an execution result of the at least one timing task; and storing the execution result of at least one timing task to the database. Therefore, the task data can be obtained from the database, the timing task is concurrently executed in a multi-protocol mode, and the execution efficiency of the timing task is improved.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is an application scenario diagram of a method for executing a timing task according to an embodiment of the present application;
fig. 2 is a flowchart of an implementation of a method for executing a timing task according to an embodiment of the present application;
fig. 3 is an implementation flowchart of a method for implementing batch execution of timed tasks in go language according to an embodiment of the present application;
fig. 4 is a diagram illustrating an example of a method for scheduling a remote host by a task scheduling center according to an embodiment of the present application;
fig. 5 is a flowchart illustrating a detailed implementation of a method for executing a timing task according to an embodiment of the present application;
fig. 6 is a first schematic structural diagram of an apparatus for executing a timing task according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of a timing task execution device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
First, some terms referred to in the embodiments of the present application will be described to facilitate understanding by those skilled in the art.
The terminal equipment: may be a mobile terminal, a fixed terminal, or a portable terminal such as a mobile handset, station, unit, device, multimedia computer, multimedia tablet, internet node, communicator, desktop computer, laptop computer, notebook computer, netbook computer, tablet computer, personal communication system device, personal navigation device, personal digital assistant, audio/video player, digital camera/camcorder, positioning device, television receiver, radio broadcast receiver, electronic book device, gaming device, or any combination thereof, including the accessories and peripherals of these devices, or any combination thereof. It is also contemplated that the terminal device can support any type of interface to the user (e.g., wearable device), and the like.
A server: the cloud server can be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and can also be a cloud server for providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, network service, cloud communication, middleware service, domain name service, security service, big data and artificial intelligence platform and the like.
Communication Sequential Process (CSP): is an abstract language for describing the behavior of interactive communication entities in a concurrent system through message exchange.
Pipe (Channel): is a structure of communication between processes, threads or coroutines.
And (3) concurrence: means that several programs are in a period from the start to the end of the operation, and the programs are all operated on the same processor, but only one program is operated on the processor at any time point.
In order to improve the execution efficiency of a timing task when the timing task is executed, embodiments of the present application provide a method, an apparatus, a device, and a storage medium for executing the timing task.
Fig. 1 is a schematic view of an application scenario of a method for executing a timing task according to an embodiment of the present application. Fig. 1 includes a task scheduling center, a server, and a database. In fig. 1, only two devices, i.e., a server 1 and a server 2, are illustrated as an example. In practical applications, the number of servers may be one or more, and is not limited herein.
The task scheduling center: the timing task execution method comprises the steps of respectively obtaining the execution time of each timing task, generating a timing task execution instruction aiming at least one timing task when at least one timing task reaches the corresponding execution time, and sending the timing task execution instruction to at least one server to enable the server to start executing the timing task.
A server: the system comprises a task scheduling center, a database and a coroutine mode, wherein the task scheduling center is used for receiving a timing task execution instruction sent by the task scheduling center, establishing connection with the database according to the timing task execution instruction, acquiring task data corresponding to at least one timing task from the database, executing the at least one timing task in the coroutine mode, acquiring an execution result of the at least one timing task, and storing the execution result in the database.
A database: the server is used for establishing connection with the server and receiving the execution result of the server.
In one embodiment, a task scheduling center respectively obtains an execution time of each timing task, determines that at least one timing task reaches a corresponding execution time, generates a timing task execution instruction for the at least one timing task, and sends the timing task execution instruction to at least one server. The method comprises the steps that a server receives a timing task execution instruction sent by a task scheduling center, establishes connection with a database according to the timing task execution instruction, obtains task data corresponding to at least one timing task from the database, creates a task data array aiming at the task data corresponding to each timing task in the at least one timing task, and obtains an array address of the task data array corresponding to the at least one timing task. The server splits at least one timing task respectively to obtain a plurality of subtasks of the timing task, creates at least one coroutine for each subtask respectively, adopts each coroutine, calls task data corresponding to one timing task according to an array address corresponding to the timing task, executes each subtask respectively, writes back an execution result of each timing task to the database, and returns the execution condition of the timing task to the scheduling task center.
Therefore, when the timing task is executed, the task data corresponding to the timing task can be obtained from the database, one timing task is divided into a plurality of subtasks, one coroutine is established for each subtask of each timing task in a coroutine mode, and the timing task is executed concurrently, so that the execution efficiency of the timing task is greatly improved, the interaction between the timing task and the database is reduced, and the pressure of the database is reduced.
In the embodiment of the present application, only the execution subject is taken as an example for description, and in practical applications, the execution subject may also be other electronic devices such as a terminal device, and is not limited herein.
Referring to fig. 2, an implementation flow chart of a method for executing a timing task according to an embodiment of the present application is shown, and with reference to the application scenario, a specific implementation flow of the method is as follows:
step 200: and receiving a timing task execution instruction distributed by the task scheduling center aiming at least one timing task.
Specifically, when the task scheduling center determines that at least one timing task reaches the corresponding execution time, the task scheduling center issues at least one timing task execution instruction to the server, and the server receives the timing task execution instruction issued by the task scheduling center for the at least one timing task.
The timing task may be written in a go language or a Java language, and in practical application, the timing task may be written in other languages, and may be determined according to practical application conditions, which is not limited herein.
The task scheduling center can cross the programming language of the timing task and cross the platform where the timing task is located to schedule the timing task.
The timing task execution instruction is distributed when the task scheduling center determines that at least one timing task reaches the corresponding execution time.
Alternatively, the task scheduling center may be a task scheduling center based on a scheduled task (cron).
In practical applications, the task scheduling center may also be a task scheduling center based on other technologies, and is not limited herein.
Wherein, cron is a standard parser and job runner.
Optionally, cron may provide the following interfaces: new creates a timer manager, Cron new within location returns a new Cron job run program, Cron schedule schedules adds job tasks to Cron to run on a given schedule, c.addfunc adds a timed task, the first parameter is the Cron time expression, the second parameter is the function to trigger execution, c.addjob adds jobs to Cron to run on a given schedule, c.start () starts a new schedule, runs timed tasks, c.run () executes timed tasks, and c.stop is the wait-to-stop signal end task, etc.
Thus, the server can receive the timing task execution instruction of the task scheduling center and execute the timing task based on the received timing task execution instruction of the task scheduling center.
Before executing step 200, the task scheduling center may execute the following steps:
the method comprises the following steps: and respectively acquiring the execution time of each timing task.
Specifically, the task scheduling center obtains the execution time of each timing task.
Optionally, the task scheduling center may obtain the specific execution time of each timing task in a task input manner.
In practical applications, the task scheduling center may obtain the execution time of the timing task in other manners, which is not limited herein.
Step two: and when the at least one timing task reaches the corresponding execution time, generating a timing task execution instruction aiming at the at least one timing task.
Specifically, when the task scheduling center determines that at least one timing task reaches the corresponding execution time, a timing task execution instruction is generated for each timing task reaching the corresponding execution time.
The timed task execution instruction may be an instruction for driving the server to execute the timed task.
In one embodiment, the task scheduling center sends a timed task execution instruction to the server in a subsequent step by generating a timer.
Step three: and sending a timing task execution instruction to at least one server.
In one embodiment, a task scheduling center acquires the execution time of each timing task, generates a timing task execution instruction for at least one timing task when determining that the execution time of at least one timing task reaches, and sends the timing task execution instruction to a server.
Therefore, the task scheduling center respectively acquires the execution time of each timing task, and sends a timing task execution instruction to the server when at least one timing task reaches the corresponding execution time, so that the server starts to execute the timing task.
Step 201: and acquiring task data corresponding to at least one timing task from the database based on the timing task execution instruction.
Specifically, after receiving a timed task execution instruction issued by a scheduling center, the server establishes connection with the database, and acquires task data corresponding to at least one timed task from the database according to a data selection condition of the timed task.
In one embodiment, the server executes the instruction based on the timed task, establishes connection with the database, and acquires the policy meeting the policy data selection condition according to the policy data selection condition of the timed task.
Optionally, the policy data selection condition may be the status of the policy, the name of the customer, the date of the policy, and the like.
Wherein the status of the policy may be active and inactive.
Further, the server receives the scheduling of the task scheduling center, and after the timing task execution instruction is completed, the timing task does not meet the execution condition, so that the timing task needs to be executed independently after the timing task execution condition is met.
The unsatisfied execution condition may be that the current time server has more important tasks to execute.
In practical applications, the timing task may not be completed in time due to other factors, which is not limited herein.
Further, after the timing task is executed at the corresponding execution time, the timing task needs to be executed at other time points, and the timing task needs to be executed separately.
Therefore, the task data of the timing task is extracted from the server, the server adopts a multi-protocol process, the timing task is executed concurrently, and the execution result of the timing task is stored in the database, so that the execution time of the timing task is shortened, and the execution efficiency of the timing task is improved. By intensively acquiring the task data of the batch timed tasks, after the batch tasks are executed, the execution results of the batch tasks are written back to the database, so that the interaction between the timed tasks and the database is reduced, the risk of processing other tasks in the database is reduced, the resource use pressure of the database is reduced, and the usability of the database is guaranteed.
In practical applications, the data selection condition may be determined according to practical application conditions, and is not limited herein.
Optionally, the server may establish a connection with the database by opening a data connection.
In practical applications, the server may establish a connection with the database in other ways according to practical application conditions, which is not limited herein.
In this way, the server can acquire the task data corresponding to at least one timing task from the database, and can execute at least one timing task based on the task data corresponding to the timing task in the subsequent steps.
Step 202: and executing at least one timing task based on the task data by adopting a coroutine mode to obtain an execution result of the at least one timing task.
Specifically, when the step 202 is executed, the following steps may be executed for each timing task of the at least one timing task, respectively:
s2021: and splitting one timing task to obtain a plurality of subtasks of the timing task.
Specifically, the server splits a timing task to obtain a plurality of sub-steps of at least one timing task, and regards the sub-steps as a plurality of sub-tasks.
S2022: at least one coroutine is created for each subtask, respectively.
Specifically, the server creates at least one coroutine for each subtask split by one timing task.
S2023: and respectively executing each subtask by adopting each coroutine based on task data corresponding to one timing task.
Specifically, the steps of: and calling task data corresponding to a timing task according to an array address corresponding to the timing task by adopting each coroutine, and executing each subtask respectively.
Specifically, the server calls task data corresponding to a timing task in a mode of each coroutine according to an array address corresponding to the timing task, and concurrently executes each subtask in the timing task in a mode of a CSP concurrent model according to the task data corresponding to the called timing task, and different subtasks are communicated through a pipeline, so that data sharing among different substeps is realized.
And different subtasks carry out data transmission through pipelines.
Optionally, other manners may also be adopted for data transmission between different sub-steps, which is not limited herein.
Therefore, the server can split the timing task, adopt a coroutine mode and concurrently execute the timing task.
Specifically, before performing step S2023, the following steps may be adopted:
the method comprises the following steps: and respectively aiming at the task data corresponding to each timing task in at least one timing task, creating a task data array.
Specifically, the server creates a task data array for at least one timing task according to task data corresponding to each timing task.
Step two: and acquiring an array address of a task data array corresponding to at least one timing task.
Specifically, the server obtains an array address of a task data array corresponding to at least one timing task.
Therefore, the server can acquire the task data corresponding to the timing task through the array address during the subsequent timing task.
Step 203: and storing the execution result of the at least one timing task to a database.
Specifically, the server establishes a connection with the database by opening a data connection, and writes back an execution result of the obtained at least one timing task to the database.
Further, most timing tasks need to be executed in a timing cycle, so after each timing task is executed, the server is required to return the execution condition of the timing task to the task scheduling center, and if the execution condition of the timing task returned by the server cannot be received, the task scheduling center waits and does not send the timing task execution instruction of the timing task to the server until the task scheduling center receives the execution condition of the timing task returned by the server.
The timing task execution instruction can be sent to the server in a timing mode based on a mode of setting a timer.
In practical applications, the timing task execution instruction may also be sent to the server in other manners according to practical application situations, and is not limited herein.
In one embodiment, the task scheduling center is a Cron packet-based task scheduling center, and the task scheduling center starts a Cron scheduler and starts to execute a timing task:
(1) and (4) a new timer is established by the task scheduling center, and a timed task execution instruction is sent to the server where the timed task is located through the timer when at least one timed task reaches the execution time.
(2) And for, selecting, after the execution of the timing task is finished, if the task scheduling center cannot receive the execution condition of the timing task returned by the server, waiting and no longer sending a timing task execution instruction of the timing task to the server.
(3) Reset, the timer is reset and the timer is restarted.
(4) Stop, task scheduling center stops the timer.
If the timed task is executed and is not executed, the task scheduling center stops the timer.
The time expression of the cron packet includes seconds, minutes, hours, a certain day of a month, and a day of the week, and the six time points in each time expression in the time expression of the cron packet are included. For example, seven tenths of an eleventh second, the time expression for a cron packet is 11107 x.
Therefore, the server can store the execution result in the database after the execution of the timing task is finished.
Referring to fig. 3, a flowchart of a method for implementing batch execution of timed tasks in go language according to an embodiment of the present application is shown, and a specific implementation flow of the method is as follows:
step 300: and the server starts a multi-program mode and acquires the timing task data through the multi-program mode.
Step 301: the server executes the timing task by the timing task data in a multi-protocol mode.
Specifically, the server adopts a for loop mode until all coroutines are executed.
Step 302: and the server starts a multi-protocol mode and stores the execution result of the timing task to the database.
It should be noted that the server can execute the timing task based on the go func function.
In practical application, other functions may be adopted to execute the timing task, and the function is not limited herein.
The server can store the execution result of the timing task to the database in a coroutine mode.
Therefore, the server can concurrently execute the timing task in a coroutine mode, and the execution efficiency of the timing task is improved.
Referring to fig. 4, an exemplary diagram of a method for scheduling a remote host by a task scheduling center according to an embodiment of the present invention is shown, where fig. 4 includes a task scheduling center for scheduling a remote host, executing a timing task, and a remote host for executing a timing task. In fig. 4, only three remote hosts, that is, the remote host 1, the remote host 2, and the remote host 3, are taken as an example for illustration, and in practical applications, the number of the remote hosts may be one or more, which is not limited herein.
And the task scheduling center generates a timing task execution instruction aiming at least one timing task when determining that at least one timing task in the three remote hosts reaches the corresponding execution time, sends the timing task execution instruction to the remote host where the at least one timing task is located, receives the timing task execution instruction of the timing task, executes the at least one timing task by adopting a coroutine method, and returns the execution condition of the at least one timing task to the task scheduling center after the execution is finished.
And the execution condition of the timing task is the execution success of the timing task or the execution failure of the timing task.
Wherein, the timing tasks of different remote hosts can be written for different languages. For example, the go language, the Java language.
Therefore, timing tasks written by different remote hosts and different languages can be scheduled through the task scheduling center, and cross-host and cross-language centralized scheduling and management of the timing tasks are achieved.
Referring to fig. 5, a detailed implementation flowchart of a method for executing a timing task according to an embodiment of the present application is shown, and the specific implementation flow of the method is as follows:
step 500: and the task scheduling center respectively acquires the execution time of each timing task.
Step 501: and when the task scheduling center determines that at least one timing task reaches the corresponding execution time, generating a timing task execution instruction aiming at the at least one timing task.
Step 502: and the task scheduling center sends a timing task execution instruction to at least one server.
Step 503: the server receives a timing task execution instruction distributed by the task scheduling center aiming at least one timing task.
Step 504: and the server acquires task data corresponding to at least one timing task from the database based on the timing task execution instruction.
Step 505: the server splits the at least one timing task to obtain a plurality of subtasks of the at least one timing task.
Step 506: the server creates at least one coroutine for each subtask respectively.
Step 507: the server respectively creates a task data array aiming at the task data corresponding to each timing task in at least one timing task.
Step 508: the server obtains an array address of a task data array corresponding to at least one timing task.
Step 509: the server adopts each coroutine, calls task data corresponding to one timing task according to an array address corresponding to the timing task, and executes each subtask respectively.
Step 510: and the server stores the execution result of the timing task to the database.
Step 511: and the server returns the execution condition of the timing task to the task scheduling center.
If the execution of the timed task is successful, the step 500 is executed when the timed task reaches the execution time again.
Specifically, when step 500 to step 511 are executed, the specific steps refer to step 200 to step 203, which are not described herein again.
The traditional timing tasks are usually executed in a database, the execution time of the timing tasks is long, the number of the timing tasks is increased along with the increase of the traffic, the database resources occupied by the timing tasks are increased more and more, and the database pressure is increased, so that other tasks cannot be processed in time. And the scheduling of the timing tasks written in different languages can be realized only by the corresponding scheduling management platform, and the centralized scheduling and management of cross-platforms cannot be realized.
According to the embodiment of the application, when the timing task is executed, the task data is obtained from the database based on the go language, one timing task is split into a plurality of subtasks, one coroutine is created for each subtask of each timing task in a coroutine mode, and the timing task is executed concurrently, so that the execution time of the timing task is shortened, and the execution efficiency of the timing task is improved. By intensively acquiring the task data of the batch timed tasks, after the batch tasks are executed, the execution results of the batch tasks are stored in the database in a write-back mode, so that the interaction between the timed tasks and the database is reduced, the risk of processing other tasks in the database is reduced, the resource use pressure of the database is reduced, and the usability of the database and the controllability of the execution time of the timed tasks are guaranteed. Furthermore, when the number of the timing tasks is increased and the logic operation of the timing tasks is complicated, the controllability of the execution time length of the timing tasks and the availability of the database can be guaranteed by expanding the number of the servers. And the go-language-based task scheduling center can not only schedule the timing tasks written by the go language, but also schedule the timing tasks written by other languages, thereby realizing the centralized scheduling and management of the cross-platform timing tasks.
As shown in fig. 6, a schematic structural diagram of a device for executing a timing task according to an embodiment of the present application includes:
a receiving unit 601, configured to receive a timing task execution instruction distributed by a task scheduling center for at least one timing task, where the timing task execution instruction is distributed when the task scheduling center determines that at least one timing task reaches a corresponding execution time;
an obtaining unit 602, configured to obtain task data corresponding to at least one timing task from a database based on a timing task execution instruction;
an executing unit 603, configured to execute at least one timing task based on task data in a coroutine manner, and obtain an execution result of the at least one timing task;
the storage unit 604 is configured to store the execution result of the at least one timing task in the database.
In an embodiment, the execution unit 603 is specifically configured to:
for each of the at least one timing task, respectively, performing the following steps:
splitting a timing task to obtain a plurality of subtasks of the timing task;
respectively establishing a coroutine aiming at each subtask;
and respectively executing each subtask by adopting each coroutine based on task data corresponding to one timing task.
In one embodiment, the execution unit 603 is further configured to:
respectively aiming at task data corresponding to each timing task in at least one timing task, creating a task data array;
acquiring an array address of a task data array corresponding to at least one timing task;
based on task data corresponding to a timing task, adopting each coroutine to respectively execute each subtask, wherein the task data comprises the following steps:
and calling task data corresponding to one timing task by adopting each coroutine according to an array address corresponding to the timing task, and executing each subtask respectively, wherein data transmission is carried out between different subtasks through a pipeline.
As shown in fig. 7, a schematic structural diagram of a timing task execution device according to an embodiment of the present application is shown, where the timing task execution device includes:
an obtaining unit 701, configured to obtain an execution time of each timing task;
a generating unit 702, configured to generate a timed task execution instruction for at least one timed task when it is determined that the at least one timed task reaches a corresponding execution time;
a sending unit 703, configured to send a timed task execution instruction to one server of the at least one server, so that the one server performs the following steps: based on the timing task execution instruction, acquiring task data corresponding to at least one timing task from a database; executing at least one timing task based on the task data to obtain an execution result of the at least one timing task; and storing the execution result of the at least one timing task to a database.
Based on the same inventive concept, the embodiment of the present application further provides a timing task execution device, and as the principle of the device and the apparatus for solving the problem is similar to that of a timing task execution method, the implementation of the device can refer to the implementation of the method, and repeated details are not repeated.
In the method, the device, the equipment and the storage medium for executing the timing task, a timing task execution instruction which is distributed by a task scheduling center aiming at least one timing task is received, wherein the timing task execution instruction is distributed when the task scheduling center determines that the at least one timing task reaches the corresponding execution time; based on the timing task execution instruction, acquiring task data corresponding to at least one timing task from a database; executing at least one timing task based on task data by adopting a coroutine mode to obtain an execution result of the at least one timing task; and storing the execution result of at least one timing task to the database. Therefore, when the timing task is executed, the task data can be obtained from the database, the timing task is executed in a multi-protocol mode, and the execution efficiency of the timing task is greatly improved.
Fig. 8 shows a schematic structural diagram of an electronic device 8000. Referring to fig. 8, the electronic device 8000 includes: the processor 8010 and the memory 8020 may further include a power supply 8030, a display unit 8040, and an input unit 8050.
The processor 8010 is the control center of the electronic device 8000, and it is to be understood that various functions of the electronic device 8000 may be performed by operating or executing software programs and/or data stored in the memory 8020 by connecting various components using various interfaces and lines, thereby performing overall monitoring of the electronic device 8000.
In an embodiment of the application, the processor 8010 may invoke a computer program stored in the memory 8020 to perform a method of timing the execution of tasks as provided in the embodiment shown in fig. 2.
Alternatively, the processor 8010 may comprise one or more processing units; preferably, the processor 8010 may integrate the application processor, which handles primarily the operating system, user interface, applications, etc., and the modem processor, which handles primarily the wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 8010. In some embodiments, the processor, memory, and/or memory may be implemented on a single chip, or in some embodiments, they may be implemented separately on separate chips.
The memory 8020 may mainly include a program storage area and a data storage area, in which an operating system, various applications, and the like may be stored; the stored data area may store data created according to the use of the electronic device 8000, and the like. Further, the memory 8020 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device.
The electronic device 8000 may also include a power supply 8030 (e.g., a battery) that may be used to provide power to the various components, which may be logically coupled to the processor 8010 via a power management system, which may be used to manage charging, discharging, and power consumption.
The display unit 8040 may be used to display information input by a user or information provided to the user, various menus of the electronic device 8000, and the like, and in the embodiment of the present invention, the display unit is mainly used to display a display interface of each application in the electronic device 8000 and objects such as texts and pictures displayed in the display interface. The display unit 8040 may include a display panel 8041. The Display panel 8041 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
The input unit 8050 can be used to receive information such as numbers or characters input by a user. The input unit 8050 may include a touch panel 8051 and other input devices 8052. Among other things, the touch panel 8051, also referred to as a touch screen, can collect touch operations by a user on or near the touch panel 8051 (e.g., operations by a user on or near the touch panel 8051 using any suitable object or accessory such as a finger, a stylus, etc.).
Specifically, the touch panel 8051 can detect a touch operation of a user, detect signals caused by the touch operation, convert the signals into touch point coordinates, send the touch point coordinates to the processor 8010, receive a command sent by the processor 8010, and execute the command. In addition, the touch panel 8051 can be implemented by various types such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. Other input devices 8052 can include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, power on/off keys, etc.), a trackball, a mouse, a joystick, and the like.
Of course, the touch panel 8051 can cover the display panel 8041, and when the touch panel 8051 detects a touch operation thereon or nearby, the touch panel 8051 is transmitted to the processor 8010 to determine the type of the touch event, and then the processor 8010 provides a corresponding visual output on the display panel 8041 according to the type of the touch event. Although in FIG. 8, the touch panel 8051 and the display panel 8041 are shown as two separate components to implement the input and output functions of the electronic device 8000, in some embodiments, the touch panel 8051 and the display panel 8041 can be integrated to implement the input and output functions of the electronic device 8000.
The electronic device 8000 may also include one or more sensors, such as pressure sensors, gravitational acceleration sensors, proximity light sensors, and the like. Of course, the electronic device 8000 may also include other components such as a camera, as required in a particular application, and these components are not shown in fig. 8 and will not be described in detail since they are not components that are used in the embodiments of the present application.
Those skilled in the art will appreciate that fig. 8 is merely an example of an electronic device and is not limiting of electronic devices and may include more or fewer components than those shown, or some components may be combined, or different components.
In an embodiment of the present application, a readable storage medium has a computer program stored thereon, and when the computer program is executed by a processor, the communication device may perform the steps in the above embodiments.
For convenience of description, the above parts are separately described as modules (or units) according to functional division. Of course, the functionality of the various modules (or units) may be implemented in the same one or more pieces of software or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (10)

1. A method for executing a timing task is applied to each server in a timing task execution system, the timing task execution system comprises a task scheduling center and at least one server, the task scheduling center adopts a computer programming language go to process the timing task, and the method comprises the following steps:
receiving a timing task execution instruction distributed by the task scheduling center aiming at least one timing task, wherein the timing task execution instruction is distributed when the task scheduling center determines that the at least one timing task reaches corresponding execution time;
based on the timing task execution instruction, acquiring task data corresponding to the at least one timing task from a database;
executing the at least one timing task based on the task data in a coroutine mode to obtain an execution result of the at least one timing task;
and storing the execution result of the at least one timing task to the database.
2. The method of claim 1, wherein said executing the at least one timed task based on the task data in a coroutine manner to obtain the result of the execution of the at least one timed task comprises:
for each of the at least one timing task, respectively, performing the following steps:
splitting a timing task to obtain a plurality of subtasks of the timing task;
respectively creating at least one coroutine for each subtask;
and respectively executing each subtask by adopting each coroutine based on the task data corresponding to the timing task.
3. The method of claim 2, wherein before executing each sub-task separately based on the task data corresponding to the one timing task using the routines, further comprising:
respectively establishing a task data array aiming at task data corresponding to each timing task in the at least one timing task;
acquiring an array address of a task data array corresponding to the at least one timing task;
the executing each subtask respectively by using a coroutine based on the task data corresponding to the timing task comprises:
and calling task data corresponding to the timing task according to the array address corresponding to the timing task by adopting each coroutine, and executing each subtask respectively, wherein data transmission is carried out between different subtasks through a pipeline.
4. A method for executing a timing task is applied to a task scheduling center in a timing task execution system, the timing task execution system comprises the task scheduling center and at least one server, the task scheduling center adopts a computer programming language go to process the timing task, and the method comprises the following steps:
respectively acquiring the execution time of each timing task;
when at least one timing task reaches corresponding execution time, generating a timing task execution instruction aiming at the at least one timing task;
sending the timed task execution instructions to the at least one server, so that the one server performs the following steps: based on the timing task execution instruction, acquiring task data corresponding to the at least one timing task from a database; executing the at least one timing task based on the task data to obtain an execution result of the at least one timing task; and storing the execution result of the at least one timing task to the database.
5. An execution device of a timing task is applied to each server in a timing task execution system, the timing task execution system comprises a task scheduling center and at least one server, the task scheduling center adopts a computer programming language go to process the timing task, and the device comprises:
a receiving unit, configured to receive a timing task execution instruction distributed by the task scheduling center for at least one timing task, where the timing task execution instruction is distributed when the task scheduling center determines that the at least one timing task reaches a corresponding execution time;
the acquisition unit is used for acquiring task data corresponding to the at least one timing task from a database based on the timing task execution instruction;
the execution unit is used for executing the at least one timing task based on the task data in a coroutine mode to obtain an execution result of the at least one timing task;
and the storage unit is used for storing the execution result of the at least one timing task to the database.
6. The apparatus of claim 5, wherein the execution unit is specifically configured to:
for each of the at least one timing task, respectively, performing the following steps:
splitting a timing task to obtain a plurality of subtasks of the timing task;
respectively establishing a coroutine aiming at each subtask;
and respectively executing each subtask by adopting each coroutine based on the task data corresponding to the timing task.
7. The apparatus of claim 6, wherein the execution unit is further to:
respectively establishing a task data array aiming at task data corresponding to each timing task in the at least one timing task;
acquiring an array address of a task data array corresponding to the at least one timing task;
the executing each subtask based on the task data corresponding to the timing task by using each coroutine comprises:
and calling task data corresponding to the timing task according to the array address corresponding to the timing task by adopting each coroutine, and executing each subtask respectively, wherein data transmission is carried out between different subtasks through a pipeline.
8. An execution device of a timing task is applied to a task scheduling center in a timing task execution system, the timing task execution system comprises the task scheduling center and at least one server, the task scheduling center adopts a computer programming language go to process the timing task, and the device comprises:
the acquisition unit is used for respectively acquiring the execution time of each timing task;
the generating unit is used for generating a timing task execution instruction aiming at least one timing task when the at least one timing task reaches the corresponding execution time;
a sending unit, configured to send the timed task execution instruction to the at least one server, so that the server performs the following steps: based on the timing task execution instruction, acquiring task data corresponding to the at least one timing task from a database; executing the at least one timing task based on the task data to obtain an execution result of the at least one timing task; and storing the execution result of the at least one timing task to the database.
9. An electronic device comprising a processor and a memory, the memory storing computer readable instructions that, when executed by the processor, perform the method of any of claims 1-3 or 4.
10. A readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-3 or 4.
CN202111562377.2A 2021-12-20 2021-12-20 Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium Pending CN114237851A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111562377.2A CN114237851A (en) 2021-12-20 2021-12-20 Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111562377.2A CN114237851A (en) 2021-12-20 2021-12-20 Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium

Publications (1)

Publication Number Publication Date
CN114237851A true CN114237851A (en) 2022-03-25

Family

ID=80759268

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111562377.2A Pending CN114237851A (en) 2021-12-20 2021-12-20 Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium

Country Status (1)

Country Link
CN (1) CN114237851A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115987652A (en) * 2022-12-27 2023-04-18 北京深盾科技股份有限公司 Account management method, system, equipment and computer storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115987652A (en) * 2022-12-27 2023-04-18 北京深盾科技股份有限公司 Account management method, system, equipment and computer storage medium
CN115987652B (en) * 2022-12-27 2023-11-03 北京深盾科技股份有限公司 Account management method, system, equipment and computer storage medium

Similar Documents

Publication Publication Date Title
US11625265B2 (en) Enabling execution of program instructions in the background
Tolia et al. Quantifying interactive user experience on thin clients
CN110300328B (en) Video playing control method and device and readable storage medium
US20130014130A1 (en) Application module for managing interactions of distributed modality components
CN110221901A (en) Container asset creation method, apparatus, equipment and computer readable storage medium
CN109308241B (en) Method and device for monitoring starting process of application program, terminal equipment and storage medium
CN111930521A (en) Method and device for deploying application, electronic equipment and readable storage medium
CN111338791A (en) Method, device and equipment for scheduling cluster queue resources and storage medium
WO2021190184A1 (en) Remote assistance method and apparatus, and storage medium and terminal
CN112363913B (en) Parallel test task scheduling optimizing method, device and computing equipment
CN111124668A (en) Memory release method and device, storage medium and terminal
CN114237851A (en) Timed task execution method, timed task execution device, timed task execution equipment and timed task execution storage medium
CN113900650A (en) Data processing method and device, electronic equipment and readable storage medium
CN110377331A (en) Monitoring method, device, equipment and the storage medium of release application program
CN110377140B (en) Method, device, terminal and storage medium for awakening operating system
Arief et al. Automatic generation of distributed system simulations from UML
CN112162840B (en) Coroutine processing and management method based on interrupt reentry mechanism
CN114896049A (en) Method, system, equipment and medium for scheduling operation tasks of electric power artificial intelligence platform
CN113568748A (en) Application process processing method and device, storage medium and electronic equipment
CN112256354A (en) Application starting method and device, storage medium and electronic equipment
CN117032940B (en) System, method and device for scheduling resources, electronic equipment and storage medium
WO2024037132A1 (en) Workflow processing method and apparatus, and device, storage medium and program product
CN117041353B (en) Task processing method and device, electronic equipment and storage medium
CN108399529A (en) The management method and system of time
CN113672579B (en) File synchronization method based on webservice

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