CN111782357B - Label control method and device, electronic equipment and readable storage medium - Google Patents

Label control method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN111782357B
CN111782357B CN202010568963.7A CN202010568963A CN111782357B CN 111782357 B CN111782357 B CN 111782357B CN 202010568963 A CN202010568963 A CN 202010568963A CN 111782357 B CN111782357 B CN 111782357B
Authority
CN
China
Prior art keywords
target
tag
instance
tag instance
target task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010568963.7A
Other languages
Chinese (zh)
Other versions
CN111782357A (en
Inventor
王翰琦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202010568963.7A priority Critical patent/CN111782357B/en
Publication of CN111782357A publication Critical patent/CN111782357A/en
Application granted granted Critical
Publication of CN111782357B publication Critical patent/CN111782357B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The application discloses a tag control method and device, electronic equipment and a readable storage medium, and relates to the cloud computing technology in the technical field of computers. The specific implementation scheme is applied to a label engine system, the label engine system comprises a plurality of parallel label examples, and the label control method comprises the following steps: before triggering logic for executing a target task, controlling a target tag instance to acquire a distributed lock, wherein the target tag instance is one tag instance in the plurality of parallel tag instances, and the distributed lock is used for controlling the target tag instance to allow the target task to be executed; and executing the target task through the target identification instance under the condition that logic for executing the target task is triggered. The present application provides a lock processing logic that consumes less resources.

Description

Label control method and device, electronic equipment and readable storage medium
Technical Field
The present invention relates to cloud computing technologies in computer technologies, and in particular, to a tag control method and apparatus, an electronic device, and a readable storage medium.
Background
Current tag engine systems utilize a Database management system (Database MANAGEMENT S stem, abbreviated DBMS) such as M4SQL (a Database) to add an exclusive lock on a row record to achieve control over the lock policy of the tag engine.
Disclosure of Invention
The present disclosure provides a tag control method and apparatus, an electronic device, and a readable storage medium.
According to an aspect of the present disclosure, there is provided a tag control method applied to a tag engine system, the tag engine system including a plurality of parallel tag instances, the tag control method including:
Before triggering logic for executing a target task, controlling a target tag instance to acquire a distributed lock, wherein the target tag instance is one tag instance in the plurality of parallel tag instances, and the distributed lock is used for controlling the target tag instance to allow the target task to be executed;
And executing the target task through the target identification example under the condition that logic for executing the target task is triggered.
According to another aspect of the present disclosure, there is provided a tag control apparatus applied to a tag engine system including a plurality of parallel tag instances, the tag control apparatus including:
The acquisition module is used for controlling a target tag instance to acquire a distributed lock before triggering logic for executing a target task, wherein the target tag instance is one tag instance in the plurality of parallel tag instances, and the distributed lock is used for controlling the target tag instance to allow the target task to be executed;
And the execution module is used for executing the target task through the target identification instance under the condition of triggering logic for executing the target task.
According to another aspect of the present disclosure, there is provided an electronic device including:
at least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method described above.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the above-described method.
The techniques according to the present application provide a lock processing logic that consumes less resources.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are included to provide a better understanding of the present application and are not to be construed as limiting the application. Wherein:
FIG. 1 is a flow chart of a method of tag control in accordance with an embodiment of the present application;
FIG. 2 is a schematic diagram of a tag engine system according to an embodiment of the application;
FIG. 3 is a schematic diagram of a label control device according to an embodiment of the present application;
fig. 4 is a block diagram of an electronic device for implementing a tag control method of an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will now be described with reference to the accompanying drawings, in which various details of embodiments of the present application are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The application provides a label control method.
As shown in fig. 1, in one embodiment, the tag control method includes:
Step S101, before triggering logic for executing target tasks, controlling target tag instances to acquire distributed locks.
The technical scheme of the embodiment relates to a cloud computing technology in computer technology, and is particularly applied to a label engine system.
The tag engine system includes a plurality of tag instances in parallel, each of which is operable to perform a task. The target tag instance is one tag instance in a plurality of parallel tag instances, and specifically refers to a tag instance in which a distributed lock is acquired in the plurality of parallel tag instances.
And step S102, executing the target task through the target identification instance under the condition that logic for executing the target task is triggered.
In practice, a distributed lock is used to control the target tag instance to allow the target task to be performed.
When the logic for executing the target task is triggered, the target tag instance of the distributed lock is obtained, the target task can be executed under the control of the distributed lock, and other tag instances cannot execute the target task.
Thus, the present application provides a lock processing logic that consumes less resources.
In the conventional DBMS in the related art, for example, M4SQL is taken as an example, the M4SQL has the problem of delayed master-slave synchronization in the case of read-write separation, that is, the slave library data possibly read in the case of multi-instance concurrency is not the latest lock data of the master library, so that the problem of lock failure in the case of distributed type is caused, and even in the case of single library, the M4SQL row lock consumes resources relatively.
According to the application, the distributed lock is acquired through the tag instance, instead of adding the exclusive lock on the line record by the DBMS, other third-party components are not required to be introduced, so that the development workload and development difficulty are reduced, and the resource consumption is reduced.
Optionally, the tag engine system includes a cache layer established based on the remote dictionary service dis, and the step S101 includes:
And controlling the target tag instance to acquire the distributed lock from the cache layer.
In this embodiment, the distributed lock is provided using the cache layer of the tag engine system.
The current floor application uses a Redis cluster to complete the cache layer logic processing of the tag engine, in one embodiment, the Redis is in cluster mode, that is, the tag engine system is in a N master (master) N slave (slaver) architecture, where N is a positive integer. That is, each master is provided with slaver nodes, each master and the corresponding slaver are synchronously backed up, and if a certain master cannot work normally, one slaver can be switched to the master, so that the high availability of the Redis cluster is ensured.
As shown in fig. 2, in step S101, before the tag instance 202 triggers the logic of the target task, the distributed lock is first obtained from the cache layer 203, and the tag instance that successfully obtains the distributed lock is the target tag instance, and under the control of the distributed lock, the target task can be executed through the target tag instance.
By acquiring the distributed lock from the cache layer 203 of the Redis, a third party component does not need to be introduced, so that the consumption of resources is reduced, the development difficulty is reduced, the development efficiency is improved, and the development cost is reduced.
Optionally, the executing the target task by the target identification instance includes:
if the tag instance is the target tag instance, controlling setnx of the Redis to return a valid value, and executing the target task through the target tag instance;
if the tag instance is not the target tag instance, then setnx, which controls the Redis, returns an invalid value.
In this particular embodiment, control of the distributed lock is achieved by setnx (set if not exists, set in the absence) atomic operations of Redis.
In a specific embodiment, the key (ke 4) is set to [ lock_service name_time-by-day time slicing ], and the value (value) is set to be the identity Information (ID) of the instance of the current Lock, that is, the identity information of the target tag instance, and furthermore, an expiration time T is set, wherein the expiration time T is given according to the average execution completion time of the routine task, so that the Lock can be automatically released when an error occurs in the running process, and the target task cannot be executed.
Specifically, the tag instance that successfully takes the distributed lock is implemented, or the target tag instance returns a valid value setnx when executing the target task, setnx maintains atomic operations, and other tag instances setnx return invalid values, so that the operation of related routine task logic is not performed, and thus, the uniqueness of the target task in the distributed state can be ensured.
Optionally, before triggering the logic for executing the target task, the method further includes:
The load of the target task is distributed to the plurality of label instances by a reverse proxy.
Specifically, before triggering execution of a target task, loads are distributed to each label instance in the label engine system through a reverse proxy at the access layer.
As shown in fig. 2, in one embodiment, the tag engine system in this embodiment includes a reverse proxy server 201, a plurality of parallel tag instances 202, and a cache layer 203.
In implementation, for example, the reverse proxy server 201 may perform reverse proxy through nglnx (a reverse proxy server) or the like, so as to implement load allocation, and obviously, other reverse proxy servers may also be selected to perform reverse proxy or in a reverse proxy manner, and the specific implementation is not limited thereto.
The load distributed to each tag instance 202 may be uniformly distributed, or the load distributed to each tag instance may be adjusted according to the situation, so that the target task can be triggered on the deployed tag instance 202. By utilizing reverse proxy server 201 for load distribution, the load of each tag instance 202 is reasonably distributed to further determine the target tag instance.
Because of the distributed lock, only one tag instance 202 is allowed to execute the target task when in implementation, and other tag instances 202 give up executing the operation under the control of the distributed lock, so that the uniqueness of the execution of the target task in the distributed state is ensured.
As shown in fig. 3, the present application further provides a tag control apparatus 300 applied to a tag engine system including a plurality of parallel tag instances, the tag control apparatus including:
An obtaining module 301, configured to control a target tag instance to obtain a distributed lock before triggering logic for executing a target task, where the target tag instance is one tag instance of the multiple parallel tag instances, and the distributed lock is configured to control the target tag instance to allow execution of the target task;
And the execution module 302 is configured to execute the target task through the target identification instance if the logic for executing the target task is triggered.
Optionally, the tag engine system includes a cache layer established based on Redis, and the acquiring module 301 includes:
And controlling the target tag instance to acquire the distributed lock from the cache layer.
Optionally, the executing module 302 includes:
The execution sub-module is used for controlling setnx of the Redis to return a valid value if the tag instance is the target tag instance, and executing the target task through the target tag instance;
and a return sub-module, configured to control setnx of the dis to return an invalid value if the tag instance is not the target tag instance.
Optionally, the method further comprises:
And the distribution module is used for distributing the load of the target task to the tag instances through a reverse proxy.
Since the tag control device of the present embodiment can implement each step of the tag control method embodiment, at least the same or similar technical effects as those of the tag control method embodiment can be achieved, and the details are not repeated here.
According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
As shown in fig. 4, there is a block diagram of an electronic device implementing a tag control method according to an embodiment of the present application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the applications described and/or claimed herein.
As shown in fig. 4, the electronic device includes: one or more processors 401, memory 402, and interfaces for connecting the components, including a high-speed interface and a low-speed interface. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the electronic device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In other embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 401 is illustrated in fig. 4.
Memory 402 is a non-transitory computer readable storage medium provided by the present application. The memory stores instructions executable by the at least one processor to cause the at least one processor to perform the tag control method provided by the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions for causing a computer to execute the tag control method provided by the present application.
The memory 402 is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules (e.g., the acquisition module 301 and the execution module 302 shown in fig. 3) corresponding to the tag control method in the embodiment of the present application. The processor 401 executes various functional applications of the server and data processing, i.e., implements the tag control method in the above-described method embodiment, by running non-transitory software programs, instructions, and modules stored in the memory 402.
Memory 402 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created according to the use of the electronic device performing the tag control method, and the like. In addition, memory 402 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 402 may optionally include memory remotely located relative to processor 401, which may be connected via a network to an electronic device performing the tag control method. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the tag control method may further include: an input device 403 and an output device 404. The processor 401, memory 402, input device 403, and output device 404 may be connected by a bus or otherwise, for example in fig. 4.
The input device 403 may receive input numeric or character information and generate key signal inputs related to user settings and function control of an electronic device performing the tag control method, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, a pointer stick, one or more mouse buttons, a track ball, a joystick, etc. input devices. The output device 404 may include a display apparatus, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device may be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
These computing programs (also referred to as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented in a high-level procedural and/or object-oriented programming language, and/or in assembly/machine language. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to the technical scheme provided by the embodiment of the application, the lock processing logic with less resource consumption is provided. According to the application, the distributed lock is acquired through the label instance, instead of adding the exclusive lock on the row record by the DBMS, other third-party components are not required to be introduced, so that the development workload and development difficulty are reduced, and the resource consumption is reduced.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present application may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed embodiments are achieved, and are not limited herein.
The above embodiments do not limit the scope of the present application. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the scope of the present application.

Claims (6)

1. A label control method applied to a label engine system, the label engine system comprising a plurality of parallel label instances, the label control method comprising:
before triggering logic for executing a target task, controlling a target tag instance to acquire a distributed lock, wherein the target tag instance is one tag instance in the plurality of parallel tag instances, and the distributed lock is used for controlling the target tag instance to allow the target task to be executed;
Executing the target task through the target tag instance under the condition of triggering logic for executing the target task;
Before triggering the logic to execute the target task, further comprising:
Distributing the load of the target task to the plurality of tag instances through a reverse proxy, wherein the load of each tag instance is distributed in a balanced manner or is distributed in an adjustment manner according to the situation;
wherein the tag engine system comprises a cache layer established based on a remote dictionary service Redis, and the controlling the target tag instance to acquire the distributed lock comprises:
And controlling the target tag instance to acquire the distributed lock from the cache layer.
2. The method of claim 1, wherein the performing the target task by the target-identifying instance comprises:
If the tag instance is the target tag instance, controlling setnx of the Redis to return a valid value, and executing the target task through the target tag instance;
If the tag instance is not the target tag instance, then setnx, which controls the Redis, returns an invalid value.
3. A label control device applied to a label engine system, the label engine system including a plurality of parallel label instances, the label control device comprising:
an acquisition module, configured to control a target tag instance to acquire a distributed lock before triggering logic for executing a target task, where the target tag instance is one tag instance of the multiple parallel tag instances, and the distributed lock is configured to control the target tag instance to allow execution of the target task;
the execution module is used for executing the target task through the target tag instance under the condition of triggering logic for executing the target task;
the apparatus further comprises:
The distribution module is used for distributing the load of the target task to the plurality of tag instances through a reverse proxy, and the load of each tag instance is distributed in a balanced manner or is distributed in an adjustment manner according to the situation;
wherein, the label engine system includes a cache layer established based on Redis, and the acquisition module includes:
And controlling the target tag instance to acquire the distributed lock from the cache layer.
4. The apparatus of claim 3, wherein the execution module comprises:
The execution sub-module is used for controlling setnx of the Redis to return a valid value if the tag instance is the target tag instance, and executing the target task through the target tag instance;
and a return sub-module, configured to control setnx of the dis to return an invalid value if the tag instance is not the target tag instance.
5. An electronic device, comprising:
at least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-2.
6. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-2.
CN202010568963.7A 2020-06-19 Label control method and device, electronic equipment and readable storage medium Active CN111782357B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010568963.7A CN111782357B (en) 2020-06-19 Label control method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010568963.7A CN111782357B (en) 2020-06-19 Label control method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN111782357A CN111782357A (en) 2020-10-16
CN111782357B true CN111782357B (en) 2024-06-04

Family

ID=

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2372620A1 (en) * 2010-03-31 2011-10-05 Sap Ag Method and system to effectuate recovery for dynamic workflows
CN102929585A (en) * 2012-09-25 2013-02-13 上海证券交易所 Batch processing method and system supporting multi-master distributed data processing
CN105787058A (en) * 2016-02-26 2016-07-20 广州品唯软件有限公司 User label system and data pushing system based on same
CN108073684A (en) * 2017-11-16 2018-05-25 深圳市买买提信息科技有限公司 A kind of data processing method, server and computer readable storage medium
CN111080342A (en) * 2019-11-27 2020-04-28 京东数字科技控股有限公司 Resource allocation method and device, storage medium and electronic device
CN111191228A (en) * 2019-12-20 2020-05-22 京东数字科技控股有限公司 Service processing method and device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2372620A1 (en) * 2010-03-31 2011-10-05 Sap Ag Method and system to effectuate recovery for dynamic workflows
CN102929585A (en) * 2012-09-25 2013-02-13 上海证券交易所 Batch processing method and system supporting multi-master distributed data processing
CN105787058A (en) * 2016-02-26 2016-07-20 广州品唯软件有限公司 User label system and data pushing system based on same
CN108073684A (en) * 2017-11-16 2018-05-25 深圳市买买提信息科技有限公司 A kind of data processing method, server and computer readable storage medium
CN111080342A (en) * 2019-11-27 2020-04-28 京东数字科技控股有限公司 Resource allocation method and device, storage medium and electronic device
CN111191228A (en) * 2019-12-20 2020-05-22 京东数字科技控股有限公司 Service processing method and device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
SAAS模式WebGIS关键技术;何洪磊;;实验室研究与探索;20191215(12);全文 *

Similar Documents

Publication Publication Date Title
CN111258609B (en) Upgrading method and device of Kubernetes cluster, electronic equipment and medium
CN110780890B (en) System upgrading method, device, electronic equipment and medium
CN110806923B (en) Parallel processing method and device for block chain tasks, electronic equipment and medium
CN111782365B (en) Timed task processing method, device, equipment and storage medium
CN111506401B (en) Automatic driving simulation task scheduling method and device, electronic equipment and storage medium
CN112527474B (en) Task processing method and device, equipment, readable medium and computer program product
EP3869336A1 (en) Method and apparatus for processing development machine operation task, device and storage medium
CN110995480B (en) Block chain network deployment method, device, electronic equipment and medium
US9143394B2 (en) System and method for graph based K-redundant resiliency for IT cloud
CN111782669B (en) Method and device for realizing distributed lock and electronic equipment
CN111562969B (en) Intelligent contract implementation method, device, equipment and medium for block chain
CN111488492B (en) Method and device for searching graph database
CN111782341B (en) Method and device for managing clusters
CN110704162A (en) Method, device and equipment for sharing container mirror image by physical machine and storage medium
CN111913809A (en) Task execution method, device, equipment and storage medium under multi-thread scene
CN112559522A (en) Data storage method and device, query method, electronic device and readable medium
CN110647570B (en) Data processing method and device and electronic equipment
CN111782147A (en) Method and apparatus for cluster scale-up
CN116302708A (en) Data backup method, device, equipment and storage medium based on load balancing
CN111782357B (en) Label control method and device, electronic equipment and readable storage medium
CN111339187A (en) Data processing method, device, equipment and storage medium based on intelligent contract
EP3859529B1 (en) Backup management method and system, electronic device and medium
CN115576565A (en) Application program deployment method and device, electronic equipment and storage medium
CN111913810B (en) Task execution method, device, equipment and storage medium in multithreading scene
CN111782357A (en) Label control method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant