WO2022188509A1 - Method and apparatus for task processing in distributed environment, and electronic device and medium - Google Patents
Method and apparatus for task processing in distributed environment, and electronic device and medium Download PDFInfo
- Publication number
- WO2022188509A1 WO2022188509A1 PCT/CN2021/140522 CN2021140522W WO2022188509A1 WO 2022188509 A1 WO2022188509 A1 WO 2022188509A1 CN 2021140522 W CN2021140522 W CN 2021140522W WO 2022188509 A1 WO2022188509 A1 WO 2022188509A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- task
- server
- designated server
- designated
- execution
- Prior art date
Links
- 238000000034 method Methods 0.000 title abstract description 23
- 238000003672 processing method Methods 0.000 claims description 29
- 238000004590 computer program Methods 0.000 claims description 4
- 238000003491 array Methods 0.000 description 9
- 238000004891 communication Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 7
- 238000010586 diagram Methods 0.000 description 4
- 238000012423 maintenance Methods 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 3
- 230000003190 augmentative effect Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000006978 adaptation Effects 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000004984 smart glass Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/465—Distributed object oriented systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
Definitions
- the present disclosure relates to the technical field of data processing, and in particular, to a task processing method, apparatus, electronic device and medium in a distributed environment.
- the processing stage within the task system includes task reception (stored in the library), task assignment, and task result presentation.
- the assignment of tasks includes the implementation of the following scenarios:
- the user terminal is not under the control of the server cluster, and security problems may occur during the task assignment process.
- the address of the server accessed by the user terminal may be invalid, which affects the user's product experience.
- the specific execution server of the task is determined by the task distribution system, which can be understood as the existence of a central control node that distributes tasks uniformly.
- the task allocation system relies on too many open source components, which affects the stability of the system and is not conducive to upgrades and later functional iterations.
- this type of system must universally serve various business lines. , that is, it needs to be compatible with various scenarios, which makes the whole system more complex and also leads to an increase in maintenance costs in the later period.
- the purpose of the present disclosure is to provide a task processing method, apparatus, electronic device and medium in a distributed environment, which at least to a certain extent overcomes the problem of low task processing efficiency in a distributed environment in the related art.
- a task processing method in a distributed environment comprising: obtaining request information requesting a server to execute a task; determining to send the task to a designated server or a non-designated server according to the request information; If it is determined to send to the non-designated server, the non-designated server capable of executing the task and the execution weight of the non-designated server are obtained; the task is allocated to the non-designated server according to the execution weight.
- the method further includes: acquiring the execution time of the non-designated server processing the task within a specified time; and updating the execution weight according to the execution time.
- updating the execution weight according to the execution time includes: setting the initial execution weights of the non-designated servers to be equal; determining the sum of execution times of all the non-designated servers; determining the execution time The proportion of time to the sum of the execution time; the execution weight is updated according to the proportion.
- determining to send the task to a designated server or a non-designated server according to the request information includes: parsing the request information to determine whether address information of the designated server is included; If the information includes the address information, the task is sent to the designated server according to the address information.
- determining to send the task to a designated server or a non-designated server according to the request information further includes: parsing the request information to determine whether address information of the designated server is included; If the request information does not include the address information, it is determined to send the task to the non-designated server.
- the method further includes: receiving result information of the non-designated server executing the task; determining triple data information and execution time field information contained in the result information; The group data information updates the triplet data in the preset library table; and the execution time of the redis cache is updated according to the execution time field information.
- acquiring request information requesting a server to perform a task includes: acquiring the request information; parsing the request information to include invocation services and invocation parameters; determining the request according to the invocation services and the invocation parameters
- the server scope includes the designated server and the non-designated server.
- a task processing apparatus in a distributed environment, comprising: an acquisition module for acquiring request information requesting a server to perform a task; a determination module for determining according to the request information The task is sent to a designated server or a non-designated server; the obtaining module is further configured to, if it is determined to be sent to the non-designated server, obtain the non-designated server capable of executing the task and the execution weight of the non-designated server; assign a module for allocating the task to the non-designated server according to the execution weight.
- an electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the foregoing by executing the executable instructions Task processing methods in a distributed environment.
- a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements any one of the above-mentioned task processing methods in a distributed environment.
- the task is determined to be sent to a designated server or a non-designated server according to the request information, and the task is allocated to all the tasks according to the execution weight.
- the non-designated server described above improves the security and reliability of task processing, optimizes the resource balance of servers in the distributed cluster, and improves the overall throughput and task processing efficiency of the distributed cluster.
- FIG. 1 shows a schematic diagram of a task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 2 shows a flowchart of another task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 3 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 4 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 5 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 6 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 7 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 8 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure
- FIG. 9 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure.
- FIG. 10 shows a schematic diagram of a task processing apparatus in a distributed environment in an embodiment of the present disclosure
- FIG. 11 shows a schematic diagram of an electronic device in an embodiment of the present disclosure.
- Example embodiments will now be described more fully with reference to the accompanying drawings.
- Example embodiments can be embodied in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
- the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
- the solution provided by the present disclosure improves the security of task processing by determining to send the task to a designated server or a non-designated server according to the request information, and assigning the task to the non-designated server according to the execution weight It optimizes the resource balance of the servers in the distributed cluster and improves the overall throughput and task processing efficiency of the distributed cluster.
- the above task processing solution in a distributed environment can be implemented through the interaction of multiple terminals and server clusters.
- the terminal can be a mobile phone, game console, tablet computer, e-book reader, smart glasses, MP4 (Moving Picture Experts Group Audio Layer IV, moving image expert compression standard audio layer 4) player, smart home equipment, AR (Augmented Reality, Augmented reality) equipment, VR (Virtual Reality, virtual reality) equipment and other mobile terminals, or, the terminal can also be a personal computer (Personal Computer, PC), such as a laptop portable computer and a desktop computer and so on.
- PC Personal Computer
- an application program for providing task processing in a distributed environment may be installed in the terminal.
- the terminal and the server cluster are connected through a communication network.
- the communication network is a wired network or a wireless network.
- a server cluster is a server, or consists of several servers, or a virtualization platform, or a cloud computing service center. Server clusters are used to provide background services for applications that provide task processing in a distributed environment.
- the server cluster undertakes the main computing work, and the terminal undertakes the secondary computing work; or, the server cluster undertakes the secondary computing work, and the terminal undertakes the main computing work; or, a distributed computing architecture is used between the terminal and the server cluster for collaborative computing. .
- the clients of the application programs installed in different terminals are the same, or the clients of the application programs installed on the two terminals are clients of the same type of application programs of different control system platforms.
- the specific form of the client of the application program may also be different, for example, the client of the application program may be a mobile phone client, a PC client, or a global wide area network client.
- the number of the above-mentioned terminals may be more or less.
- the above-mentioned terminal may be only one, or the above-mentioned terminal may be dozens or hundreds, or more.
- the embodiments of the present disclosure do not limit the number of terminals and device types.
- the system may further include a management device, and the management device and the server cluster are connected through a communication network.
- the communication network is a wired network or a wireless network.
- the above-mentioned wireless network or wired network uses standard communication technologies and/or protocols.
- the network is usually the Internet, but can be any network, including but not limited to Local Area Network (LAN), Metropolitan Area Network (MAN), Wide Area Network (WAN), mobile, wired or wireless network, private network, or any combination of virtual private networks).
- data exchanged over a network is represented using technologies and/or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), and the like.
- HTML Hyper Text Mark-up Language
- XML Extensible Markup Language
- you can also use services such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc.
- SSL Secure Socket Layer
- TLS Transport Layer Security
- VPN Virtual Private Network
- IPsec Internet Protocol Security
- Conventional encryption techniques to encrypt all or some of the links.
- custom and/or dedicated data communication techniques may also be used in place of or in addition to the data communication techniques
- FIG. 1 shows a flowchart of a task processing method in a distributed environment in an embodiment of the present disclosure.
- the methods provided by the embodiments of the present disclosure may be executed by any electronic device with computing processing capability.
- the method for processing tasks in a distributed environment by an electronic device includes the following steps:
- Step S102 acquiring request information requesting the server to perform the task.
- Step S104 determining to send the task to a designated server or a non-designated server according to the request information.
- Step S106 if it is determined to send to the non-designated server, obtain the non-designated server capable of executing the task and the execution weight of the non-designated server.
- Step S108 Allocate the task to the non-designated server according to the execution weight.
- the task is improved.
- the security and reliability of processing optimize the resource balance of servers in the distributed cluster, and improve the overall throughput and task processing efficiency of the distributed cluster.
- the task processing method in the distributed environment further includes:
- Step S202 acquiring the execution time of the non-designated server processing the task within the designated time.
- Step S204 Update the execution weight according to the execution time.
- the execution efficiency of the non-designated server is determined by acquiring the execution time of the non-designated server processing the task within the designated time, and then the computing resources and service resources that the non-designated server can provide are determined, The allocation of subsequent tasks can be optimized based on this updated execution weight to optimize task processing efficiency in a distributed environment.
- updating the execution weight according to the execution time includes:
- Step S302 setting the initial execution weights of the non-designated servers to be equal.
- Step S304 determining the sum of the execution time of all the non-designated servers.
- Step S306 determining the ratio of the execution time to the total execution time.
- Step S308 update the execution weight according to the ratio.
- the task processing capability of the server in a distributed environment is synthesized, based on In this way, the execution weight of each server is updated, which not only improves the task processing efficiency in a distributed environment, but also balances the load and throughput of each server.
- determining to send the task to a designated server or a non-designated server according to the request information includes:
- Step S402 Parse the request information to determine whether the address information of the designated server is included.
- Step S404 if it is determined that the request information includes the address information, send the task to the designated server according to the address information.
- the designated server improves the processing efficiency of designated tasks.
- the priority of the task of the designated server can be set higher than the priority of the task of the non-designated server.
- determining to send the task to a designated server or a non-designated server according to the request information further includes:
- Step S502 Parse the request information to determine whether the address information of the designated server is included.
- Step S504 if it is determined that the request information does not include the address information, it is determined to send the task to the non-designated server.
- the server that is, the task is sent to the corresponding non-designated server according to the execution weight. Without the need to determine the designated server, the steps to resolve the address of the designated server are reduced, and the load and throughput of the non-designated server are balanced by the execution weight. quantity.
- the task processing method in the distributed environment further includes:
- Step S602 receiving result information of the non-designated server executing the task.
- Step S604 determining triple data information and execution time field information contained in the result information.
- Step S606 Update triple data in the preset library table according to the triple data information.
- Step S608 update the execution time of the redis cache according to the execution time field information.
- the triplet data in the table and the execution time of the redis cache are used as an important basis for the feedback of the execution task and the update of the execution weight.
- the triple data information includes task parameters, request address, and application identifier to which the task belongs.
- the execution time field information may be written into the redis cache in the format of the task ID, the server ID, and the execution time.
- obtaining the request information requesting the server to perform the task also includes:
- Step S702 acquiring the request information.
- Step S704 parse that the request information contains the calling service and calling parameters.
- Step S706 Determine a requested server range according to the invocation service and the invocation parameter, where the server range includes the designated server and the non-designated server.
- the servers within the server range are based on a distributed architecture. Responding to task processing requests, it can meet the selection requirements of designated servers and non-designated servers, has high flexibility, and does not require cumbersome architecture layout and maintenance.
- the task processing scheme in a distributed environment includes:
- the system obtains the server list of application A from zookeeper (distributed system coordination), and the servers in the list are available.
- ZooKeeper is a distributed, open source distributed application coordination service, an open source implementation of Google's Chubby, and an important component of Hadoop and Hbase. It is a software that provides consistent services for distributed applications. The functions provided include: configuration maintenance, domain name service, distributed synchronization, group service, etc.
- ZooKeeper The goal of ZooKeeper is to encapsulate complex and error-prone key services, and provide users with an easy-to-use interface and a system with high performance and stable functions.
- ZooKeeper includes a simple set of primitives that provide Java and C interfaces.
- interfaces for distributed exclusive locks, elections, and queues are provided.
- the code is in zookeeper_home ⁇ src ⁇ recipes.
- the first round respectively take the first elements of the three arrays arrayM[0], arrayN[0] and arrayK[0], and put them into the final array array in turn.
- the second round respectively take the first elements of the three arrays arrayM[1], arrayN[1] and arrayK[1], and put them into the final array array in turn.
- the third round respectively take the first elements of the three arrays arrayM[2], arrayN[2] and arrayK[2], and put them into the final array array in turn.
- hash hash
- hash User's ip address
- the ratio value shows that the efficiency of the first server 802 is higher, followed by the second server 804 and the third server 806, so the number of tasks allocated to the first server 802 can be increased.
- the execution weight can be allocated in reverse order, as follows. :
- the calculation result is rounded up to 4.
- the execution time of the second server 804 accounts for 32%, the weight of the second server 804 is 32%, and the calculation result of 9 ⁇ 32% is rounded to 3. If the execution time of the third server 806 accounts for 45%, the weight of the third server 806 is 21%, and the calculation result of 9 ⁇ 21% is rounded to 2.
- the server identifier (that is, the identifier that can uniquely find the server, which can be an ip address) is put into an array by weight, and the three arrays are recorded as array M', array N' and array K' respectively. .
- the first round take the first elements of the three arrays arrayM'[0], arrayN'[0], arrayK'[0], and put them into the final array array in turn.
- the second round respectively take the first elements of the three arrays arrayM'[1], arrayN'[1], arrayK'[1], and put them into the final array array in turn.
- the fourth round the first element of the array M', arrayM'[3], is put into the final array array.
- the average execution time of the last Z tasks T may be taken, where Z is a positive integer, and Z may be set to 5, for example, to redefine the execution weight of each server.
- the task execution time it is affected by many factors, such as: the configuration of the server executing the task, the load status of the server's CPU, etc., so the historical execution time of the task does not have much reference value, only the most recent execution time.
- the reference value measures the current load of the server through the average execution time of the last Z.
- the reason for taking the average value of the execution time instead of the variance is because the average value can reflect the load of the server, and the variance can only reflect the fluctuation of the execution time, but cannot reflect the server load, that is, the variance
- the load of a small server can be very high or very low, so it is impossible to judge the load state of the server, so the average value of the execution time is preferred to evaluate the execution weight of the server.
- the task processing apparatus 1000 in a distributed environment will be described below with reference to FIG. 10 .
- the task processing apparatus 1000 in a distributed environment shown in FIG. 10 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.
- the task processing apparatus 1000 in a distributed environment is represented in the form of hardware modules.
- the components of the task processing apparatus 1000 in a distributed environment may include, but are not limited to: an acquisition module 1002 , a determination module 1004 and an allocation module 1006 .
- the obtaining module 1002 is configured to obtain request information for requesting the server to perform a task.
- the determining module 1004 is configured to determine, according to the request information, to send the task to a designated server or a non-designated server.
- the acquiring module 1002 is further configured to acquire the non-designated server capable of executing the task and the execution weight of the non-designated server if it is determined to be sent to the non-designated server.
- An allocation module 1006, configured to allocate the task to the non-designated server according to the execution weight.
- the electronic device 1100 according to this embodiment of the present disclosure is described below with reference to FIG. 11 .
- the electronic device 1100 shown in FIG. 11 is only an example, and should not impose any limitation on the function and scope of use of the embodiments of the present disclosure.
- electronic device 1100 takes the form of a general-purpose computing device.
- Components of the electronic device 1100 may include, but are not limited to: the above-mentioned at least one processing unit 1110 , the above-mentioned at least one storage unit 1120 , and a bus 1130 connecting different system components (including the storage unit 1120 and the processing unit 1110 ).
- the storage unit stores program codes, which can be executed by the processing unit 1110, so that the processing unit 1110 performs the steps according to various exemplary embodiments of the present disclosure described in the above-mentioned "Exemplary Methods" section of this specification.
- the processing unit 1110 may execute the steps defined in the task processing method in a distributed environment of the present disclosure.
- the storage unit 1120 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 11201 and/or a cache storage unit 11202 , and may further include a read only storage unit (ROM) 11203 .
- RAM random access storage unit
- ROM read only storage unit
- the storage unit 1120 may also include a program/utility 11204 having a set (at least one) of program modules 11205 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, An implementation of a network environment may be included in each or some combination of these examples.
- the bus 1130 may be representative of one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local area using any of a variety of bus structures bus.
- the electronic device 1100 may also communicate with one or more external devices 1140 (eg, keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device, and/or The electronic device 1100 can communicate with any device (eg, router, modem, etc.) that communicates with one or more other computing devices. Such communication may occur through input/output (I/O) interface 1150 . Also, the electronic device 1100 can communicate with one or more networks (eg, a local area network (LAN), a wide area network (WAN), and/or a public network such as the Internet) through a network adapter 1110 , which communicates with the electronic device 1100 through a bus 1130 . communication with other modules.
- LAN local area network
- WAN wide area network
- Internet public network
- the exemplary embodiments described herein may be implemented by software, or may be implemented by software combined with necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure may be embodied in the form of software products, and the software products may be stored in a non-volatile storage medium (which may be CD-ROM, U disk, mobile hard disk, etc.) or on the network , including several instructions to cause a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to an embodiment of the present disclosure.
- a computing device which may be a personal computer, a server, a terminal device, or a network device, etc.
- a computer-readable storage medium on which a program product capable of implementing the above-described method of the present specification is stored.
- various aspects of the present disclosure can also be implemented in the form of a program product, which includes program code, when the program product runs on a terminal device, the program code is used to cause the terminal device to execute the above-mentioned procedures in this specification. Steps according to various exemplary embodiments of the present disclosure are described in the "Example Methods" section.
- a program product for implementing the above method according to an embodiment of the present disclosure may adopt a portable compact disc read only memory (CD-ROM) and include program codes, and may run on a terminal device, such as a personal computer.
- CD-ROM compact disc read only memory
- the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
- a computer readable signal medium may include a propagated data signal in baseband or as part of a carrier wave with readable program code embodied thereon. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
- a readable signal medium can also be any readable medium, other than a readable storage medium, that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
- Program code embodied on a readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
- Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages—such as Java, C++, etc., as well as conventional procedural programming Language - such as the "C" language or similar programming language.
- the program code may execute entirely on the user computing device, partly on the user device, as a stand-alone software package, partly on the user computing device and partly on a remote computing device, or entirely on the remote computing device or server execute on.
- the remote computing device may be connected to the user computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (eg, using an Internet service provider business via an Internet connection).
- LAN local area network
- WAN wide area network
- modules or units of the apparatus for action performance are mentioned in the above detailed description, this division is not mandatory. Indeed, according to embodiments of the present disclosure, the features and functions of two or more modules or units described above may be embodied in one module or unit. Conversely, the features and functions of one module or unit described above may be further divided into multiple modules or units to be embodied.
- the exemplary embodiments described herein may be implemented by software, or may be implemented by software combined with necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure may be embodied in the form of software products, and the software products may be stored in a non-volatile storage medium (which may be CD-ROM, U disk, mobile hard disk, etc.) or on the network , which includes several instructions to cause a computing device (which may be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute a method according to an embodiment of the present disclosure.
- a computing device which may be a personal computer, a server, a mobile terminal, or a network device, etc.
- the task is determined to be sent to a designated server or a non-designated server according to the request information, and the task is allocated to all the tasks according to the execution weight.
- the non-designated server described above improves the security and reliability of task processing, optimizes the resource balance of servers in the distributed cluster, and improves the overall throughput and task processing efficiency of the distributed cluster.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Computing Systems (AREA)
- Computer And Data Communications (AREA)
Abstract
The present disclosure provides a method and apparatus for task processing in a distributed environment, and an electronic device and a medium, which relate to the technical field of data processing. The method for task processing in a distributed environment comprises: acquiring request information for requesting a server to execute a task; determining, according to the request information, whether to send the task to a designated server or a non-designated server; if it is determined that the task will be sent to a non-designated server, acquiring a non-designated server that can execute the task, and an execution weight of the non-designated server; and allocating the task to the non-designated server according to the execution weight. By means of the technical solution of the present disclosure, the efficiency of task processing, and the balance and reliability of service resources are improved.
Description
本公开要求于2021年3月12日提交的申请号为202110270111.4、名称为“分布式环境下的任务处理方法、装置、电子设备和介质”的中国专利申请的优先权,该中国专利申请的全部内容通过引用全部并入本文。This disclosure claims the priority of the Chinese patent application with the application number 202110270111.4 and titled "Task Processing Method, Apparatus, Electronic Device and Medium in Distributed Environment", filed on March 12, 2021, and all of the Chinese patent application The contents are incorporated herein by reference in their entirety.
本公开涉及数据处理技术领域,尤其涉及一种分布式环境下的任务处理方法、装置、电子设备和介质。The present disclosure relates to the technical field of data processing, and in particular, to a task processing method, apparatus, electronic device and medium in a distributed environment.
在分布式集群架构下,多个应用任务通常由该架构中的多个服务器协同执行,任务系统内部的处理阶段包括任务的接收(存储到库)、任务的分配和任务结果的展示,其中,任务分配包括以下方案实现:Under the distributed cluster architecture, multiple application tasks are usually executed collaboratively by multiple servers in the architecture. The processing stage within the task system includes task reception (stored in the library), task assignment, and task result presentation. Among them, The assignment of tasks includes the implementation of the following scenarios:
(1)将任务分配的功能直接下沉到用户终端上,在用户终端上已经获取到要将任务发送到哪台服务器执行。(1) The function of task allocation is directly lowered to the user terminal, and the user terminal has obtained which server to send the task to for execution.
但是,用户终端不在服务器集群的管控范围内,任务分配过程中可能出现安全等问题。However, the user terminal is not under the control of the server cluster, and security problems may occur during the task assignment process.
另外,若服务地址列表更新不及时,则可能导致用户终端访问的服务器的地址无效,就影响使用者的产品体验。In addition, if the service address list is not updated in time, the address of the server accessed by the user terminal may be invalid, which affects the user's product experience.
(2)由任务分配系统来决定任务的具体执行服务器,可以理解为存在一个中心控制节点,统一对任务进行分派。(2) The specific execution server of the task is determined by the task distribution system, which can be understood as the existence of a central control node that distributes tasks uniformly.
但是,任务分配系统依赖的开源组件过多,影响系统的稳定性,不利于升级和后期的功能迭代,大多数的软件公司中,该类型的系统都要普适性地为各条业务线服务,也即需要兼容各种场景,从而导致整个系统愈加复杂,也会导致后期维护成本的增加。However, the task allocation system relies on too many open source components, which affects the stability of the system and is not conducive to upgrades and later functional iterations. In most software companies, this type of system must universally serve various business lines. , that is, it needs to be compatible with various scenarios, which makes the whole system more complex and also leads to an increase in maintenance costs in the later period.
(3)上述两种任务分配方案还存在任务分配不均的问题,这就可能导致一部分服务器资源未被利用,而另一部分服务器处于过载状态,这就会导致分布式集群处理任务的效率降低,也严重影响了服务器的可靠性、吞吐量和资源均衡性。(3) The above two task allocation schemes also have the problem of uneven task allocation, which may cause some server resources to be unused, while another part of the server is in an overloaded state, which will reduce the efficiency of distributed cluster processing tasks. It also seriously affects the reliability, throughput and resource balance of the server.
需要说明的是,在上述背景技术部分公开的信息仅用于加强对本公开的背景的理解,因此可以包括不构成对本领域普通技术人员已知的现有技术的信息。It should be noted that the information disclosed in the above Background section is only for enhancement of understanding of the background of the present disclosure, and therefore may contain information that does not form the prior art that is already known to a person of ordinary skill in the art.
发明内容SUMMARY OF THE INVENTION
本公开的目的在于提供一种分布式环境下的任务处理方法、装置、电子设备和介质,至少在一定程度上克服了相关技术中分布式环境下的任务处理效率低的问题。The purpose of the present disclosure is to provide a task processing method, apparatus, electronic device and medium in a distributed environment, which at least to a certain extent overcomes the problem of low task processing efficiency in a distributed environment in the related art.
本公开的其他特性和优点将通过后续的详细描述变得显然,或部分地通过本公开的实践而习得。Other features and advantages of the present disclosure will become apparent from the ensuing detailed description, or be learned in part by practice of the present disclosure.
根据本公开的一个方面,提供一种分布式环境下的任务处理方法,包括:获取请求服务器执行任务的请求信息;根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器;若确定发送至所述非指定服务器,则获取能够执行所述任务的非指定服务器和所述非指定服务器的执行权重;根据所述执行权重将所述任务分配至所述非指定服务器。According to one aspect of the present disclosure, there is provided a task processing method in a distributed environment, comprising: obtaining request information requesting a server to execute a task; determining to send the task to a designated server or a non-designated server according to the request information; If it is determined to send to the non-designated server, the non-designated server capable of executing the task and the execution weight of the non-designated server are obtained; the task is allocated to the non-designated server according to the execution weight.
在本公开的一个实施例中,还包括:获取所述非指定服务器在指定时间内处理所述任务的执行时间;根据所述执行时间更新所述执行权重。In an embodiment of the present disclosure, the method further includes: acquiring the execution time of the non-designated server processing the task within a specified time; and updating the execution weight according to the execution time.
在本公开的一个实施例中,根据所述执行时间更新所述执行权重包括:设置所述非指定服务器的初始执行权重相等;确定全部所述非指定服务器的执行时间的总和;确定所述执行时间占所述执行时间的总和的比例;根据所述比例更新所述执行权重。In an embodiment of the present disclosure, updating the execution weight according to the execution time includes: setting the initial execution weights of the non-designated servers to be equal; determining the sum of execution times of all the non-designated servers; determining the execution time The proportion of time to the sum of the execution time; the execution weight is updated according to the proportion.
在本公开的一个实施例中,根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器包括:解析所述请求信息确定是否包含所述指定服务器的地址信息;若确定所述请求信息包含所述地址信息,则根据所述地址信息将所述任务发送至所述指定服务器。In an embodiment of the present disclosure, determining to send the task to a designated server or a non-designated server according to the request information includes: parsing the request information to determine whether address information of the designated server is included; If the information includes the address information, the task is sent to the designated server according to the address information.
在本公开的一个实施例中,根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器还包括:解析所述请求信息确定是否包含所述指定服务器的地址信息;若确定所述请求信息不包含所述地址信息,则确定发送所述任务至所述非指定服务器。In an embodiment of the present disclosure, determining to send the task to a designated server or a non-designated server according to the request information further includes: parsing the request information to determine whether address information of the designated server is included; If the request information does not include the address information, it is determined to send the task to the non-designated server.
在本公开的一个实施例中,还包括:接收所述非指定服务器执行所述任务的结果信息;确定所述结果信息中包含的三元组数据信息和执行时间字段信息;根据所述三元组数据信息更新预设库表中的三元组数据;根据所述执行时间字段信息更新redis缓存的执行时间。In an embodiment of the present disclosure, the method further includes: receiving result information of the non-designated server executing the task; determining triple data information and execution time field information contained in the result information; The group data information updates the triplet data in the preset library table; and the execution time of the redis cache is updated according to the execution time field information.
在本公开的一个实施例中,获取请求服务器执行任务的请求信息包括:获取所述请求信息;解析所述请求信息中包含调用服务和调用参数;根据所述调用服务和所述调用参数确定请求的服务器范围,所述服务器范围包括所述指定服务器和所述非指定服务器。In an embodiment of the present disclosure, acquiring request information requesting a server to perform a task includes: acquiring the request information; parsing the request information to include invocation services and invocation parameters; determining the request according to the invocation services and the invocation parameters The server scope includes the designated server and the non-designated server.
根据本公开的另一个方面,提供一种分布式环境下的任务处理装置,包括:获取模块,用于获取请求服务器执行任务的请求信息;确定模块,用于根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器;所述获取模块还用于,若确定发送至所述非指定服务器,则获取能够执行所述任务的非指定服务器和所述非指定服务器的执行权重;分配模块,用于根据所述执行权重将所述任务分配至所述非指定服务器。According to another aspect of the present disclosure, there is provided a task processing apparatus in a distributed environment, comprising: an acquisition module for acquiring request information requesting a server to perform a task; a determination module for determining according to the request information The task is sent to a designated server or a non-designated server; the obtaining module is further configured to, if it is determined to be sent to the non-designated server, obtain the non-designated server capable of executing the task and the execution weight of the non-designated server; assign a module for allocating the task to the non-designated server according to the execution weight.
根据本公开的再一个方面,提供一种电子设备,包括:处理器;以及存储器,用于存储处理器的可执行指令;其中,处理器配置为经由执行可执行指令来执行上述任意一项的分布式环境下的任务处理方法。According to yet another aspect of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the foregoing by executing the executable instructions Task processing methods in a distributed environment.
根据本公开的又一个方面,提供一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现上述任意一项的分布式环境下的任务处理方法。According to yet another aspect of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements any one of the above-mentioned task processing methods in a distributed environment.
本公开的实施例所提供的分布式环境下的任务处理方案,通过根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器,并根据所述执行权重将所述任务分配 至所述非指定服务器,提高了任务处理的安全性和可靠性,优化了分布式集群中的服务器的资源均衡度,提升了分布式集群的整体吞吐量和任务处理效率。In the task processing solution in a distributed environment provided by the embodiments of the present disclosure, the task is determined to be sent to a designated server or a non-designated server according to the request information, and the task is allocated to all the tasks according to the execution weight. The non-designated server described above improves the security and reliability of task processing, optimizes the resource balance of servers in the distributed cluster, and improves the overall throughput and task processing efficiency of the distributed cluster.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure.
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。显而易见地,下面描述中的附图仅仅是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description serve to explain the principles of the disclosure. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and for those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort.
图1示出本公开实施例中一种分布式环境下的任务处理方法的示意图;1 shows a schematic diagram of a task processing method in a distributed environment in an embodiment of the present disclosure;
图2示出本公开实施例中另一种分布式环境下的任务处理方法的流程图;FIG. 2 shows a flowchart of another task processing method in a distributed environment in an embodiment of the present disclosure;
图3示出本公开实施例中又一种分布式环境下的任务处理方法的流程图;3 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure;
图4示出本公开实施例中又一种分布式环境下的任务处理方法的流程图;4 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure;
图5示出本公开实施例中又一种分布式环境下的任务处理方法的流程图;5 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure;
图6示出本公开实施例中又一种分布式环境下的任务处理方法的流程图;6 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure;
图7示出本公开实施例中又一种分布式环境下的任务处理方法的流程图;7 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure;
图8示出本公开实施例中又一种分布式环境下的任务处理方法的流程图;8 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure;
图9示出本公开实施例中又一种分布式环境下的任务处理方法的流程图;9 shows a flowchart of yet another task processing method in a distributed environment in an embodiment of the present disclosure;
图10示出本公开实施例中一种分布式环境下的任务处理装置的示意图;10 shows a schematic diagram of a task processing apparatus in a distributed environment in an embodiment of the present disclosure;
图11示出本公开实施例中一种电子设备的示意图。FIG. 11 shows a schematic diagram of an electronic device in an embodiment of the present disclosure.
现在将参考附图更全面地描述示例实施方式。然而,示例实施方式能够以多种形式实施,且不应被理解为限于在此阐述的范例;相反,提供这些实施方式使得本公开将更加全面和完整,并将示例实施方式的构思全面地传达给本领域的技术人员。所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施方式中。Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments, however, can be embodied in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
此外,附图仅为本公开的示意性图解,并非一定是按比例绘制。图中相同的附图标记表示相同或类似的部分,因而将省略对它们的重复描述。附图中所示的一些方框图是功能实体,不一定必须与物理或逻辑上独立的实体相对应。可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repeated descriptions will be omitted. Some of the block diagrams shown in the figures are functional entities that do not necessarily necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
本公开提供的方案,通过根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器,并根据所述执行权重将所述任务分配至所述非指定服务器,提高了任务处理的安全性和可靠性,优化了分布式集群中的服务器的资源均衡度,提升了分布式集群的整 体吞吐量和任务处理效率。The solution provided by the present disclosure improves the security of task processing by determining to send the task to a designated server or a non-designated server according to the request information, and assigning the task to the non-designated server according to the execution weight It optimizes the resource balance of the servers in the distributed cluster and improves the overall throughput and task processing efficiency of the distributed cluster.
上述分布式环境下的任务处理方案可以通过多个终端和服务器集群的交互实现。The above task processing solution in a distributed environment can be implemented through the interaction of multiple terminals and server clusters.
终端可以是手机、游戏主机、平板电脑、电子书阅读器、智能眼镜、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、智能家居设备、AR(Augmented Reality,增强现实)设备、VR(Virtual Reality,虚拟现实)设备等移动终端,或者,终端也可以是个人计算机(Personal Computer,PC),比如膝上型便携计算机和台式计算机等等。The terminal can be a mobile phone, game console, tablet computer, e-book reader, smart glasses, MP4 (Moving Picture Experts Group Audio Layer IV, moving image expert compression standard audio layer 4) player, smart home equipment, AR (Augmented Reality, Augmented reality) equipment, VR (Virtual Reality, virtual reality) equipment and other mobile terminals, or, the terminal can also be a personal computer (Personal Computer, PC), such as a laptop portable computer and a desktop computer and so on.
其中,终端中可以安装有用于提供分布式环境下的任务处理的应用程序。Wherein, an application program for providing task processing in a distributed environment may be installed in the terminal.
终端与服务器集群之间通过通信网络相连。可选的,通信网络是有线网络或无线网络。The terminal and the server cluster are connected through a communication network. Optionally, the communication network is a wired network or a wireless network.
服务器集群是一台服务器,或者由若干台服务器组成,或者是一个虚拟化平台,或者是一个云计算服务中心。服务器集群用于为提供分布式环境下的任务处理的应用程序提供后台服务。可选地,服务器集群承担主要计算工作,终端承担次要计算工作;或者,服务器集群承担次要计算工作,终端承担主要计算工作;或者,终端和服务器集群之间采用分布式计算架构进行协同计算。A server cluster is a server, or consists of several servers, or a virtualization platform, or a cloud computing service center. Server clusters are used to provide background services for applications that provide task processing in a distributed environment. Optionally, the server cluster undertakes the main computing work, and the terminal undertakes the secondary computing work; or, the server cluster undertakes the secondary computing work, and the terminal undertakes the main computing work; or, a distributed computing architecture is used between the terminal and the server cluster for collaborative computing. .
可选地,不同的终端中安装的应用程序的客户端是相同的,或两个终端上安装的应用程序的客户端是不同控制系统平台的同一类型应用程序的客户端。基于终端平台的不同,该应用程序的客户端的具体形态也可以不同,比如,该应用程序客户端可以是手机客户端、PC客户端或者全球广域网客户端等。Optionally, the clients of the application programs installed in different terminals are the same, or the clients of the application programs installed on the two terminals are clients of the same type of application programs of different control system platforms. Based on different terminal platforms, the specific form of the client of the application program may also be different, for example, the client of the application program may be a mobile phone client, a PC client, or a global wide area network client.
本领域技术人员可以知晓,上述终端的数量可以更多或更少。比如上述终端可以仅为一个,或者上述终端为几十个或几百个,或者更多数量。本公开实施例对终端的数量和设备类型不加以限定。Those skilled in the art may know that the number of the above-mentioned terminals may be more or less. For example, the above-mentioned terminal may be only one, or the above-mentioned terminal may be dozens or hundreds, or more. The embodiments of the present disclosure do not limit the number of terminals and device types.
可选的,该系统还可以包括管理设备,该管理设备与服务器集群之间通过通信网络相连。可选的,通信网络是有线网络或无线网络。Optionally, the system may further include a management device, and the management device and the server cluster are connected through a communication network. Optionally, the communication network is a wired network or a wireless network.
可选的,上述的无线网络或有线网络使用标准通信技术和/或协议。网络通常为因特网、但也可以是任何网络,包括但不限于局域网(Local Area Network,LAN)、城域网(Metropolitan Area Network,MAN)、广域网(Wide Area Network,WAN)、移动、有线或者无线网络、专用网络或者虚拟专用网络的任何组合)。在一些实施例中,使用包括超文本标记语言(Hyper Text Mark-up Language,HTML)、可扩展标记语言(Extensible MarkupLanguage,XML)等的技术和/或格式来代表通过网络交换的数据。此外还可以使用诸如安全套接字层(Secure Socket Layer,SSL)、传输层安全(Transport Layer Security,TLS)、虚拟专用网络(Virtual Private Network,VPN)、网际协议安全(Internet ProtocolSecurity,IPsec)等常规加密技术来加密所有或者一些链路。在另一些实施例中,还可以使用定制和/或专用数据通信技术取代或者补充上述数据通信技术。Optionally, the above-mentioned wireless network or wired network uses standard communication technologies and/or protocols. The network is usually the Internet, but can be any network, including but not limited to Local Area Network (LAN), Metropolitan Area Network (MAN), Wide Area Network (WAN), mobile, wired or wireless network, private network, or any combination of virtual private networks). In some embodiments, data exchanged over a network is represented using technologies and/or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), and the like. In addition, you can also use services such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. Conventional encryption techniques to encrypt all or some of the links. In other embodiments, custom and/or dedicated data communication techniques may also be used in place of or in addition to the data communication techniques described above.
下面,将结合附图及实施例对本示例实施方式中的分布式环境下的任务处理方法的各个步骤进行更详细的说明。Hereinafter, each step of the task processing method in a distributed environment in this exemplary embodiment will be described in more detail with reference to the accompanying drawings and embodiments.
图1示出本公开实施例中一种分布式环境下的任务处理方法流程图。本公开实施例提供的方法可以由任意具备计算处理能力的电子设备执行。FIG. 1 shows a flowchart of a task processing method in a distributed environment in an embodiment of the present disclosure. The methods provided by the embodiments of the present disclosure may be executed by any electronic device with computing processing capability.
如图1所示,电子设备执行分布式环境下的任务处理方法,包括以下步骤:As shown in FIG. 1 , the method for processing tasks in a distributed environment by an electronic device includes the following steps:
步骤S102,获取请求服务器执行任务的请求信息。Step S102, acquiring request information requesting the server to perform the task.
步骤S104,根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器。Step S104, determining to send the task to a designated server or a non-designated server according to the request information.
步骤S106,若确定发送至所述非指定服务器,则获取能够执行所述任务的非指定服务器和所述非指定服务器的执行权重。Step S106, if it is determined to send to the non-designated server, obtain the non-designated server capable of executing the task and the execution weight of the non-designated server.
步骤S108,根据所述执行权重将所述任务分配至所述非指定服务器。Step S108: Allocate the task to the non-designated server according to the execution weight.
在本公开的一个实施例中,通过根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器,并根据所述执行权重将所述任务分配至所述非指定服务器,提高了任务处理的安全性和可靠性,优化了分布式集群中的服务器的资源均衡度,提升了分布式集群的整体吞吐量和任务处理效率。In an embodiment of the present disclosure, by determining to send the task to a designated server or a non-designated server according to the request information, and allocating the task to the non-designated server according to the execution weight, the task is improved. The security and reliability of processing optimize the resource balance of servers in the distributed cluster, and improve the overall throughput and task processing efficiency of the distributed cluster.
进一步地,通过集中分布式环境下的处理任务的请求信息,而不是交给用户终端确定执行任务的服务器,提高了任务处理的安全性和可靠性,并且有利于降低分布式架构的维护成本。Further, by concentrating the request information of processing tasks in a distributed environment, rather than handing it over to the user terminal to determine the server that executes the task, the security and reliability of task processing are improved, and the maintenance cost of the distributed architecture is reduced.
如图2所示,分布式环境下的任务处理方法还包括:As shown in Figure 2, the task processing method in the distributed environment further includes:
步骤S202,获取所述非指定服务器在指定时间内处理所述任务的执行时间。Step S202, acquiring the execution time of the non-designated server processing the task within the designated time.
步骤S204,根据所述执行时间更新所述执行权重。Step S204: Update the execution weight according to the execution time.
在本公开的一个实施例中,通过获取所述非指定服务器在指定时间内处理所述任务的执行时间,确定非指定服务器的执行效率,进而确定非指定服务器能够提供的计算资源和服务资源,基于此更新后的执行权重能够优化后续任务的分配,以优化分布式环境下的任务处理效率。In an embodiment of the present disclosure, the execution efficiency of the non-designated server is determined by acquiring the execution time of the non-designated server processing the task within the designated time, and then the computing resources and service resources that the non-designated server can provide are determined, The allocation of subsequent tasks can be optimized based on this updated execution weight to optimize task processing efficiency in a distributed environment.
如图3所示,根据所述执行时间更新所述执行权重包括:As shown in Figure 3, updating the execution weight according to the execution time includes:
步骤S302,设置所述非指定服务器的初始执行权重相等。Step S302, setting the initial execution weights of the non-designated servers to be equal.
步骤S304,确定全部所述非指定服务器的执行时间的总和。Step S304, determining the sum of the execution time of all the non-designated servers.
步骤S306,确定所述执行时间占所述执行时间的总和的比例。Step S306, determining the ratio of the execution time to the total execution time.
步骤S308,根据所述比例更新所述执行权重。Step S308, update the execution weight according to the ratio.
在本公开的一个实施例中,通过确定所述执行时间占所述执行时间的总和的比例,并根据所述比例更新所述执行权重,综合了分布式环境下的服务器的任务处理能力,基于此,来更新各服务器的执行权重,既提升了分布式环境下的任务处理效率,也均衡了各服务器的负载量和吞吐量。In an embodiment of the present disclosure, by determining the ratio of the execution time to the sum of the execution time, and updating the execution weight according to the ratio, the task processing capability of the server in a distributed environment is synthesized, based on In this way, the execution weight of each server is updated, which not only improves the task processing efficiency in a distributed environment, but also balances the load and throughput of each server.
如图4所示,根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器包括:As shown in Figure 4, determining to send the task to a designated server or a non-designated server according to the request information includes:
步骤S402,解析所述请求信息确定是否包含所述指定服务器的地址信息。Step S402: Parse the request information to determine whether the address information of the designated server is included.
步骤S404,若确定所述请求信息包含所述地址信息,则根据所述地址信息将所述任 务发送至所述指定服务器。Step S404, if it is determined that the request information includes the address information, send the task to the designated server according to the address information.
在本公开的一个实施例中,通过解析所述请求信息确定是否包含所述指定服务器的地址信息,若确定所述请求信息包含所述地址信息,则根据所述地址信息将所述任务发送至所述指定服务器,提高了指定任务的处理效率。In an embodiment of the present disclosure, it is determined by parsing the request information whether the address information of the designated server is included, and if it is determined that the request information includes the address information, the task is sent to the address information according to the address information. The designated server improves the processing efficiency of designated tasks.
进一步地,可以设置指定服务器的任务的优先级高于非指定服务器的任务的优先级。Further, the priority of the task of the designated server can be set higher than the priority of the task of the non-designated server.
如图5所示,根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器还包括:As shown in FIG. 5 , determining to send the task to a designated server or a non-designated server according to the request information further includes:
步骤S502,解析所述请求信息确定是否包含所述指定服务器的地址信息。Step S502: Parse the request information to determine whether the address information of the designated server is included.
步骤S504,若确定所述请求信息不包含所述地址信息,则确定发送所述任务至所述非指定服务器。Step S504, if it is determined that the request information does not include the address information, it is determined to send the task to the non-designated server.
在本公开的一个实施例中,通过解析所述请求信息确定是否包含所述指定服务器的地址信息,若确定所述请求信息不包含所述地址信息,则确定发送所述任务至所述非指定服务器,即按照执行权重确定将任务发送至对应的非指定服务器,在不需要确定指定服务器的前提下,减少了解析指定服务器地址的步骤,而通过执行权重来均衡非指定服务器的负载量和吞吐量。In an embodiment of the present disclosure, it is determined by parsing the request information whether the address information of the designated server is included, and if it is determined that the request information does not include the address information, it is determined to send the task to the non-designated server The server, that is, the task is sent to the corresponding non-designated server according to the execution weight. Without the need to determine the designated server, the steps to resolve the address of the designated server are reduced, and the load and throughput of the non-designated server are balanced by the execution weight. quantity.
如图6所示,分布式环境下的任务处理方法还包括:As shown in Figure 6, the task processing method in the distributed environment further includes:
步骤S602,接收所述非指定服务器执行所述任务的结果信息。Step S602, receiving result information of the non-designated server executing the task.
步骤S604,确定所述结果信息中包含的三元组数据信息和执行时间字段信息。Step S604, determining triple data information and execution time field information contained in the result information.
步骤S606,根据所述三元组数据信息更新预设库表中的三元组数据。Step S606: Update triple data in the preset library table according to the triple data information.
步骤S608,根据所述执行时间字段信息更新redis缓存的执行时间。Step S608, update the execution time of the redis cache according to the execution time field information.
在本公开的一个实施例中,通过接收所述非指定服务器执行所述任务的结果信息,并确定所述结果信息中包含的三元组数据信息和执行时间字段信息,并分别更新预设库表中的三元组数据和redis缓存的执行时间,以作为执行任务的反馈和更新执行权重的重要依据。In an embodiment of the present disclosure, by receiving the result information of the non-designated server executing the task, determining the triple data information and the execution time field information contained in the result information, and updating the preset database respectively The triplet data in the table and the execution time of the redis cache are used as an important basis for the feedback of the execution task and the update of the execution weight.
可例如,三元组数据信息包括任务参数、请求地址、任务所属的应用标识。For example, the triple data information includes task parameters, request address, and application identifier to which the task belongs.
可例如,执行时间字段信息按照任务标识、服务器标识和执行时间的格式写入redis缓存中。For example, the execution time field information may be written into the redis cache in the format of the task ID, the server ID, and the execution time.
如图7所示,获取请求服务器执行任务的请求信息还包括:As shown in Figure 7, obtaining the request information requesting the server to perform the task also includes:
步骤S702,获取所述请求信息。Step S702, acquiring the request information.
步骤S704,解析所述请求信息中包含调用服务和调用参数。Step S704, parse that the request information contains the calling service and calling parameters.
步骤S706,根据所述调用服务和所述调用参数确定请求的服务器范围,所述服务器范围包括所述指定服务器和所述非指定服务器。Step S706: Determine a requested server range according to the invocation service and the invocation parameter, where the server range includes the designated server and the non-designated server.
在本公开的一个实施例中,通过解析所述请求信息中包含调用服务和调用参数,并根据所述调用服务和所述调用参数确定请求的服务器范围,服务器范围内的服务器基于分布式架构来响应任务处理请求,能够满足指定服务器和非指定服务器的选择需求,灵活度 高,且不需要繁琐的架构布局和维护。In an embodiment of the present disclosure, by parsing the request information including the calling service and the calling parameter, and determining the requested server range according to the calling service and the calling parameter, the servers within the server range are based on a distributed architecture. Responding to task processing requests, it can meet the selection requirements of designated servers and non-designated servers, has high flexibility, and does not require cumbersome architecture layout and maintenance.
下面参照图8和图9来描述根据本公开的这种实施方式的分布式环境下的任务处理方案。The task processing scheme in the distributed environment according to this embodiment of the present disclosure will be described below with reference to FIG. 8 and FIG. 9 .
如图8所示,分布式环境下的任务处理方案包括:As shown in Figure 8, the task processing scheme in a distributed environment includes:
以用户终端User对分布式应用A发出执行任务T的请求举例,即本系统接收到User的请求,要求在应用A上执行任务T,任务分配模块的流程如下:Take the user terminal User's request to the distributed application A to execute the task T as an example, that is, the system receives the User's request and requests to execute the task T on the application A. The process of the task allocation module is as follows:
(1)得到任务T的信息,包括调用的服务和参数等。(1) Obtain the information of task T, including called services and parameters.
(2)本系统从zookeeper(分布式系统协调)上取应用A的服务器列表,列表中的服务器是可用的。(2) The system obtains the server list of application A from zookeeper (distributed system coordination), and the servers in the list are available.
其中,ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。Among them, ZooKeeper is a distributed, open source distributed application coordination service, an open source implementation of Google's Chubby, and an important component of Hadoop and Hbase. It is a software that provides consistent services for distributed applications. The functions provided include: configuration maintenance, domain name service, distributed synchronization, group service, etc.
ZooKeeper的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。The goal of ZooKeeper is to encapsulate complex and error-prone key services, and provide users with an easy-to-use interface and a system with high performance and stable functions.
ZooKeeper包含一个简单的原语集,提供Java和C的接口。ZooKeeper代码版本中,提供了分布式独享锁、选举、队列的接口,代码在zookeeper_home\src\recipes。ZooKeeper includes a simple set of primitives that provide Java and C interfaces. In the ZooKeeper code version, interfaces for distributed exclusive locks, elections, and queues are provided. The code is in zookeeper_home\src\recipes.
其中分布锁和队列有Java和C两个版本,选举只有Java版本。There are two versions of distributed locks and queues in Java and C, and only the Java version is available for elections.
从该服务器列表中依照我们自定义的分配策略,选出一台服务器,执行任务。From the server list, select a server to execute the task according to our customized allocation strategy.
(3)如图8所示,假设分布式应用A有3台服务器,记作第一服务,802、第二服务器804和第三服务器806,且均可用,本系统初始时认为每台服务器都有相同的执行机会,即相同的执行权重,以数组表示这个数据结构。将任务数组的大小扩展为9,以为各台服务器的执行权重留出空间,三个数组分别记作数组M、数组N和数组K。(3) As shown in Fig. 8, assuming that the distributed application A has 3 servers, denoted as the first service, 802, the second server 804 and the third server 806, and all are available, the system initially considers that each server is With the same execution opportunity, that is, the same execution weight, this data structure is represented by an array. Expand the size of the task array to 9 to leave room for the execution weights of each server. The three arrays are denoted as array M, array N, and array K respectively.
第一轮:分别取三个数组的第一个元素arrayM[0]、arrayN[0]和arrayK[0],依次放入最终数组array中。The first round: respectively take the first elements of the three arrays arrayM[0], arrayN[0] and arrayK[0], and put them into the final array array in turn.
第二轮:分别取三个数组的第一个元素arrayM[1]、arrayN[1]和arrayK[1],依次放入最终数组array中。The second round: respectively take the first elements of the three arrays arrayM[1], arrayN[1] and arrayK[1], and put them into the final array array in turn.
第三轮:分别取三个数组的第一个元素arrayM[2]、arrayN[2]和arrayK[2],依次放入最终数组array中。The third round: respectively take the first elements of the three arrays arrayM[2], arrayN[2] and arrayK[2], and put them into the final array array in turn.
检测接收到User的请求时,若User不指定hash(哈希)字段值,则直接执行hash(User的ip地址)%9,得到要执行任务的服务器的ip地址。When the user's request is detected, if the user does not specify the hash (hash) field value, then directly execute hash (User's ip address)% 9 to obtain the ip address of the server to perform the task.
若User指定了hash字段值,则执行hash(指定字段值)%9,来挑选执行的服务器,这样User可以自主决定由哪台服务器执行任务T。If User specifies the hash field value, execute hash (specified field value)%9 to select the server to be executed, so that User can independently decide which server to execute task T on.
(4)当任务T执行完毕后,会主动更新库表和redis中该任务的执行时间字段(单位毫秒ms)。(4) When the task T is executed, it will actively update the library table and the execution time field of the task in redis (in milliseconds ms).
如图9所示,分布式应用A中各台服务器的执行权重也会被更新,具体的更新方法 如下:As shown in Figure 9, the execution weight of each server in distributed application A will also be updated. The specific update method is as follows:
(1)对第一服务器802取任务T最近5个的执行时间,取均值
假设结果为21ms,同理对第二服务器804和第三服务器806取平均执行时间,分别为32ms和45ms。则第一服务器802执行时间的占比为21ms/(21ms+32ms+45ms)=21%,第二服务器804执行时间的占比为32ms/(21ms+32ms+45ms)=32%,第三服务器806执行时间的占比为45ms/(21ms+32ms+45ms)=45%。
(1) Take the execution time of the last 5 tasks T from the first server 802, and take the average value Assuming that the result is 21ms, the average execution time of the second server 804 and the third server 806 is similarly 32ms and 45ms, respectively. Then the proportion of the execution time of the first server 802 is 21ms/(21ms+32ms+45ms)=21%, the proportion of the execution time of the second server 804 is 32ms/(21ms+32ms+45ms)=32%, the third server The proportion of 806 execution time is 45ms/(21ms+32ms+45ms)=45%.
(2)占比值说明第一服务器802的效率较高,其次为第二服务器804和第三服务器806,所以可以提高分配给第一服务器802的任务数量,可例如采用逆序分配执行权重,具体如下:(2) The ratio value shows that the efficiency of the first server 802 is higher, followed by the second server 804 and the third server 806, so the number of tasks allocated to the first server 802 can be increased. For example, the execution weight can be allocated in reverse order, as follows. :
(2.1)数组的个数为服务器数量
2,即3
2=9个,第一服务器802执行时间占比为21%,则其第一服务器802所占权重调整为45%,9×45%的计算结果取整为4。第二服务器804执行时间占比为32%,则其第二服务器804所占权重为32%,9×32%的计算结果取整为3。第三服务器806执行时间占比为45%,则其第三服务器806所占权重21%,9×21%的计算结果取整为2。
(2.1) The number of arrays is the number of servers 2 , that is, 3 2 = 9, and the execution time of the first server 802 accounts for 21%, then the weight of the first server 802 is adjusted to 45%, and 9×45% The calculation result is rounded up to 4. The execution time of the second server 804 accounts for 32%, the weight of the second server 804 is 32%, and the calculation result of 9×32% is rounded to 3. If the execution time of the third server 806 accounts for 45%, the weight of the third server 806 is 21%, and the calculation result of 9×21% is rounded to 2.
(2.2)如图9所示,将服务器标识(就是能唯一找到该服务器的标识,可以为ip地址)按权重放入数组,三个数组分别记作数组M’、数组N’和数组K’。(2.2) As shown in Figure 9, the server identifier (that is, the identifier that can uniquely find the server, which can be an ip address) is put into an array by weight, and the three arrays are recorded as array M', array N' and array K' respectively. .
第一轮:分别取三个数组的第一个元素arrayM’[0]、arrayN’[0]、arrayK’[0],依次放入最终数组array中。The first round: take the first elements of the three arrays arrayM'[0], arrayN'[0], arrayK'[0], and put them into the final array array in turn.
第二轮:分别取三个数组的第一个元素arrayM’[1]、arrayN’[1]、arrayK’[1],依次放入最终数组array中。The second round: respectively take the first elements of the three arrays arrayM'[1], arrayN'[1], arrayK'[1], and put them into the final array array in turn.
第三轮:由于arrayK’只有两个元素,所以不再参与第三轮,取arrayM’[2]和arrayN’[2],依次放入最终数组array中。Third round: Since arrayK' has only two elements, it will not participate in the third round. Take arrayM'[2] and arrayN'[2] and put them into the final array array in turn.
第四轮:数组M’的第一个元素arrayM’[3],放入最终数组array中。The fourth round: the first element of the array M', arrayM'[3], is put into the final array array.
其中,本实施例可以采取任务T最近Z个的平均执行时间,Z为正整数,可例如设置Z为5,来重新定义各台服务器的执行权重。In this embodiment, the average execution time of the last Z tasks T may be taken, where Z is a positive integer, and Z may be set to 5, for example, to redefine the execution weight of each server.
对任务执行时间来说,受到诸多因素的影响,例如:执行任务的服务器的配置,服务器的CPU的负载状态等,所以任务的历史执行时间并没有多参考价值,最近几次的执行时间才有参考价值,通过最近Z个的平均执行时间,来衡量服务器的当前负载情况。For the task execution time, it is affected by many factors, such as: the configuration of the server executing the task, the load status of the server's CPU, etc., so the historical execution time of the task does not have much reference value, only the most recent execution time. The reference value measures the current load of the server through the average execution time of the last Z.
在本公开的实施例中,对执行时间取平均值而不是方差的原因,是因为平均值可以反映出服务器的负载情况,方差只能反映执行时间上的波动,不能反映服务器负载,也就是方差小的服务器负载可以很高也可以很低,从而无法判断服务器的负载状态,所以优选执行时间的均值来评定该服务器的执行权重。In the embodiment of the present disclosure, the reason for taking the average value of the execution time instead of the variance is because the average value can reflect the load of the server, and the variance can only reflect the fluctuation of the execution time, but cannot reflect the server load, that is, the variance The load of a small server can be very high or very low, so it is impossible to judge the load state of the server, so the average value of the execution time is preferred to evaluate the execution weight of the server.
下面参照图10来描述根据本公开的这种实施方式的分布式环境下的任务处理装置1000。图10所示的分布式环境下的任务处理装置1000仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。The task processing apparatus 1000 in a distributed environment according to this embodiment of the present disclosure will be described below with reference to FIG. 10 . The task processing apparatus 1000 in a distributed environment shown in FIG. 10 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.
如图10所示,分布式环境下的任务处理装置1000以硬件模块的形式表现。分布式环境下的任务处理装置1000的组件可以包括但不限于:获取模块1002、确定模块1004和分配模块1006。As shown in FIG. 10 , the task processing apparatus 1000 in a distributed environment is represented in the form of hardware modules. The components of the task processing apparatus 1000 in a distributed environment may include, but are not limited to: an acquisition module 1002 , a determination module 1004 and an allocation module 1006 .
获取模块1002,用于获取请求服务器执行任务的请求信息。The obtaining module 1002 is configured to obtain request information for requesting the server to perform a task.
确定模块1004,用于根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器。The determining module 1004 is configured to determine, according to the request information, to send the task to a designated server or a non-designated server.
所述获取模块1002还用于,若确定发送至所述非指定服务器,则获取能够执行所述任务的非指定服务器和所述非指定服务器的执行权重。The acquiring module 1002 is further configured to acquire the non-designated server capable of executing the task and the execution weight of the non-designated server if it is determined to be sent to the non-designated server.
分配模块1006,用于根据所述执行权重将所述任务分配至所述非指定服务器。An allocation module 1006, configured to allocate the task to the non-designated server according to the execution weight.
下面参照图11来描述根据本公开的这种实施方式的电子设备1100。图11显示的电子设备1100仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。The electronic device 1100 according to this embodiment of the present disclosure is described below with reference to FIG. 11 . The electronic device 1100 shown in FIG. 11 is only an example, and should not impose any limitation on the function and scope of use of the embodiments of the present disclosure.
如图11所示,电子设备1100以通用计算设备的形式表现。电子设备1100的组件可以包括但不限于:上述至少一个处理单元1110、上述至少一个存储单元1120、连接不同系统组件(包括存储单元1120和处理单元1110)的总线1130。As shown in FIG. 11, electronic device 1100 takes the form of a general-purpose computing device. Components of the electronic device 1100 may include, but are not limited to: the above-mentioned at least one processing unit 1110 , the above-mentioned at least one storage unit 1120 , and a bus 1130 connecting different system components (including the storage unit 1120 and the processing unit 1110 ).
其中,存储单元存储有程序代码,程序代码可以被处理单元1110执行,使得处理单元1110执行本说明书上述“示例性方法”部分中描述的根据本公开各种示例性实施方式的步骤。例如,处理单元1110可以执行本公开的分布式环境下的任务处理方法中限定的步骤。The storage unit stores program codes, which can be executed by the processing unit 1110, so that the processing unit 1110 performs the steps according to various exemplary embodiments of the present disclosure described in the above-mentioned "Exemplary Methods" section of this specification. For example, the processing unit 1110 may execute the steps defined in the task processing method in a distributed environment of the present disclosure.
存储单元1120可以包括易失性存储单元形式的可读介质,例如随机存取存储单元(RAM)11201和/或高速缓存存储单元11202,还可以进一步包括只读存储单元(ROM)11203。The storage unit 1120 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 11201 and/or a cache storage unit 11202 , and may further include a read only storage unit (ROM) 11203 .
存储单元1120还可以包括具有一组(至少一个)程序模块11205的程序/实用工具11204,这样的程序模块11205包括但不限于:操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。The storage unit 1120 may also include a program/utility 11204 having a set (at least one) of program modules 11205 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, An implementation of a network environment may be included in each or some combination of these examples.
总线1130可以为表示几类总线结构中的一种或多种,包括存储单元总线或者存储单元控制器、外围总线、图形加速端口、处理单元或者使用多种总线结构中的任意总线结构的局域总线。The bus 1130 may be representative of one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local area using any of a variety of bus structures bus.
电子设备1100也可以与一个或多个外部设备1140(例如键盘、指向设备、蓝牙设备等)通信,还可与一个或者多个使得用户能与该电子设备交互的设备通信,和/或与使得该电子设备1100能与一个或多个其它计算设备进行通信的任何设备(例如路由器、调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口1150进行。并且,电子设备1100还可以通过网络适配器1110与一个或者多个网络(例如局域网(LAN),广域网(WAN)和/或公共网络,例如因特网)通信,网络适配器1110通过总线1130与电子设备1100的其它模块通信。应当明白,尽管图中未示出,可以结合电子设备使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RA标 识系统、磁带驱动器以及数据备份存储系统等。The electronic device 1100 may also communicate with one or more external devices 1140 (eg, keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device, and/or The electronic device 1100 can communicate with any device (eg, router, modem, etc.) that communicates with one or more other computing devices. Such communication may occur through input/output (I/O) interface 1150 . Also, the electronic device 1100 can communicate with one or more networks (eg, a local area network (LAN), a wide area network (WAN), and/or a public network such as the Internet) through a network adapter 1110 , which communicates with the electronic device 1100 through a bus 1130 . communication with other modules. It should be understood that, although not shown in the figures, other hardware and/or software modules may be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RA identification systems, tape drives and data backup storage systems.
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本公开实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、终端装置、或者网络设备等)执行根据本公开实施方式的方法。From the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein may be implemented by software, or may be implemented by software combined with necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure may be embodied in the form of software products, and the software products may be stored in a non-volatile storage medium (which may be CD-ROM, U disk, mobile hard disk, etc.) or on the network , including several instructions to cause a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to an embodiment of the present disclosure.
在本公开的示例性实施例中,还提供了一种计算机可读存储介质,其上存储有能够实现本说明书上述方法的程序产品。在一些可能的实施方式中,本公开的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当程序产品在终端设备上运行时,程序代码用于使终端设备执行本说明书上述“示例性方法”部分中描述的根据本公开各种示例性实施方式的步骤。In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium on which a program product capable of implementing the above-described method of the present specification is stored. In some possible implementations, various aspects of the present disclosure can also be implemented in the form of a program product, which includes program code, when the program product runs on a terminal device, the program code is used to cause the terminal device to execute the above-mentioned procedures in this specification. Steps according to various exemplary embodiments of the present disclosure are described in the "Example Methods" section.
根据本公开的实施方式的用于实现上述方法的程序产品,其可以采用便携式紧凑盘只读存储器(CD-ROM)并包括程序代码,并可以在终端设备,例如个人电脑上运行。然而,本公开的程序产品不限于此,在本文件中,可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。A program product for implementing the above method according to an embodiment of the present disclosure may adopt a portable compact disc read only memory (CD-ROM) and include program codes, and may run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了可读程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。可读信号介质还可以是可读存储介质以外的任何可读介质,该可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。A computer readable signal medium may include a propagated data signal in baseband or as part of a carrier wave with readable program code embodied thereon. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium can also be any readable medium, other than a readable storage medium, that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于无线、有线、光缆、RF等等,或者上述的任意合适的组合。Program code embodied on a readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
可以以一种或多种程序设计语言的任意组合来编写用于执行本公开操作的程序代码,程序设计语言包括面向对象的程序设计语言—诸如Java、C++等,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算设备上执行、部分地在用户设备上执行、作为一个独立的软件包执行、部分在用户计算设备上部分在远程计算设备上执行、或者完全在远程计算设备或服务器上执行。在涉及远程计算设备的情形中,远程计算设备可以通过任意种类的网络,包括局域网(LAN)或广域网(WAN),连接到用户计算设备,或者,可以连接到外部计算设备(例如利用因特网服务提供商来通过因特网连接)。Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages—such as Java, C++, etc., as well as conventional procedural programming Language - such as the "C" language or similar programming language. The program code may execute entirely on the user computing device, partly on the user device, as a stand-alone software package, partly on the user computing device and partly on a remote computing device, or entirely on the remote computing device or server execute on. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (eg, using an Internet service provider business via an Internet connection).
应当注意,尽管在上文详细描述中提及了用于动作执行的设备的若干模块或者单元,但是这种划分并非强制性的。实际上,根据本公开的实施方式,上文描述的两个或更多模块或者单元的特征和功能可以在一个模块或者单元中具体化。反之,上文描述的一个模块或者单元的特征和功能可以进一步划分为由多个模块或者单元来具体化。It should be noted that although several modules or units of the apparatus for action performance are mentioned in the above detailed description, this division is not mandatory. Indeed, according to embodiments of the present disclosure, the features and functions of two or more modules or units described above may be embodied in one module or unit. Conversely, the features and functions of one module or unit described above may be further divided into multiple modules or units to be embodied.
此外,尽管在附图中以特定顺序描述了本公开中方法的各个步骤,但是,这并非要求或者暗示必须按照该特定顺序来执行这些步骤,或是必须执行全部所示的步骤才能实现期望的结果。附加的或备选的,可以省略某些步骤,将多个步骤合并为一个步骤执行,以及/或者将一个步骤分解为多个步骤执行等。Additionally, although the various steps of the methods of the present disclosure are depicted in the figures in a particular order, this does not require or imply that the steps must be performed in the particular order or that all illustrated steps must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step for execution, and/or one step may be decomposed into multiple steps for execution, and the like.
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本公开实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、移动终端、或者网络设备等)执行根据本公开实施方式的方法。From the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein may be implemented by software, or may be implemented by software combined with necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure may be embodied in the form of software products, and the software products may be stored in a non-volatile storage medium (which may be CD-ROM, U disk, mobile hard disk, etc.) or on the network , which includes several instructions to cause a computing device (which may be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute a method according to an embodiment of the present disclosure.
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由所附的权利要求指出。Other embodiments of the present disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common general knowledge or techniques in the technical field not disclosed by this disclosure . The specification and examples are to be regarded as exemplary only, with the true scope and spirit of the disclosure being indicated by the appended claims.
本公开的实施例所提供的分布式环境下的任务处理方案,通过根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器,并根据所述执行权重将所述任务分配至所述非指定服务器,提高了任务处理的安全性和可靠性,优化了分布式集群中的服务器的资源均衡度,提升了分布式集群的整体吞吐量和任务处理效率。In the task processing solution in a distributed environment provided by the embodiments of the present disclosure, the task is determined to be sent to a designated server or a non-designated server according to the request information, and the task is allocated to all the tasks according to the execution weight. The non-designated server described above improves the security and reliability of task processing, optimizes the resource balance of servers in the distributed cluster, and improves the overall throughput and task processing efficiency of the distributed cluster.
Claims (10)
- 一种分布式环境下的任务处理方法,其特征在于,包括:A task processing method in a distributed environment, comprising:获取请求服务器执行任务的请求信息;Get the request information that requests the server to perform the task;根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器;Determine to send the task to a designated server or a non-designated server according to the request information;若确定发送至所述非指定服务器,则获取能够执行所述任务的非指定服务器和所述非指定服务器的执行权重;If it is determined to send to the non-designated server, obtain the non-designated server capable of executing the task and the execution weight of the non-designated server;根据所述执行权重将所述任务分配至所述非指定服务器。The tasks are allocated to the non-designated servers according to the execution weights.
- 根据权利要求1所述的分布式环境下的任务处理方法,其特征在于,还包括:The task processing method in a distributed environment according to claim 1, further comprising:获取所述非指定服务器在指定时间内处理所述任务的执行时间;Obtain the execution time of the non-designated server processing the task within the specified time;根据所述执行时间更新所述执行权重。The execution weight is updated according to the execution time.
- 根据权利要求2所述的分布式环境下的任务处理方法,其特征在于,根据所述执行时间更新所述执行权重包括:The task processing method in a distributed environment according to claim 2, wherein updating the execution weight according to the execution time comprises:设置所述非指定服务器的初始执行权重相等;Set the initial execution weights of the non-designated servers to be equal;确定全部所述非指定服务器的执行时间的总和;determining the sum of the execution times of all said non-designated servers;确定所述执行时间占所述执行时间的总和的比例;determining the proportion of the execution time to the sum of the execution times;根据所述比例更新所述执行权重。The execution weights are updated according to the scale.
- 根据权利要求1所述的分布式环境下的任务处理方法,其特征在于,根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器包括:The task processing method in a distributed environment according to claim 1, wherein determining to send the task to a designated server or a non-designated server according to the request information comprises:解析所述请求信息确定是否包含所述指定服务器的地址信息;Parse the request information to determine whether it contains the address information of the specified server;若确定所述请求信息包含所述地址信息,则根据所述地址信息将所述任务发送至所述指定服务器。If it is determined that the request information includes the address information, the task is sent to the designated server according to the address information.
- 根据权利要求1所述的分布式环境下的任务处理方法,其特征在于,根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器还包括:The task processing method in a distributed environment according to claim 1, wherein determining to send the task to a designated server or a non-designated server according to the request information further comprises:解析所述请求信息确定是否包含所述指定服务器的地址信息;Parse the request information to determine whether it contains the address information of the specified server;若确定所述请求信息不包含所述地址信息,则确定发送所述任务至所述非指定服务器。If it is determined that the request information does not include the address information, it is determined to send the task to the non-designated server.
- 根据权利要求1-5中任一项所述的分布式环境下的任务处理方法,其特征在于,还包括:The task processing method in a distributed environment according to any one of claims 1-5, further comprising:接收所述非指定服务器执行所述任务的结果信息;receiving result information of the non-designated server performing the task;确定所述结果信息中包含的三元组数据信息和执行时间字段信息;Determine the triple data information and execution time field information contained in the result information;根据所述三元组数据信息更新预设库表中的三元组数据;Update the triple data in the preset library table according to the triple data information;根据所述执行时间字段信息更新redis缓存的执行时间。Update the execution time of the redis cache according to the execution time field information.
- 根据权利要求1-5中任一项所述的分布式环境下的任务处理方法,其特征在于,获取请求服务器执行任务的请求信息包括:The task processing method in a distributed environment according to any one of claims 1-5, wherein obtaining request information requesting a server to perform a task comprises:获取所述请求信息;obtain the request information;解析所述请求信息中包含调用服务和调用参数;Parse the request information including the calling service and calling parameters;根据所述调用服务和所述调用参数确定请求的服务器范围,所述服务器范围包括所述指定服务器和所述非指定服务器。The server scope of the request is determined according to the invocation service and the invocation parameter, and the server scope includes the designated server and the non-designated server.
- 一种分布式环境下的任务处理装置,其特征在于,包括:A task processing device in a distributed environment, comprising:获取模块,用于获取请求服务器执行任务的请求信息;The obtaining module is used to obtain the request information for requesting the server to perform the task;确定模块,用于根据所述请求信息确定将所述任务发送至指定服务器或非指定服务器;a determining module, configured to determine to send the task to a designated server or a non-designated server according to the request information;所述获取模块还用于,若确定发送至所述非指定服务器,则获取能够执行所述任务的非指定服务器和所述非指定服务器的执行权重;The obtaining module is further configured to, if it is determined to be sent to the non-designated server, obtain the non-designated server capable of executing the task and the execution weight of the non-designated server;分配模块,用于根据所述执行权重将所述任务分配至所述非指定服务器。an allocation module, configured to allocate the task to the non-designated server according to the execution weight.
- 一种电子设备,其特征在于,包括:An electronic device, comprising:处理器;以及processor; and存储器,用于存储所述处理器的可执行指令;a memory for storing executable instructions for the processor;其中,所述处理器配置为经由执行所述可执行指令来执行权利要求1-7中任一项所述的分布式环境下的任务处理方法。Wherein, the processor is configured to execute the task processing method in a distributed environment according to any one of claims 1-7 by executing the executable instructions.
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,A computer-readable storage medium on which a computer program is stored, characterized in that:所述计算机程序被处理器执行时实现权利要求1-7中任一项所述的分布式环境下的任务处理方法。When the computer program is executed by the processor, the task processing method in a distributed environment according to any one of claims 1-7 is implemented.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110270111.4 | 2021-03-12 | ||
CN202110270111.4A CN115080193A (en) | 2021-03-12 | 2021-03-12 | Task processing method and device in distributed environment, electronic equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022188509A1 true WO2022188509A1 (en) | 2022-09-15 |
Family
ID=83227397
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/140522 WO2022188509A1 (en) | 2021-03-12 | 2021-12-22 | Method and apparatus for task processing in distributed environment, and electronic device and medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115080193A (en) |
WO (1) | WO2022188509A1 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117955748B (en) * | 2024-03-26 | 2024-06-18 | 中电工业互联网有限公司 | Data asset processing method, system, equipment and medium based on privacy calculation |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106657354A (en) * | 2016-12-29 | 2017-05-10 | 努比亚技术有限公司 | Load balancing device and method |
JP2017091330A (en) * | 2015-11-13 | 2017-05-25 | 株式会社日立製作所 | Computer system and task executing method of computer system |
CN108681484A (en) * | 2018-04-04 | 2018-10-19 | 阿里巴巴集团控股有限公司 | A kind of distribution method of task, device and equipment |
CN109842665A (en) * | 2017-11-29 | 2019-06-04 | 北京京东尚科信息技术有限公司 | Task processing method and device for task distribution server |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106850834A (en) * | 2017-03-01 | 2017-06-13 | 郑州云海信息技术有限公司 | A kind of service request method and apparatus and load equalizer |
CN108961033B (en) * | 2018-05-17 | 2023-09-01 | 平安科技(深圳)有限公司 | Multi-service system interaction method and device, storage medium and electronic terminal |
CN111782360B (en) * | 2020-06-28 | 2023-08-11 | 中国工商银行股份有限公司 | Distributed task scheduling method and device |
-
2021
- 2021-03-12 CN CN202110270111.4A patent/CN115080193A/en active Pending
- 2021-12-22 WO PCT/CN2021/140522 patent/WO2022188509A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2017091330A (en) * | 2015-11-13 | 2017-05-25 | 株式会社日立製作所 | Computer system and task executing method of computer system |
CN106657354A (en) * | 2016-12-29 | 2017-05-10 | 努比亚技术有限公司 | Load balancing device and method |
CN109842665A (en) * | 2017-11-29 | 2019-06-04 | 北京京东尚科信息技术有限公司 | Task processing method and device for task distribution server |
CN108681484A (en) * | 2018-04-04 | 2018-10-19 | 阿里巴巴集团控股有限公司 | A kind of distribution method of task, device and equipment |
Also Published As
Publication number | Publication date |
---|---|
CN115080193A (en) | 2022-09-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR102391806B1 (en) | Integrated apis and uis for consuming services across different distributed networks | |
CN112104723B (en) | Multi-cluster data processing system and method | |
CN110839084A (en) | Session management method, device, equipment and medium | |
CN112988223B (en) | Frame integration method, frame integration device, electronic equipment and storage medium | |
CN112367370A (en) | Management method, device, equipment and medium for hybrid cloud resource data | |
WO2023174013A1 (en) | Video memory allocation method and apparatus, and medium and electronic device | |
CN114296953B (en) | Multi-cloud heterogeneous system and task processing method | |
CN114513552B (en) | Data processing method, device, equipment and storage medium | |
WO2022188509A1 (en) | Method and apparatus for task processing in distributed environment, and electronic device and medium | |
CN114756390A (en) | Message queue consumption method and system, electronic equipment, readable medium and product | |
EP3387816A1 (en) | Connecting and retrieving security tokens based on context | |
CN111062682B (en) | Work order processing method and device | |
US10637924B2 (en) | Cloud metadata discovery API | |
CN112953992A (en) | Network system, communication and networking method, device and storage medium | |
WO2021227636A1 (en) | Microservice processing method and apparatus, storage medium, and electronic device | |
WO2015196586A1 (en) | Virtual desktop configuration and acquisition method and apparatus | |
CN117472555A (en) | Computing power resource allocation method, system, device, equipment and storage medium | |
CN113127550B (en) | Information processing method, information processing device, electronic equipment and storage medium | |
CN115509744A (en) | Container distribution method, system, device, equipment and storage medium | |
CN112181605A (en) | Load balancing method and device, electronic equipment and computer readable medium | |
CN115086321B (en) | Multi-cluster traffic forwarding method and device and electronic equipment | |
US20240036939A1 (en) | Deterministic execution of background jobs in a load-balanced system | |
CN115348310B (en) | Reverse proxy method, device, system, electronic equipment and storage medium | |
CN115086425B (en) | Message transmission method, device, program product, medium and electronic equipment | |
CN116661955B (en) | Hardware access method, device, electronic equipment and storage medium |
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: 21929971 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: 21929971 Country of ref document: EP Kind code of ref document: A1 |