CN114363221A - Heartbeat detection method based on micro-service system, storage medium, electronic device and system - Google Patents
Heartbeat detection method based on micro-service system, storage medium, electronic device and system Download PDFInfo
- Publication number
- CN114363221A CN114363221A CN202111681591.XA CN202111681591A CN114363221A CN 114363221 A CN114363221 A CN 114363221A CN 202111681591 A CN202111681591 A CN 202111681591A CN 114363221 A CN114363221 A CN 114363221A
- Authority
- CN
- China
- Prior art keywords
- url
- recording
- response
- file
- record
- 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.)
- Granted
Links
- 238000001514 detection method Methods 0.000 title claims abstract description 68
- 230000004044 response Effects 0.000 claims abstract description 54
- 238000000034 method Methods 0.000 claims abstract description 20
- 230000006870 function Effects 0.000 claims description 38
- 238000004590 computer program Methods 0.000 claims description 22
- VHYFNPMBLIVWCW-UHFFFAOYSA-N 4-Dimethylaminopyridine Chemical group CN(C)C1=CC=NC=C1 VHYFNPMBLIVWCW-UHFFFAOYSA-N 0.000 claims description 19
- 229960000549 4-dimethylaminophenol Drugs 0.000 claims description 6
- 230000009191 jumping Effects 0.000 description 17
- 238000012545 processing Methods 0.000 description 9
- 238000010586 diagram Methods 0.000 description 8
- 230000002159 abnormal effect Effects 0.000 description 6
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 239000002699 waste material Substances 0.000 description 4
- 238000010219 correlation analysis Methods 0.000 description 3
- 238000013507 mapping Methods 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000001413 cellular effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a heartbeat detection method, a storage medium, electronic equipment and a system based on a micro-service system, relating to the field of computer software, wherein the method comprises the steps of corresponding each functional module in micro-service to at least one URL (uniform resource locator) to obtain a query file, and recording all functional modules to be detected to obtain a polling file; reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URL; according to the response condition of the URL, recording: if the normal response of the URL is obtained, recording the time information of the current access and the disconnection of the URL; and if the response of the URL is obtained, adding one to the reconnection times, re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL. The invention can feed back the running state of each service of the micro-service system flexibly and timely, and reduce the consumption of front and back end request resources.
Description
Technical Field
The invention relates to the field of computer software, in particular to a heartbeat detection method, a storage medium, electronic equipment and a system based on a micro service system.
Background
With the development of the current software industry, more and more software systems form a micro service system architecture. Under the new micro-service system architecture, independent running individuals are formed among background services to provide a service module with a certain function. The functions can be realized more flexibly through the micro-service, the consumed resources are less, and the efficiency is higher.
However, the existing micro-service is replicated and deployed in different processes, and the traditional single-point service exception of the existing micro-service can cause the exception of the functional interface of the existing micro-service, and further cause the unavailability of software functions. After a single service node of the micro-service system is abnormal, the service can be continuously and normally used as long as other copied service nodes are in normal operation. This results in that the heartbeat detection between the client and the server can no longer be detected in the conventional manner (the conventional heartbeat detection usually determines whether the service is available only by testing the link of one bus for normal use).
In addition, the conventional heartbeat detection mechanism usually requests background services through a timed polling thread, so that the repeated timed polling mechanism cannot stop regardless of whether the network requests are normal, and the waste of rated network requests is caused.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a heartbeat detection method, a storage medium, electronic equipment and a system based on a micro-service system, which can provide various strategies for each specific function module of the micro-service system through a configuration method so as to perform heartbeat detection on each specific service module of the micro-service system and feed back the running state of each service of the micro-service system in time; and an elastic detection strategy is introduced to reduce the request calling times and reduce the consumption of front and back end request resources.
To achieve the above object, in a first aspect, an embodiment of the present invention provides a heartbeat detection method based on a microservice system:
each functional module in the micro service corresponds to at least one URL to obtain a query file, and all functional modules needing to be detected are recorded to obtain a polling file;
reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URL;
according to the response condition of the URL, recording:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
On the basis of the above technical solution, the searching and accessing the corresponding URL in the query file includes:
searching the URL in the query file and reading a record corresponding to the URL;
if the URL in the record is disconnected, acquiring a next URL or inquiring and accessing a URL corresponding to a next functional module;
and if the record is empty or the URL in the record is not disconnected, accessing the URL.
On the basis of the above technical solution, the recording the current access time information and disconnection of the URL until the reconnection number exceeds the preset number includes:
when the reconnection times caused by URL response overtime exceed the preset times, recording the current URL, the function module, the disconnection, the reconnection times and the access time;
and informing all application parties of disconnection of the URL corresponding to the functional module.
On the basis of the technical scheme, the query file is HMAP, the polling file is DMAP, and the file recording the response condition of the URL is RECORD.
On the basis of the technical scheme, in each heartbeat period according to the sequence in the DMAP, the response condition is tested according to the URL in the HMAP and recorded in the RECORD.
On the basis of the above technical solution, the searching the function module in the query file and accessing the corresponding URL includes:
inquiring the URL of the query file according to the functional module;
judging whether the URL is matched with RECORD, if so, directly reading the RECORD, judging whether the module is available, otherwise, recording according to the response condition of the URL
On the basis of the technical scheme, if the response of obtaining the URL is overtime, switching to other URLs corresponding to the functional module until the response of all the URLs is overtime or at least one URL normally responds.
In a second aspect, an embodiment of the present invention provides a heartbeat detection system based on a microservice system, including:
the creating module is used for corresponding each functional module in the micro-service to at least one URL to obtain a query file, and recording all functional modules needing to be detected to obtain a polling file;
the round-robin module is used for reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URLs;
a recording module, configured to record, according to the response condition of the URL:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
In a third aspect, an embodiment of the present invention further provides a storage medium, where a computer program is stored on the storage medium, and when being executed by a processor, the computer program implements the method in the embodiment of the first aspect.
In a fourth aspect, an embodiment of the present invention further provides an electronic device, which includes a memory and a processor, where the memory stores a computer program running on the processor, and the processor executes the computer program to implement the method in the first aspect.
Compared with the prior art, the invention has the advantages that:
the heartbeat detection method based on the micro-service system records the functions of each micro-service module one by one to ensure that any function can be detected, and secondly, the heartbeat detection method can detect and record the heartbeat of each URL, thereby realizing flexible heartbeat detection of the micro-service system, respectively monitoring the running states of a plurality of service modules, feeding back the abnormal conditions of the system in time, and simultaneously effectively reducing the times of heartbeat requests and effectively relieving the consumption of heartbeat detection network resources through the correlation analysis processing with other requests of the system.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings corresponding to the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart illustrating steps of a heartbeat detection method based on a micro service system according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating the steps of the main processing logic heartbeat detection in an embodiment of a heartbeat detection method based on a micro service system according to the present invention;
fig. 3 is a flowchart of other foreground request detection steps in an embodiment of a heartbeat detection method based on a micro service system according to the present invention.
Detailed Description
Embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
Referring to fig. 1, an embodiment of the present invention provides a heartbeat detection method, a storage medium, an electronic device, and a system based on a micro service system, which flexibly detect functional modules of a micro service in a URL manner, and monitor the operation of each functional module, thereby ensuring an abnormal instant feedback, reducing resource consumption of heartbeat detection, and simultaneously achieving an instant abnormal few functional modules and enabling the micro service to normally operate.
In order to achieve the technical effects, the general idea of the application is as follows:
each functional module in the micro service corresponds to at least one URL to obtain a query file, and all functional modules needing to be detected are recorded to obtain a polling file;
reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URL;
according to the response condition of the URL, recording:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
In summary, if the conventional micro services operate independently, if the detection is performed according to the previous whole detection, the failure of one micro service to respond may cause a whole judgment error. The invention corresponds each micro service with URL, and realizes flexible detection by heartbeat detection of the URL. The invention further provides an elastic detection strategy, the detection result is recorded, the detected functional module is not continuously detected, and the waste of resources is reduced.
In order to better understand the technical solution, the following detailed description is made with reference to specific embodiments.
The embodiment of the invention provides a heartbeat detection method based on a micro-service system, which comprises the following steps:
s1, each functional module in the micro service is corresponding to at least one URL to obtain a query file, and all functional modules needing to be detected are recorded to obtain a polling file;
each micro service is corresponded in a URL form, and the functional module to be detected is recorded, so that all the micro services and the functional modules are corresponded singly, and flexible detection and elastic recording can be realized.
Preferably, the query file is HMAP, the polling file is DMAP, and the file recording the response condition of the URL is RECORD.
Furthermore, the collection record is carried out in a file form, so that the management of the micro-service and the functional module can be more effectively realized.
Preferably, the response is tested against the URL in HMAP and recorded in RECORD, in order in DMAP, for each heartbeat cycle.
And further, judging whether the URL is matched with RECORD, if so, directly reading the RECORD, judging whether the module is available, otherwise, recording according to the response condition of the URL.
S2, reading the function modules in the polling file one by one according to the heartbeat cycle, searching the function modules in the query file and accessing the corresponding URL;
the real-time polling can cause a large amount of resource waste, and the embodiment of the invention can reduce the resource waste by polling the functional module through the heartbeat cycle and can track the current state of the functional module.
Furthermore, the functional modules in the query file are queried and accessed, so that the query sequence can be better determined, and the query file can give out effective URLs for accessing.
Specifically, the searching and accessing the corresponding URL in the query file includes:
searching the URL in the query file and reading a record corresponding to the URL;
if the URL in the record is disconnected, acquiring a next URL or inquiring and accessing a URL corresponding to a next functional module;
and if the record is empty or the URL in the record is not disconnected, accessing the URL.
S3, recording, based on the response of the URL:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
Specifically, the recording the current access time information and disconnection of the URL until the reconnection number exceeds a preset number includes:
when the reconnection times caused by URL response overtime exceed the preset times, recording the current URL, the function module, the disconnection, the reconnection times and the access time;
and informing all application parties of disconnection of the URL corresponding to the functional module.
Optionally, if the response to obtain the URL is overtime, the URL is switched to another URL corresponding to the functional module until the response of all URLs is overtime or at least one URL normally responds.
Providing a plurality of strategies through a configuration method to perform heartbeat detection on each specific service module of the micro-service system so as to feed back the running state of each service of the micro-service system in time; and an elastic detection strategy is introduced to reduce the request calling times and reduce the consumption of front and back end request resources.
The configuration method may focus on heartbeat detection of the core function module, may detect the heartbeat one by one, may detect the heartbeat at random, and may detect the heartbeat at random as long as the function module in the micro service can be detected.
As shown in fig. 2, taking heartbeat detection of a main program as an example, the present invention provides an embodiment of a heartbeat detection method based on a microservice system:
a1, setting a heartbeat detection URL access address corresponding to a service module, storing the address by using a Map data structure (the key value is the service name, and the value is the heartbeat detection URL address corresponding to the service module), and defining the address as HMap; establishing a many-to-one mapping rule dictionary between the same type of URL addresses and the service modules, and storing the mapping rule dictionary in a Map data structure (the key value is the name of the service module, the value is a List, and one or more regular expression character strings are stored in the List) to define the mapping rule dictionary as Record;
a2, setting heartbeat detection related parameters (a heartbeat detection default time period T (unit: millisecond) and heartbeat detection failure times N (unit: times)), initializing Map (wherein key value is a service module name, value is a structural body Record, the Record contains fields of service module name, disconnection, last heartbeat detection time and failure reconnection times) of heartbeat detection records, and defining the parameters as a polling file DMap;
a3, starting a detection thread and preparing heartbeat polling;
a4, polling all service module names according to the query file HMap, and acquiring a detection Record corresponding to the service module name in the polling file DMap through the service module name;
a5, judging that Record exists in the polling file DMap, if the Record does not exist, directly jumping to the step A8, and if the Record exists, jumping to the step A6;
a6, judging whether Record is disconnected or not, if yes, jumping to the step A4, continuing to perform polling to the next, and if not, jumping to the step A7;
a7, judging whether the current time and the last heartbeat detection time are less than the heartbeat detection period T, if not, jumping to the step A4, and if so, jumping to the step A8;
a8, obtaining the heartbeat detection URL address of the module in HMap through the name of the service module, and simulating access;
a9, judging whether the access returns normally, if yes, jumping to the step A10, and if not, jumping to the step A11;
a10, setting Record information corresponding to the module in the DMap (no disconnection, the last heartbeat detection time as the current time, and the number of failed reconnection times as 0);
a11, after the reconnection times in Record are added with 1, judging whether the reconnection times exceed the heartbeat detection failure times N, if so, jumping to the step A13, and if not, jumping to the step A12;
a12, setting Record information (no disconnection, the last heartbeat detection time as the current time, and the number of failed reconnection times plus 1) corresponding to the service module in the DMap, and jumping to the step A15;
a13, setting Record information (disconnection, last heartbeat detection time as current time, and number of failed reconnection times plus 1) corresponding to the service module in the DMap;
a14, triggering a heartbeat timeout event, and broadcasting and informing all application program client access terminals;
a15, judging whether the heartbeat detection is stopped, if not, jumping to the step A4, and if so, ending the flow.
As shown in fig. 3, in addition to the host process, other foreground may also request to update the record:
b1, calling a URL interface by using a system function by a user;
b2, judging whether the URL interface returns normally, if the URL interface returns normally, jumping to the step B3, and if the URL interface returns abnormally, jumping to the step B6;
b3, judging whether the URL can be matched with a regular expression stored by Value in Record, if so, jumping to B4, otherwise, jumping to B6;
b4, acquiring a corresponding Key (service module name) according to the Value, and then finding a Record corresponding to the service module from the DMap according to the service module name;
b5, setting whether the Record service is normal or not, the last heartbeat detection time as the current time and the failure reconnection time as 0;
b6, judging whether the system is finished, if not, jumping to the step B1, if so, ending the flow.
Namely, no matter the main process or other foreground, the embodiment of the invention can realize the heartbeat detection of the micro-service system, can respectively monitor the running states of a plurality of service modules and timely feed back the abnormal condition of the system. And the correlation analysis and processing with other requests of the system are carried out, so that the frequency of heartbeat requests is effectively reduced, and the consumption of heartbeat detection network resources is effectively relieved.
Based on the same inventive concept, the present application provides an embodiment of a heartbeat detection device based on a micro service system, and a specific implementation manner thereof is as follows.
The creating module is used for corresponding each functional module in the micro-service to at least one URL to obtain a query file, and recording all functional modules needing to be detected to obtain a polling file;
the round-robin module is used for reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URLs;
a recording module, configured to record, according to the response condition of the URL:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
Various modifications and specific examples in the foregoing method embodiments are also applicable to the system of the present embodiment, and the detailed description of the method is clear to those skilled in the art, so that the detailed description is omitted here for the sake of brevity.
Based on the same inventive concept, the present application provides an embodiment of a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements a microservice-based heartbeat detection method according to any embodiment of the present invention, the method including:
each functional module in the micro service corresponds to at least one URL to obtain a query file, and all functional modules needing to be detected are recorded to obtain a polling file;
reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URL;
according to the response condition of the URL, recording:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer-readable storage medium may be, for example but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Based on the same inventive concept, the present application provides an electronic device, which includes a memory and a processor, where the memory stores a computer program running on the processor, and the processor executes the computer program to implement all or part of the method steps in the first embodiment.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like which is the control center for the computer device and which connects the various parts of the overall computer device using various interfaces and lines.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the cellular phone, etc. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Generally speaking, the heartbeat detection method, the storage medium, the electronic device and the system based on the micro-service system provided by the embodiment of the invention can detect any function, and secondly, the heartbeat detection and recording can be carried out on each URL, so that the flexible heartbeat detection of the micro-service system is realized, the running states of a plurality of service modules are respectively monitored, the abnormal condition of the system is timely fed back, meanwhile, the heartbeat request frequency is effectively reduced through the correlation analysis and processing with other requests of the system, and the network resource consumption of heartbeat detection is effectively relieved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.
Claims (10)
1. A heartbeat detection method based on a micro service system is characterized by comprising the following steps:
each functional module in the micro service corresponds to at least one URL to obtain a query file, and all functional modules needing to be detected are recorded to obtain a polling file;
reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URL;
according to the response condition of the URL, recording:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
2. The heartbeat detection method based on micro service system as claimed in claim 1,
the searching and accessing of the corresponding URL in the query file includes:
searching the URL in the query file and reading a record corresponding to the URL;
if the URL in the record is disconnected, acquiring a next URL or inquiring and accessing a URL corresponding to a next functional module;
and if the record is empty or the URL in the record is not disconnected, accessing the URL.
3. The heartbeat detection method based on micro service system as claimed in claim 1,
recording the current access time information and disconnection of the URL until the reconnection times exceed the preset times, wherein the recording comprises the following steps:
when the reconnection times caused by URL response overtime exceed the preset times, recording the current URL, the function module, the disconnection, the reconnection times and the access time;
and informing all application parties of disconnection of the URL corresponding to the functional module.
4. The heartbeat detection method based on the microservice system as claimed in claim 1, wherein: the query file is HMAP, the polling file is DMAP, and the file for recording the response condition of the URL is RECORD.
5. The heartbeat detection method based on micro service system as claimed in claim 4, wherein: in order in DMAP, within each heartbeat cycle, the response is tested according to the URL in HMAP and recorded in RECORD.
6. The method as claimed in claim 4, wherein the step of searching the functional module in the query file and accessing the corresponding URL comprises:
inquiring the URL of the query file according to the functional module;
and judging whether the URL is matched with RECORD, if so, directly reading the RECORD, judging whether the module is available, otherwise, recording according to the response condition of the URL.
7. The method as claimed in claim 1, wherein if the response of obtaining URL is overtime, switching to other URLs corresponding to the functional module until the response of all URLs is overtime or at least one URL normally responds.
8. A heartbeat detection device based on a microservice system is characterized in that:
the creating module is used for corresponding each functional module in the micro-service to at least one URL to obtain a query file, and recording all functional modules needing to be detected to obtain a polling file;
the round-robin module is used for reading the function modules in the polling file one by one according to the heartbeat period, searching the function modules in the query file and accessing the corresponding URLs;
a recording module, configured to record, according to the response condition of the URL:
if a normal response of the URL is obtained, recording the time information of the URL currently visited and the disconnection;
if the response of obtaining the URL is overtime, adding one to the reconnection times, and re-trying to obtain the URL response until the reconnection times exceed the preset times, and recording the current access time information and disconnection of the URL.
9. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program that runs on the processor, characterized in that: the processor, when executing the computer program, implements the method of any of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that: the computer program, when executed by a processor, implements the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111681591.XA CN114363221B (en) | 2021-12-29 | 2021-12-29 | Heartbeat detection method, storage medium, electronic equipment and system based on micro-service system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111681591.XA CN114363221B (en) | 2021-12-29 | 2021-12-29 | Heartbeat detection method, storage medium, electronic equipment and system based on micro-service system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114363221A true CN114363221A (en) | 2022-04-15 |
CN114363221B CN114363221B (en) | 2024-05-03 |
Family
ID=81105828
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111681591.XA Active CN114363221B (en) | 2021-12-29 | 2021-12-29 | Heartbeat detection method, storage medium, electronic equipment and system based on micro-service system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114363221B (en) |
Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150381650A1 (en) * | 2014-05-06 | 2015-12-31 | Synack, Inc. | Computer system for distributed discovery of vulnerabilities in applications |
US20160226871A1 (en) * | 2015-01-30 | 2016-08-04 | Calgary Scientific Inc. | Highly scalable, fault tolerant remote access architecture and method of connecting thereto |
CN108173911A (en) * | 2017-12-18 | 2018-06-15 | 中国科学院声学研究所 | A kind of micro services fault detect processing method and processing device |
CN108400904A (en) * | 2018-01-26 | 2018-08-14 | 北京奇艺世纪科技有限公司 | A kind of health examination method and device based on micro services framework |
CN108427581A (en) * | 2018-02-07 | 2018-08-21 | 平安普惠企业管理有限公司 | System micro services method and terminal device |
CN111078688A (en) * | 2019-11-18 | 2020-04-28 | 福建天泉教育科技有限公司 | Method for micro-service health check and storage medium |
CN111147308A (en) * | 2019-12-30 | 2020-05-12 | 武汉市烽视威科技有限公司 | Network management method and system based on micro-service architecture |
CN111341445A (en) * | 2020-02-05 | 2020-06-26 | 网宿科技股份有限公司 | Health detection method and health detection system of micro-service call chain |
CN112039723A (en) * | 2020-08-18 | 2020-12-04 | 北京金和网络股份有限公司 | Method and device for detecting state of micro-service network and electronic equipment |
CN112218325A (en) * | 2020-09-03 | 2021-01-12 | 苏宁云计算有限公司 | Network testing method and device |
CN112564980A (en) * | 2020-12-17 | 2021-03-26 | 航天精一(广东)信息科技有限公司 | Service monitoring method and system based on micro-service architecture |
CN112994958A (en) * | 2021-05-17 | 2021-06-18 | 新华三技术有限公司 | Network management system, method and device and electronic equipment |
CN113010378A (en) * | 2021-03-04 | 2021-06-22 | 万翼科技有限公司 | Log processing method and device of microservice module, storage medium and electronic device |
CN113656473A (en) * | 2021-07-30 | 2021-11-16 | 平安消费金融有限公司 | Interface access method, device, equipment and medium |
-
2021
- 2021-12-29 CN CN202111681591.XA patent/CN114363221B/en active Active
Patent Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150381650A1 (en) * | 2014-05-06 | 2015-12-31 | Synack, Inc. | Computer system for distributed discovery of vulnerabilities in applications |
US20160226871A1 (en) * | 2015-01-30 | 2016-08-04 | Calgary Scientific Inc. | Highly scalable, fault tolerant remote access architecture and method of connecting thereto |
CN108173911A (en) * | 2017-12-18 | 2018-06-15 | 中国科学院声学研究所 | A kind of micro services fault detect processing method and processing device |
CN108400904A (en) * | 2018-01-26 | 2018-08-14 | 北京奇艺世纪科技有限公司 | A kind of health examination method and device based on micro services framework |
CN108427581A (en) * | 2018-02-07 | 2018-08-21 | 平安普惠企业管理有限公司 | System micro services method and terminal device |
CN111078688A (en) * | 2019-11-18 | 2020-04-28 | 福建天泉教育科技有限公司 | Method for micro-service health check and storage medium |
CN111147308A (en) * | 2019-12-30 | 2020-05-12 | 武汉市烽视威科技有限公司 | Network management method and system based on micro-service architecture |
CN111341445A (en) * | 2020-02-05 | 2020-06-26 | 网宿科技股份有限公司 | Health detection method and health detection system of micro-service call chain |
CN112039723A (en) * | 2020-08-18 | 2020-12-04 | 北京金和网络股份有限公司 | Method and device for detecting state of micro-service network and electronic equipment |
CN112218325A (en) * | 2020-09-03 | 2021-01-12 | 苏宁云计算有限公司 | Network testing method and device |
CN112564980A (en) * | 2020-12-17 | 2021-03-26 | 航天精一(广东)信息科技有限公司 | Service monitoring method and system based on micro-service architecture |
CN113010378A (en) * | 2021-03-04 | 2021-06-22 | 万翼科技有限公司 | Log processing method and device of microservice module, storage medium and electronic device |
CN112994958A (en) * | 2021-05-17 | 2021-06-18 | 新华三技术有限公司 | Network management system, method and device and electronic equipment |
CN113656473A (en) * | 2021-07-30 | 2021-11-16 | 平安消费金融有限公司 | Interface access method, device, equipment and medium |
Also Published As
Publication number | Publication date |
---|---|
CN114363221B (en) | 2024-05-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021180025A1 (en) | Message processing method and apparatus, electronic device and medium | |
CN113840012B (en) | Block chain-based screen recording evidence obtaining method and system and electronic equipment | |
CN111752799A (en) | Service link tracking method, device, equipment and storage medium | |
WO2021151312A1 (en) | Method for determining inter-service dependency, and related apparatus | |
CN112667426B (en) | Log analysis method and device | |
CN113595788B (en) | API gateway management method and device based on plug-in | |
CN111064626B (en) | Configuration updating method, device, server and readable storage medium | |
CN111858007A (en) | Task scheduling method and device based on message middleware | |
US20170085653A1 (en) | Method, device and system for message distribution | |
CN110457132B (en) | Method and device for creating functional object and terminal equipment | |
CN114398179B (en) | Method and device for acquiring tracking identifier, server and storage medium | |
CN106997313B (en) | Signal processing method and system of application program and terminal equipment | |
CN110881224B (en) | Network long connection method, device, equipment and storage medium | |
CN111782431A (en) | Exception processing method, exception processing device, terminal and storage medium | |
CN108647102B (en) | Service request processing method and device of heterogeneous system and electronic equipment | |
CN112559565A (en) | Abnormity detection method, system and device | |
CN112689248A (en) | Message processing method and system | |
CN111376255B (en) | Robot data acquisition method and device and terminal equipment | |
CN114363221B (en) | Heartbeat detection method, storage medium, electronic equipment and system based on micro-service system | |
CN108805741B (en) | Fusion method, device and system of power quality data | |
CN113032477A (en) | Long-distance data synchronization method and device based on GTID and computing equipment | |
CN111459819A (en) | Software testing method and device, electronic equipment and computer readable medium | |
CN112751893A (en) | Message track data processing method and device and electronic equipment | |
CN116955287A (en) | Data processing method, device, equipment and storage medium | |
CN115203063B (en) | Playback method and system of production flow re-running risk program based on real-time recording |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |