CN113835854A - Task processing method and device - Google Patents

Task processing method and device Download PDF

Info

Publication number
CN113835854A
CN113835854A CN202111036581.0A CN202111036581A CN113835854A CN 113835854 A CN113835854 A CN 113835854A CN 202111036581 A CN202111036581 A CN 202111036581A CN 113835854 A CN113835854 A CN 113835854A
Authority
CN
China
Prior art keywords
processing
task
server
authority
permission
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
CN202111036581.0A
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.)
China Unionpay Co Ltd
Original Assignee
China Unionpay 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 China Unionpay Co Ltd filed Critical China Unionpay Co Ltd
Priority to CN202111036581.0A priority Critical patent/CN113835854A/en
Publication of CN113835854A publication Critical patent/CN113835854A/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
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention provides a task processing method and a task processing device, wherein the method comprises the following steps: the processing server acquires the tasks generated by the production server from the middleware; the processing server determines the working state of a thread pool for processing each task; if the processing server determines that the working state is a non-high-voltage state, generating an authority acquisition request according to the processing rate requirement of the task, and sending the authority acquisition request to a current limiting server, wherein the current limiting server is used for determining a corresponding authority indication according to the processing rate requirement in each authority acquisition request; wherein, different processing rate requirements correspond to different authority distribution mechanisms; and when the received permission acquisition response contains a permission indication, the processing server processes the task through the thread in the thread pool. The method is used for realizing constant speed processing aiming at different tasks, reducing task processing delay and improving the success rate of task processing.

Description

Task processing method and device
Technical Field
The invention relates to the technical field of computers, in particular to a task processing method and a task processing device.
Background
With the development of computer technology, more and more technologies are applied to the fields of finance, IT technology and the like, but higher requirements are also put forward on the technologies due to the requirements of safety and real-time performance of various industries. Take the example that the financial institution sends the promotion message and repayment reminding message to the user.
The prior art generally determines the user group of the promotion message and the user group of the repayment reminding message through an institution system. And generating corresponding batch promotion messages according to the number of the users of the user group of the promotion messages, generating corresponding batch repayment reminding messages according to the number of the users of the user group of the repayment reminding messages, and sending the batch promotion messages and the batch repayment reminding messages to the Kafka server. And when the processing server monitors that the messages are cached in the queue of the Kafka server, the processing server acquires the messages from the Kafka server and sends the messages to the Kafka server. However, in this manner, if the promotion message in the queue of the Kafka server is before the repayment reminding message, the processing server will process the batch promotion message and then process the batch repayment reminding message, which may cause a delay in sending the repayment reminding message. And if the quantity of the batch promotion messages and the batch repayment reminding messages is large, the concurrent processing pressure of the processing server is possibly too high, and the message sending is possibly failed.
Therefore, a task processing method and a task processing device are needed to implement constant speed processing for different tasks, reduce the delay of task processing, and improve the success rate of task processing.
Disclosure of Invention
The embodiment of the invention provides a task processing method and a task processing device, which are used for realizing constant-speed processing aiming at different tasks, reducing task processing delay and improving task processing success rate.
In a first aspect, an embodiment of the present invention provides a task processing method, where the method includes:
the processing server acquires the tasks generated by the production server from the middleware;
the processing server determines the working state of a thread pool for processing each task;
if the processing server determines that the working state is a non-high-voltage state, generating an authority acquisition request according to the processing rate requirement of the task, and sending the authority acquisition request to a current limiting server, wherein the current limiting server is used for determining a corresponding authority indication according to the processing rate requirement in each authority acquisition request; wherein, different processing rate requirements correspond to different authority distribution mechanisms;
and when the received permission acquisition response contains a permission indication, the processing server processes the task through the thread in the thread pool.
In the method, the current limiting server is used for determining the corresponding permission indication according to the processing speed requirement. Therefore, processing according to different authorities can be realized for different tasks, the time delay of task processing is reduced, and the success rate of task processing is improved. And the processing server determines that the working state of the thread pool is a non-high-voltage state, generates an authority acquisition request according to the processing speed requirement of the task, and sends the authority acquisition request to the current limiting server. Therefore, the method not only considers that different tasks have different requirements on the processing speed of the task processing and the corresponding tasks have different emergency situations of the task processing, but also considers the working state of the thread pool in the processing server, and improves the success rate of the task processing. For example, in one case, if the task is a message to be processed, the processing rate requirement may be a message channel rate requirement, and the throttling server is configured to limit the message processing speed according to the message channel rate. Therefore, the respective fixed speed processing can be realized aiming at the messages with different message channel rate requirements, and the message sending delay is reduced. And the processing server determines whether to generate an authority acquisition request according to the working state of the thread pool and the message channel rate of the message. Therefore, the message sending emergency corresponding to the requirements of different messages on the message sending channel rate is considered, the working state of the thread pool in the processing server is also considered, and the message sending success rate is improved.
Optionally, the method further includes: and if the processing server determines that the working state is a high-voltage state, the task is put back to the middleware.
In the method, when the working state of the thread pool is a high-pressure processing state, the task can be returned to the middleware, the task is processed when the concurrent pressure of the processing server is low, and the situations of task loss and task processing failure caused by excessive concurrent pressure of the processing server are effectively reduced.
Optionally, if the processing server determines that the working state is a non-high-voltage state, the processing server generates an authority obtaining request according to the processing rate requirement of the task, including:
the processing server determines that the working state is an ultra-low-voltage state, or if the working state is a low-voltage state and the processing speed requirement is a high speed, a first permission obtaining request is generated according to the processing speed requirement of the task; the first permission obtaining request is used for obtaining permission indication and obtaining indication of the next moment.
In the method, the thread pool working state is an ultra-low-pressure processing state, or the thread pool working state is a low-pressure processing state and the processing rate requirement of the task corresponds to a high-speed processing rate requirement. That is, when the working state of the thread pool is the ultra-low pressure state, the thread pool concurrency pressure of the processing server is extremely low, if the task cannot acquire the permission indication, enough thread resources can wait for acquiring the generation time of the next permission indication, and when the generation time of the next permission indication is up, the permission indication is immediately acquired to complete the task processing. Therefore, the timeliness of task processing is guaranteed. When the working state of the thread pool is a low-pressure state and the processing rate requirement of the task corresponds to the high-speed processing rate requirement, the concurrent pressure of the thread pool of the processing server is low, the processing rate requirement of the task corresponds to the high-speed processing rate requirement, namely, the task is in an emergency state, if the task cannot acquire the permission indication, in order to ensure the task to be processed in time, the generation time of acquiring the next permission indication can be waited, and when the generation time of the next permission indication arrives, the permission indication is immediately acquired to complete the processing. Thus, the timeliness of task processing is also guaranteed.
Optionally, the method further includes: when the processing server does not contain the authority indication in the received authority acquisition response and contains an acquisition indication of the next moment,
and the processing server sends the permission acquisition request to the current limiting server again according to the time of the acquisition indication.
In the method, the permission obtaining response does not include the permission indication and includes the obtaining indication of the next moment. And waiting for obtaining the generation time of the next permission indication, and immediately obtaining the permission indication to finish the task processing when the generation time of the next permission indication is up. Therefore, the timeliness of task processing is guaranteed.
Optionally, if the processing server determines that the working state is a non-high-voltage state, the processing server generates an authority obtaining request according to the processing rate requirement of the task, including:
the processing server determines the working state to be a medium-voltage state, or if the working state is a low-voltage state and the processing speed requirement is a non-high speed, a second permission obtaining request is generated according to the processing speed requirement of the task; the second permission obtaining request is used for obtaining permission indication;
the method further comprises the following steps:
and when the received permission obtaining response does not contain the permission indication, the processing server puts the task back to the middleware.
In the method, the thread pool working state is a medium-voltage state, or the thread pool working state is a low-voltage state and the processing speed requirement of the task corresponds to a non-high-speed processing speed requirement. That is, when the working state of the thread pool is the medium-voltage state, the concurrent pressure of the thread pool of the processing server is high, and if the task cannot obtain the permission indication, the task is returned to the middleware to wait for the next processing. And when the working state of the thread pool is a low-pressure state and the processing speed requirement of the task corresponds to a non-high-speed processing speed requirement, the thread pool of the processing server has common concurrent pressure and the task is in a non-emergency state, and if the task cannot acquire the permission indication, the task is returned to the middleware to wait for the next processing. In this way, resources in the processing server are guaranteed to maintain an optimal operating state.
Optionally, before generating the permission obtaining request according to the processing rate requirement of the task, the method further includes:
the processing server generates a clock acquisition request and sends the clock acquisition request to the current limiting server;
the processing server acquires clock information returned by the current limiting server; the permission acquisition request includes the clock information.
In the method, the processing server acquires the clock information returned by the current limiting server through the clock acquisition request. Therefore, the consistency of the time dimensions of the processing server clusters is ensured, and whether the authority distribution mechanism corresponding to the task contains the available authority indication or the next authority instruction generation time can be determined according to the clock information. If the clock information is that the current clock is 11:00, the current limiting server determines that the earliest generated time of the current available permission instruction is 10: and 59, if the generation speed of the permission instruction is 1/min, determining that the number of the current available permission instructions is more than 0, and returning the permission instruction. If no permission instruction exists, the current limiting server determines that the earliest time of generation of the current available permission instruction is 11: 01, 11:00 < 11: 01, generating the next authority instruction by the following steps of: 01 return.
Optionally, after the processing server obtains the task generated by the production server from the middleware, the method further includes:
the processing server sends an authority algorithm to the current limiting server to obtain an algorithm number determined by the current limiting server according to the authority algorithm, wherein the authority algorithm is used for generating an authority distribution mechanism;
generating a permission acquisition request according to the processing rate requirement of the task, wherein the permission acquisition request comprises the following steps:
and the processing server generates an authority acquisition request according to the processing speed requirement of the task and the algorithm number, wherein the algorithm number is used for the current limiting server to determine the applied authority algorithm according to the algorithm number.
In the method, the processing server sends the authority algorithm to the current limiting server. And ensuring that the authority algorithm exists in the current limiting server, generating an authority distribution mechanism according to the authority algorithm, determining a corresponding authority algorithm according to the algorithm number in the authority acquisition request of the processing server, and determining the authority distribution mechanism according to the processing speed requirement of the task in the authority acquisition request. The processing of different tasks according to different authorities is realized.
Optionally, the task is a message sending task; the middleware is a message middleware; the permission indication is a token; different processing rate requirements correspond to different token buckets.
In the method, the task is a message sending task, the current-limited sending of the message sending processing task is realized according to the method in the first aspect, and the message is sent according to the message channel rate requirement of the message, namely, the message emergency, so that the timeliness of the message is ensured and the failure rate of message sending is reduced.
In a second aspect, an embodiment of the present invention provides a task processing system, where the task processing system includes a production server cluster, a middleware, a processing server cluster, and a current limiting server cluster; the system comprises:
any production server in the production server cluster is used for production tasks;
the middleware is used for storing tasks according to a queue mode;
any processing server in the processing server cluster is configured to perform the method according to any of the first aspect;
and any current limiting server in the current limiting server cluster is used for limiting the task processing speed according to the permission algorithm and the processing speed requirement.
In a third aspect, an embodiment of the present invention provides a task processing device, including:
the acquisition module is used for acquiring the tasks generated by the production server from the middleware;
the processing module is used for determining the working state of a thread pool for processing each task; if the working state is determined to be a non-high-voltage state, generating an authority acquisition request according to the processing rate requirement of the task, and sending the authority acquisition request to a current limiting server, wherein the current limiting server is used for determining a corresponding authority indication according to the processing rate requirement in each authority acquisition request; wherein, different processing rate requirements correspond to different authority distribution mechanisms;
the acquiring module is further configured to process the task through a thread in the thread pool of the processing module when the received permission acquisition response includes a permission indication.
In a fourth aspect, an embodiment of the present invention further provides a computing device, including: a memory for storing a program; a processor for calling the program stored in said memory and executing the method as described in the various possible designs of the first aspect according to the obtained program.
In a fifth aspect, the embodiments of the present invention also provide a computer-readable non-volatile storage medium, which includes a computer-readable program, and when the computer-readable program is read and executed by a computer, the computer is caused to execute the method as described in the various possible designs of the first aspect.
These and other implementations of the invention will be more readily understood from the following description of the embodiments.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic diagram of a system architecture for task processing according to an embodiment of the present invention;
FIG. 2 is a system architecture diagram of task processing according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a task processing method according to an embodiment of the present invention;
fig. 4 is a flowchart illustrating a method for determining an available permission indication according to an embodiment of the present invention;
fig. 5 is a flowchart illustrating a task processing method according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a task processing device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a task processing system architecture provided by an embodiment of the present invention, where a production server 101 is used for producing a task and storing the task in a middleware 102. The processing server 103 monitors the task storage condition in the middleware 102, and when the processing server 103 determines that the task is stored in the middleware 102, the task is acquired from the middleware 102. After the processing server 103 obtains the task, it determines the working state of the thread pool.
If the processing server 103 determines that the operating state of the thread pool is a high-voltage state, the task is placed back to the middleware 102.
If the processing server 103 determines that the working state of the thread pool is a medium-voltage state in a non-high-voltage state, or a low-voltage state and the processing rate requirement of the task is a non-high-speed processing rate requirement. And generating an authority acquisition request according to the processing rate requirement of the task and the algorithm number corresponding to the authority algorithm, and sending the authority acquisition request to the current limiting server 104. The current limiting server 104 determines a corresponding authority algorithm according to the algorithm number in the authority obtaining request, determines an authority allocation mechanism of the corresponding authority algorithm according to the processing rate requirement of the task in the authority obtaining request, if an available authority instruction exists in the authority allocation mechanism, the current limiting server 104 generates an authority obtaining response according to the authority instruction, returns the authority obtaining response to the processing server 103, and the processing server 103 processes the task according to the authority instruction contained in the authority obtaining response. If there is no available permission instruction in the permission allocation mechanism, the current limiting server 104 returns a permission acquisition response containing no permission instruction to the processing server 103. The processing server 103 puts the task back to the middleware 102.
If the processing server 103 determines that the working state of the thread pool is an ultra-low-voltage state in a non-high-voltage state, or a low-voltage state and the processing rate requirement of the task is a high-speed processing rate requirement. And generating an authority acquisition request according to the processing rate requirement of the task and the algorithm number corresponding to the authority algorithm, and sending the authority acquisition request to the current limiting server 104. The current limiting server 104 determines a corresponding authority algorithm according to the algorithm number in the authority obtaining request, determines an authority allocation mechanism of the corresponding authority algorithm according to the processing rate requirement of the task in the authority obtaining request, if an available authority instruction exists in the authority allocation mechanism, the current limiting server 104 generates an authority obtaining response according to the authority instruction, returns the authority obtaining response to the processing server 103, and the processing server 103 processes the task according to the authority instruction contained in the authority obtaining response. If no available permission instruction exists in the permission allocation mechanism, the current limiting server 104 generates a permission acquisition response according to the generation time of the next permission instruction, returns the permission acquisition response to the processing server 103, waits according to the generation time of the next permission instruction included in the permission acquisition response by the processing server 103, and generates a permission acquisition request again to acquire the permission instruction when the generation time of the next permission instruction is reached. The current limiting server 104 generates an authority obtaining response according to the generated authority instruction, returns the authority obtaining response to the processing server 103, and the processing server 103 processes the task according to the generated authority instruction contained in the authority obtaining response. Therefore, different authorities are set for different tasks to be processed, pertinence of a task processing scheme is increased, and accuracy and timeliness of task processing are improved. In addition, in the initialization stage of the task processing system, the processing server 103 monitors that the middleware 102 stores tasks, acquires the tasks from the middleware 102, sends the authority algorithm to the current limiting server 104, and acquires the algorithm number of the authority algorithm returned by the current limiting server 104. Therefore, the right algorithm is contained in the current limiting server 104, manual installation of the right algorithm is not needed, installation accuracy is improved, installation speed of the right algorithm is improved, and cost is saved.
Based on the task processing system architecture in fig. 1, a task processing system architecture provided by an embodiment of the present invention is shown in fig. 2; the task processing system comprises a production server cluster 201 (including a production server 1 and a production server 2 …, wherein m is greater than or equal to 1, any one or more production servers in the production server cluster 201 can be the production server 101 in the system architecture of fig. 1), middleware 202, a processing server cluster 203 (including a processing server 1 and a processing server 2 …, n is greater than or equal to 1, any one or more processing servers in the processing server cluster 203 can be the processing server 103 in the system architecture of fig. 1) and a current limiting server cluster 204 (including a current limiting server 1, a current limiting server 2 …, k is greater than or equal to 1, and any one or more current limiting servers in the current limiting server cluster 204 can be the current limiting server 104 in the system architecture of fig. 1);
any production server in the production server cluster 201 is used for production tasks;
the middleware 202 is used for storing tasks according to a queue mode;
any processing server in the processing server cluster 203 is used for acquiring a permission instruction according to the working state of the thread pool and the requirement of task processing rate, and processing the task according to the permission instruction;
any current limiting server in the current limiting server cluster 204 is used for limiting the task processing speed according to the permission algorithm and the processing speed requirement.
Based on the system architecture, an embodiment of the present invention provides a flow of a task processing method, as shown in fig. 3, including:
301, the processing server obtains a task generated by the production server from the middleware;
here, a task may be a task that contains batch messages, where the processing speed requirements for the batch messages in the task are the same, e.g., the message channel rate requirements are the same. The task may also be a system transaction, such as a status reporting transaction, an alarm transaction, etc. corresponding to each subsystem of the transaction processing system. The specific object of the task is not limited, and the method is applicable to all objects to which the invention can be applied. The middleware may be mq (message queue) message queue middleware, Kafka distributed message publishing and subscribing system, etc., and may be the most suitable middleware for the application adaptively according to the specific object of the task, and the application-specific middleware is not limited in the present invention.
Step 302, the processing server determines the working state of a thread pool for processing each task;
here, the operating state of the thread pool may be set by the processing server to an operating state threshold. For example, a thread pool size is defined in the processing server to be 200, that is, 200 threads can be concurrently processed by the thread pool, and the maximum number of concurrent threads applied by the processing server does not exceed 200. The thread pool operating state may be determined according to the number of concurrent threads in the thread pool, for example, a low-voltage state: the quantity of the concurrent threads is 100, and the quantity of the current simultaneous processing tasks is moderate within the proportion of 30 percent and 50 percent of the concurrent threads in the thread pool. And (3) medium-pressure state: the number of the concurrent threads is 150, the number of the short messages which are sent at the same time is indicated within the concurrent thread proportion (50% and 75%) in the thread pool, the high-voltage state is 190, the number of the concurrent thread proportion (75% and 95%) in the thread pool is indicated to be very large, and the concurrency is very high.
Step 303, if the processing server determines that the working state is a non-high-voltage state, generating an authority acquisition request according to a processing rate requirement of the task, and sending the authority acquisition request to a current limiting server, where the current limiting server is configured to determine a corresponding authority indication according to the processing rate requirement in each authority acquisition request; wherein, different processing rate requirements correspond to different authority distribution mechanisms;
here, if the task is a message sending task including a batch of messages, the processing rate requirement may be a message channel rate requirement, and if the task is an abnormal alarm task, the processing rate requirement may be an effective time of the abnormal alarm task. The processing rate requirement may be set according to a specific task, and the present invention is not limited to the specific requirement. The current limiting server may be a redis (remote Dictionary server), i.e., a remote Dictionary service, or other server that can run a permission algorithm. The system or service in the current limiting server is not limited herein.
And step 304, when the received permission obtaining response contains a permission indication, the processing server processes the task through the thread in the thread pool.
Here, the authority indication may be an indication including a processing scheme, for example, the authority indication corresponding to the alarm type of the abnormal alarm task may be an alarm mail generated to a worker for different human roles. The permission indication may also be a token, for example, if the message acquires the token, the sending process may be directly performed. The specific content of the permission indication is not limited, and can be specifically set according to the scheme requirement and the task object.
In the method, the current limiting server is used for determining the corresponding permission indication according to the processing speed requirement. Therefore, processing according to different authorities can be realized for different tasks, the time delay of task processing is reduced, and the success rate of task processing is improved. And the processing server determines that the working state of the thread pool is a non-high-voltage state, generates an authority acquisition request according to the processing speed requirement of the task, and sends the authority acquisition request to the current limiting server. Therefore, the method not only considers that different tasks have different requirements on the processing speed of the task processing and the corresponding tasks have different emergency situations of the task processing, but also considers the working state of the thread pool in the processing server, and improves the success rate of the task processing. For example, in one case, if the task is a message to be processed, the processing rate requirement may be a message channel rate requirement, and the throttling server is configured to limit the message processing speed according to the message channel rate. Therefore, the respective fixed speed processing can be realized aiming at the messages with different message channel rate requirements, and the message sending delay is reduced. And the processing server determines whether to generate an authority acquisition request according to the working state of the thread pool and the message channel rate of the message. Therefore, the message sending emergency corresponding to the requirements of different messages on the message sending channel rate is considered, the working state of the thread pool in the processing server is also considered, and the message sending success rate is improved.
The invention provides a task processing method, which further comprises the following steps: and if the processing server determines that the working state is a high-voltage state, the task is put back to the middleware. In the above example, if the size of the thread concurrency number is 190, within 76% -95% of the concurrent thread proportion in the thread pool, it indicates that the number of short messages currently sent at the same time is very large, and the concurrency amount is very high, and at this time, most threads in the thread pool are all working, so for a task newly taken out from the middleware, the tail of the middleware task queue is directly replaced again. Therefore, the normal running state of the task processor is ensured, the condition that the task is lost or the task processing fails and the like due to overlarge concurrent pressure in the thread pool is prevented from being sent, and the success rate of the task processing is improved.
The invention provides a task processing method, wherein if a processing server determines that the working state is a non-high-voltage state, a permission acquisition request is generated according to the processing speed requirement of a task, and the method comprises the following steps:
the processing server determines that the working state is an ultra-low-voltage state, or if the working state is a low-voltage state and the processing speed requirement is a high speed, a first permission obtaining request is generated according to the processing speed requirement of the task; the first permission obtaining request is used for obtaining permission indication and obtaining indication of the next moment.
In the above example, the size of the number of concurrent threads is less than 60, and the proportion of concurrent threads in the thread pool is less than 30%; or, the number of the concurrent threads is 61-100, the concurrent thread proportion in the thread pool is within 30% and 50%, and the processing speed requirement of the task is high speed, a first permission obtaining request is generated to obtain permission indication from the current limiting server, if the permission indication cannot be obtained, the generation time of the next permission indication is obtained, and when the generation time is up, the permission indication is obtained from the current limiting server.
For another example, if the task is a short message, the threads in the thread pool are short message sending and processing threads, the number of concurrent threads is less than 60, and the proportion of the concurrent threads in the thread pool is less than 30%; or, the number of the concurrent threads is 61-100, the concurrent threads account for within 30%, 50% in the thread pool, and the channel rate requirement of the short message on the short message sending channel provided by the operator is high speed (greater than a set rate threshold, which can be set as required), then a first permission obtaining request is generated to obtain the token and the waiting time from the current limiting server, if the token is not obtained, the next token generation time is obtained, then the current short message sending processing thread sleep is obtained until the generation time is reached, the token is obtained from the current limiting server, and the short message sending processing is performed. If the generation time is reached, the short message can be placed back to the tail of the middleware queue if the token is not obtained from the current limiting server.
The invention provides a task processing method, which further comprises the following steps: and when the processing server does not contain the permission indication in the received permission acquisition response and contains an acquisition indication at the next moment, the processing server sends the permission acquisition request to the current limiting server again according to the time of the acquisition indication. That is, the different authority allocation mechanisms have different authority instruction generation speeds, such as 1/s or 1/min, and if there is no available authority instruction in the corresponding authority allocation mechanism, the next authority instruction generation time may be obtained, and the processing server re-obtains the generated authority instruction when the next authority instruction generation time arrives.
The invention provides a task processing method, wherein if a processing server determines that the working state is a non-high-voltage state, a permission acquisition request is generated according to the processing speed requirement of a task, and the method comprises the following steps:
the processing server determines the working state to be a medium-voltage state, or if the working state is a low-voltage state and the processing speed requirement is a non-high speed, a second permission obtaining request is generated according to the processing speed requirement of the task; the second permission obtaining request is used for obtaining permission indication;
the method further comprises the following steps: and when the received permission obtaining response does not contain the permission indication, the processing server puts the task back to the middleware. In the above example, the low pressure state: the number of the concurrent threads is 61-100, the concurrent thread occupation ratio in the thread pool is within (30% and 50%) and the task processing speed requirement is non-high speed, or the number of the concurrent threads is 101-150, the concurrent thread occupation ratio in the thread pool is within (50% and 75% >).
The invention provides a task processing method, which comprises the following steps that before generating an authority acquisition request according to the processing speed requirement of a task: the processing server generates a clock acquisition request and sends the clock acquisition request to the current limiting server; the processing server acquires clock information returned by the current limiting server; the permission acquisition request includes the clock information. That is, the processing server needs to acquire clock information of the current limiting server before generating the authority acquisition request. Because the generation speed of the authority indication in the authority distribution mechanism in the current-limiting server takes the clock information in the current-limiting server as a reference, in order to ensure that the processing server can accurately judge the time for acquiring the authority indication, if the processing server acquires the next authority indication generation time, the clock information of the processing server is synchronous with the clock information in the current-limiting server, and the authority indication can be acquired in time when the next authority indication generation time arrives. When the processing server cluster performs task processing simultaneously, any task processing server in the task processing server cluster acquires the permission indication from the current limiting server or the current limiting server cluster, and it is required to ensure that all the processing servers in the task processing server cluster and all the current limiting servers in the current limiting server cluster are in the same time process.
In addition, the permission acquisition request generated by the processing server includes clock information, and the current limiting server can also judge whether the available permission indication exists at present according to the clock information, and the present invention provides a method flow for judging the available permission indication, as shown in fig. 4, including:
step 401, the current limiting server obtains the permission obtaining request, and obtains a clock in the permission obtaining request.
Step 402, judging whether the clock is greater than the earliest generation time corresponding to the available authority indication, if so, executing step 403, otherwise, executing step 404.
In step 403, the number of available permission indications is calculated, where the number of permission indications is (the earliest generation time corresponding to the clock-available permission indication)/the generation speed of the permission indication.
In step 404, whether the number of available permission indications is greater than 0, if so, step 405 is executed, and if not, step 406 is executed.
And 405, generating an authority acquisition response according to the available authority indication corresponding to the current earliest generation time by the current limiting server and returning the authority acquisition response to the processing server.
And step 406, the current limiting server generates an authority obtaining response according to the next authority indication generation time and returns the authority obtaining response to the processing server. Or returning the authority acquisition response which does not contain the available authority indication and the next authority indication generation time to the processing server. Here, the current limiting server may determine whether to return the next right indication generation time in the right acquisition response when no right indication is available, according to the type of instruction in the received right acquisition request. In an example, if the permission indication is a token and the permission allocation mechanism is a token bucket, the instruction type in the token obtaining request may be acquire or tryAcquire, the acquire instruction is used to obtain the token but does not need to obtain the next token out-of-bucket time, the tryAcquire instruction directly obtains the token, and if the token cannot be obtained, the next token out-of-bucket time is obtained.
It should be noted that the above flow is only an example of a method for determining an authority indication by a current-limiting server, and does not limit the specific method for determining an authority indication of the present invention.
The embodiment of the invention provides a method for acquiring an authority algorithm by a current limiting server, which comprises the following steps after a processing server acquires a task generated by a production server from a middleware:
the processing server sends an authority algorithm to the current limiting server to obtain an algorithm number determined by the current limiting server according to the authority algorithm, wherein the authority algorithm is used for generating an authority distribution mechanism; generating a permission acquisition request according to the processing rate requirement of the task, wherein the permission acquisition request comprises the following steps: and the processing server generates an authority acquisition request according to the processing speed requirement of the task and the algorithm number, wherein the algorithm number is used for the current limiting server to determine the applied authority algorithm according to the algorithm number. That is to say, before the processing server processes the task for the first time, the authority algorithm needs to be sent to the current limiting server, the current limiting server runs the algorithm, and returns the algorithm number of the algorithm (which may be transmitted by a hash value), so that the request sent by the processing server subsequently includes the algorithm number, and further, the current limiting server can accurately obtain the authority algorithm corresponding to the request. In one embodiment, the authority algorithm may be a token bucket algorithm based on delayed computation implemented by lua (a lightweight and compact scripting language) script algorithm, and the corresponding authority allocation mechanism may be to generate token buckets with different token speeds.
The embodiment of the invention provides a task, wherein the task is a message sending task; the middleware is a message middleware; the permission indication is a token; different processing rate requirements correspond to different token buckets.
Based on the method and the flow, the embodiment of the invention provides the flow of a task processing method; the task is a task containing batch messages, and the task processing speed requirement is a message channel speed requirement. The message channel rate requirements for all messages in the batch of messages are the same. The authority distribution mechanism in the current-limiting server is a token bucket, the token generation speeds of different token buckets are different, and different tasks can correspond to the same or different token buckets, so that messages of different batches can be sent at a fixed speed, namely, the current limitation of the messages of different batches is realized. As shown in fig. 5, includes:
step 501, the production server generates a task including batch messages as required, and each message of the task includes parameter information such as message channel rate, task number (different types of batch messages may correspond to different task numbers), task type, and the like.
Step 502, the production server sends the task to the message middleware.
Step 503, the processing server monitors that the task exists in the message middleware, and then obtains the message.
Step 504, the processing server sends the token bucket algorithm script to the current limiting server.
And 505, the current limiting server receives the algorithm script and stores the algorithm script, generates an algorithm number according to the algorithm script and sends the algorithm number to the processing server. The algorithm number may be a hash value.
Step 506, after receiving the algorithm number, the processing server stores the algorithm number.
Step 507, the processing server judges the working state of the current thread pool. If the current thread pool working state is a high-pressure state, executing step 508; if the current thread pool working state is the medium-voltage state or the low-voltage state and the message channel rate corresponding to the message is not the high speed, the steps 509 to 514 are executed. And if the working state of the current thread pool is an ultra-low voltage state or a low voltage state and the message channel rate corresponding to the message is high speed, executing the steps 515 to 519.
Step 508, send the message to message middleware.
Step 509, generate a clock request and send the clock request to the current limiting server.
Step 510, after receiving the clock acquisition request, the current limiting server sends the clock information of the current limiting server to the processing server.
Step 511, after receiving the clock information sent by the current limiting server, the processing server generates a permission acquisition request according to parameters such as the message channel rate, the task number, the task type, the clock information and the like, and sends the permission acquisition request to the current limiting server.
And step 512, the current limiting server receives the permission acquisition request, judges whether a token can be acquired according to clock information in the permission acquisition request, generates a permission acquisition response according to a judgment result, and returns the permission acquisition response to the processing server. In one example, the task is a message, the permission indication is a token, the permission allocation mechanism is a token bucket, and the permission acquisition request is a token acquisition request including an acquire instruction.
Step 513, the processing server determines whether the message acquires a token according to the permission acquisition response. If the token is obtained, go to step 514; if the token is not obtained, step 508 is performed.
Step 514, the processing server sends the message.
Step 515, generate a clock request and send to the current limit server.
Step 516, after receiving the clock acquisition request, the current limiting server sends the clock information of the current limiting server to the processing server.
Step 517, after receiving the clock information sent by the current limiting server, the processing server generates an authority obtaining request according to parameters such as message channel rate, task number, task type, clock information and the like, and sends the authority obtaining request to the current limiting server.
Step 518, the current limiting server receives the permission acquisition request, judges whether a token can be acquired or the out-of-bucket time of the next token according to the clock information in the permission acquisition request, generates a permission acquisition response according to the judgment result and the out-of-bucket time of the next token, and returns the permission acquisition response to the processing server. In one example, the task is a message, the permission indication is a token, the permission allocation mechanism is a token bucket, and the permission acquisition request is a token acquisition request, where the token acquisition request includes a tryacquire instruction.
Step 519, the processing server determines whether the message obtains a token according to the determination result. If the token is obtained, the message is directly sent; and if the bucket-out time of the next token is obtained, obtaining the token and sending the message when the next token is out of the bucket.
It should be noted that the above-mentioned steps of the flow are not exclusive, and the processor may perform the steps only once for each task when the task processing system is initialized in steps 504 to 506. The current limiting server may receive the token bucket algorithm script once for each processing server, and store the token bucket algorithm script only once, that is, if the current limiting server determines that the token bucket algorithm script included in the current request (the token bucket algorithm script sent by the processing server) is already included, the current limiting server ignores the request.
Based on the same concept, an embodiment of the present invention provides a task processing device, and fig. 6 is a schematic diagram of a task processing device provided in an embodiment of the present application, as shown in fig. 6, including:
an obtaining module 601, configured to obtain a task generated by a production server from a middleware;
a processing module 602, configured to determine a working state of a thread pool for processing each task; if the working state is determined to be a non-high-voltage state, generating an authority acquisition request according to the processing rate requirement of the task, and sending the authority acquisition request to a current limiting server, wherein the current limiting server is used for determining a corresponding authority indication according to the processing rate requirement in each authority acquisition request; wherein, different processing rate requirements correspond to different authority distribution mechanisms; the obtaining module 601 is further configured to, when the received permission obtaining response includes a permission indication, process the task through a thread in the thread pool of the processing module 602.
Optionally, the processing module 602 is further configured to, if it is determined that the working state is a high-voltage state, replace the task in the middleware.
Optionally, the processing module 602 is specifically configured to determine that the working state is an ultra-low voltage state, or if the working state is a low voltage state and the processing rate requirement is a high speed, generate a first permission obtaining request according to the processing rate requirement of the task; the first permission obtaining request is used for obtaining permission indication and obtaining indication of the next moment.
Optionally, the obtaining module 601 is further configured to, when the received permission obtaining response does not include the permission indication and includes a obtaining indication at a next time, send the permission obtaining request to the current limiting server again according to the time of the obtaining indication.
Optionally, the processing module 602 is specifically configured to determine that the working state is a medium-voltage state, or generate a second permission obtaining request according to the processing rate requirement of the task if the working state is a low-voltage state and the processing rate requirement is a non-high speed state; the second permission obtaining request is used for obtaining permission indication; the obtaining module 601 is further configured to, when the received permission obtaining response does not include the permission indication, replace the task to the middleware through the processing module 602.
Optionally, the processing module 602 is further configured to generate a clock acquisition request, and send the clock acquisition request to the current limiting server through the acquisition module 601; the obtaining module 601 is further configured to obtain clock information returned by the current limiting server; the permission acquisition request includes the clock information.
Optionally, the obtaining module 601 is further configured to send a permission algorithm to the current-limiting server, obtain an algorithm number determined by the current-limiting server according to the permission algorithm, where the permission algorithm is used to generate a permission allocation mechanism; the processing module 602 is specifically configured to generate an authority obtaining request according to the processing rate requirement of the task and the algorithm number, where the algorithm number is used by the current limiting server to determine the authority algorithm applied according to the algorithm number.
Optionally, the task is a message sending task; the middleware is a message middleware; the permission indication is a token; different processing rate requirements correspond to different token buckets.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention 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 invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the invention. 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.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (12)

1. A method for processing a task, the method comprising:
the processing server acquires the tasks generated by the production server from the middleware;
the processing server determines the working state of a thread pool for processing each task;
if the processing server determines that the working state is a non-high-voltage state, generating an authority acquisition request according to the processing rate requirement of the task, and sending the authority acquisition request to a current limiting server, wherein the current limiting server is used for determining a corresponding authority indication according to the processing rate requirement in each authority acquisition request; wherein, different processing rate requirements correspond to different authority distribution mechanisms;
and when the received permission acquisition response contains a permission indication, the processing server processes the task through the thread in the thread pool.
2. The method as recited in claim 1, further comprising:
and if the processing server determines that the working state is a high-voltage state, the task is put back to the middleware.
3. The method as claimed in claim 1, wherein if the processing server determines that the working status is a non-high-voltage status, generating an authorization acquisition request according to a processing rate requirement of the task, comprises:
the processing server determines that the working state is an ultra-low-voltage state, or if the working state is a low-voltage state and the processing speed requirement is a high speed, a first permission obtaining request is generated according to the processing speed requirement of the task; the first permission obtaining request is used for obtaining permission indication and obtaining indication of the next moment.
4. The method as recited in claim 3, further comprising:
when the processing server does not contain the authority indication in the received authority acquisition response and contains an acquisition indication of the next moment,
and the processing server sends the permission acquisition request to the current limiting server again according to the time of the acquisition indication.
5. The method as claimed in claim 1, wherein if the processing server determines that the working status is a non-high-voltage status, generating an authorization acquisition request according to a processing rate requirement of the task, comprises:
the processing server determines the working state to be a medium-voltage state, or if the working state is a low-voltage state and the processing speed requirement is a non-high speed, a second permission obtaining request is generated according to the processing speed requirement of the task; the second permission obtaining request is used for obtaining permission indication;
the method further comprises the following steps:
and when the received permission obtaining response does not contain the permission indication, the processing server puts the task back to the middleware.
6. The method as recited in claim 1, wherein prior to generating a permission acquisition request based on a processing rate requirement of the task, further comprising:
the processing server generates a clock acquisition request and sends the clock acquisition request to the current limiting server;
the processing server acquires clock information returned by the current limiting server; the permission acquisition request includes the clock information.
7. The method of claim 1, wherein after the processing server obtains the production server generated tasks from the middleware, further comprising:
the processing server sends an authority algorithm to the current limiting server to obtain an algorithm number determined by the current limiting server according to the authority algorithm, wherein the authority algorithm is used for generating an authority distribution mechanism;
generating a permission acquisition request according to the processing rate requirement of the task, wherein the permission acquisition request comprises the following steps:
and the processing server generates an authority acquisition request according to the processing speed requirement of the task and the algorithm number, wherein the algorithm number is used for the current limiting server to determine the applied authority algorithm according to the algorithm number.
8. The method of any of claims 1-7, wherein the task is a messaging task; the middleware is a message middleware; the permission indication is a token; different processing rate requirements correspond to different token buckets.
9. A task processing system is characterized in that the task processing system comprises a production server cluster, a middleware, a processing server cluster and a current limiting server cluster;
any production server in the production server cluster is used for production tasks;
the middleware is used for storing tasks according to a queue mode;
any processing server in the processing server cluster is configured to perform the method of any of claims 1 to 8;
and any current limiting server in the current limiting server cluster is used for limiting the task processing speed according to the permission algorithm and the processing speed requirement.
10. A task processing apparatus, characterized in that the apparatus comprises:
the acquisition module is used for acquiring the tasks generated by the production server from the middleware;
the processing module is used for determining the working state of a thread pool for processing each task; if the working state is determined to be a non-high-voltage state, generating an authority acquisition request according to the processing rate requirement of the task, and sending the authority acquisition request to a current limiting server, wherein the current limiting server is used for determining a corresponding authority indication according to the processing rate requirement in each authority acquisition request; wherein, different processing rate requirements correspond to different authority distribution mechanisms;
the acquiring module is further configured to process the task through a thread in the thread pool of the processing module when the received permission acquisition response includes a permission indication.
11. A computer-readable storage medium, characterized in that it stores a program which, when run on a computer, causes the computer to carry out the method of any one of claims 1 to 8.
12. A computer device, comprising:
a memory for storing a computer program;
a processor for calling a computer program stored in said memory to execute the method of any of claims 1 to 8 in accordance with the obtained program.
CN202111036581.0A 2021-09-06 2021-09-06 Task processing method and device Pending CN113835854A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111036581.0A CN113835854A (en) 2021-09-06 2021-09-06 Task processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111036581.0A CN113835854A (en) 2021-09-06 2021-09-06 Task processing method and device

