A service scheduling method and device

By registering and bucketing business primary keys in the database, and using multiple hosts to execute scheduling tasks in parallel, the problem of low business scheduling efficiency and insufficient guarantee in the existing technology is solved, and efficient and low-cost business scheduling is achieved.

CN111782352BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911203874.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-11-29
Publication Date
2024-10-18
Estimated Expiration
2039-11-29

AI Technical Summary

Technical Problem

In the existing technology, Spring quartz's business scheduling efficiency is low, its applicability is narrow, and the coupling of subsystem collaborative scheduling is high, resulting in low execution guarantee and high cost of business scheduling.

Method used

By obtaining the business in the message queue for database registration, bucketing according to the business primary key, and using the hosts in the business cluster to perform scheduling, multiple hosts can execute scheduling tasks in parallel, reducing scheduling costs and improving security.

Benefits of technology

It improves the applicability and guarantee of business scheduling, reduces scheduling costs, enables multiple hosts to execute scheduling tasks in parallel, has wide applicability, and improves the efficiency of business scheduling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111782352B_ABST
    Figure CN111782352B_ABST
Patent Text Reader

Abstract

The present invention discloses a service scheduling method and device, and relates to the field of computer technology. A specific implementation of the method includes: receiving services in a message queue, registering the services in a database, and the service registration indicates the scheduling time of the services; bucketing the services according to the service primary key corresponding to the services, and determining the service bucket number corresponding to the services; and scheduling the services through the hosts in the service cluster according to the service bucket number and the scheduling time. This implementation can realize the parallel execution of scheduling tasks by multiple hosts, and the method has wide applicability, improves the security and scheduling efficiency of service scheduling, and reduces scheduling costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a service scheduling method and device. Background Art

[0002] There are a lot of scenarios in existing application systems where scheduled services are required. For example, in the actual development process of application systems, there are a lot of system background services that do not require manual intervention but need to be executed regularly. The following methods are mainly used in the existing technology to schedule services: one is the Spring quartz scheduled scheduling execution system applied in the Java field; the other is to coordinate the processing of service scheduling through the two subsystems of the service management system and the service execution system.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] 1. Spring Quartz has low business scheduling efficiency and narrow applicability, and is difficult to use in scenarios with a large number of business scheduling;

[0005] 2. The coupling of subsystem collaborative scheduling is high. When a subsystem crashes or fails, the execution of business scheduling cannot continue. The execution security of business scheduling is low and the scheduling cost is high. Summary of the invention

[0006] In view of this, an embodiment of the present invention provides a service scheduling method and device, which can realize the parallel execution of scheduling tasks by multiple hosts, has wide applicability, improves the security and scheduling efficiency of service scheduling, and reduces scheduling costs.

[0007] To achieve the above object, according to a first aspect of an embodiment of the present invention, a service scheduling method is provided, comprising:

[0008] Get the business in the message queue and register the business in the database. Business registration indicates the scheduling time of the business.

[0009] Divide the business into buckets according to the business primary key corresponding to the business, and determine the business bucket number corresponding to the business;

[0010] The service is scheduled through the host in the service cluster according to the service bucket number and scheduling time.

[0011] Furthermore, after the step of acquiring the services in the message queue, the service scheduling method further includes: filtering the services according to the scheduling parameters.

[0012] Furthermore, the business is divided into buckets according to the business primary key corresponding to the business, and the step of determining the business bucket number corresponding to the business includes: performing hash calculation on the business primary key corresponding to the business to obtain a hash value, and determining the business bucket number corresponding to the business according to the hash value and the number of business buckets.

[0013] Furthermore, the step of scheduling the execution of services through the host in the business cluster according to the business bucket number and the scheduling time includes: determining the initial business bucket number corresponding to each host in the business cluster, and according to the business bucket number, traversing and executing the services that meet the scheduling time in all business bucket numbers starting from the initial business bucket number through the host.

[0014] Furthermore, before the step of determining the initial service bucket number corresponding to each host in the service cluster, the service scheduling method also includes: configuring a scheduling task corresponding to each host, the scheduling task indicates a scheduling cycle and a scheduling quantity, and executing the steps described in the previous step in a loop according to the scheduling task.

