WO2019237593A1 - 任务处理方法、装置、计算机设备及存储介质 - Google Patents

任务处理方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2019237593A1
WO2019237593A1 PCT/CN2018/109449 CN2018109449W WO2019237593A1 WO 2019237593 A1 WO2019237593 A1 WO 2019237593A1 CN 2018109449 W CN2018109449 W CN 2018109449W WO 2019237593 A1 WO2019237593 A1 WO 2019237593A1
Authority
WO
WIPO (PCT)
Prior art keywords
preset
task
executed
queue
tasks
Prior art date
Application number
PCT/CN2018/109449
Other languages
English (en)
French (fr)
Inventor
丁文祥
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019237593A1 publication Critical patent/WO2019237593A1/zh

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/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

Definitions

  • the present application relates to the field of Internet technologies, and in particular, to a method, an apparatus, a computer device, and a storage medium for task processing.
  • the Web platform is usually developed using a combination of Ansible and the Celery framework, but the tasks in the Celery queue can only be executed in a single process. Process execution will cause task consumption to be slow, which in turn will cause performance bottlenecks when executing on remote servers, causing Celery queues to accumulate a large number of tasks. Therefore, it is necessary to provide a task processing method to solve the above problems.
  • This application provides a task processing method, device, computer equipment, and storage medium, which aims to speed up the response speed of the Web platform.
  • the present application provides a task processing method, which includes:
  • the present application provides a task processing apparatus, including:
  • a first obtaining unit configured to obtain a task to be executed in a Celery queue in the Web platform
  • a task saving unit configured to save the to-be-executed task to the preset task queue
  • a second obtaining unit configured to obtain a to-be-executed task in the preset task queue that satisfies a preset execution condition, where the preset execution condition corresponds to a preset processing mode;
  • a task execution unit is configured to execute a task to be executed that meets the preset execution condition according to the preset processing mode.
  • the present application further provides a computer device including a memory, a processor, and a computer program stored on the memory and executable on the processor.
  • the processor implements the program when the program is executed. The steps of the task processing method according to any one of the present application.
  • the present application further provides a storage medium, wherein the storage medium stores a computer program, where the computer program includes program instructions, and the program instructions, when executed by a processor, cause the processor to execute the application The steps of the task processing method according to any one of the provided.
  • a preset task queue can be created by using the Redis tool, and different preset processing methods can be used to quickly consume tasks in the Celery queue through the preset task queue, thereby avoiding a large accumulation of tasks and solving the problem of execution on a remote server.
  • FIG. 1 is a schematic flowchart of a task processing method according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of sub-steps of the task processing method in FIG. 1;
  • FIG. 3 is a schematic flowchart of sub-steps of the task processing method in FIG. 2;
  • FIG. 4 is a schematic flowchart of a task processing method according to another embodiment of the present application.
  • FIG. 5 is a schematic block diagram of a task processing apparatus according to an embodiment of the present application.
  • FIG. 6 is a schematic block diagram of a task processing apparatus according to another embodiment of the present application.
  • FIG. 7 is a schematic block diagram of a computer device according to an embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a task processing method according to an embodiment of the present application. As shown in FIG. 1, the task processing method includes steps S101 to S105.
  • the web platform is a web platform developed based on Ansible and Celery framework.
  • Ansible is an automated operation and maintenance tool developed based on Python.
  • Celery is a distributed asynchronous message task queue based on Python. Asynchronous processing of tasks. Among them, Celery can only perform tasks in a single thread, so Celery queues can accumulate a large number of tasks, affecting the responsiveness of the Web platform.
  • the Redis tool is a high-performance key-value database and a memory database.
  • the Redis tool is added to the Web platform, and a preset task queue is created through the Redis tool, and the preset task queue is used to record tasks.
  • the preset task queue may be in the form of a queue list.
  • the obtaining the to-be-executed tasks in the Celery queue in the Web platform includes periodically polling the Celery queue to obtain the to-be-executed tasks in the Celery queue in the Web platform.
  • the duration of the timing polling can be set according to actual needs, and is not limited herein.
  • the acquiring a task to be executed in a Celery queue in the Web platform includes: acquiring a Web application corresponding to the task to be executed.
  • the Web application corresponding to the task to be executed specifically refers to a task to be executed issued by a certain Web application.
  • the preset task queue is a task queue created in a memory database by a Redis tool, so it is convenient to quickly save or read the content of the preset task queue, thereby speeding up the processing of tasks to be executed speed.
  • the preset execution condition is used to classify the tasks to be executed in the preset task queue, so that different preset processing modes are selected for execution according to different tasks to be executed.
  • the preset processing mode is a multi-threaded processing mode, thereby speeding up the processing speed of the tasks to be executed.
  • the preset execution condition is, for example, that a Web application corresponding to a task to be executed is in a running state.
  • step S104 includes sub-steps S104a and S104b.
  • S104a Monitor whether the web application corresponding to the task to be executed in the preset task queue is running;
  • S104b If the web application corresponding to the task to be executed is running, determine that the task to be executed meets the requirements
  • the preset execution conditions are described.
  • step S104a includes sub-steps S104al and S104a2.
  • S104al monitor the status of the running loop of the main thread corresponding to the web application corresponding to the task to be executed; S104a2, determine whether the web application is running according to the status of the running loop of the main thread.
  • the state of the running loop of the main thread corresponding to the web application is monitored to determine whether the web application is running. If the state of the running loop of the main thread is a sleep state, the web application is in an idle state; instead This indicates that the web application is running.
  • obtaining the to-be-executed tasks in the preset task queue that satisfies a preset execution condition includes determining a preset number range corresponding to the number of to-be-executed tasks in the preset task queue, wherein Different preset number ranges correspond to different preset processing methods; a preset processing method corresponding to the preset number range is acquired according to the determined preset number range.
  • the preset quantity range includes a first quantity range or a second quantity range, and of course, other quantity ranges may also be included, where the first quantity range and the second quantity range correspond to different numbers of tasks to be performed, and correspond to different presets.
  • Set the processing mode for example, both adopt multi-thread processing, but the multi-thread processing includes the first multi-thread processing and the second multi-thread processing.
  • the two multi-thread processing methods have different numbers of open threads, where the first The quantity range corresponds to the first multi-threaded processing mode, and the second quantity range corresponds to the second multi-threaded processing mode. This can determine the range of numbers corresponding to different numbers of tasks to be executed, and select the corresponding multi-threaded processing mode for execution. Not only can speed up processing, but also save resources.
  • a to-be-executed task that satisfies the preset execution condition is executed according to a preset processing manner corresponding to the preset execution condition to complete the to-be-executed task in the preset task queue.
  • a to-be-executed task corresponding to a running Web application is executed in a multi-thread processing manner to complete processing of the to-be-executed task.
  • the tasks to be executed in the preset task queue that satisfy the preset number range are executed according to a preset processing manner corresponding to the preset number range.
  • a Redis tool is added to the Web platform, and a preset task queue is created through the Redis tool; a pending task in the Celery queue in the Web platform is obtained; and the pending task is saved to the preset.
  • This method can use the preset task queue created by the Redis tool, and select different preset processing methods to quickly consume the tasks of the Celery queue through the preset task queue, thereby avoiding a large accumulation of tasks and speeding up the processing speed of the tasks to be executed. , Which in turn improves the response speed of the Web platform and improves the user experience.
  • FIG. 4 is a schematic flowchart of a task processing method according to another embodiment of the present application. As shown in FIG. 4, the task processing method includes steps S201 to S208.
  • the preset task queue is created in an in-memory database by using a Redis tool, and is used to record a task to be executed.
  • the task to be executed is a task to be processed corresponding to each Web application, and of course, it may include a Web application-related task. Pending tasks for other applications.
  • the preset task queue may be in the form of a queue list.
  • the Celery queue is polled to obtain the to-be-executed tasks in the Celery queue in the Web platform, and the web application corresponding to the to-be-executed tasks is also obtained.
  • S203 Determine whether the number of tasks to be executed in the Celery queue is greater than the preset number of tasks.
  • the preset task number may be an empirical value, and the preset task number may be used to determine whether the number of tasks to be executed in the Celery queue will form a stack. When the number of tasks to be executed in the Celery queue is greater than The preset number of tasks indicates that there is a possibility of task accumulation.
  • the number of tasks to be executed in the Celery queue is greater than the number of preset tasks, it is monitored whether a web application corresponding to the tasks to be executed in the preset task queue is in a running state.
  • the monitoring whether the web application corresponding to the task to be executed is in a running state specifically adopting: monitoring a state of a running loop of a main thread corresponding to the web application corresponding to the task to be executed; according to the running of the main thread The state of the loop determines whether the Web application is in a running state.
  • the preset task queue is a task queue created in an in-memory database by a Redis tool, so it is convenient to quickly save or read the content of the preset task queue, thereby speeding up the processing speed of tasks to be executed.
  • the preset quantity range includes a first quantity range and a second quantity range, and of course, other quantity ranges may also be included, where the first quantity range and the second quantity range correspond to different numbers of tasks to be performed.
  • the first quantity range corresponds to the first multi-threaded processing manner
  • the second quantity range corresponds to the second multi-threaded processing manner, wherein the first multi-threaded processing manner and the first The number of open threads in the second multi-threaded processing mode is different.
  • the first multi-threaded processing mode opens 8 threads for processing
  • the second multi-threaded processing mode opens 16 threads for processing.
  • a range corresponding to the number of tasks to be executed may be determined. For example, a range corresponding to the number of tasks to be executed corresponds to a first number range, and then a first multi-threaded processing manner may be determined to process the tasks to be executed. According to the range of the number of tasks to be executed, a corresponding multi-thread processing mode is selected for execution, which can not only accelerate the processing speed, but also save resources.
  • the tasks to be executed in the preset task queue are processed according to a first multi-thread processing mode corresponding to the first number range. Execute to complete the processing of the task to be performed.
  • a Redis tool is added to the Web platform, and a preset task queue is created by using the Redis tool; a task to be executed in the Celery queue that meets a condition is stored in the preset task queue; and the preset task is obtained To-be-executed tasks in a queue that satisfy a preset execution condition, wherein the preset execution condition corresponds to a preset processing method; in order to execute tasks to be executed corresponding to different preset execution conditions by using different preset processing methods. This can speed up the processing speed of the tasks to be executed, thereby improving the response speed of the Web platform to improve the user experience.
  • FIG. 5 is a schematic block diagram of a task processing apparatus according to an embodiment of the present application.
  • the task processing apparatus 300 includes: an adding creating unit 301, a first obtaining unit 302, a task saving unit 303, a second obtaining unit 304, and a task execution unit 305.
  • the adding and creating unit 301 is configured to add a Redis tool on a Web platform and create a preset task queue through the Redis tool, wherein the Web platform is a web platform developed based on the Ansible and Celery frameworks.
  • the first obtaining unit 302 is configured to obtain a task to be executed in a Celery queue in the Web platform.
  • the first obtaining unit 302 is further configured to obtain a Web application corresponding to the task to be executed.
  • the task saving unit 303 is configured to save the to-be-executed task to the preset task queue.
  • the second obtaining unit 304 is configured to obtain a task to be executed in the preset task queue that meets a preset execution condition, where the preset execution condition corresponds to a preset processing mode.
  • the second obtaining unit 304 includes: a task monitoring subunit 3041 and a condition determination subunit 3042; a task monitoring subunit 3041 is configured to monitor whether a web application corresponding to a task to be executed in the preset task queue is located A running state; a condition determining subunit 3042 is configured to determine, if the web application corresponding to the task to be executed is in a running state, that the task to be executed meets the preset execution condition.
  • the task monitoring sub-unit 3041 is specifically configured to: monitor the status of the running loop of the main thread corresponding to the web application corresponding to the task to be executed; and determine whether the web application is in a state according to the status of the running loop of the main thread. Operating status.
  • the task execution unit 305 is configured to execute a task to be executed that meets the preset execution condition according to the preset processing mode.
  • FIG. 6 is a schematic block diagram of a task processing apparatus according to an embodiment of the present application.
  • the task processing apparatus 500 includes: an adding creation unit 501, a first acquisition unit 502, a first determination unit 503, a status monitoring unit 504, a task storage unit 505, a range determination unit 506, a mode acquisition unit 507, and Task execution unit 508.
  • the adding and creating unit 501 is configured to add a Redis tool on a Web platform and create a preset task queue through the Redis tool, wherein the Web platform is a web platform developed based on the Ansible and Celery frameworks.
  • a first obtaining unit 502 is configured to obtain a to-be-executed task in a Celery queue in the Web platform and a web application corresponding to the to-be-executed task.
  • the first determining unit 503 is configured to determine whether the number of tasks to be executed in the Celery queue is greater than a preset number of tasks.
  • the status monitoring unit 504 is configured to monitor whether a web application corresponding to the to-be-executed task in the preset task queue is running if the number of to-be-executed tasks in the Celery queue is greater than the preset task number.
  • the status monitoring unit 504 is specifically configured to: monitor the status of the running loop of the main thread corresponding to the web application corresponding to the task to be executed; and determine whether the web application is running according to the status of the running loop of the main thread. status.
  • a task saving unit 505 is configured to save the to-be-executed task to the preset task queue if the web application corresponding to the to-be-executed task is in a running state.
  • a range determining unit 506 is configured to determine a preset number range corresponding to the number of tasks to be executed in the preset task queue, where different preset number ranges correspond to different preset processing methods;
  • a mode obtaining unit 507 is configured to obtain a preset processing mode corresponding to the preset quantity range according to the determined preset quantity range.
  • a task execution unit 508 is configured to execute tasks to be executed in the preset task queue that satisfy the preset quantity range according to a preset processing manner corresponding to the preset quantity range.
  • the above apparatus may be implemented in the form of a computer program, and the computer program may be run on a computer device as shown in FIG. 7.
  • FIG. 7 is a schematic block diagram of a computer device according to an embodiment of the present application.
  • the computer device 700 device may be a server.
  • the computer device 700 includes a processor 720, a memory, and a network interface 750 connected through a system bus 710.
  • the memory may include a non-volatile storage medium 730 and an internal memory 740.
  • the non-volatile storage medium 730 can store an operating system 731 and a computer program 732.
  • the processor 720 can execute any task processing method.
  • the processor 720 is used to provide computing and control capabilities to support the operation of the entire computer device 700.
  • the internal memory 740 provides an environment for running the computer program 732 in the non-volatile storage medium 730.
  • the processor 720 can execute any task processing method.
  • the network interface 750 is used for network communication, such as sending assigned tasks.
  • the structure shown in FIG. 7 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer equipment 700 to which the solution of the present application is applied. 700 may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
  • the processor 720 is configured to run program code stored in a memory to implement the following steps:
  • the processor 720 is configured to run program code stored in a memory to implement the task before saving the to-be-executed task to the preset task queue, and further implement the following steps:
  • the processor 720 is configured to run the program code stored in the memory to implement the obtaining of the to-be-executed tasks in the Celery queue in the Web platform, and further implement the following steps:
  • the web application corresponding to the task to be executed is in a running state, it is determined that the task to be executed satisfies the preset execution condition.
  • the processor 720 is configured to run program code stored in a memory to implement the monitoring whether a web application corresponding to the task to be executed is in a running state, and specifically implement the following steps:
  • the processor 720 is configured to run the program code stored in the memory to implement the obtaining of the to-be-executed tasks in the preset task queue that satisfy the preset execution conditions, and further implement the following steps:
  • the tasks to be executed in the preset task queue that satisfy the preset number range are executed according to a preset processing manner corresponding to the preset number range.
  • the processor 720 may be a central processing unit (CPU), and the processor 720 may also be another general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor, or the processor may be any conventional processor.
  • FIG. 7 does not constitute a limitation on the computer device 700, and may include more or fewer components than shown in the figure, or combine some components, or different components. Layout.
  • the computer program can be stored in a storage medium, which is a computer-readable medium. Read storage media.
  • the computer program may be stored in a storage medium of a computer system and executed by at least one processor in the computer system, so as to implement process steps including the embodiments of the methods described above.
  • the computer-readable storage medium may be any medium that can store program code, such as a magnetic disk, an optical disk, a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a magnetic disk, or an optical disk.
  • program code such as a magnetic disk, an optical disk, a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a magnetic disk, or an optical disk.
  • the disclosed task processing apparatus and method may be implemented in other manners.
  • the task processing apparatus embodiments described above are merely exemplary.
  • the division of each unit is only a logical function division, and there may be another division manner in actual implementation.
  • multiple units or components may be combined or integrated into another system, or some features may be ignored or not implemented.
  • the units in the apparatus of the embodiment of the present application may be combined, divided, and deleted according to actual needs.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each of the units may exist separately physically, or two or more units may be integrated into one unit.
  • the above integrated unit may be implemented in the form of hardware or in the form of software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of this application is essentially a part that contributes to the existing technology, or all or part of the technical solution may be embodied in the form of a software product, which is stored in a storage medium. Included are instructions for causing a computer device (which may be a personal computer, a terminal, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)

Abstract

一种任务处理方法、装置、计算机设备及存储介质,其中方法包括:在Web平台上添加Redis工具,并通过Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台(S101);获取Web平台中的Celery队列中的待执行任务(S102);将待执行任务保存至预设任务队列(S103);获取预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式(S104);将满足预设执行条件的待执行任务按照预设处理方式执行(S105)。

Description

任务处理方法、装置、计算机设备及存储介质
本申请要求于2018年6月13日提交中国专利局、申请号为201810609360.X、发明名称为“任务处理方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及互联网技术领域,尤其涉及一种任务处理方法、装置、计算机设备及存储介质。
背景技术
目前,在互联网行业,为了便于运维管理,Web平台通常会使用Ansible和Celery框架相结合进行开发,但是Celery队列里的任务在执行时只能是单进程执行,如果任务过多,这种单进程执行会导致任务消费很慢,进而导致在远程服务器上执行会有性能瓶颈,导致Celery队列会堆积大量任务。因此,需要提供一种任务处理方法以解决上述问题。
发明内容
本申请提供了一种任务处理方法、装置、计算机设备及存储介质,旨在加快Web平台的响应速度。
第一方面,本申请提供了一种任务处理方法,其包括:
在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台;
获取所述Web平台中的Celery队列中的待执行任务;
将所述待执行任务保存至所述预设任务队列;
获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以及
将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
第二方面,本申请提供了一种任务处理装置,其包括:
添加创建单元,用于在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台;
第一获取单元,用于获取所述Web平台中的Celery队列中的待执行任务;
任务保存单元,用于将所述待执行任务保存至所述预设任务队列;
第二获取单元,用于获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以及
任务执行单元,用于将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。。
第三方面,本申请还提供了一种计算机设备,其包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述程序时实现本申请提供的任意一项所述的任务处理方法的步骤。
第四方面,本申请还提供了一种存储介质,其中所述存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行本申请提供的任意一项所述的任务处理方法的步骤。
本申请实施例可借助Redis工具创建预设任务队列,通过预设任务队列选择不同预设处理方式快速消费掉Celery队列的任务,由此可避免了任务的大量堆积,解决了远程服务器上执行会有性能瓶颈问题。加快了待执行任务的处理速度,进而提高了Web平台的响应速度,提高了用户体验。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请一实施例提供的一种任务处理方法的示意流程图;
图2是图1中任务处理方法的子步骤示意流程图;
图3是图2中任务处理方法的子步骤示意流程图;
图4是本申请另一实施例提供的一种任务处理方法的示意流程图;
图5是本申请一实施例提供的一种任务处理装置的示意性框图;
图6是本申请另一实施例提供的一种任务处理装置的示意性框图;
图7是本申请一实施例提供的一种计算机设备的示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
请参阅图1,图1是本申请一实施例提供的一种任务处理方法的示意流程图。如图1所示,该任务处理方法包括步骤S101~S105。
S101、在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台。
在本实施例中,Web平台是基于Ansible和Celery框架开发而成的网页平台,Ansible是基于Python开发的自动化运维工具,Celery是一个基于Python开发的分布式异步消息任务队列,通过它可以轻松的实现任务的异步处理。其中Celery只能单线程执行任务,因此会导致Celery队列会堆积大量任务,影响Web平台的响应式速度。
其中,Redis工具是一个高性能的key-value数据库,也是内存数据库,将Redis工具添加到Web平台中,并通过该Redis工具创建预设任务队列,该预设任务队列用于记录任务。具体地,该预设任务队列可以为一个队列表的形式。
S102、获取所述Web平台中的Celery队列中的待执行任务。
在本实施例中,由于Celery只能单线程执行任务,因此Celery队列有可能堆积很多待执行任务。因此,所述获取所述Web平台中的Celery队列中的待执行任务,包括:定时轮询所述Celery队列以获取所述Web平台中的Celery队列中的待执行任务。其中,所述定时轮询的时长可以根据实际需要进行设定,在此不做限定。
在一实施例中,所述获取所述Web平台中的Celery队列中的待执行任务,包括:获取所述待执行任务对应的Web应用。所述待执行任务对应的Web应用具体是指由某个Web应用下发的待执行任务。
S103、将所述待执行任务保存至所述预设任务队列。
在本实施例中,所述预设任务队列是通过Redis工具在内存数据库中创建的任务队列,因此方便快速保存或读取所述预设任务队列的内容,由此加快了待执行任务的处理速度。
S104、获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式。
在本实施例中,该预设执行条件用于将所述预设任务队列中的待执行任务进行分类,以便根据不同的待执行任务选择不同预设处理方式进行执行。比如该预设处理方式为多线程处理方式,进而加快待执行任务的处理速度。
在一实施例中,该预设执行条件比如为待执行任务对应的Web应用处于正在运行状态。具体地,如图2所示,步骤S104包括子步骤S104a和S104b。其中,S104a、监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态;S104b、若所述待执行任务对应的Web应用处于运行状态,则判定所述待执行任务满足所述预设执行条件。
其中,监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态,具体通过监控所述Web应用的对应的主线程。如图3所示,步骤S104a包括子步骤S104al和S104a2。其中S104al、监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;S104a2、根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
具体地,通过监测Web应用对应的主线程的运行回路的状态,来判断该Web应用是否处于运行状态,若所述主线程的运行回路的状态为睡眠状态,则 该Web应用处于空闲状态;相反这表明该Web应用处于运行状态。
在一实施例中,所述获取所述预设任务队列中满足预设执行条件的待执行任务,包括:确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式;根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式。
具体地,预设数量范围包括第一数量范围或第二数量范围,当然还可以包括其他数量范围,其中所述第一数量范围和第二数量范围对应不同数量的待执行任务,对应不同的预设处理方式,比如均采用多线程处理方式,但是多线程处理方式包括第一多线程处理方式和第二多线程处理方式,其中两种多线程处理方式打开线程的数量不同,其中所述第一数量范围与所述第一多线程处理方式相对应,所述第二数量范围与所述第二多线程处理方式相对应。由此可以确定不同数量的待执行任务对应的数量范围,选择相应的多线程处理方式进行执行。不仅可以加快处理速度,还可以节省资源。
S105、将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
在本实施例中,具体是将满足所述预设执行条件的待执行任务按照所述预设执行条件对应的预设处理方式进行执行以完成对预设任务队列中的待执行任务。
比如,将正在运行的Web应用对应的待执行任务通过多线程处理方式进行执行以完成对所述待执行任务的处理。
再比如,将所述预设任务队列中满足所述预设数量范围的待执行任务按照所述预设数量范围对应的预设处理方式执行。
上述实施例在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列;获取所述Web平台中的Celery队列中的待执行任务;将所述待执行任务保存至所述预设任务队列;获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。该方法可借助Redis工具创建的预设任务队列,通过预设任务队列选择不同预设处理方式快速消费掉Celery队列的任务,由此可避免了任务的大量堆积,加快了待执行任务的处理速度,进而提高了Web平台的响应速度,提高了用户体验。
请参阅图4,图4是本申请另一实施例提供的一种任务处理方法的示意流程图。如图4所示,该任务处理方法包括步骤S201~S208。
S201、在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台。
具体地,所述预设任务队列为通过Redis工具在内存数据库中创建的,用于记录待执行任务,该待执行任务为各个Web应用对应的待处理任务,当然也可以包括与Web应用相关的其他应用对应的待处理任务。具体地,该预设任务队列可以为一个队列表的形式。
S202、获取所述Web平台中的Celery队列中的待执行任务以及所述待执行任务对应的Web应用。
具体地,时轮询所述Celery队列以获取所述Web平台中的Celery队列中的待执行任务,同时还获取所述待执行任务对应的Web应用。
S203、判断所述Celery队列中的待执行任务的数量是否大于预设任务数量。
在本实施例,所述预设任务数量可以为一个经验值,通过该预设任务数量可以判断Celery队列中的待执行任务的数量是否会形成堆积,当Celery队列中的待执行任务的数量大于该预设任务数量时表示有可能会形成任务堆积。
S204、监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态。
具体地,若所述Celery队列中的待执行任务的数量大于所述预设任务数量,监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态。
当监测出所述待执行任务对应的Web应用处于运行状态,说明用户正在使用该Web应用,进而执行以下步骤,以便通过本申请提供的任务处理方法,加快任务处理速度,进而提高了正在运行的Web应用的响应速度。
具体地,所述监测所述待执行任务对应的Web应用是否处于运行状态,具体采用:监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
S205、将所述待执行任务保存至所述预设任务队列。
具体地,若所述待执行任务对应的Web应用处于运行状态,将所述待执行任务保存至所述预设任务队列。其中,所述预设任务队列是通过Redis工具在内存数据库中创建的任务队列,因此方便快速保存或读取所述预设任务队列的内 容,进而加快了待执行任务的处理速度。
S206、确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式。
在本实施例中,预设数量范围包括第一数量范围和第二数量范围,当然还可以包括其他数量范围,其中所述第一数量范围和第二数量范围对应不同数量的待执行任务。
具体地,所述第一数量范围与所述第一多线程处理方式相对应,所述第二数量范围与所述第二多线程处理方式相对应,其中所述第一多线程处理方式和第二多线程处理方式的打开线程的数量不同,比如第一多线程处理方式打开8个线程进行处理,第二多线程处理方式打开16个线程进行处理。
S207、根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式。
具体地,可以确定待执行任务的数量对应数量范围,比如所述待执行任务的数量对应数量范围对应第一数量范围,则可确定采用第一多线程处理方式处理待执行任务。根据所述待执行任务对应的数量范围,选择相应的多线程处理方式进行执行,不仅可以加快处理速度,还可以节省资源。
S208、将所述预设任务队列中满足所述预设数量范围的待执行任务按照所述预设数量范围对应的预设处理方式执行。
比如,确定所述预设任务队列中的待执行任务的数量满足第一数量范围,则将所述预设任务队列中的待执行任务按照所述第一数量范围对应的第一多线程处理方式执行以完成对待执行任务的处理。
上述实施例通过在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列;将Celery队列中的满足条件的待执行任务保存在所述预设任务队列;获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以便根据将对应不同预设执行条件的待执行任务采用不同的预设处理方式执行。由此可加快待执行任务的处理速度,进而提高了Web平台的响应速度,以提高用户体验。
请参阅图5,图5是本申请实施例提供的一种任务处理装置的示意性框图。如图5所示,该任务处理装置300包括:添加创建单元301、第一获取单元302、 任务保存单元303、第二获取单元304和任务执行单元305。
添加创建单元301,用于在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台。
第一获取单元302,用于获取所述Web平台中的Celery队列中的待执行任务。
在一实施例中,第一获取单元302,还用于获取所述待执行任务对应的Web应用。
任务保存单元303,用于将所述待执行任务保存至所述预设任务队列。
第二获取单元304,用于获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式。
其中,所述第二获取单元304,包括:任务监测子单元3041和条件判定子单元3042;任务监测子单元3041,用于监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态;条件判定子单元3042,用于若所述待执行任务对应的Web应用处于运行状态,则判定所述待执行任务满足所述预设执行条件。
具体地,任务监测子单元3041,具体用于:监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
任务执行单元305,用于将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
请参阅图6,图6是本申请实施例提供的一种任务处理装置的示意性框图。如图6所示,该任务处理装置500包括:添加创建单元501、第一获取单元502、第一判断单元503、状态监测单元504、任务保存单元505、范围确定单元506、方式获取单元507和任务执行单元508。
添加创建单元501,用于在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台。
第一获取单元502,用于获取所述Web平台中的Celery队列中的待执行任务以及所述待执行任务对应的Web应用。
第一判断单元503,用于判断所述Celery队列中的待执行任务的数量是否大于预设任务数量。
状态监测单元504,用于若所述Celery队列中的待执行任务的数量大于所述预设任务数量,监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态。
具体地,状态监测单元504,具体用于:监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
任务保存单元505,用于若所述待执行任务对应的Web应用处于运行状态,将所述待执行任务保存至所述预设任务队列。
范围确定单元506,用于确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式;
方式获取单元507,用于根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式。
任务执行单元508,用于将所述预设任务队列中满足所述预设数量范围的待执行任务按照所述预设数量范围对应的预设处理方式执行。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的任务处理装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
上述装置可以实现为一种计算机程序的形式,计算机程序可以在如图7所示的计算机设备上运行。
请参阅图7,图7是本申请实施例提供的一种计算机设备的示意性框图。该计算机设备700设备可以是服务器。
参照图7,该计算机设备700包括通过系统总线710连接的处理器720、存储器和网络接口750,其中,存储器可以包括非易失性存储介质730和内存储器740。
该非易失性存储介质730可存储操作系统731和计算机程序732。该计算机程序732被执行时,可使得处理器720执行任意一种任务处理方法。
该处理器720用于提供计算和控制能力,支撑整个计算机设备700的运行。
该内存储器740为非易失性存储介质730中的计算机程序732的运行提供环境,该计算机程序732被处理器720执行时,可使得处理器720执行任意一种任务处理方法。
该网络接口750用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图7中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备700的限定,具体的计算机设备700可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。其中,所述处理器720用于运行存储在存储器中的程序代码,以实现如下步骤:
在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台;
获取所述Web平台中的Celery队列中的待执行任务;
将所述待执行任务保存至所述预设任务队列;
获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以及
将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
在一实施例中,所述处理器720用于运行存储在存储器中的程序代码以实现所述将所述待执行任务保存至所述预设任务队列之前,还实现如下步骤:
判断所述Celery队列中的待执行任务的数量是否大于预设任务数量;
若所述Celery队列中的待执行任务的数量大于所述预设任务数量,所述将所述待执行任务保存至所述预设任务队列。
在一实施例中,所述处理器720用于运行存储在存储器中的程序代码以实现所述获取所述Web平台中的Celery队列中的待执行任务时,还实现如下步骤:
获取所述待执行任务对应的Web应用;
监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态;
若所述待执行任务对应的Web应用处于运行状态,则判定所述待执行任务满足所述预设执行条件。
在一实施例中,所述处理器720用于运行存储在存储器中的程序代码以实现所述监测所述待执行任务对应的Web应用是否处于运行状态,具体实现如下 步骤:
监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;
根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
在一实施例中,所述处理器720用于运行存储在存储器中的程序代码以实现所述获取所述预设任务队列中满足预设执行条件的待执行任务时,还实现如下步骤:
确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式;
根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式;
将所述预设任务队列中满足所述预设数量范围的待执行任务按照所述预设数量范围对应的预设处理方式执行。
应当理解,在本申请实施例中,处理器720可以是中央处理单元(Central Processing Unit,CPU),该处理器720还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
本领域技术人员可以理解,图7中示出的计算机设备700结构并不构成对计算机设备700的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
本领域普通技术人员可以理解的是实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,计算机程序可存储于一存储介质中,该存储介质为计算机可读存储介质。如本申请实施例中,该计算机程序可存储于计算机系统的存储介质中,并被该计算机系统中的至少一个处理器执行,以实现包括如上述各方法的实施例的流程步骤。
该计算机可读存储介质可以是磁碟、光盘、U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现, 为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
在本申请所提供的几个实施例中,应该理解到,所揭露的任务处理装置和方法,可以通过其它的方式实现。例如,以上所描述的任务处理装置实施例仅仅是示意性的。例如,各个单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。
本申请实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减。
本申请实施例装置中的单元可以根据实际需要进行合并、划分和删减。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,终端,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种任务处理方法,其包括:
    在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台;
    获取所述Web平台中的Celery队列中的待执行任务;
    将所述待执行任务保存至所述预设任务队列;
    获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以及
    将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
  2. 根据权利要求1所述的任务处理方法,其中,所述将所述待执行任务保存至所述预设任务队列之前,还包括:
    判断所述Celery队列中的待执行任务的数量是否大于预设任务数量;
    若所述Celery队列中的待执行任务的数量大于所述预设任务数量,执行所述将所述待执行任务保存至所述预设任务队列的步骤。
  3. 根据权利要求1所述的任务处理方法,其中,所述获取所述Web平台中的Celery队列中的待执行任务,包括:获取所述待执行任务对应的Web应用;
    所述获取所述预设任务队列中满足预设执行条件的待执行任务,包括:
    监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态;
    若所述待执行任务对应的Web应用处于运行状态,则判定所述待执行任务满足所述预设执行条件。
  4. 根据权利要求3所述的任务处理方法,其中,所述监测所述待执行任务对应的Web应用是否处于运行状态,包括:
    监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;
    根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
  5. 根据权利要求1所述的任务处理方法,其中,所述获取所述预设任务队列中满足预设执行条件的待执行任务,包括:
    确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式;
    根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式;
    所述将满足所述预设执行条件的待执行任务按照所述预设处理方式执行,包括:
    将所述预设任务队列中满足所述预设数量范围的待执行任务按照所述预设数量范围对应的预设处理方式执行。
  6. 根据权利要求1所述的任务处理方法,其中,所述获取所述预设任务队列中满足预设执行条件的待执行任务,包括:
    确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式;以及
    根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式。
  7. 根据权利要求1所述的任务处理方法,其中,所述获取所述Web平台中的Celery队列中的待执行任务,包括:
    定时轮询所述Celery队列以获取所述Web平台中的Celery队列中的待执行任务。
  8. 一种任务处理装置,其包括:
    添加创建单元,用于在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台;
    第一获取单元,用于获取所述Web平台中的Celery队列中的待执行任务;
    任务保存单元,用于将所述待执行任务保存至所述预设任务队列;
    第二获取单元,用于获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以及
    任务执行单元,用于将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
  9. 一种计算机设备,其包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现以下步骤:
    在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台;
    获取所述Web平台中的Celery队列中的待执行任务;
    将所述待执行任务保存至所述预设任务队列;
    获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以及
    将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
  10. 根据权利要求9所述的计算机设备,其中,所述处理器执行所述计算机程序时实现所述将所述待执行任务保存至所述预设任务队列之前,还实现以下步骤:
    判断所述Celery队列中的待执行任务的数量是否大于预设任务数量;
    若所述Celery队列中的待执行任务的数量大于所述预设任务数量,执行所述将所述待执行任务保存至所述预设任务队列的步骤。
  11. 根据权利要求9所述的计算机设备,其中,所述处理器执行所述计算机程序时实现所述获取所述Web平台中的Celery队列中的待执行任务,具体实现:获取所述待执行任务对应的Web应用;
    同时,所述处理器执行所述计算机程序时实现所述获取所述预设任务队列中满足预设执行条件的待执行任务时,具体实现以下步骤:
    监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态;
    若所述待执行任务对应的Web应用处于运行状态,则判定所述待执行任务满足所述预设执行条件。
  12. 根据权利要求11所述的计算机设备,其中,所述处理器执行所述计算机程序时实现所述监测所述待执行任务对应的Web应用是否处于运行状态时,具体实现以下步骤:
    监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;
    根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
  13. 根据权利要求9所述的计算机设备,其中,所述处理器执行所述计算机程序时实现所述获取所述预设任务队列中满足预设执行条件的待执行任务时,具体实现以下步骤:
    确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式;以及
    根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式。
  14. 根据权利要求9所述的计算机设备,其中,所述处理器执行所述计算机程序时实现所述获取所述Web平台中的Celery队列中的待执行任务时,具体实现以下步骤:
    定时轮询所述Celery队列以获取所述Web平台中的Celery队列中的待执行任务。
  15. 一种计算机存储介质,其中,所述计算机存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器执行以下步骤:
    在Web平台上添加Redis工具,并通过所述Redis工具创建预设任务队列,其中所述Web平台为基于Ansible和Celery框架开发而成的网页平台;
    获取所述Web平台中的Celery队列中的待执行任务;
    将所述待执行任务保存至所述预设任务队列;
    获取所述预设任务队列中满足预设执行条件的待执行任务,其中所述预设执行条件对应预设处理方式;以及
    将满足所述预设执行条件的待执行任务按照所述预设处理方式执行。
  16. 根据权利要求15所述的计算机存储介质,其中,所述计算机程序被处理器执行时使所述处理器执行所述将所述待执行任务保存至所述预设任务队列之前,还执行以下步骤:
    判断所述Celery队列中的待执行任务的数量是否大于预设任务数量;
    若所述Celery队列中的待执行任务的数量大于所述预设任务数量,执行所述将所述待执行任务保存至所述预设任务队列的步骤。
  17. 根据权利要求15所述的计算机存储介质,其中,所述计算机程序被处理器执行时使所述处理器执行所述获取所述Web平台中的Celery队列中的待执行任务时,具体执行:获取所述待执行任务对应的Web应用;
    同时,执行所述获取所述预设任务队列中满足预设执行条件的待执行任务时,具体执行以下步骤:
    监测所述预设任务队列中的待执行任务对应的Web应用是否处于运行状态;
    若所述待执行任务对应的Web应用处于运行状态,则判定所述待执行任务满足所述预设执行条件。
  18. 根据权利要求17所述的计算机存储介质,其中,所述计算机程序被处 理器执行时使所述处理器执行所述监测所述待执行任务对应的Web应用是否处于运行状态时,具体执行以下步骤:
    监测所述待执行任务对应的Web应用对应的主线程的运行回路的状态;
    根据所述主线程的运行回路的状态判断所述Web应用是否处于运行状态。
  19. 根据权利要求15所述的计算机存储介质,其中,所述计算机程序被处理器执行时使所述处理器执行所述获取所述预设任务队列中满足预设执行条件的待执行任务时,具体执行以下步骤:
    确定所述预设任务队列中的待执行任务的数量对应的预设数量范围,其中不同的预设数量范围对应不同的预设处理方式;以及
    根据确定的预设数量范围获取所述预设数量范围对应的预设处理方式
  20. 根据权利要求15所述的计算机存储介质,其中,所述计算机程序被处理器执行时使所述处理器执行所述获取所述Web平台中的Celery队列中的待执行任务时,具体执行以下步骤:
    定时轮询所述Celery队列以获取所述Web平台中的Celery队列中的待执行任务。
