CN113791876A - System, method and apparatus for processing tasks - Google Patents

System, method and apparatus for processing tasks Download PDF

Info

Publication number
CN113791876A
CN113791876A CN202011540949.2A CN202011540949A CN113791876A CN 113791876 A CN113791876 A CN 113791876A CN 202011540949 A CN202011540949 A CN 202011540949A CN 113791876 A CN113791876 A CN 113791876A
Authority
CN
China
Prior art keywords
task
server
client
tasks
processing
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
CN202011540949.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.)
Jingdong Technology Holding Co Ltd
Original Assignee
Jingdong Technology Holding 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 Jingdong Technology Holding Co Ltd filed Critical Jingdong Technology Holding Co Ltd
Priority to CN202011540949.2A priority Critical patent/CN113791876A/en
Publication of CN113791876A publication Critical patent/CN113791876A/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
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load

Abstract

Embodiments of the present disclosure disclose systems, methods, and apparatuses for processing tasks. One embodiment of the system comprises: the client is used for sending a task processing request to the server; the server is used for pushing the tasks to the client according to the received task processing request; and the client is also used for processing the received task to obtain a task processing result. This embodiment helps to reduce the load on the server side.

Description

System, method and apparatus for processing tasks
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a system, method, and apparatus for processing tasks.
Background
With business development, task scheduling needs are almost all encountered for many enterprises. For example, many of the tedious timing tasks require repeated timing execution. Task scheduling development involves multi-thread concurrency, runtime policy, resource allocation and maintenance, and other tasks. Therefore, many enterprises use existing open-source task scheduling frameworks to implement various task scheduling existing in their business scenarios.
In the existing various task scheduling systems, tasks are generally created by a task system, the tasks are dispatched to a service system according to preset time and a scheduling policy, and the service system is waited to execute the tasks to return task execution results.
Disclosure of Invention
Embodiments of the present disclosure propose systems, methods, and apparatuses for processing tasks.
In a first aspect, an embodiment of the present disclosure provides a system for processing a task, including a client and a server; the client is used for sending a task processing request to the server; the server is used for pushing the tasks to the client according to the received task processing request; and the client is also used for processing the received task to obtain a task processing result.
In some embodiments, the client is further configured to send the obtained task processing result to the server; the server is also used for updating the processing state of the corresponding task according to the received task processing result.
In some embodiments, the task processing request includes description information for describing the requested task.
In some embodiments, the description information includes at least one of: total number of tasks, type of tasks.
In some embodiments, the client is further configured to send a task processing request to the server at the target time.
In some embodiments, the server is further configured to determine whether a task matching the received task processing request exists in the set of tasks to be executed; and responding to the task which is determined to exist in the task set to be executed and is matched with the received task processing request, and pushing the task which is matched with the received task processing request in the task set to be executed to the client.
In some embodiments, the server is further configured to update the processing state of the pushed task to be the locked state after the task is pushed to the client.
In some embodiments, the server is further configured to detect whether a locking duration of the task in the locking state exceeds a preset threshold; and updating the processing state of the task to be executed in response to the fact that the locking duration of the task in the locking state exceeds a preset threshold value.
In some embodiments, the server comprises a master server and a slave server; the slave server is used for receiving the task processing request sent by the client, acquiring the task from the master server according to the received task processing request, and pushing the acquired task to the client.
In a second aspect, an embodiment of the present disclosure provides a method for processing a task, the method including: sending a task processing request to a server; receiving a task pushed by a server according to a task processing request; and processing the received task to obtain a task processing result.
In a third aspect, an embodiment of the present disclosure provides a method for pushing a task, where the method includes: receiving a task processing request sent by a client; and pushing the task to the client according to the task processing request, wherein the client processes the received task to obtain a task processing result.
In a fourth aspect, an embodiment of the present disclosure provides an apparatus for processing a task, the apparatus including: a request sending unit configured to send a task processing request to a server; the task receiving unit is configured to receive a task pushed by the server according to the task processing request; and the task processing unit is configured to process the received task to obtain a task processing result.
In a fifth aspect, an embodiment of the present disclosure provides an apparatus for pushing a task, including: a request receiving unit configured to receive a task processing request sent by a client; and the task pushing unit is configured to push the task to the client according to the task processing request, wherein the client processes the received task to obtain a task processing result.
In a sixth aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; storage means for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any implementation of the second or third aspects.
In a seventh aspect, embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, which, when executed by a processor, implements the method as described in any of the implementation manners of the second or third aspects.
According to the system, the method and the device for processing the task, the client actively sends the task processing request to the server, the server pushes the task to the client according to the received task processing request, and the client executes the received task to obtain the task processing result. In this way, the server side is not required to execute a complex task dispatching strategy, and the task executing state of each client side is not required to be concerned at all times so as to dispatch the tasks to each client side. The client can actively control the task processing request while relieving the processing pressure of the server, and the flexibility of the task processing flow of the client is improved.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram of a system for processing tasks of the present disclosure;
FIG. 2 is a timing diagram of one embodiment of a system for processing tasks according to the present disclosure;
FIG. 3 is a timing diagram of yet another embodiment of a system for processing tasks according to the present disclosure;
FIG. 4 is a flow diagram for one embodiment of a method for processing tasks according to the present disclosure;
FIG. 5 is a flow diagram for one embodiment of a method for pushing tasks, according to the present disclosure;
FIG. 6 is a schematic block diagram illustrating one embodiment of an apparatus for processing tasks according to the present disclosure;
FIG. 7 is a schematic diagram illustrating an embodiment of an apparatus for pushing tasks according to the present disclosure;
FIG. 8 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 of a system for processing tasks of the present disclosure.
As shown in fig. 1, the system architecture 100 may include a client 101 and a server 102. The client 101 and the server 102 may be communicatively coupled via various connection types. Such as wire, wireless communication links, or fiber optic cables, among others.
Various client applications may be installed on the client 101. Such as browser-like applications, search-like applications, instant messaging tools, social platform applications, and so forth. The client 101 may be hardware or software. When the client 101 is hardware, it can be various electronic devices including, but not limited to, a smart phone, a tablet computer, an e-book reader, a laptop portable computer, a desktop computer, and the like. When the client 101 is software, it can be installed in the electronic devices listed above. It may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 102 may be a server that provides various services, such as a backend server that provides services for the client 101. The server 102 may receive a task processing request sent by the client 101, and push a task to the client 101 according to the received task processing request.
The server 102 may be hardware or software. When the server 102 is hardware, it may be implemented as a distributed server cluster composed of multiple servers, or may be implemented as a single server. When the server 102 is software, it may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be understood that the number of clients 101 and servers 102 in fig. 1 is merely illustrative. There may be any number of clients and servers, as desired for implementation.
With continued reference to FIG. 2, an exemplary timing sequence 200 for one embodiment of a system for processing tasks according to the present disclosure is shown.
The system for processing tasks in the embodiment of the present disclosure may include a client (such as the client 101 shown in fig. 1) and a server (such as the server shown in fig. 1).
As shown in fig. 2, in step 201, the client sends a task processing request to the server.
In this embodiment, the task processing request may be used to request the server to push a task to perform task processing.
In step 202, the server pushes the task to the client according to the received task processing request.
In this embodiment, after receiving a task processing request from a client, the server may select a task matching the task processing request from a local or a database connected thereto, and push the selected task to the client.
Specifically, the server may determine a task matching the received task processing request according to a preset task matching method. The task matching method can be preset according to an actual application scene. For example, the server may randomly select a task from the tasks to be executed currently as a task matching the received task processing request.
In step 203, the client processes the task pushed by the server to obtain a task processing result.
In this embodiment, after receiving the task from the server, the client may execute the received task, thereby obtaining a task processing result. Different task execution methods may differ.
In some optional implementations of this embodiment, the task processing result may include indication information indicating whether the corresponding task is successfully processed. At this time, after the client obtains the task processing result, the client can also send the obtained task processing result to the server, so that the server knows whether the pushed task is successfully processed.
Specifically, the server may update the processing state of the corresponding task according to the received task processing result, so as to record the task processing result of the task at this time. The processing state of the task may be used to describe the processing stage of the task. Various processing state partitioning methods may be employed according to different application requirements and application scenarios. For example, the processing state of a task may include pending execution, in execution, successful execution, failed execution, and the like.
As an example, if the task processing result received by the server indicates that the corresponding task is successfully executed, the server may modify the processing state of the corresponding task to be successfully executed. If the task processing result received by the server indicates that the corresponding task fails to be executed, the server may modify the processing state of the corresponding task to be failed to be executed or modify the processing state of the corresponding task to be ready to be executed for re-execution.
The client requests the task from the server and feeds back the task processing result actively, so that the server does not need to pay attention to the task processing condition of the client all the time, and the load of the server is reduced.
In some optional implementations of this embodiment, the task processing request sent by the client may include description information. Wherein the description information may be used to describe the requested task. For example, the description information may include task execution time. The task execution time may refer to an execution time of a task requested by the task processing request. At this time, the server may select a task whose task execution time matches the task execution time indicated by the received task processing request to be pushed to the client.
Optionally, the description information may include at least one of: total number of tasks, type of tasks. Wherein, the total number of tasks may refer to the total number of tasks requested by the task processing request. The task type may refer to a type of task requested by the task processing request. Different application scenarios can set different task type division modes.
The description information included in the task processing request can limit the total number, types, execution time and the like of the tasks pushed by the server, so that the client can flexibly select the processable tasks according to the actual conditions (such as available resources) of the client, and the task processing efficiency and the task processing quality of the client are improved.
In some optional implementations of this embodiment, the client may send the task processing request to the server at the target time. The target time can be flexibly set by the client according to the actual application requirement. For example, the client may determine the time when the task processing request is sent to the server next time according to the number of tasks currently not processed by the client and the number of tasks being processed by the client.
Therefore, the client can flexibly select proper time to send the task processing request to the server according to the actual situation of the client, the situations of task accumulation and the like of the client are avoided, and the flexibility of task processing of the client is improved.
In some optional implementation manners of this embodiment, after receiving the task processing request, the server may determine whether a task matching the task processing request exists in the set of tasks to be executed. The server side can push the tasks matched with the received task processing requests in the task set to be executed to the client side in response to the fact that the tasks matched with the received task processing requests exist in the task set to be executed.
The set of tasks to be processed may be composed of a plurality of tasks to be processed. The set of tasks to be processed may be stored locally at the server or in a database connected to the server. According to the conditions of updating the processing state of the tasks in the set of tasks to be processed or the occurrence of new tasks to be executed, the set of tasks to be processed can be updated all the time.
For example, a certain task in the set of tasks to be processed is pushed to the client, and the client successfully executes the task and returns information that the task is successfully executed to the server, then the server may modify the processing state of the task to be successfully executed and remove the task from the set of tasks to be processed.
Optionally, a local or connected database of the server may store the task set to record all tasks. And selecting the corresponding processing state as the task to be executed to form a task set to be processed according to the processing state of each task in the task set, so as to improve the processing efficiency of the task to be processed. The mode of selecting the tasks to be processed from the task set can be flexibly set according to the actual application scene.
As an example, the server may select a plurality of tasks to form a task set to be processed according to the execution time of each task in the task set and in a manner of inverse narrative of the execution time.
In particular, the set of tasks to be processed may be implemented in the form of a queue (e.g., a buffer queue).
Optionally, the set of tasks to be processed may be divided into at least one subset of tasks to be processed according to task type. Each to-be-processed task subset corresponds to one task type, and the task types corresponding to different to-be-processed task subsets are different.
At this time, after receiving the task processing request sent by the client, the server can select the corresponding task according to the task type to push, which is beneficial to improving the task pushing efficiency, and classifies the to-be-processed tasks according to the task type, which is also convenient for managing the to-be-processed tasks.
Optionally, the client may send a task creation request to the server according to an actual application requirement, and the server may create a corresponding task according to the task creation request. Wherein the task creation request may indicate attribute information of the task to be created.
By way of example, the attribute information of the task includes, but is not limited to, at least one of: task identification, task name, task type, task execution time, etc.
Optionally, after receiving the task creation request, the server may check whether the task set has the same task as the task requested to be created according to the task identifier indicated by the task creation request. And if not, creating a corresponding task. Thereby, a situation of repeatedly creating tasks can be avoided.
Correspondingly, when the server selects a task from the task set and adds the selected task to the task set to be executed, the server may also determine whether the selected task exists in the task set to be executed according to the identifier of the task selected from the task set. If so, the task addition may be aborted. If not, the selected task can be added to the task set to be executed.
In some optional implementation manners of this embodiment, after receiving the task processing request, if there is no task matching the received task processing request in the set of tasks to be executed, it indicates that there is no task that needs to be executed at present. At this time, the server may wait for a preset time period and then check whether a task matching the received task processing request exists in the set of tasks to be executed, and loop with this.
If there is no task matching with the received task processing request in the set of tasks to be executed after the specified number of times of checking, the server may return information indicating that there is no task currently executable to the client. The preset duration and the specified times can be preset according to the actual application scene. Therefore, the communication times between the service segment and the client can be reduced, and the task pushing efficiency is improved.
In some optional implementation manners of this embodiment, after the server pushes the task to the client, the processing state of the pushed task may be modified to be a locked state. Wherein the locked state may be used to indicate that other clients are currently unable to modify the relevant data for the task. Specifically, the pushed task may be locked using various existing locking mechanisms (e.g., pessimistic locks, etc.).
At this time, after receiving the task execution result for the task returned by the client, the server may unlock the task according to the task execution result. For example, if the task execution result indicates that the task was successfully executed, the lock status of the task may be updated to be successfully executed. If the task execution result indicates that the task fails to execute, the locking state of the task can be updated to a state to be executed, so that the task can be executed again later.
By locking and unlocking the tasks, the consistency and the safety of related data in the task processing process can be ensured.
In some optional implementation manners of this embodiment, the server may check whether the locking duration of the task whose processing state is the locking state exceeds a preset threshold at regular time, and in response to determining that the locking duration of the task whose processing state is the locking state exceeds the preset threshold, may update the processing state of the task to be the to-be-executed state. The preset threshold value can be set according to actual application requirements and application scenes.
If the locking duration of the task is too long, it can be stated that a task deadlock and the like may occur. At the moment, the processing state of the task can be modified in time to unlock the task, and the situation that the task cannot be processed for a long time due to task deadlock is avoided.
In the prior art, a server actively sends a task to a client according to a preset task scheduling rule, and pays attention to the task execution situation all the time. If the task execution duration is too long, if the task execution duration exceeds the preset execution duration, the server side usually throws out the timeout exception, and the task fails to be executed, and then the task is re-distributed to the client side. In some cases, the client may have already performed the task, and at this time, the client repeatedly receives the task from the server and repeatedly performs the task, so that an endless loop occurs until the task expires.
According to the scheme, the client requests the server for the task actively according to the actual situation, and the task execution result can be returned to the server after the task pushed by the server is executed, so that the server does not need to set a complex task scheduling rule, and the server does not need to pay attention to the task execution situation all the time. Meanwhile, the client can flexibly request the tasks, and the situations of long backlog or consumed time, uncertain task execution time and the like of the tasks can be reduced. In addition, a locking and unlocking mechanism of the task can be utilized, and the problems of overtime dead cycle and the like caused by task deadlock are avoided.
With continued reference to FIG. 3, a timing sequence 300 for yet another embodiment of a system for processing tasks according to the present disclosure is shown. The system comprises a client and a server. The server side comprises a main server and a slave server.
The number of the master servers and the number of the slave servers can be flexibly set according to actual application scenarios. Generally, one master server and at least one slave server may be provided. Specifically, the master server and the slave server may be set up by using some existing distributed service frameworks (e.g., Zookeeper, etc.).
In step 301, a task processing request sent by a client is received from a server.
In step 302, the slave server selects a task from the set of tasks to be executed of the master server according to the received task processing request.
In this embodiment, after receiving the task processing request from the client, the slave server may select, according to the task processing request, a task matching the task processing request from a set of tasks to be executed in a database local to or connected to the master server.
Specifically, the slave server may determine a task matching the received task processing request according to a preset task matching method. The task matching method can be preset according to an actual application scene. For example, the slave server may randomly select a task from the set of pending tasks as a task matching the received task processing request.
In step 303, the selected task is pushed from the server to the client.
In some optional implementations of this embodiment, the task processing result may include indication information indicating whether the corresponding task is successfully processed. At this time, after obtaining the task processing result, the client may further send the obtained task processing result to the slave server, so that the server knows whether the pushed task is successfully processed.
Specifically, the slave server may notify the master server of updating the processing state of the corresponding task according to the received task processing result, so as to record the task processing result of the task at this time. The processing state of the task may be used to describe the processing stage of the task. Various processing state partitioning methods may be employed according to different application requirements and application scenarios. For example, the processing state of a task may include pending execution, in execution, successful execution, failed execution, and the like.
As an example, if the task processing result received from the server indicates that the corresponding task was successfully executed, the slave server may notify the master server that the processing status of the corresponding task was modified to be successfully executed. If the task processing result received from the slave server indicates that the corresponding task fails to be executed, the slave server may notify the master server that the processing state of the corresponding task may be modified to be the execution failure or the processing state of the corresponding task may be modified to be ready for execution for re-execution.
In some optional implementations of this embodiment, the task processing request sent by the client may include description information. Wherein the description information may be used to describe the requested task. For example, the description information may include task execution time. The task execution time may refer to an execution time of a task requested by the task processing request. At this time, the slave server may select a task whose task execution time matches the task execution time indicated by the received task processing request to push to the client.
In some optional implementations of this embodiment, the client may send the task processing request to the slave server at the target time. The target time can be flexibly set by the client according to the actual application requirement. For example, the client may determine the time when the task processing request is next sent according to the number of tasks that it currently does not process and the number of tasks that it is processing.
In some optional implementation manners of this embodiment, after receiving the task processing request, the slave server may first determine whether a task matching the task processing request exists in the set of tasks to be executed of the master server. The slave server may push the tasks in the set of tasks to be executed that match the received task processing request to the client in response to determining that the tasks in the set of tasks to be executed that match the received task processing request exist.
The set of tasks to be processed may be composed of a plurality of tasks to be processed. The set of tasks to be processed may be stored locally on the main server or in a database connected to the main server. According to the conditions of updating the processing state of the tasks in the task set to be processed or the occurrence of new tasks to be executed and the like, the task set to be processed can be updated by the main server all the time.
For example, when a certain task in the set of tasks to be processed is pushed to the client, and the client successfully executes the task and returns information that the task was successfully executed to the slave server service, the slave server may notify the master server that the processing state of the task was modified as being successfully executed, and remove the task from the set of tasks to be processed.
Alternatively, a set of tasks may be stored in a database, local or connected to the main server, to keep track of all tasks. And selecting the corresponding processing state as the task to be executed to form a task set to be processed according to the processing state of each task in the task set, so as to improve the processing efficiency of the task to be processed.
Optionally, the set of tasks to be processed may be divided into at least one subset of tasks to be processed according to task type. Each to-be-processed task subset corresponds to one task type, and the task types corresponding to different to-be-processed task subsets are different.
At this time, after receiving the task processing request sent by the client, the slave server may select a corresponding task according to the task type to push, which is beneficial to improving the task pushing efficiency.
Optionally, the client may send a task creation request to the main server according to an actual application requirement, and the main server may create a corresponding task according to the task creation request. Wherein the task creation request may indicate attribute information of the task to be created.
Optionally, after receiving the task creation request, the main server may check whether the same task as the task requested to be created exists in the task set according to the task identifier indicated by the task creation request. And if not, creating a corresponding task. Thereby, a situation of repeatedly creating tasks can be avoided.
Correspondingly, when the main server selects a task from the task set and adds the selected task to the task set to be executed, the main server may also determine whether the selected task exists in the task set to be executed according to the identifier of the task selected from the task set. If so, the task addition may be aborted. If not, the selected task can be added to the task set to be executed.
In some optional implementation manners of this embodiment, after the slave server receives the task processing request, if there is no task matching the received task processing request in the set of tasks to be executed of the master server, it indicates that there is no task that needs to be executed at present. At this time, the slave server may wait for a preset time period, then check whether a task matching the received task processing request exists in the set of tasks to be executed of the master server, and loop accordingly.
If there is no task matching the received task processing request in the set of tasks to be executed after the specified number of checks, the server may return information indicating that there is no task currently executable to the client. The preset duration and the specified times can be preset according to the actual application scene. Therefore, the communication times between the service segment and the client can be reduced, and the task pushing efficiency is improved.
In some optional implementations of the embodiment, after the task is pushed to the client from the server, the master server may be notified to modify the processing state of the pushed task to the locked state. Wherein the locked state may be used to indicate that other clients are currently unable to modify the relevant data for the task. Specifically, the pushed task may be locked using various existing locking mechanisms (e.g., pessimistic locks, etc.).
At this time, after receiving the task execution result for the task returned by the client, the slave server may notify the master server to unlock the task according to the task execution result. For example, if the task execution result indicates that the task was successfully executed, the lock status of the task may be updated to be successfully executed. If the task execution result indicates that the task fails to execute, the locking state of the task can be updated to a state to be executed, so that the task can be executed again later.
In some optional implementation manners of this embodiment, the main server may check whether the locking duration of the task whose processing state is the locking state exceeds a preset threshold at regular time, and in response to determining that the locking duration of the task whose processing state is the locking state exceeds the preset threshold, may update the processing state of the task to be the to-be-executed state. The preset threshold value can be set according to actual application requirements and application scenes.
If the locking duration of the task is too long, it can be stated that a task deadlock and the like may occur. At this moment, the main server can modify the processing state of the task in time to unlock the task, and the situation that the task cannot be processed for a long time due to task deadlock is avoided.
The content that is not described in detail in this embodiment may refer to the related description in the embodiment corresponding to fig. 2, and is not described herein again.
The method provided by the above embodiment of the present disclosure may further ensure data consistency in the task processing process by dividing the server into two roles, namely, a master server and a slave server, and enabling the master server and the slave server to respectively execute different operations, for example, associating some atomic operations and contents to the master server.
With further reference to FIG. 4, a flow 400 of one embodiment of a method for processing tasks is shown. The flow 400 of the method for processing tasks includes the steps of:
step 401, a task processing request is sent to a server.
Step 402, receiving a task pushed by a server according to a task processing request.
And step 403, processing the received task to obtain a task processing result.
In this embodiment, an execution main body of the method for processing the task may be the client shown in fig. 1, that is, the client in the embodiment corresponding to fig. 2 or fig. 3, and the specific execution process of the steps 401, 402, and 403 may refer to the relevant description of the client in the embodiment corresponding to fig. 2 or fig. 3, and is not described herein again.
According to the method for processing the tasks, the client actively requests the tasks to the server according to the actual conditions, the server does not need to set complex task scheduling rules, and the server does not need to pay attention to the task execution conditions all the time, so that the load of the server is reduced, and meanwhile, the flexibility of the task processing flow of the client is improved.
With further reference to FIG. 5, a flow 500 of one embodiment of a method for pushing tasks is shown. The process 500 of the method for pushing a task includes the following steps:
step 501, receiving a task processing request sent by a client.
Step 502, pushing a task to a client according to the task processing request.
In this embodiment, after receiving the task pushed by the server, the client may further process the received task to obtain a task processing result.
In this embodiment, an execution main body of the method for pushing the task may be a server shown in fig. 1, that is, the server in the embodiment corresponding to fig. 2 or fig. 3, and the specific execution process of the steps 501 and 502 may refer to the relevant description of the server in the embodiment corresponding to fig. 2 or fig. 3, and is not described herein again.
According to the method for processing the tasks, the server does not need to set a complex task scheduling rule, and does not need to pay attention to the task execution situation all the time, the server receives the task processing request sent by the client, and pushes the tasks to the client according to the task processing request, so that the load of the server is favorably reduced.
With further reference to fig. 6, as an implementation of the method shown in fig. 4 described above, the present disclosure provides an embodiment of an apparatus for processing tasks, which corresponds to the method embodiment shown in fig. 4, and which is particularly applicable in various electronic devices.
As shown in fig. 6, the apparatus 600 for processing a task provided by the present embodiment includes a request transmitting unit 601, a task receiving unit 602, and a task processing unit 603. Wherein, the request sending unit 601 is configured to send a task processing request to the server; the task receiving unit 602 is configured to receive a task pushed by a server according to a task processing request; the task processing unit 603 is configured to process the received task, resulting in a task processing result.
In the present embodiment, in the apparatus for processing tasks 600: for specific processing of the request sending unit 601, the task receiving unit 602, and the task processing unit 603 and technical effects brought by the processing, reference may be made to the related descriptions of step 401, step 402, and step 403 in the corresponding embodiment of fig. 4, which is not described herein again.
The device provided by the above embodiment of the present disclosure sends a task processing request to the server through the request sending unit; the task receiving unit receives a task pushed by the server according to the task processing request; the task processing unit processes the received task to obtain a task processing result, and the flexibility of the task processing flow of the client side is improved.
With further reference to fig. 7, as an implementation of the method shown in fig. 5, the present disclosure provides an embodiment of an apparatus for pushing a task, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 5, and the apparatus may be applied to various electronic devices in particular.
As shown in fig. 7, the apparatus 700 for pushing a task provided by the present embodiment includes a request receiving unit 701 and a task pushing unit 702. Wherein, the request receiving unit 701 is configured to receive a task processing request sent by a client; the task pushing unit 702 is configured to push a task to a client according to a task processing request, where the client processes the received task to obtain a task processing result.
In the present embodiment, in the apparatus 700 for pushing a task: the specific processing of the request receiving unit 701 and the task pushing unit 702 and the technical effects thereof can refer to the related descriptions of step 501 and step 502 in the corresponding embodiment of fig. 5, which are not repeated herein.
The device provided by the above embodiment of the present disclosure receives, by a request receiving unit, a task processing request sent by a client; and the task pushing unit pushes the tasks to the client according to the task processing request, wherein the client processes the received tasks to obtain task processing results, and the task pushing unit is beneficial to reducing the load of the server.
Referring now to FIG. 8, a block diagram of an electronic device (e.g., a client or server as in FIG. 1) 800 suitable for use in implementing embodiments of the present disclosure is shown. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 8, an electronic device 800 may include a processing means (e.g., central processing unit, graphics processor, etc.) 801 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM803, various programs and data necessary for the operation of the electronic apparatus 800 are also stored. The processing apparatus 801, the ROM 802, and the RAM803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
Generally, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage 808 including, for example, magnetic tape, hard disk, etc.; and a communication device 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 8 illustrates an electronic device 800 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 8 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 809, or installed from the storage means 808, or installed from the ROM 802. The computer program, when executed by the processing apparatus 801, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: sending a task processing request to a server; receiving a task pushed by a server according to a task processing request; and processing the received task to obtain a task processing result. Or, causing the electronic device to: receiving a task processing request sent by a client; and pushing the task to the client according to the task processing request, wherein the client processes the received task to obtain a task processing result.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a request transmitting unit, a task receiving unit, and a task processing unit. The names of these units do not form a limitation on the unit itself in some cases, and for example, the request sending unit may also be described as a "unit sending a task processing request to the server".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (15)

1. A system for processing tasks comprises a client and a server;
the client is used for sending a task processing request to the server;
the server is used for pushing the tasks to the client according to the received task processing request;
the client is further used for processing the received tasks to obtain task processing results.
2. The system of claim 1, wherein the client is further configured to send the obtained task processing result to the server;
and the server is also used for updating the processing state of the corresponding task according to the received task processing result.
3. The system of claim 1, wherein the task processing request includes description information for describing the requested task.
4. The system of claim 3, wherein the descriptive information includes at least one of: total number of tasks, type of tasks.
5. The system of claim 1, wherein the client is further configured to send a task processing request to the server at a target time.
6. The system of claim 1, wherein the server is further configured to determine whether a task matching the received task processing request exists in the set of tasks to be executed; and responding to the task which is determined to exist in the task set to be executed and is matched with the received task processing request, and pushing the task which is matched with the received task processing request in the task set to be executed to the client.
7. The system of claim 6, wherein the server is further configured to update the processing state of the pushed task to a locked state after pushing the task to the client.
8. The system of claim 7, wherein the server is further configured to detect whether a locking duration of the task in the locking state exceeds a preset threshold; and updating the processing state of the task to be executed in response to the fact that the locking duration of the task in the locking state exceeds a preset threshold value.
9. The system of claim 1, wherein the server comprises a master server and a slave server;
the slave server is used for receiving the task processing request sent by the client, acquiring the task from the master server according to the received task processing request, and pushing the acquired task to the client.
10. A method for processing tasks, comprising:
sending a task processing request to a server;
receiving a task pushed by the server according to the task processing request;
and processing the received task to obtain a task processing result.
11. A method for pushing tasks, comprising:
receiving a task processing request sent by a client;
and pushing a task to the client according to the task processing request, wherein the client processes the received task to obtain a task processing result.
12. An apparatus for processing tasks, comprising:
a request sending unit configured to send a task processing request to a server;
the task receiving unit is configured to receive a task pushed by the server according to the task processing request;
and the task processing unit is configured to process the received task to obtain a task processing result.
13. An apparatus for pushing tasks, comprising:
a request receiving unit configured to receive a task processing request sent by a client;
and the task pushing unit is configured to push a task to the client according to the task processing request, wherein the client processes the received task to obtain a task processing result.
14. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, cause the one or more processors to implement the method of claim 10 or 11.
15. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method of claim 10 or 11.
CN202011540949.2A 2020-12-23 2020-12-23 System, method and apparatus for processing tasks Pending CN113791876A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011540949.2A CN113791876A (en) 2020-12-23 2020-12-23 System, method and apparatus for processing tasks

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011540949.2A CN113791876A (en) 2020-12-23 2020-12-23 System, method and apparatus for processing tasks

Publications (1)

Publication Number Publication Date
CN113791876A true CN113791876A (en) 2021-12-14

Family

ID=79181124

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011540949.2A Pending CN113791876A (en) 2020-12-23 2020-12-23 System, method and apparatus for processing tasks

Country Status (1)

Country Link
CN (1) CN113791876A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114610461A (en) * 2022-03-17 2022-06-10 北京火山引擎科技有限公司 Task processing method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130290412A1 (en) * 2012-04-27 2013-10-31 Beijing Founder Apabi Technology Ltd. Method, apparatus, and system for data task processing
US20160292011A1 (en) * 2015-03-31 2016-10-06 Stitch Fix, Inc. Systems and methods for intelligently distributing tasks received from clients among a plurality of worker resources
CN108958922A (en) * 2017-05-17 2018-12-07 北京京东尚科信息技术有限公司 Method and apparatus for executing task
US20190196875A1 (en) * 2017-10-27 2019-06-27 EMC IP Holding Company LLC Method, system and computer program product for processing computing task
CN109947568A (en) * 2019-03-15 2019-06-28 深圳市牛鼎丰科技有限公司 Timed task processing method, system, computer equipment and storage medium
CN110673959A (en) * 2019-10-14 2020-01-10 京东数字科技控股有限公司 System, method and apparatus for processing tasks

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130290412A1 (en) * 2012-04-27 2013-10-31 Beijing Founder Apabi Technology Ltd. Method, apparatus, and system for data task processing
US20160292011A1 (en) * 2015-03-31 2016-10-06 Stitch Fix, Inc. Systems and methods for intelligently distributing tasks received from clients among a plurality of worker resources
CN108958922A (en) * 2017-05-17 2018-12-07 北京京东尚科信息技术有限公司 Method and apparatus for executing task
US20190196875A1 (en) * 2017-10-27 2019-06-27 EMC IP Holding Company LLC Method, system and computer program product for processing computing task
CN109947568A (en) * 2019-03-15 2019-06-28 深圳市牛鼎丰科技有限公司 Timed task processing method, system, computer equipment and storage medium
CN110673959A (en) * 2019-10-14 2020-01-10 京东数字科技控股有限公司 System, method and apparatus for processing tasks

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114610461A (en) * 2022-03-17 2022-06-10 北京火山引擎科技有限公司 Task processing method and device
CN114610461B (en) * 2022-03-17 2023-06-09 北京火山引擎科技有限公司 Task processing method and device

Similar Documents

Publication Publication Date Title
KR102121159B1 (en) Event-driven blockchain workflow processing
US7673029B2 (en) Grid automation bus to integrate management frameworks for dynamic grid management
US8301779B2 (en) Mechanisms for obtaining access to shared resources using a single timestamp technique
US8396961B2 (en) Dynamic control of transaction timeout periods
US8756613B2 (en) Scalable, parallel processing of messages while enforcing custom sequencing criteria
US20170093988A1 (en) Workflow service using state transfer
CN102971711A (en) An apparatus for processing a batched unit of work
CN110673959A (en) System, method and apparatus for processing tasks
CN112688799B (en) Redis cluster-based client number distribution method and distribution device
CN111338834B (en) Data storage method and device
CN115544044A (en) Data consistency keeping method, device, equipment and storage medium
CN109828830B (en) Method and apparatus for managing containers
CN113791876A (en) System, method and apparatus for processing tasks
CN114090113A (en) Method, device and equipment for dynamically loading data source processing plug-in and storage medium
CN111597035B (en) Simulation engine time propulsion method and system based on multithreading
CN112825525B (en) Method and apparatus for processing transactions
CN113051055A (en) Task processing method and device
US11163601B2 (en) Dynamically determine the transaction coordinator in multitier hybrid transaction processing middleware systems
US9059992B2 (en) Distributed mobile enterprise application platform
CN115499493A (en) Asynchronous transaction processing method and device, storage medium and computer equipment
CN107632893B (en) Message queue processing method and device
US20180063242A1 (en) Method and apparatus for operating infrastructure layer in cloud computing architecture
CN116775231A (en) Service processing method, service processing device, electronic equipment and storage medium
CN110231983B (en) Data concurrent processing method, device and system, computer equipment and readable medium
CN112783613B (en) Method and device for scheduling units

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