[0015] Furthermore, when each host executes the business corresponding to the corresponding business bucket number, the corresponding business bucket is locked through a database lock.

[0016] According to a second aspect of an embodiment of the present invention, a service scheduling device is provided, including:

[0017] The service registration module is used to receive services in the message queue and register the services in the database. The service registration indicates the scheduling time of the services.

[0018] The business bucket number determination module is used to divide the business into buckets according to the business primary key indicated by the business and determine the business bucket number corresponding to the business;

[0019] The scheduling module is used to execute the service scheduling through the hosts in the service cluster according to the service bucket number and scheduling time.

[0020] Furthermore, the scheduling module is also used to: determine the initial service bucket number corresponding to each host in the service cluster, and according to the service bucket number, traverse and execute the services that meet the scheduling time in all service bucket numbers starting from the initial service bucket number through the host.

[0021] According to a third aspect of an embodiment of the present invention, a terminal device is provided, including:

[0022] one or more processors;

[0023] a storage device for storing one or more programs,

[0024] When one or more programs are executed by one or more processors, the one or more processors implement any of the above-mentioned service scheduling methods.

[0025] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned service scheduling methods is implemented.

[0026] An embodiment of the above invention has the following advantages or beneficial effects: because the business in the message queue is obtained and the business is registered in the database, the business registration indicates the scheduling time of the business; the business is divided into buckets according to the business primary key corresponding to the business, and the business bucket number corresponding to the business is determined; according to the business bucket number and the scheduling time, the technical means of scheduling the business is performed by the host in the business cluster, so the technical problems of narrow applicability, low security and high scheduling cost of the existing business scheduling method are overcome, and then the technical effect of being able to realize the parallel execution of scheduling tasks by multiple hosts, wide applicability, improved security and scheduling efficiency of business scheduling, and reduced scheduling costs is achieved.

[0027] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0029] Figure 1 is a schematic diagram of the main process of the service scheduling method provided according to the first embodiment of the present invention;

[0030] Figure 2 is a schematic diagram of the main process of the service scheduling method provided according to the second embodiment of the present invention;

[0031] Figure 3 is a schematic diagram of main modules of a service scheduling device provided according to an embodiment of the present invention;

[0032] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0033] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0035] Figure 1 Schematic diagram of the main process of the service scheduling method provided according to the first embodiment of the present invention; Figure 1 As shown, the service scheduling method provided by the embodiment of the present invention mainly includes:

[0036] Step S101, obtaining the service in the message queue, registering the service in the database, and the service registration indicates the scheduling time of the service.

[0037] Furthermore, according to an embodiment of the present invention, before the step of acquiring the services in the message queue, the above service scheduling method further includes: collecting services of the application program to form a message queue.

[0038] By collecting the services within an application through a message queue and then executing the scheduling of subsequent services, the scheduling and execution of services are decoupled, ensuring that the service scheduling method provided by the present invention can still be applied in scenarios with high service volume, thereby improving the applicability of the scheduling method.

[0039] Further, according to an embodiment of the present invention, after the step of acquiring the services in the message queue, the service scheduling method further includes: filtering the services according to the scheduling parameters.

[0040] Services are filtered through common protocol parameters or application-defined parameters, improving overall call efficiency.

[0041] Step S102, bucketing is performed according to the business primary key corresponding to the business, and the business bucket number corresponding to the business is determined.

[0042] Specifically, according to an embodiment of the present invention, bucketing is performed according to the business primary key corresponding to the business, and the step of determining the business bucket number corresponding to the business includes: performing hash calculation on the business primary key corresponding to the business to obtain a hash value, and determining the business bucket number corresponding to the business according to the hash value and the number of business buckets. Each business bucket number corresponds to at least one business.

[0043] Each business has a unique business primary key. By performing hash calculation on the business primary key and then taking the modulus of the obtained hash value and the number of business buckets, the business bucket number of each business can be determined relatively easily. The above setting also avoids the scenario where all businesses with the same scheduling time are put into the same business bucket, which reduces the scheduling efficiency of the business.