Publications (1)

Publication Number Publication Date
CN113835854A true CN113835854A (en) 2021-12-24

Family

ID=78962226

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111036581.0A Pending CN113835854A (en) 2021-09-06 2021-09-06 Task processing method and device

Country Status (1)

Country Link
CN (1) CN113835854A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114584519A (en) * 2022-05-05 2022-06-03 飞狐信息技术(天津)有限公司 Message middleware and current limiting method thereof
CN114726798A (en) * 2022-02-28 2022-07-08 福建星云电子股份有限公司 Lithium battery test channel current limiting method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114726798A (en) * 2022-02-28 2022-07-08 福建星云电子股份有限公司 Lithium battery test channel current limiting method and system
CN114584519A (en) * 2022-05-05 2022-06-03 飞狐信息技术(天津)有限公司 Message middleware and current limiting method thereof

Similar Documents

Publication Publication Date Title
CN113835854A (en) Task processing method and device
CN109347757B (en) Message congestion control method, system, device and storage medium
CN108848039A (en) The method and storage medium that server, message are distributed
CN110300067B (en) Queue adjusting method, device, equipment and computer readable storage medium
CN110795254A (en) Method for processing high-concurrency IO based on PHP
US11656902B2 (en) Distributed container image construction scheduling system and method
CN110471651B (en) Method and server for realizing control inversion based on C++
CN102904961A (en) Method and system for scheduling cloud computing resources
CN111343102A (en) Flow rate control method, server-side server, client-side server and system
US8769233B2 (en) Adjusting the amount of memory allocated to a call stack
CN112346834A (en) Database request processing method and device, electronic equipment and medium
CN111866101A (en) Access request processing method and device, storage medium and electronic equipment
CN108628677B (en) Distributed task processing system, method and device
US20060020678A1 (en) Time and event controlled message processing
CN115904761A (en) System on chip, vehicle and video processing unit virtualization method
GB2607475A (en) Generating a scaling plan for external systems during cloud tenant onboarding/offboarding
CN114584618A (en) Information interaction method, device, equipment, storage medium and system
CN112596761B (en) Service update release method and device and related equipment
CN115658745A (en) Data processing method, data processing device, computer equipment and computer readable storage medium
EP4086753A1 (en) Decision scheduling customization method and device based on information flow
CN114385351A (en) Cloud management platform load balancing performance optimization method, device, equipment and medium
CN112333262A (en) Data updating prompting method and device, computer equipment and readable storage medium
CN113742071A (en) Task processing method and electronic equipment
CN113259261B (en) Network flow control method and electronic equipment
CN106484536B (en) IO scheduling method, device and equipment

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