PCT/CN2018/109449 2018-06-13 2018-10-09 任务处理方法、装置、计算机设备及存储介质 WO2019237593A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810609360.X 2018-06-13
CN201810609360.XA CN108829521B (zh) 2018-06-13 2018-06-13 任务处理方法、装置、计算机设备及存储介质

Publications (1)

Publication Number Publication Date
WO2019237593A1 true WO2019237593A1 (zh) 2019-12-19

Family

ID=64141353

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/109449 WO2019237593A1 (zh) 2018-06-13 2018-10-09 任务处理方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN108829521B (zh)
WO (1) WO2019237593A1 (zh)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111240834A (zh) * 2020-01-02 2020-06-05 北京字节跳动网络技术有限公司 任务执行方法、装置、电子设备和存储介质
CN111290846A (zh) * 2020-02-26 2020-06-16 杭州涂鸦信息技术有限公司 一种分布式任务调度方法及系统
CN111831420A (zh) * 2020-07-20 2020-10-27 北京百度网讯科技有限公司 用于任务调度的方法、装置、电子设备及计算机可读存储介质
CN112231092A (zh) * 2020-11-24 2021-01-15 政采云有限公司 一种定时任务管理方法、装置、设备及可读存储介质
CN113722068A (zh) * 2021-08-31 2021-11-30 平安普惠企业管理有限公司 基于Azkaban的批量任务处理方法、装置、设备及存储介质
CN113806058A (zh) * 2021-10-09 2021-12-17 京东科技控股股份有限公司 任务管理方法及装置、存储介质及电子设备
CN114253683A (zh) * 2021-11-26 2022-03-29 北京百度网讯科技有限公司 任务处理方法、装置、电子设备及存储介质
CN114978929A (zh) * 2022-04-29 2022-08-30 苏州浪潮智能科技有限公司 一种网络调度装置和方法

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109739529A (zh) * 2018-12-04 2019-05-10 贵阳朗玛信息技术股份有限公司 一种程序自动发布的方法及装置
CN111182061B (zh) * 2019-12-30 2023-04-14 苏宁云计算有限公司 任务分发处理方法、系统、计算机设备和存储介质
CN113411226A (zh) * 2020-03-16 2021-09-17 北京奇虎科技有限公司 路由器分布式自动化测试方法、系统、存储介质及其计算机设备
CN111427694A (zh) * 2020-03-26 2020-07-17 北京金山云网络技术有限公司 任务执行方法、装置、系统和服务器
CN112181625A (zh) * 2020-10-12 2021-01-05 联通智网科技有限公司 一种任务调度方法、系统、装置、存储介质和计算机设备
CN112667385A (zh) * 2021-01-15 2021-04-16 北京金和网络股份有限公司 一种云服务系统及其任务执行方法和装置及服务器
CN115601195B (zh) * 2022-10-17 2023-09-08 桂林电子科技大学 基于电力用户实时标签的交易双向推荐系统及其方法
CN117194549B (zh) * 2023-11-07 2024-01-26 上海柯林布瑞信息技术有限公司 基于任务数据配置的数据传输方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902573A (zh) * 2012-09-20 2013-01-30 北京搜狐新媒体信息技术有限公司 一种基于共享资源的任务的处理方法及装置
CN107239328A (zh) * 2016-03-29 2017-10-10 上海普兰金融服务有限公司 任务分配方法及装置
CN107423120A (zh) * 2017-04-13 2017-12-01 阿里巴巴集团控股有限公司 任务调度方法及装置
WO2018095298A1 (zh) * 2016-11-23 2018-05-31 腾讯科技(深圳)有限公司 一种信息处理方法、设备和计算机存储介质

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102402459B (zh) * 2010-09-10 2013-09-11 中兴通讯股份有限公司 网管系统性能数据汇总的方法和装置
CN102591721A (zh) * 2011-12-30 2012-07-18 北京新媒传信科技有限公司 一种分配线程执行任务的方法和系统
CN103902646B (zh) * 2013-12-27 2017-04-19 北京天融信软件有限公司 一种分布式任务管理系统与方法
WO2016138067A1 (en) * 2015-02-24 2016-09-01 Cloudlock, Inc. System and method for securing an enterprise computing environment
CN107918572A (zh) * 2016-10-08 2018-04-17 中兴通讯股份有限公司 一种大批量硬盘检测方法、装置及平台
US20180101391A1 (en) * 2016-10-09 2018-04-12 The Charles Stark Draper Laboratory, Inc. System for co-adaptive human-computer interaction
CN107220033A (zh) * 2017-07-05 2017-09-29 百度在线网络技术(北京)有限公司 用于控制线程池中线程数量的方法和装置
CN107463439A (zh) * 2017-08-21 2017-12-12 山东浪潮通软信息科技有限公司 一种线程池实现方法及装置
CN107748695B (zh) * 2017-10-24 2020-11-24 平安科技(深圳)有限公司 定时任务处理方法、装置、存储介质和计算机设备
CN107704398A (zh) * 2017-11-01 2018-02-16 网易(杭州)网络有限公司 自动化测试方法及装置、存储介质、电子设备
CN108011931B (zh) * 2017-11-22 2021-06-11 用友金融信息技术股份有限公司 Web数据采集方法和Web数据采集系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902573A (zh) * 2012-09-20 2013-01-30 北京搜狐新媒体信息技术有限公司 一种基于共享资源的任务的处理方法及装置
CN107239328A (zh) * 2016-03-29 2017-10-10 上海普兰金融服务有限公司 任务分配方法及装置
WO2018095298A1 (zh) * 2016-11-23 2018-05-31 腾讯科技(深圳)有限公司 一种信息处理方法、设备和计算机存储介质
CN107423120A (zh) * 2017-04-13 2017-12-01 阿里巴巴集团控股有限公司 任务调度方法及装置

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111240834A (zh) * 2020-01-02 2020-06-05 北京字节跳动网络技术有限公司 任务执行方法、装置、电子设备和存储介质
CN111240834B (zh) * 2020-01-02 2024-02-02 北京字节跳动网络技术有限公司 任务执行方法、装置、电子设备和存储介质
CN111290846A (zh) * 2020-02-26 2020-06-16 杭州涂鸦信息技术有限公司 一种分布式任务调度方法及系统
CN111290846B (zh) * 2020-02-26 2023-08-18 杭州涂鸦信息技术有限公司 一种分布式任务调度方法及系统
CN111831420B (zh) * 2020-07-20 2023-08-08 北京百度网讯科技有限公司 用于任务调度的方法、相关装置及计算机程序产品
CN111831420A (zh) * 2020-07-20 2020-10-27 北京百度网讯科技有限公司 用于任务调度的方法、装置、电子设备及计算机可读存储介质
CN112231092A (zh) * 2020-11-24 2021-01-15 政采云有限公司 一种定时任务管理方法、装置、设备及可读存储介质
CN113722068A (zh) * 2021-08-31 2021-11-30 平安普惠企业管理有限公司 基于Azkaban的批量任务处理方法、装置、设备及存储介质
CN113806058A (zh) * 2021-10-09 2021-12-17 京东科技控股股份有限公司 任务管理方法及装置、存储介质及电子设备
US11640319B1 (en) 2021-11-26 2023-05-02 Beijing Baidu Netcom Science Technology Co., Ltd. Task processing method and apparatus, electronic device and storage medium
CN114253683A (zh) * 2021-11-26 2022-03-29 北京百度网讯科技有限公司 任务处理方法、装置、电子设备及存储介质
CN114978929A (zh) * 2022-04-29 2022-08-30 苏州浪潮智能科技有限公司 一种网络调度装置和方法
CN114978929B (zh) * 2022-04-29 2023-08-18 苏州浪潮智能科技有限公司 一种网络调度装置和方法