[0044] It should be noted that the above is only a method of allocating services to different business buckets (i.e., determining corresponding business bucket numbers for different services), but it is not a limitation of this application. In actual processing, any existing method can be used to determine the business bucket number.

[0045] Step S103, according to the service bucket number and the scheduling time, the host in the service cluster executes the scheduling of the service.

[0046] According to an embodiment of the present invention, the step of scheduling services through hosts in a business cluster based on business bucket numbers and scheduling time includes: determining an initial business bucket number corresponding to each host in the business cluster, and based on the business bucket number, traversing and executing services in all business bucket numbers that meet the scheduling time through the host starting from the initial business bucket number.

[0047] By determining an initial business bucket number for each host (which can be determined randomly, as long as the initial business bucket number of each host is different), it is convenient for multiple hosts to execute business scheduling in parallel, avoiding the scenario of contention lock caused by multiple hosts scheduling business for the same business bucket, and improving the scheduling rate of the business.

[0048] Further, according to an embodiment of the present invention, before determining the initial business bucket number corresponding to each host in the business cluster, the scheduling method of the above-mentioned business also includes: configuring a scheduling task corresponding to each host, the scheduling task indicates a scheduling period and a scheduling quantity, and cyclically executing the steps of determining the initial business bucket number corresponding to each host in the business cluster according to the scheduling period and the scheduling quantity, and according to the business bucket number, traversing and executing the services that meet the scheduling time in all business bucket numbers starting from the initial business bucket number through the host.

[0049] Specifically, according to an embodiment of the present invention, when each host executes a service corresponding to a corresponding service bucket number, the corresponding service bucket is locked by a database lock.

[0050] Since the number of businesses that meet the scheduling time in each business bucket is inconsistent, as the scheduling is executed, multiple hosts may schedule the businesses in a business bucket at the same time. The database lock ensures that a host is not interfered with by other hosts when scheduling the businesses in a business bucket, effectively ensuring the smooth execution of business scheduling.

[0051] According to the technical solution of the embodiment of the present invention, the business in the message queue is obtained, and the business is registered in the database, and the business registration indicates the scheduling time of the business; the business is bucketed according to the business primary key corresponding to the business, and the business bucket number corresponding to the business is determined; according to the business bucket number and the scheduling time, the technical means of scheduling the business is performed by the host in the business cluster, so the technical problems of narrow applicability, low security and high scheduling cost of the existing business scheduling method are overcome, and then the technical effect of being able to realize the parallel execution of scheduling tasks by multiple hosts, wide applicability, improved security and scheduling efficiency of business scheduling, and reduced scheduling cost is achieved.

[0052] Figure 2is a schematic diagram of the main process of the service scheduling method provided according to the second embodiment of the present invention; Figure 2 As shown, the service scheduling method provided by the embodiment of the present invention mainly includes:

[0053] Step S201, collect the services of the application, form a message queue, and obtain the services in the message queue.

[0054] By collecting the services within an application through a message queue and then executing the scheduling of subsequent services, the scheduling and execution of services are decoupled, ensuring that the service scheduling method provided by the present invention can still be applied in scenarios with high service volume, thereby improving the applicability of the scheduling method.

[0055] Specifically, according to an embodiment of the present invention, when an application has a scheduled service to be executed, a service topic is first registered, in which a calling interface of the corresponding service is set, and the service in the corresponding application is called through the service topic to form a message queue.

[0056] Step S202: filtering services according to scheduling parameters.

[0057] Specifically, according to an embodiment of the present invention, after receiving the business, the business is filtered through two parts of scheduling parameters, one part is a common parameter, and the other part is a parameter customized by each application. For example, for the business of json (JavaScript Object Notation, JS object notation) interface, the parameter "{"jobKey":"promotion","jobName":"promotion business push",data:""}" is set, where jobKey and jobName are common, and each business is filtered by this parameter (of course, there are some others, which are just examples here); data is a parameter customized by the application.

[0058] Services are filtered through common protocol parameters or application-defined parameters, improving overall call efficiency.

[0059] Step S203, register the service in the database, the service registration indicates the scheduling time of the service. The scheduled scheduling of the service is realized by setting the scheduling time.

[0060] According to a specific implementation of an embodiment of the present invention, a redis database is used to register the business of the business. Redis is an excellent distributed memory database with the advantages of fast reading and writing speed and rich data types. Redis works under a single process and solves the concurrency problem in a distributed environment very well. The method provided by the present invention can first register the business in the database and then divide it into buckets; it can also first divide the business into buckets according to the business primary key, and after obtaining the corresponding business bucket number, encode the task primary key and save it in redis to complete the registration of the task. The scheduling method provided by the present invention can support the delayed start of the business (i.e., the scheduling of the execution of scheduled business), and the scheduling time can be recorded in the business for storage when the business is registered.

[0061] Through the above settings, business tasks are registered through the redis database, and each scheduling execution node (host in the business cluster) obtains business from redis. When a single point fails, it only reduces the number of execution hosts for scheduling tasks and reduces the scheduling processing speed, but does not affect the availability of the scheduling system. In addition, when a single node exits (a host fails or stops executing scheduling tasks) or joins the execution of scheduling tasks, there is no need to divide the business into buckets again, because once the number of business buckets is determined, the corresponding business bucket number determined by hash calculation will not change, reducing the complexity of the scheduling system.

[0062] Step S204, bucketing is performed according to the business primary key corresponding to the business, and the business bucket number corresponding to the business is determined.

[0063] Specifically, according to an embodiment of the present invention, bucketing is performed according to the business primary key corresponding to the business, and the step of determining the business bucket number corresponding to the business includes: performing hash calculation on the business primary key corresponding to the business to obtain a hash value, and determining the business bucket number corresponding to the business according to the hash value and the number of business buckets.

[0064] According to a specific implementation of the first embodiment of the present invention, the hash value obtained by performing hash calculation on the business primary key of a certain business is 1345. Assuming that the number of business buckets is 100, the hash value is modulo the number of business buckets, that is, the remainder obtained by dividing 1345 by 100 is 45, and it can be determined that the business bucket number corresponding to the business is 45. It should be noted that the number of business buckets is only an example and can be adjusted according to actual conditions.

[0065] Each business has a unique business primary key. By performing hash calculation on the business primary key and then taking the modulus of the obtained hash value and the number of business buckets, the business bucket number of each business can be determined relatively easily. The above setting also avoids the scenario where all businesses with the same scheduling time are put into the same business bucket, which reduces the scheduling efficiency of the business.

[0066] Step S205, configuring the scheduling task corresponding to each host, where the scheduling task indicates the scheduling period and scheduling quantity.

[0067] The method provided by the present invention is particularly suitable for scheduling scheduled services, which involves the host needing to scan and execute the services in the service bucket in a timely manner. According to a specific implementation of an embodiment of the present invention, this embodiment mainly uses a stand-alone spring task to realize the scheduled start of the service. Spring task is a simple stand-alone service scheduler that relies on JDK Timer and can complete single-point scheduled call services. By setting up scheduling tasks for each host, the corresponding host traverses different service bucket numbers according to the scheduling cycle and executes services that meet the scheduling time. The scheduling quantity can be configured, mainly to ensure that the scheduling of the corresponding business is completed as much as possible within a scheduling cycle.

[0068] The scheduling period configured on each host in the business cluster can be consistent or inconsistent. However, if the scheduling period of each host is set to be consistent, the scheduling tasks of multiple machines can be deployed by setting only one code, and the scheduling tasks of multiple machines can be maintained uniformly, further reducing the load pressure of the scheduling system.

[0069] Step S206, determine the initial service bucket number corresponding to each host in the service cluster, and according to the service bucket number, traverse and execute the services that meet the scheduling time in all service bucket numbers starting from the initial service bucket number through the host.

[0070] According to an embodiment of the present invention, when a scheduling task is executed, each host first generates a random number as the initial task bucket number of the scheduling task of the host, wherein the random number ranges from 0 to N-1, (N is the total number of service buckets). Then each host starts from the service bucket corresponding to the initial service bucket number, and cyclically executes the scheduling of services that meet the scheduling time in all service buckets.

[0071] Specifically, according to a specific implementation of an embodiment of the present invention, assuming that the initial service bucket number of a host is S, the host sequentially executes services in service buckets S to N-1, and then continues to execute services in service buckets from 0 to S-1, traversing a circle to complete the scheduling of services in all service buckets that meet the scheduling time. The initial service bucket number is to reduce contention when multiple hosts start scheduling tasks at the same time, and the purpose of sequential execution is to ensure that the scheduling task execution of each host will execute each task bucket sequentially once.

[0072] Specifically, during the execution of the scheduling, the logic of the scheduling task can be implemented through the calling interface set above, and the business scheduling can also be implemented through RPC (Remote Procedure Call Protocol, remote service call).

[0073] According to an embodiment of the present invention, when each host executes a service corresponding to a corresponding service bucket number, the corresponding service bucket is locked by a database lock.

[0074] Since the number of businesses that meet the scheduling time in each business bucket is inconsistent, as the scheduling is executed, multiple hosts may schedule the businesses in a business bucket at the same time. The database lock ensures that a host is not interfered with by other hosts when scheduling the businesses in a business bucket, effectively ensuring the smooth execution of business scheduling.

[0075] Through the above settings, the competition for business buckets by multiple nodes (hosts) is guaranteed by the redis lock mechanism (other database locks can also be used), so that there will be no repeated execution of tasks, which effectively solves the single point problem that often occurs in existing scheduling methods.

[0076] According to an application scenario provided by an embodiment of the present invention: During the execution process, after a host determines the next service bucket number to be scheduled, it locks the corresponding service bucket through the redis lock mechanism. If other hosts also cycle to the service scheduling of the service bucket, they will skip the service bucket in order and execute the scheduling of the service in the next service bucket. In each scheduling cycle, the corresponding host executes the corresponding scheduling task according to the scheduling quantity. If the scheduling quantity is too large and is not completed in one scheduling cycle, the remaining scheduling quantity will be executed in the next scheduling cycle until the scheduling quantity set in the previous scheduling cycle is completed.

[0077] Through the above settings, when the scheduling of each node (host) in the business cluster starts, different initial business bucket numbers and bucketing mechanisms are assigned to the nodes, which reduces the generation of contention locks, realizes multi-node parallel execution of scheduling tasks, and improves scheduling efficiency.

[0078] According to the technical solution of the embodiment of the present invention, the business in the message queue is obtained, and the business is registered in the database, and the business registration indicates the scheduling time of the business; the business is bucketed according to the business primary key corresponding to the business, and the business bucket number corresponding to the business is determined; according to the business bucket number and the scheduling time, the technical means of scheduling the business is performed by the host in the business cluster, so the technical problems of narrow applicability, low security and high scheduling cost of the existing business scheduling method are overcome, and then the technical effect of being able to realize the parallel execution of scheduling tasks by multiple hosts, wide applicability, improved security and scheduling efficiency of business scheduling, and reduced scheduling cost is achieved.

[0079] Figure 3 is a schematic diagram of main modules of a service scheduling device according to an embodiment of the present invention; Figure 3As shown, the service scheduling device 300 provided in the embodiment of the present invention mainly includes:

[0080] The service registration module 301 is used to obtain the service in the message queue and register the service in the database. The service registration indicates the scheduling time of the service.

[0081] Furthermore, according to an embodiment of the present invention, the service scheduling device 300 further includes a message queue constituting module. Before the step of acquiring services in the message queue, the message queue constituting module is used to collect services of the application program and constitute a message queue.

[0082] By collecting the services within an application through a message queue and then executing the scheduling of subsequent services, the scheduling and execution of services are decoupled, ensuring that the service scheduling method provided by the present invention can still be applied in scenarios with high service volume, thereby improving the applicability of the scheduling method.