Also Published As

Publication number Publication date
CN108829521B (zh) 2022-05-13
CN108829521A (zh) 2018-11-16

Similar Documents

Publication Publication Date Title
WO2019237593A1 (zh) 任务处理方法、装置、计算机设备及存储介质
US7441240B2 (en) Process scheduling apparatus, process scheduling method, program for process scheduling, and storage medium recording a program for process scheduling
US20190363988A1 (en) System and/or method for predictive resource management in file transfer servers
US9104423B2 (en) Method and system for advance wakeup from low-power sleep states
JP4811830B1 (ja) コンピュータリソース制御システム
JP2018533122A (ja) マルチバージョンタスクの効率的なスケジューリング
WO2014019428A1 (en) Method and system for allocating fpga resources
JP2013524317A5 (zh)
WO2013107141A1 (zh) 一种用于云计算的策略调度系统和方法
WO2019134304A1 (zh) 任务处理方法、装置、电子终端及可读存储介质
US10521258B2 (en) Managing test services in a distributed production service environment
US20210334228A1 (en) Managing network interface controller-generated interrupts
US11061841B2 (en) System and method for implementing a multi-threaded device driver in a computer system
KR20120115398A (ko) 전자 디바이스에서 전력을 제어하는 시스템 및 방법
CN109889406B (zh) 用于管理网络连接的方法、装置、设备和存储介质
WO2012087104A1 (en) Intelligent load handling in cloud infrastructure using trend analysis
WO2020098266A1 (zh) 一种异常响应的方法及设备
US11243603B2 (en) Power management of an event-based processing system
WO2020026010A2 (zh) 任务执行的调控方法、装置、设备/终端/服务器及存储介质
JP6189545B2 (ja) 電力消費の低減のためのネットワークアプリケーション並行スケジューリング
WO2023165485A1 (zh) 调度方法及计算机系统
CN111475317A (zh) Spark批次时间修改方法、装置、设备和存储介质
US11797334B1 (en) BMC parameter configuration and effect-taking method and apparatus, device, and medium
CN110192183B (zh) 计算机装置、任务启动方法以及计算机可读的存储介质
CN115904644A (zh) 任务调度方法、电子设备和计算机程序产品

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18922430

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18922430

Country of ref document: EP

Kind code of ref document: A1