[0083] Furthermore, according to an embodiment of the present invention, the above-mentioned service scheduling device 300 further includes a filtering module. After the step of acquiring the service in the message queue, the filtering module is used to filter the service according to the scheduling parameters.

[0084] Services are filtered through common protocol parameters or application-defined parameters, improving overall call efficiency.

[0085] The business bucket number determination module 302 is used to divide the business into buckets according to the business primary key corresponding to the business, and determine the business bucket number corresponding to the business.

[0086] Specifically, according to an embodiment of the present invention, the business bucket number determination module 302 is further used to: perform hash calculation on the business primary key corresponding to the business to obtain a hash value, and determine the business bucket number corresponding to the business according to the hash value and the number of business buckets.

[0087] Each business has a unique business primary key. By performing hash calculation on the business primary key and then taking the modulus of the obtained hash value and the number of business buckets, the business bucket number of each business can be determined relatively easily. The above setting also avoids the scenario where all businesses with the same scheduling time are put into the same business bucket, which reduces the scheduling efficiency of the business.

[0088] The scheduling module 303 is used to schedule services through hosts in the service cluster according to the service bucket number and the scheduling time.

[0089] According to an embodiment of the present invention, the above-mentioned scheduling module 303 is also used to: determine the initial business bucket number corresponding to each host in the business cluster, and according to the business bucket number, traverse and execute the services that meet the scheduling time in all business bucket numbers starting from the initial business bucket number through the host.

[0090] By determining an initial business bucket number for each host (which can be determined randomly, as long as the initial business bucket number of each host is different), it is convenient for multiple hosts to execute business scheduling in parallel, avoiding the scenario of contention lock caused by multiple hosts scheduling business for the same business bucket, and improving the scheduling rate of the business.

[0091] Further, according to an embodiment of the present invention, the scheduling device 300 of the above-mentioned business also includes a scheduling task configuration module. Before determining the initial business bucket number corresponding to each host in the business cluster, the scheduling task configuration module is used to configure the scheduling task corresponding to each host. The scheduling task indicates a scheduling period and a scheduling quantity. According to the scheduling period and the scheduling quantity, the initial business bucket number corresponding to each host in the business cluster is determined cyclically. According to the business bucket number, starting from the initial business bucket number, the host traverses the steps of executing the services that meet the scheduling time in all business bucket numbers.

[0092] Specifically, according to an embodiment of the present invention, the service scheduling device 300 further includes a database lock module. When each host executes the scheduling of the service corresponding to the corresponding service bucket number, the database lock module is used to lock the corresponding service bucket through a database lock.

[0093] Since the number of businesses that meet the scheduling time in each business bucket is inconsistent, as the scheduling is executed, multiple hosts may schedule the businesses in a business bucket at the same time. The database lock ensures that a host is not interfered with by other hosts when scheduling the businesses in a business bucket, effectively ensuring the smooth execution of business scheduling.

[0094] According to the technical solution of the embodiment of the present invention, the business in the message queue is obtained, and the business is registered in the database, and the business registration indicates the scheduling time of the business; the business is bucketed according to the business primary key corresponding to the business, and the business bucket number corresponding to the business is determined; according to the business bucket number and the scheduling time, the technical means of scheduling the business is performed by the host in the business cluster, so the technical problems of narrow applicability, low security and high scheduling cost of the existing business scheduling method are overcome, and then the technical effect of being able to realize the parallel execution of scheduling tasks by multiple hosts, wide applicability, improved security and scheduling efficiency of business scheduling, and reduced scheduling cost is achieved.

[0095] It can be understood that since the method embodiment and the device embodiment are different presentation forms of the same technical concept, the content of the method embodiment part in this application should be synchronously adapted to the device embodiment part and will not be repeated here.

[0096] Figure 4 An exemplary system architecture 400 is shown to which the service scheduling method or service scheduling device according to the embodiment of the present invention can be applied.

[0097] like Figure 4 As shown, the system architecture 400 may include terminal devices 401, 402, 403, a network 404 and a server 405 (this architecture is only an example, and the components included in the specific architecture may be adjusted according to the specific application). The network 404 is used to provide a medium for a communication link between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0098] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0099] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0100] The server 405 may be a server that provides various services, such as a background management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 401, 402, and 403. The background management server may analyze and process the received data such as services and scheduling time, and feed back the processing results (such as the scheduling of executing services - only an example) to the terminal device.

[0101] It should be noted that the service scheduling method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the service scheduling device is generally disposed in the server 405 .

[0102] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0103] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device suitable for implementing an embodiment of the present invention. Figure 5 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0104] like Figure 5As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0105] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0106] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.

[0107] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0108] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0109] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a service registration module, a service bucket number determination module, and a scheduling module. The names of these modules do not, in some cases, constitute a limitation on the modules themselves. For example, the service registration module may also be described as "a module for obtaining services in a message queue and registering the services in a database."

[0110] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining the business in the message queue, registering the business in the database, and the business registration indicates the scheduling time of the business; bucketing according to the business primary key corresponding to the business, and determining the business bucket number corresponding to the business; and scheduling the business through the host in the business cluster according to the business bucket number and the scheduling time.

[0111] According to the technical solution of the embodiment of the present invention, the business in the message queue is obtained, and the business is registered in the database, and the business registration indicates the scheduling time of the business; the business is bucketed according to the business primary key corresponding to the business, and the business bucket number corresponding to the business is determined; according to the business bucket number and the scheduling time, the technical means of scheduling the business is performed by the host in the business cluster, so the technical problems of narrow applicability, low security and high scheduling cost of the existing business scheduling method are overcome, and then the technical effect of being able to realize the parallel execution of scheduling tasks by multiple hosts, wide applicability, improved security and scheduling efficiency of business scheduling, and reduced scheduling cost is achieved.

[0112] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A service scheduling method, characterized in that: include: Obtaining a service in a message queue, and registering the service in a database, wherein the service registration indicates a scheduling time for the service; Divide the business into buckets according to the business primary key corresponding to the business, and determine the business bucket number corresponding to the business; According to the service bucket number and the scheduling time, the service is scheduled through the host in the service cluster; specifically including: configuring the scheduling task corresponding to each host, the scheduling task indicates the scheduling period and the scheduling quantity, and cyclically executing according to the scheduling task: determining the initial service bucket number corresponding to each host in the service cluster, and according to the service bucket number, traversing and executing the services that meet the scheduling time in all service bucket numbers starting from the initial service bucket number through the host.

2. The service scheduling method according to claim 1, characterized in that: After the step of acquiring the services in the message queue, the service scheduling method further comprises: filtering the services according to scheduling parameters.

3. The service scheduling method according to claim 1, characterized in that: The step of bucketing according to the business primary key corresponding to the business and determining the business bucket number corresponding to the business includes: performing hash calculation on the business primary key corresponding to the business to obtain a hash value, and determining the business bucket number corresponding to the business according to the hash value and the number of business buckets.

4. The service scheduling method according to claim 1, characterized in that: When each host executes the scheduling of the business corresponding to the corresponding business bucket number, the corresponding business bucket is locked through the database lock.

5. A service scheduling device, characterized in that: include: A service registration module is used to obtain services in the message queue and register the services in the database, wherein the service registration indicates the scheduling time of the services; A business bucket number determination module, used to divide the business into buckets according to the business primary key corresponding to the business, and determine the business bucket number corresponding to the business; The scheduling module is used to schedule the execution of services through the host in the service cluster according to the service bucket number and the scheduling time, and is specifically used to: configure the scheduling task corresponding to each host, the scheduling task indicates the scheduling period and the scheduling quantity, and cyclically execute according to the scheduling task: determine the initial service bucket number corresponding to each host in the service cluster, and according to the service bucket number, traverse and execute the services that meet the scheduling time in all service bucket numbers starting from the initial service bucket number through the host.

6. A terminal device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

7. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Method for dynamic reconfiguration of extensive network service

    CN101299679A

  • Data processing method and device applied to multi-level cache in cluster

    CN110046029A