CN118694651A - Microservice health check method, device, system and computer equipment - Google Patents
Microservice health check method, device, system and computer equipment Download PDFInfo
- Publication number
- CN118694651A CN118694651A CN202310355931.2A CN202310355931A CN118694651A CN 118694651 A CN118694651 A CN 118694651A CN 202310355931 A CN202310355931 A CN 202310355931A CN 118694651 A CN118694651 A CN 118694651A
- Authority
- CN
- China
- Prior art keywords
- service
- health check
- micro
- health
- client
- 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.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/02—Standardisation; Integration
- H04L41/0246—Exchanging or transporting network management information using the Internet; Embedding network management web servers in network elements; Web-services-based protocols
- H04L41/0273—Exchanging or transporting network management information using the Internet; Embedding network management web servers in network elements; Web-services-based protocols using web services for network management, e.g. simple object access protocol [SOAP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/50—Network service management, e.g. ensuring proper service fulfilment according to agreements
- H04L41/5077—Network service management, e.g. ensuring proper service fulfilment according to agreements wherein the managed service relates to simple transport services, i.e. providing only network infrastructure
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/12—Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- General Health & Medical Sciences (AREA)
- Medical Informatics (AREA)
- Computer And Data Communications (AREA)
Abstract
The present application relates to a microservice health check method, apparatus and system, as well as a computer device, a computer readable storage medium and a computer program product, the method comprising: acquiring a service port address allocated to a health check service end from available server ports according to the port occupation condition of the service node under the condition that the health check service end is called by the service node; in the case that a micro service in an application node invokes a health check client, determining the micro service as a health check object; establishing an inspection channel with the health inspection client based on the service port address; based on the communication of the checking channel and the health checking client, the health checking client performs health checking on the micro service to obtain the health checking result of the micro service. By adopting the method, the performance loss of the service system to be detected caused by accessing the health check service can be reduced, and the data processing efficiency is further improved.
Description
Technical Field
The present application relates to the field of computer technology, and in particular, to a method, apparatus and system for microservice health check, and a computer device, a computer readable storage medium and a computer program product.
Background
With the rapid development of computer technology, it is difficult for traditional individual architecture modes to meet the demands of the market for complex solutions, and a micro-service architecture for decoupling the solutions has been created by decomposing service functions into discrete micro-services. Since the health status of the micro-service directly determines whether the business function can be implemented, it is necessary to check the health status of the micro-service.
The traditional micro-service health checking method is realized based on an open-source health checking tool, and the open-source health checking items integrate a plurality of additional functions, so that a plurality of memory and performance consumption are increased for a micro-service system, and the defect of low data processing efficiency exists.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a micro-service health inspection method, apparatus and system, and a computer device, a computer-readable storage medium, and a computer program product that can improve data processing efficiency.
In a first aspect, the present application provides a method of microservice health check, the method comprising:
acquiring a service port address allocated by a service node; the service port address is distributed from available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end;
in the case that a micro-service in an application node invokes a health check client, determining the micro-service as a health check object;
establishing an inspection channel between the health inspection client and the health inspection client based on the service port address;
And based on the communication of the checking channel and the health checking client, health checking is carried out on the micro service through the health checking client, and a health checking result of the micro service is obtained.
In a second aspect, the present application also provides a micro-service health inspection device, the device comprising:
the acquisition module is used for acquiring the service port address distributed by the service node; the service port address is distributed from available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end;
The health examination object determining module is used for determining the micro service as a health examination object when the micro service in the application node calls the health examination client;
The connection module is used for establishing an inspection channel between the health inspection client and the health inspection client based on the service port address;
and the health check module is used for communicating with the health check client based on the check channel, and carrying out health check on the micro service through the health check client to obtain a health check result of the micro service.
In a third aspect, the present application also provides a micro-service health inspection system, the system comprising:
in the case that a micro-service in an application node invokes the health check client, determining the micro-service as a health check object;
The health examination client and the health examination server establish an examination channel based on the service port address of the health examination server; the service port address is allocated from available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end;
And the health check server communicates with the health check client based on the check channel, and performs health check on the micro service through the health check client to obtain a health check result of the micro service.
In a fourth aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of the above method when the processor executes the computer program.
In a fifth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the above method.
In a sixth aspect, the application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of the above method.
According to the micro-service health check method, the device and the system, the computer equipment, the computer readable storage medium and the computer program product, the micro-service is deployed in the application node for health check, particularly, under the condition that the service node calls the health check service end, the service port address is distributed to the health check service end from the available server port according to the port occupation condition of the service node, under the condition that the micro-service in the application node calls the health check client, the micro-service is determined to be a health check object, a check channel between the health check service end and the health check client is established based on the service port address, and based on the check channel and the communication with the health check client, the health check of the micro-service corresponding to the health check client is realized, which is equivalent to the realization of the health check of the micro-service through a calling mode, no redundant function is introduced, the memory and the computing resource are saved, the performance loss caused by the access of the service system to be detected to the health check service is reduced, and the data processing efficiency is further improved.
Drawings
FIG. 1 is a diagram of an application environment for a micro-service health check method in some embodiments;
FIG. 2 is a schematic diagram of a deployment of micro services in an application server in some embodiments;
FIG. 3 is a schematic diagram illustrating a call situation of each application server to a health check client in the embodiment corresponding to FIG. 2;
FIG. 4 is a flow chart of a micro-service health check method in some embodiments;
FIG. 5 is a health status display page schematic in some embodiments;
FIG. 6 is a schematic diagram of a health status display page in other embodiments;
FIG. 7 is a schematic diagram of a License activation page in some embodiments;
FIG. 8 is a schematic diagram of a process for establishing a check channel between a health check client and a health check server in one embodiment;
FIG. 9 is a flow chart of a micro-service health check method in other embodiments;
FIG. 10 is a block diagram of the components of a micro-service health check system in some embodiments;
FIG. 11 is a block diagram of the components of a micro-service health check system in further embodiments;
FIG. 12 is a schematic diagram of registration principles of nodes and micro services in some embodiments;
FIG. 13 is a schematic diagram of storage content in a data storage node of one embodiment;
FIG. 14 is a schematic diagram of a health check system deployed by multiple servers in an apportioned mode;
FIG. 15 is a schematic diagram of a health check system deployed by multiple servers in a master mode;
FIG. 16 is a block diagram of a micro-service health check device in some embodiments;
FIG. 17 is an internal block diagram of a computer device in some embodiments.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
First, the terms involved in the embodiments of the present application will be briefly explained:
virtual machine deployment: english Virtual Machine, VM for short, refers to a complete computer system with complete hardware system functions, which runs in a completely isolated environment, through software simulation.
And (3) containerized deployment: containerization is a method of software development by which an application or service, its dependencies and its configuration (abstracted into a deployment manifest file) can be packaged together into a container image. The containerized application may be tested as a unit and may be deployed as a container image instance to a host Operating System (OS).
Application node: refers to an application server currently deploying a micro-service.
Service node: refers to an application server that invokes a health check server.
Micro-services: refers to service engineering of each sub-function in the business system.
Polling mechanism: the server periodically communicates with the client in the checked state and inquires about the current state information. If the client returns a delayed status message, no return, or a wrong or invalid message, the server may consider the client down. At this time, the server will save the state of the client. And subsequently, if the client returns to normal, changing back to the normal state.
Heartbeat mechanism: the heartbeat does not actively send information to the server to detect the state of the client, but stores the state information of all clients at the server, waits for the clients to access the server at regular time, updates the current state of the client, and considers that the client is down or the state of the client is abnormal if the client does not update the state beyond the designated time.
HC: the full scale HEALTH CHECK is translated into a health check.
The micro-service health check method provided by the embodiment of the application can be applied to an application environment shown in figure 1. The application scenario may include the terminal 100, the web server 200, and the application server 300. The network server 200 and the application server 300 are connected through an interface, and the terminal 100 and the network server 200 can communicate through a communication network. The communication network may be a wired network or a wireless network. Accordingly, the terminal 100 and the web server 200 may be directly or indirectly connected through wired or wireless communication. For example, the terminal 100 may be indirectly connected to the web server 200 through a wireless access point, or the terminal 100 may be directly connected to the web server 200 through the internet, which is not limited herein.
The terminal 100 includes, but is not limited to, a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, an aircraft, and the like. The embodiment of the invention can be applied to various business scenes realized based on the micro-service architecture, including but not limited to various scenes such as cloud technology, artificial intelligence, intelligent traffic, auxiliary driving and the like. The terminal 100 may be provided with a micro-service health check-related client, which may be software (e.g., a browser, video software, etc.), a web page, an applet, etc. The application server 300 is a background server corresponding to software, web pages, applets, etc. Further, the network server 200 and the application server 300 may be independent physical servers, or may be a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network ), and basic cloud computing services such as big data and an artificial intelligence platform. The data storage system may store data that the application server 300 needs to process. The data storage system may be integrated on the application server 300 or may be located on the cloud or other server.
The micro-services are deployed in application nodes, which refer to the application servers 300 where the micro-services are currently deployed. If the computer system adopts a virtual machine deployment mode, each application node can deploy a plurality of micro-services; if the computer system adopts a containerized deployment mode, each application node can deploy one micro-service. The service node refers to the application server 300 that invokes the health check server. It will be appreciated that if an application server invokes both a health check client and a health check server, the application server is both a service node and an application node.
Specifically, under the condition that the health examination server is called, the service node allocates a service port address for the health examination server from the available server ports according to the port occupation condition of the service node. The health check server acquires a service port address allocated by a service node in the process of realizing the micro-service health check method, determines the micro-service as a health check object under the condition that the micro-service in the application node calls the health check client, and establishes a check channel with the health check client based on the service port address. And then, the health check server communicates with the health check client based on the check channel, and the health check client performs health check on the micro service to obtain a health check result of the micro service. The health check result may be sent to the terminal 100 through the web server 200, so that the terminal user may timely obtain the health check result, and perform targeted processing according to the health check result.
In one possible implementation, the micro-service health checking method can be applied to application scenes of containerized deployment. In this scenario, one application node may deploy one micro-service. And under the condition that the health examination server is called by the service node, distributing a service port address for the health examination server from the available server ports according to the port occupation condition of the service node. Then, the health check server obtains the service port address distributed by the service node, and when the micro service in the application node calls the health check client, the micro service is determined to be a health check object, a check channel between the micro service and the health check client is established based on the service port address, and the health check result of the micro service is obtained by performing health check on the micro service through the health check client based on the communication between the check channel and the health check client.
In one possible implementation, the micro-service health checking method can be applied to application scenarios of virtual machine deployment. In this scenario, one application node may deploy a plurality of micro services, for example, in fig. 2, micro service 1 and micro service 2 are deployed in application server 310, micro service 3 and micro service 4 are deployed in application server 320, and application server 310 invokes health check server 312, then application server 310 may be an application node and a service node, and application server 320 is an application node. In this scenario, as shown in fig. 3, each micro service may call the health check client respectively, so that the micro service corresponds to the health check client one by one, and the health check server may establish check channels with each health check client respectively, and based on the check channels corresponding to each health check client, may implement health check on the micro service corresponding to each health check client, and obtain the health check result of each micro service.
The micro-service health check method in the present application is described below.
In some embodiments, as shown in fig. 4, a method for micro-service health inspection is provided, and this embodiment is described by taking the application of the method to a health inspection server as an example, where the method includes the following steps:
Step S402, obtain the service port address that the service node distributes.
The service port address is allocated from the available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end. The service node refers to an application server that invokes the health check server. The health check server can be deployed in the form of a plug-in or script. Further, the service node may initiate a micro-service health check by invoking a health check server in plug-in or script form. The service port address may be characterized by the address and port number of the service node. The address of the serving node may be an IP (Internet Protocol ) address or a domain name. The ports of the service node, i.e. the server ports, comprise the physical interfaces of the server and Socket application program interfaces. Through different ports, the service node can communicate with the outside without interference.
Specifically, the health examination server is started in a calling mode, so that light deployment of the health examination server can be realized, and compared with the traditional mode of installing software and configuring a registry, the method has lower requirements on service ports and better flexibility. Based on the above, the service node can allocate a service port address for the health check service end from the available server ports according to the occupation condition of the service node and the service port address is used for supporting the health check service end to realize communication with the health check client. And then, the health check server acquires the service port address allocated by the service node. Further, the specific way for the health check server to acquire the service port address may be active acquisition or passive reception. For example, the service node may write the service port address allocated to the health check server into the local storage space, and the health check server obtains the corresponding service port address from the local storage space; the service node can also directly send the service port address allocated for the health examination service end to the health examination service end.
In step S404, in the case where the micro service in the application node invokes the health check client, the micro service is determined as a health check object.
The application node refers to an application server where a micro service is currently deployed. That is, the micro service health check method in the present application is a health check for the micro service deployed in the application node. Similar to the health check server, the health check client may be deployed in plug-in form or in script form. The micro-services in the application node may initiate a micro-service health check for themselves by invoking a health check client in plug-in form or in script form. In a specific implementation, the health check server and the health check client are deployed in the form of plug-ins, which is equivalent to the fact that the deployment of the health check server and the health check client can be realized by using external resources of the application server, without occupying resources of the application server, the access of the health check service can be realized by only calling corresponding plug-in packages in the application process, and redundant miscellaneous functions can not be introduced, the lightweight deployment of the health check service can be realized, and the data processing efficiency of the application server is further improved.
Specifically, in the case where the micro-service invokes the health check client, this corresponds to registering the micro-service to be checked with the health check service. That is, in the case that the micro service invokes the health check client, the micro service is determined as a health check object, so that the front-end health check can be performed on the micro service before the micro service application is started (itself started or invoked by other micro services), thereby ensuring the stability of the micro service application process.
Step S406, based on the service port address, a checking channel is established with the health checking client.
The channel refers to a communication channel, that is, a channel through which a signal is transmitted in a communication system, and is a transmission medium through which the signal is transmitted from a transmitting end to a receiving end. The inspection channel refers to a communication channel for performing a micro-service health inspection. The inspection channel may be a wireless channel, a wired channel, or a memory channel, in particular, without limitation.
Specifically, when the micro service calls the health check client, the registering of the micro service to be checked with the health check service is equivalent, and on the premise that the micro service to be checked is registered with the health check service, the health check server can establish a check channel with the health check client based on the service port address of the micro service, so that the follow-up health check of the micro service calling the health check client is facilitated through the health check client. Further, in the case of a micro-service invoking a health check client, the application node may also assign a client port address to the health check client, the client port address being used to support communication between the health check client implementation and the health check server. Similar to the service port address, the client port address may be characterized by the address and port number of the application node. The address of the application node may be an IP address or a domain name. The ports of the application node, i.e. the server ports, comprise the physical interfaces of the server and Socket application program interfaces.
Further, the specific manner of establishing the inspection channel is not unique. For example, a connection request can be actively initiated to the health check server by the health check client based on the service port address of the health check server, and a check channel is established with the health check client by the health check server in response to the connection request; the health check server side can also actively initiate a connection request to the health check client side based on the client port address of the health check client side, and establish a check channel with the health check client side under the condition that the health check client side sends confirmation information through the service port address.
Step S408, based on the communication between the inspection channel and the health inspection client, the health inspection client performs health inspection on the micro service to obtain the health inspection result of the micro service.
As described above, in the case where the micro service calls the health check client, this corresponds to registering the micro service to be checked with the health check service, that is, for a business system including a plurality of micro services, each micro service may call the health check client separately to achieve one-to-one correspondence of the micro service and the health check client. Therefore, the health check server can realize the health check of the micro-service corresponding to the health check client only by checking the communication condition between the health check server and the health check client.
Specifically, the health check service end communicates with a health check client based on a check channel, and performs health check on a micro service calling the health check client through the health check client to obtain a health check result of the micro service. The specific manner in which the health check is performed may include at least one of a polling mechanism and a heartbeat mechanism. Wherein the health check results of the micro-service may include normal and abnormal; the health status of the micro-service may include a normal status, an on-hook status, and an initialized status. The normal state refers to that no abnormality is found in the health checking process, namely the communication of the current micro-service is normal; the on-hook state is that the health checking process captures communication abnormality, namely the communication abnormality of the current micro-service; the initialization state refers to that the corresponding check channel is not established yet in the process that the current micro service is being started.
Further, health inspection can be performed on the micro-service, and meanwhile, statistics of health states can be performed on application nodes deploying the micro-service. The health status of the application node may include a normal status, an on-hook status, and an abnormal status, among others. The normal state indicates that the health check results of all micro services under the application node are in the normal state; the on-hook state indicates that the health check result of all micro-services under the application node is the on-hook state; the abnormal state indicates that the health check result of part of the micro-services under the application node is in the on-hook state, and the health check result of part of the micro-services is in the normal state. In practical applications, after the health check result of the micro service is obtained, the health check server may also display the health check result of the micro service through a dashboard (dashboard) of the web server.
In a specific application, after obtaining the health check result of the micro service, the health check server may also send the health check result to the terminal through the web server, so that the terminal can display the health check result. Fig. 5 is a schematic diagram of a health status display page. The node health statistics are statistics indicating the health state of the application node, and the service health statistics are statistics indicating the health state of micro services in the application node. The user can acquire the whole health condition of the whole service system through the health condition display page, and the whole health condition is used as a reference for operation and maintenance decision.
Further, besides the current overall health status of the service system can be shown through the health status showing page, the status of each application node and each micro service under each application node can be shown through the detailed health status showing page. That is, the health status presentation page may include a health general bulletin and a health detail bulletin. As shown in fig. 6, the main presentation fields in the health detail board include: node ID (unique identification of each application node), node IP, node status, and failure time. When an application node is in an abnormal state or an on-hook state, the fault time of the micro service which is firstly in the on-hook state under the application node is taken as the fault time of the application node; when the application node is in a normal state, the failure time is empty. I.e. when the state of the application node returns to normal, the last failure time is cleared. The presentation information of the micro service under the application node may include a service ID, a service type, and a service status of the micro service. The service types may include, among other things, authentication services, payment services, management console services, and the like. Through the health details board, the user can locate the machine with the fault at the first time, and then can specifically find the machine according to the information provided by the machine details for further processing.
In addition, for a service system deployed by a virtual machine, a License (License) is often required to be used for a management and control system. After the health check result of each micro service is obtained, as shown in fig. 7, the health status of each application node can be determined, and the node activation in normal operation can be screened, so that it can be ensured that the application nodes in on-hook state and abnormal state will not appear in the activation list, and a complete and reliable activation environment is further provided.
According to the micro-service health check method, health check is conducted on deployed micro-services in the application node, particularly, under the condition that the service node calls the health check service end, a service port address is distributed to the health check service end from available server ports according to the port occupation condition of the service node, the health check service end is started in a calling mode, light deployment of the health check service end can be achieved, and compared with the traditional mode of installing software and configuring a registry, the requirement on the service port is lower, and the flexibility is better; under the condition that the micro-service in the application node calls the health check client, determining the micro-service as a health check object, and performing front-end health check on the micro-service before the micro-service application is started, so that the stability of the micro-service application process is ensured; based on the service port address, an inspection channel between the health inspection service end and the health inspection client is established, and based on the inspection channel and the communication of the health inspection client, the health inspection of micro service corresponding to the health inspection client is realized, the micro service health inspection is realized in the process in a calling mode, no redundant function is introduced, the memory and the computing resource are saved, the performance loss of a service system to be detected due to the access to the health inspection service is reduced, and the data processing efficiency is further improved.
In some embodiments, step S406 includes: starting a service port corresponding to the service port address; under the condition that the micro-service calls the health check client, acquiring a connection request sent by the health check client; in response to the connection request, a check channel is established with the health check client.
The connection request is sent by the health check client through the service port under the condition of acquiring the service port address. Specifically, the health check server is a server for directly detecting and deciding the health condition of each micro service, and the health check client is deployed in the corresponding micro service in the form of plug-in or script.
Taking a virtual machine deployment manner as an example, the whole server system comprises a network server and an application server, and the number of the network server and the application server can be one or a plurality of. As shown in fig. 8, the number of web servers is one, and the number of application servers is three. The web server provides web services, proxy services, and is configured with a dashboard that supports visualization of inspection results. Each application Server is provided with a micro-service, each micro-service calls a corresponding health check Client (namely HC Client), and the application Server 1 calls a health check Server (namely HC Server). In the process of establishing the checking channel, firstly, the HC Server starts the service port corresponding to the service port address, and waits for the connection request of each HC Client in a state of waiting for connection. And then, on the premise of acquiring the service port address, each HC Client transmits a connection request to the HC Server through the service port. When the socket (i.e. service port) at the HC Server end receives the connection request at the HC Client end, a new thread is established to respond to the connection request, and a description is sent to the HC Client, once the HC Client confirms the description, the two parties formally establish a check channel. Meanwhile, the HC Server socket continues to receive connection requests of other HC Client sockets.
Further, the application Server 1 stores the service port address allocated to the HC Server to the data storage system in the case of calling the HC Server, and the HC Client can obtain the service port address from the data storage system. In order to avoid frequent access of each HC Client to a database in a data storage system, after the HC Client in a certain application node finishes data query from the database and obtains a service port address of the HC Server, the service port address is stored in a local storage space of the application node, so that other HC clients on the application node can obtain the service port address of the HC Server through the local storage space, and if no address is needed in the local storage space, the operation of querying the database is performed. For the situation that a plurality of HC servers are deployed, addresses of the plurality of HC servers may be stored in a local storage space, and a detection mode of the HC Client connection servers may be determined by configuring a connection mode, for example, the plurality of HC Client services may be all connected with one HC Server; multiple HC clients may be connected to multiple HC servers at random.
In this embodiment, since the health check server and the health check client are in one-to-many relationship, the health check client actively initiates the connection request, which can reduce the load of the health check server and is beneficial to further improving the data processing efficiency.
In some embodiments, step S408 includes: acquiring a micro service identifier of the micro service by checking a channel; adding the micro-service into the polling list based on the micro-service identification; according to the polling list, the polling mechanism is based on communication with a health check client, and the health check client performs health check on the micro-service to obtain a health check result of the micro-service.
Specifically, after the health check server and the health check client establish the check channel, the health check server can acquire the micro-service identifier of the micro-service to which the health check client belongs from the health check client through the check channel, and based on the micro-service identifier, add the corresponding micro-service into the polling list, and perform state detection on the health check client sending messages corresponding to the micro-service according to the polling mechanism at regular time, so as to realize health check for the micro-service. If the channel abnormality is detected, the checking channel is immediately disconnected, and the state of the micro service corresponding to the health checking client is determined to be an on-hook state. The micro-service identifier may be unique identifier information of the micro-service, i.e. UUID (Universally Unique Identifier, universal unique identifier code), or may be address information of the micro-service, for example, an address of an application node where the micro-service is located and a service port number of the micro-service. The abnormal condition of the channel can be that the health examination client returns information delay and no information, or that the health examination client returns error or failure information, etc.
In the embodiment, the polling mechanism is based on checking the health state of the micro-service, and the method is simple in algorithm, easy to implement and high in compatibility.
In one embodiment, the microservice health check method further comprises: under the condition that the health check result is abnormal, removing the micro-service from the polling list, and updating the state of the micro-service into an on-hook state; responding to a micro-service registration event triggered when the health check client is called, and acquiring a micro-service identifier of a registration micro-service for calling the health check client; in the event that the registered micro-service is determined to be a restart micro-service based on the micro-service identification, the registered micro-service is added to the polling list.
The restarting of the micro-service refers to the micro-service that once establishes a checking channel with the health checking server by calling the health checking client, but is currently in an on-hook state. Specifically, when a health check client connected to a health check server and operating normally suddenly goes down for some reason, the established check channel is disconnected and is located and found when the health check server polls, at this time, the health check server removes the micro service corresponding to the health check client which has been disconnected currently from the polling list, and updates the state of the micro service to the on-hook state.
Further, as described above, in the case where the micro service invokes the health check client, this corresponds to registering the micro service to be checked with the health check service. Therefore, the micro-service health check server responds to the micro-service registration event triggered when the health check client is called, the micro-service identification of the registered micro-service calling the health check client can be obtained, and then the micro-service identification is matched with each historical micro-service identification which is polled. If the micro-service identifier is consistent with a certain historical micro-service identifier, the health check server determines that the current registered micro-service is the restart micro-service, establishes a check channel between the health check clients corresponding to the restart micro-service, and adds the registered micro-service into a polling list.
In this embodiment, the health check server actively adds the registered micro service to the polling list instead of passively waiting for the connection request sent by the health check client when the registered micro service is determined to be the restart micro service based on the micro service identifier, which is beneficial to further improving efficiency.
In some embodiments, the microservice health check method further comprises: through the checking channel, communication with the health checking client based on a heartbeat mechanism, determining the stability of the checking channel; in the case of an unstable inspection channel, the communication connection with the health inspection client is disconnected.
In practical applications, the checking channel established between the HC Server and the HC Client essentially belongs to a long link. In long-chain communication, the situation that communication message is lost sometimes occurs due to poor external transmission environment, external interference and the like, and when the number of lost situations reaches a certain condition, the accuracy and normal use of health detection can be affected, so that the user experience is affected. Therefore, for unstable communication, a mechanism for detecting stability and an active disconnection capability are required, and specifically, a heartbeat mechanism may be used to detect the stability of the channel.
Specifically, for the HC Server, if the communication message from the HC Client is not received beyond the set period of time, it is considered that the channel from the HC Client to the HC Server is blocked once. The set period of time may be, for example, 15S or 16S, or the like. At this time, the HC Client is given a time-out opportunity for sending messages with a set number of times, if the time-out number of messages exceeds the set number of times, the HC Server end actively disconnects the connection with the HC Client, and sets the state of the micro service where the HC Client is located as an on-hook state. The set number of times may be, for example, two or three times. After the HC Client is disconnected, a disconnection reconnection mechanism is triggered to retry to establish a check channel with the rest of available HC servers.
Furthermore, in practical application, the mechanism for detecting stability and the capability of actively disconnecting can be set up at both ends of the HC Server and the HC Client, that is, the HC Client can also actively disconnect the connection with the HC Server. Specifically, for the HC Client, if the communication message from the HC Server is not received beyond the preset duration, it is considered that the channel from the HC Server to the HC Client is blocked once. The preset time period is generally smaller than the set time period, and may be 10S or 12S, for example. The HC Client can actively disconnect from the HC Server, and reconnect to reconnect the remaining available HC servers. It can be understood that, because the authority of the HC Server is larger, more strict management and control are required, so the heartbeat detection requirement for the HC Server is far higher than the heartbeat detection requirement for the HC Client.
In this embodiment, the stability of the inspection channel is determined based on the heartbeat mechanism, so that the micro-service health inspection can be ensured under the condition that the inspection channel is stable, and the accuracy of the health inspection result is ensured.
In some embodiments, the health check client includes a first health check client invoked by a first micro-service and a second health check client invoked by a second micro-service. On the premise of this embodiment, the micro-service health check method further includes: the communication message between the first micro-service and the second micro-service is forwarded based on a first inspection channel with the first health check client and a second inspection channel with the second health check client.
Wherein the communication message between the first micro service and the second micro service may include a key agreement message, an encryption message, and the like. Specifically, after the HC Server establishes an inspection channel with each HC Client, the HC Server can serve as a message forwarding center, and based on the established inspection channel, the HC Server assists in mutually transmitting messages between the HC clients, and the HC clients can also mutually transmit messages with the micro-service calling the HC clients, so that low-cost communication between the micro-services is realized. The communication messages among the micro services can be matched with the corresponding information encryption modes according to the message level of the transmitted information, and the operability and the expansibility are high. For example, for information with low security requirements, such as high openness data to be transmitted between micro services, simple encoding and decoding can be used; for information with medium security requirements, such as data generated in the running of micro-services, symmetric encryption can be used, namely, common encryption and decryption keys are negotiated between all micro-services and used in information transmission; for higher security information, such as data information associated with a user, asymmetric encryption or complex encryption may be used to protect the transmitted information.
In this embodiment, the health check server may also be used as a message forwarding center, and based on the built check channel, the message is assisted to be transmitted between the health check clients, so that communication loss between the micro services can be reduced, and low-cost communication between the micro services is further realized.
In some embodiments, as shown in fig. 9, the micro-service health check method includes the steps of:
in step S901, the service node invokes the health check server, and allocates a service port address to the health check server.
The service node refers to an application server for calling the health check service end. The service port address is allocated from the available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end. The health check server can be deployed in the form of a plug-in or script. Further, the service node may initiate a micro-service health check by invoking a health check server in plug-in or script form. The service port address may be characterized by the address and port number of the service node. The address of the service node may be an IP address or a domain name. The port of the service node, namely the server port corresponding to the service node, comprises a physical interface of the service node and a Socket application program interface. Through different ports, the service node can communicate with the outside without interference.
Specifically, the health examination server is started in a calling mode, so that light deployment of the health examination server can be realized, and compared with the traditional mode of installing software and configuring a registry, the method has lower requirements on service ports and better flexibility. Based on the above, the service node can allocate a service port address for the health check service end from the available server ports according to the occupation condition of the service node and the service port address is used for supporting the health check service end to realize communication with the health check client.
In step S902, the health check server starts a service port corresponding to the service port address.
Specifically, in the process of establishing the inspection channel, firstly, the health inspection server starts the service port corresponding to the service port address, and waits for the connection request of each health inspection client in a state of waiting for connection.
In step S903, the micro service in the application node invokes the health check client and determines the client port address of the health check client.
The application node refers to an application server where a micro service is currently deployed. That is, the micro service health check method in the present application is a health check for the micro service deployed in the application node. Similar to the health check server, the health check client may be deployed in plug-in form or in script form. The micro-services in the application node may initiate a micro-service health check for themselves by invoking a health check client in plug-in form or in script form.
Specifically, in the case where the micro-service invokes the health check client, this corresponds to registering the micro-service to be checked with the health check service. That is, in the case that the micro service invokes the health check client, the micro service is determined as a health check object, so that the front-end health check can be performed on the micro service before the micro service application is started (itself started or invoked by other micro services), thereby ensuring the stability of the micro service application process. In the case where a micro service in an application node invokes a health check client, the application node determines the client port address of the health check client from its available ports.
Similar to the service port address, the client port address may be characterized by the address and port number of the application node. The address of the application node may be an IP address or a domain name. The port of the application node, namely the port of the server corresponding to the application node, comprises a physical interface of the application node and a Socket application program interface. Through different ports, the application node can communicate with the outside without interference.
In step S904, the health inspection client obtains the service port address of the health inspection server, and sends a connection request to the health inspection server through the service port corresponding to the service port address.
The connection request is sent by the health check client through the service port under the condition of acquiring the service port address. Specifically, the health examination client acquires a service port address of the health examination server, and sends a connection request to the health examination server through a service port corresponding to the service port address.
In step S905, the health check server establishes a check channel with the health check client based on the service port address and the client port address in response to the connection request.
The channel refers to a communication channel, that is, a channel through which a signal is transmitted in a communication system, and is a transmission medium through which the signal is transmitted from a transmitting end to a receiving end. The inspection channel refers to a communication channel for performing a micro-service health inspection. The inspection channel may be a wireless channel, a wired channel, or a memory channel, in particular, without limitation.
Specifically, when the micro service calls the health check client, the registering of the micro service to be checked with the health check service is equivalent, and on the premise that the micro service to be checked is registered with the health check service, the health check server can establish a check channel with the health check client based on the service port address of the micro service and the client address of the health check client, so that the follow-up health check of the micro service calling the health check client is facilitated through the health check client.
For example, a connection request can be actively initiated to the health check server by the health check client based on the service port address of the health check server, the connection request carries the client address of the health check client, and the health check server responds to the connection request and establishes a check channel with the health check client based on the client address; the health check server side can also actively initiate a connection request to the health check client side based on the client port address of the health check client side, and establish a check channel with the health check client side under the condition that the health check client side sends confirmation information through the service port address.
In step S906, the health check server communicates with the health check client through the check channel based on the heartbeat mechanism to determine the stability of the check channel.
In practical application, the checking channel established between the health checking server and the health checking client essentially belongs to a long link. In long-chain communication, the situation that communication message is lost sometimes occurs due to poor external transmission environment, external interference and the like, and when the number of lost situations reaches a certain condition, the accuracy and normal use of health detection can be affected, so that the user experience is affected. Therefore, for unstable communication, a mechanism for detecting stability and an active disconnection capability are required, and specifically, a heartbeat mechanism may be used to detect the stability of the channel.
In step S907, in the case of unstable checking channel, the health checking server disconnects the communication with the health checking client.
Specifically, for the health check server, if the communication message from the health check client is not received beyond a set period of time, the channel from the health check client to the health check server is considered to be blocked. The set period of time may be, for example, 15S or 16S, or the like. At this time, the health checking client is given a time-out opportunity for sending the message for the set times, if the time-out times of the message exceeds the set times, the health checking server actively disconnects the connection with the health checking client, and sets the state of the micro service where the health checking client is located as an on-hook state. The set number of times may be, for example, two or three times. After the health check client is disconnected, a disconnection reconnection mechanism is triggered to retry to establish a check channel with the rest of available health check servers.
Furthermore, in practical application, the capability of detecting the stability and the capability of actively disconnecting can be set up at both the health examination server and the health examination client, that is, the health examination client can actively disconnect the connection with the health examination server. Specifically, for the health check client, if the communication message from the health check server is not received beyond the preset time period, the channel from the health check server to the health check client is regarded as channel blocking. The preset time period is generally smaller than the set time period, and may be 10S or 12S, for example. The health check client actively disconnects from the health check server and reconnects to reconnect the remaining available health check servers. It can be understood that, because the authority of the health check server is larger, more strict management and control are required, so the heartbeat detection requirement for the health check server is far higher than the heartbeat detection requirement for the health check client.
Step S908, the health check client searches for the remaining available health check servers, and returns to step S904.
Specifically, under the condition that the inspection channel is unstable, the health inspection server breaks communication connection with the health inspection client, the health inspection client searches for other available health inspection servers, returns to the health inspection client to acquire a service port address of the health inspection server, and sends a connection request to the health inspection server through a service port corresponding to the service port address.
In step S909, under the condition that the inspection channel is stable, the health inspection server obtains the micro-service identifier of the micro-service corresponding to the health inspection client through the inspection channel.
The micro-service identifier may be unique identifier information of the micro-service, i.e. UUID (Universally Unique Identifier, universal unique identifier code), or may be address information of the micro-service, for example, an address of an application node where the micro-service is located and a service port number of the micro-service.
Specifically, after the health check server and the health check client establish the check channel, the health check server may obtain the micro-service identifier of the micro-service to which the health check client belongs from the health check client through the check channel, and based on the micro-service identifier
Step S910, the health check service terminal adds the micro-service into the polling list based on the micro-service identifier, and communicates with the health check client terminal based on the polling mechanism according to the polling list, and the health check client terminal performs health check on the micro-service to obtain a health check result of the micro-service.
The abnormal condition of the channel can be that the health checking client returns information delay and no information, or that the health checking client returns error or failure information, etc. The health check results of the micro-service may include normal and abnormal; the health status of the micro-service may include a normal status, an on-hook status, and an initialized status. The normal state refers to that no abnormality is found in the health checking process, namely the communication of the current micro-service is normal; the on-hook state is that the health checking process captures communication abnormality, namely the communication abnormality of the current micro-service; the initialization state refers to that the corresponding check channel is not established yet in the process that the current micro service is being started.
Specifically, the health check server can add the corresponding micro services into the polling list based on the micro service identification of the micro services, and send messages to the health check clients corresponding to the micro services according to a polling mechanism at regular time to detect the state of the messages, so that health check for the micro services is realized. If the channel abnormality is detected, the checking channel is immediately disconnected, and the state of the micro service corresponding to the health checking client is determined to be an on-hook state.
Further, health inspection can be performed on the micro-service, and meanwhile, statistics of health states can be performed on application nodes deploying the micro-service. The health status of the application node may include a normal status, an on-hook status, and an abnormal status, among others. The normal state indicates that the health check results of all micro services under the application node are in the normal state; the on-hook state indicates that the health check result of all micro-services under the application node is the on-hook state; the abnormal state indicates that the health check result of part of the micro-services under the application node is in the on-hook state, and the health check result of part of the micro-services is in the normal state. In practical application, after the health check result of the micro-service is obtained, the health check server side can also display the health check result of the micro-service through the dashboard of the web server. In a specific implementation, after obtaining the health check result of the micro service, the health check server may also send the health check result to the terminal through the network server, so that the terminal can display the health check result. In addition, besides the current overall health state of the service system can be shown through the health state showing page, the states of each application node and each micro service under each application node can be shown through the detailed health state showing page.
According to the micro-service health check method, the health check service end is started in a calling mode, so that light deployment of the health check service end can be realized, compared with a traditional mode of installing software and configuring a registry, the requirement on a service port is lower, the flexibility is better, no redundant function is introduced, memory and computing resources are saved, performance loss of a service system to be detected due to access to the health check service is reduced, and further data processing efficiency is improved; under the condition that the micro-service in the application node calls the health check client, determining the micro-service as a health check object, and performing front-end health check on the micro-service before the micro-service application is started, so that the stability of the micro-service application process is ensured; in the process, the micro-service health check is realized in a calling mode, no redundant function is introduced, the memory and the computing resource are saved, the performance loss of the service system to be detected due to the access to the health check service is reduced, and the data processing efficiency is further improved. And, combine heartbeat and polling mechanism to carry out the health check of microservice, be favorable to improving the reliability of inspection result.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
In some embodiments, as shown in fig. 10, the present application further provides a micro-service health check system, including a health check server 1001 and a health check client 1002. In the case where a micro service in the application node invokes the health check client 1002, the micro service is determined as a health check object; the health check client 1002 and the health check server 1001 establish a check channel based on the service port address of the health check server 1001; the health check server 1001 performs health check on the micro service by the health check client 1003 based on the check channel and the health check client communication 1002, and obtains a health check result of the micro service.
The service port address of the health check service terminal 1001 is allocated by the service node from available server ports according to the port occupation condition of the service node under the condition of calling the health check service terminal 1001. Specific definitions of application nodes, service port addresses, and health check results are referred to above and will not be described here. The health check server 1001 and the health check client 1002 may be deployed in a plug-in form or a script form, and realize access to the micro-service health check service by being invoked by a corresponding node. Specifically, the service node allocates a service port address to the health check server 1001 in the case of calling the health check server 1001. In the case where the micro service in the application node invokes the health check client 1002, the health check client 1002 and the health check server 1001 establish a check channel based on the service port address of the health check server 1001. Next, the health check server 1001 performs health check on the micro service by the health check client 1002 based on the check channel and the health check client communication 1002, and obtains a health check result of the micro service.
According to the micro-service health inspection method system, health inspection is conducted on deployed micro-services in the application node, particularly, under the condition that the service node calls the health inspection service end, a service port address is distributed to the health inspection service end from available server ports according to the port occupation condition of the service node, the health inspection service end is started in a calling mode, light-weight deployment of the health inspection service end can be achieved, and compared with the traditional mode of installing software and configuring a registry, the requirement on the service port is lower, and the flexibility is better; under the condition that the micro-service in the application node calls the health check client, determining the micro-service as a health check object, and performing front-end health check on the micro-service before the micro-service application is started, so that the stability of the micro-service application process is ensured; based on the service port address, an inspection channel between the health inspection service end and the health inspection client is established, and based on the inspection channel and the communication of the health inspection client, the health inspection of micro service corresponding to the health inspection client is realized, the micro service health inspection is realized in the process in a calling mode, no redundant function is introduced, the memory and the computing resource are saved, the performance loss of a service system to be detected due to the access to the health inspection service is reduced, and the data processing efficiency is further improved.
In some embodiments, as shown in fig. 11, the micro-service health check system further comprises a data storage node 1003. The data storage node 1003 updates a micro service list of the application node and stores service information of the micro service in the case that the micro service calls the health check client 1002; the data storage node 1003 is further configured to store a service port address of the health check server 1001.
The service information of the micro service may include a UUID of the micro service, an address of an application node where the micro service is located, a service port number of the micro service, and the like. Specifically, in the case where the micro service invokes the health check client 1002, corresponding to registering the micro service to be checked with the health check service, the node information of the application node, the service port address of the health check server 1001, and the service information of each micro service may be uniformly stored by the data storage node 1003. It will be appreciated that the address of the application node where the micro service is located, that is, the address of the application node corresponding to the health check client 1002 invoked by the micro service, and the service port number of the micro service, that is, the client port number of the health check client 1002 invoked by the micro service. That is, the data storage node 1003 uniformly holds the service port address of the health check server 1001 and the client port address of the health check client 1002.
In one embodiment, as shown in fig. 12, taking a virtual machine deployment manner as an example, the health check server and the health check client are both called in the form of plug-in packages, and each micro service uses the same database cluster as a storage layer of data (i.e., a data storage system). When each virtual machine application server node is started, node information and micro-service information are registered in a storage layer. The network server 1 and the network server 2 may be standby with each other.
In one particular implementation, the particular content of node information and microservice information stored in the data storage node 1003 is shown in FIG. 13. The node ID is a unique identifier of the application node, and may be user-defined, or may use a device ID or a database ID in the virtual machine for node identification. The node IP refers to the IP address where the application node is located. The service list of the node refers to a UUID list of all micro services deployed under the application node. It can be appreciated that in the containerized deployment manner, the UUID list of the node includes only one UUID of the microservice. The service port number of the micro service refers to a micro service start port number, and the service port number can uniquely characterize the micro service together with the node IP of the application node where the micro service is located. That is, in combination with the service port number and the node IP, it can be determined whether a micro service being started is a new service or a registered micro service.
In the above embodiment, the configuration data storage node 1003 uniformly stores the service port address of the health check server 1001 and the client port address of the health check client 1002, so that uniform management of the port addresses can be realized, and a check channel can be conveniently established between the server and the client deployed on different application servers, thereby improving flexibility of the micro-service health check method.
In some embodiments, at least a first micro-service and a second micro-service are deployed in an application node; the health check clients include at least a first health check client invoked by a first micro-service and a second health check client invoked by a second micro-service. The method comprises the steps that under the condition that a first health check client is called by a first micro service, a service port address is obtained from a data storage node, and a check channel is established based on the service port address and a health check server; the first health check client writes the service port address into the local storage space of the application node; and the second health check client acquires the service port address from the local storage space under the condition of being called by the second micro service, and establishes a check channel with the health check server based on the service port address.
The local storage space of the application node refers to a storage space configured inside the application node, and the local storage space may be a storage space in a cache (cache) memory or a Random Access Memory (RAM) or the like. The first health check client establishes a check channel with the health check server before the second health check client.
Specifically, as described above, in the virtual machine deployment manner, a plurality of micro services may be deployed in one application node. And each micro service in the same application node accesses micro service health check by calling the health check client, and each health check client needs to acquire the service port address of the health check server in the process of establishing a check channel between each health check client and the health check server. In order to avoid performance degradation of the data storage system caused by frequent access of each health check client to the data storage system, after a certain health check client obtains a service port address of a health check server from the data storage system, the service port address is stored in a local storage space of the application node. Thus, other health check clients on the application node can acquire the service port address of the health check server through the local storage space.
In a specific implementation, each health check client of the same application node is connected to the same health check server. And in each health check client, the first client establishing a check channel with the health check server acquires the service port address of the health check server from the data storage system, and writes the service port address into the local storage space of the application node. And the rest health examination clients in the application node acquire the service port address from the local storage space under the condition of being called by the corresponding micro service, and establish an examination channel with the health examination server based on the service port address.
In the above embodiment, the first health check client establishing the check channel writes the service port address into the local storage space of the application node, so that the second health check client can obtain the service port address from the local storage space when being called by the second micro service, thereby avoiding frequent access of the data storage system, further avoiding performance degradation of the data storage system, and further being beneficial to improving data processing efficiency.
In some embodiments, the number of health check servers is at least two; each health examination service end is deployed at different service nodes in the form of plug-ins. Under the condition that the micro service calls the health check client, the health check client obtains the load weight of each health check server, and determines a target server from each health check server based on each load weight; the health examination client and the target server establish an examination channel based on the service port address of the target server.
The respective load weight of each health check server can be determined according to the number of health check clients of the checking channel currently established by each health check server, and the greater the number of connected health check clients, the greater the load weight of the health check server, and the heavier the load. Specifically, each health check server is deployed at different service nodes in the form of plug-ins. Under the condition that the micro service calls the health check client, the health check client can acquire the load weight of each health check server and determine the target server from each health check server based on the load weight. And then, the health examination client acquires the service port address of the target server, and sends a connection request to the target server based on the service port address, so as to establish an examination channel with the target server. The target server may be a server with the smallest load weight in each health inspection server, or may be any one of multiple servers with the load weight satisfying the weight condition in each health inspection server. The weight condition may mean that the load weight is less than a preset weight, or that the load weight is less than or equal to a preset weight.
In this embodiment, a plurality of health inspection servers are deployed, and the target server connected to the health inspection client is determined based on the load weight, so that load balance of each health inspection server can be ensured, and the overall performance of the micro-service health inspection system is improved.
In some embodiments, the health check service includes a downtime service and an availability service; each health examination service end is deployed at different service nodes in the form of plug-ins. Under the condition that a downtime server exists in each health inspection server, a target client connected with the downtime server acquires a service port address of an available server, and establishes a standby inspection channel with the available server based on the service port address of the available server; the target client updates the available identifier of the available server so that each non-target client obtains the service port address of the available server and establishes a standby check channel with the available server based on the service port address of the available server.
The target client is a health check client for establishing a standby check channel in the first health check clients connected with the downtime server; the non-target clients are health check clients except the target clients among the health check clients connected with the downtime server. Specifically, under the condition that a downtime server exists in each health inspection server, a target client connected with the downtime server acquires a service port address of an available server, and establishes a standby inspection channel with the available server based on the service port address of the available server; the target client updates the available identifier of the available server so that each non-target client obtains the service port address of the available server and establishes a standby check channel with the available server based on the service port address of the available server.
As shown in fig. 14, a health check system in which two health check servers are deployed is taken as an example. All HC clients currently establish a check channel with HC Server 1. If the HC Server1 is down at this time, all HC clients will enter the re-search available HC Server link. The first HC Client connected to HC Server2 stores the information of HC Server2 in the data storage system, and updates the available identifier of HC Server2 to prompt the rest of HC clients to be connected until all HC clients are connected to HC Server2, then HC Server2 establishes a polling check relation with each HC Client, and takes over the health check work of HC Server1 which has been down. And after the HC Server1 resumes the online, the HC Server2 still dominates the judgment right of the health check system and does not submit the detection master control right.
It should be noted that, if the number of available service ends is multiple, the target client may determine the target service end according to the respective load weights of the available service ends, further obtain the service end address of the target service end, and establish an inspection channel with the target service end. For a specific process of determining the target server based on the load weight, refer to the above, and will not be described herein.
In this embodiment, at least two health inspection servers are deployed, and a take-over mechanism of inspection service of the downtime server by the available servers is provided, so that high availability of the micro-service health inspection system can be ensured, and accuracy of health inspection results is further ensured.
In some embodiments, referring still to fig. 11, the micro-service health system further comprises a health check configuration end 1004 connecting the health check service end 1001 and the health check client end 1002. The health check configuration terminal 1004 is configured to configure the working parameters for the health check server 1001 and the health check client 1002 in response to the working parameter configuration event.
The working parameters configured for the health check server 1001 and the health check client 1002 include a connection mode between the client and the server, a health check mechanism, and check parameters of the health check mechanism. The connection modes may include a master mode, a random connection model, and a load balancing mode. In the main control mode, corresponding standby service ends are configured for each health examination service end, and the standby service ends take over the health examination work of the health examination service ends under the condition that the health examination service ends are down. The random connection mode is also called an allocation mode, in which a plurality of deployed health check servers take effect simultaneously, and as shown in fig. 16, each HC Client can randomly join a polling list of a certain HC Server to perform fixed polling check. The apportionment mode has the advantages that the polling pressure of a single HC Server in the master control mode is apportioned, and meanwhile, the judgment authority of the project health result is apportioned. The load balancing mode is further optimized for the split mode, and specifically, a target server connected with the current client is determined according to respective load weights of effective health inspection servers. For example, in fig. 15, since HC Server1 is connected to three HC clients and HC Server2 is connected to two HC clients, the load weight of HC Server1 is large, and if a new HC Client is connected, the new HC Client will be connected to HC Server2. Further, the health check mechanism may include a polling mechanism and a heartbeat mechanism. The checking parameters of the health checking mechanism may include a polling interval duration in the polling mechanism, a timeout duration and a timeout number threshold in the heartbeat mechanism, and so on.
Specifically, the operating parameters may be entered or selected by a worker through a terminal, and used by the health check configuration terminal 1004 to configure the operating parameters for the health check server 1001 and the health check client 1002 in response to an operating parameter configuration event. Then, the health check server 1001 and the health check client 1002 establish a check channel based on the configured operation parameters to communicate, and complete health check for the micro service.
In this embodiment, the health check configuration end 1004 configures the working parameters for the health check server 1001 and the health check client 1002 in response to the working parameter configuration event, which is beneficial to improving the flexibility of the health check system, and further expanding the application scenario of the health check system.
Based on the same inventive concept, the embodiment of the application also provides a micro-service health inspection device for realizing the micro-service health inspection method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the micro-service health checking device or devices provided below may be referred to the limitation of the micro-service health checking method hereinabove, and will not be repeated here.
In some embodiments, as shown in fig. 16, a micro-service health check device 1600 is provided, which is applied to a health check server and includes an acquisition module 1601, a health check object determination module 1602, a connection module 1603, and a health check module 1604. Wherein,
An acquiring module 1601, configured to acquire a service port address allocated by a service node; the service port address is distributed from the available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end;
a health check object determining module 1602, configured to determine a micro service in an application node as a health check object in a case where the micro service invokes a health check client;
a connection module 1603 for establishing an inspection channel with the health inspection client based on the service port address;
The health check module 1604 is configured to communicate with a health check client based on the check channel, and perform health check on the micro-service by the health check client to obtain a health check result of the micro-service.
In some embodiments, the connection module 1603 is specifically for: starting a service port corresponding to the service port address; under the condition that the micro-service calls the health check client, acquiring a connection request sent by the health check client; the connection request is sent by the health check client through the service port under the condition of acquiring the service port address; in response to the connection request, a check channel is established with the health check client.
In some embodiments, the health check module 1604 is specifically for: acquiring a micro service identifier of the micro service by checking a channel; adding the micro-service into the polling list based on the micro-service identification; according to the polling list, the polling mechanism is based on communication with a health check client, and the health check client performs health check on the micro-service to obtain a health check result of the micro-service.
In some embodiments, the health check module 1604 is further for: under the condition that the health check result is abnormal, removing the micro-service from the polling list, and updating the state of the micro-service into an on-hook state; responding to a micro-service registration event triggered when the health check client is called, and acquiring a micro-service identifier of a registration micro-service for calling the health check client; under the condition that the registration micro service is determined to be the restart micro service based on the micro service identification, the registration micro service is added into a polling list; restarting the micro-service refers to the micro-service that once establishes a check channel with the health check server by calling the health check client, but is currently in an on-hook state.
In some embodiments, the micro-service health check device 1600 further comprises a channel stability check module for: through the checking channel, communication with the health checking client based on a heartbeat mechanism, determining the stability of the checking channel; in the case of an unstable inspection channel, the communication connection with the health inspection client is disconnected.
In some embodiments, the health check client includes a first health check client invoked by a first micro-service and a second health check client invoked by a second micro-service. In the case of this embodiment, the micro-service health check device 1600 further includes a message forwarding module for: the communication message between the first micro-service and the second micro-service is forwarded based on a first inspection channel with the first health check client and a second inspection channel with the second health check client.
The respective modules in the above-described micro-service health check device may be implemented in whole or in part by software, hardware, and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In some embodiments, a computer device, which may be a terminal or a server, is provided, and in this embodiment, an example in which the computer device is a server is described, and an internal structure thereof may be as shown in fig. 17. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing the data involved in the above method. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a micro-service health check method.
It will be appreciated by persons skilled in the art that the architecture shown in fig. 17 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements are applicable, and that a computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In some embodiments, a computer device is provided comprising a memory having a computer program stored therein and a processor that when executing the computer program performs the steps of the micro-service health check method described above.
In some embodiments, a computer readable storage medium is provided, on which a computer program is stored which, when executed by a processor, implements the steps in the micro-service health check method described above.
In some embodiments, a computer program product is provided comprising a computer program which, when executed by a processor, implements the steps in the micro-service health check method described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magneto-resistive random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.
Claims (16)
1. A method for micro-service health inspection, applied to a health inspection server, the method comprising:
acquiring a service port address allocated by a service node; the service port address is distributed from available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end;
in the case that a micro-service in an application node invokes a health check client, determining the micro-service as a health check object;
establishing an inspection channel between the health inspection client and the health inspection client based on the service port address;
And based on the communication of the checking channel and the health checking client, health checking is carried out on the micro service through the health checking client, and a health checking result of the micro service is obtained.
2. The method of claim 1, wherein the establishing a check channel with the health check client based on the service port address comprises:
starting a service port corresponding to the service port address;
under the condition that the micro-service calls the health check client, acquiring a connection request sent by the health check client; the connection request is sent by the health check client through the service port under the condition that the service port address is acquired;
in response to the connection request, a check channel is established with the health check client.
3. The method of claim 1, wherein the communicating with the health check client based on the check channel, by the health check client, health checking the micro-service, obtaining a health check result for the micro-service, comprises:
Acquiring a micro service identifier of the micro service through the checking channel;
adding the micro service to a polling list based on the micro service identification;
And according to the polling list, communicating with the health check client based on a polling mechanism, and performing health check on the micro service through the health check client to obtain a health check result of the micro service.
4. A method according to claim 3, characterized in that the method further comprises:
removing the micro-service from the polling list and updating the state of the micro-service to an on-hook state under the condition that the health check result is abnormal;
Responding to a micro-service registration event triggered when the health check client is called, and acquiring a micro-service identifier of a registration micro-service for calling the health check client;
Adding the registered micro service to the polling list under the condition that the registered micro service is determined to restart the micro service based on the micro service identifier; the restart micro-service refers to a micro-service which establishes a checking channel with the health checking server by calling the health checking client, but is currently in an on-hook state.
5. The method according to claim 1, wherein the method further comprises:
determining, by the inspection channel, stability of the inspection channel based on a heartbeat mechanism in communication with the health inspection client;
and in the case that the checking channel is unstable, disconnecting the communication connection with the health checking client.
6. The method of any one of claims 1 to 5, wherein the health check client comprises a first health check client called by a first micro-service and a second health check client called by a second micro-service; the method further comprises the steps of:
Forwarding a communication message between the first micro-service and the second micro-service based on a first inspection channel with the first health check client and a second inspection channel with the second health check client.
7. The micro-service health check system is characterized by comprising a health check server and a health check client;
in the case that a micro-service in an application node invokes the health check client, determining the micro-service as a health check object;
The health examination client and the health examination server establish an examination channel based on the service port address of the health examination server; the service port address is allocated from available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end;
And the health check server communicates with the health check client based on the check channel, and performs health check on the micro service through the health check client to obtain a health check result of the micro service.
8. The system of claim 7, further comprising a data storage node;
the data storage node updates a micro-service list of the application node and stores service information of the micro-service under the condition that the micro-service calls the health check client;
The data storage node is further configured to store a service port address of the health check server.
9. The system of claim 8, wherein at least a first micro-service and a second micro-service are deployed in the application node; the health check client comprises at least a first health check client called by the first micro-service and a second health check client called by the second micro-service;
the first health check client acquires the service port address from the data storage node under the condition of being called by the first micro service, and establishes a check channel with the health check server based on the service port address;
the first health check client writes the service port address into a local storage space of the application node;
and the second health check client acquires the service port address from the local storage space under the condition of being called by the second micro service, and establishes a check channel with the health check server based on the service port address.
10. The system of claim 7, wherein the number of health check servers is at least two; each health examination server is deployed at different service nodes in the form of plug-ins;
under the condition that the micro service calls the health check client, the health check client obtains the respective load weight of each health check server, and determines a target server from each health check server based on each load weight;
And the health check client and the target server establish a check channel based on the service port address of the target server.
11. The system according to any one of claims 7 to 10, characterized in that: the health check server comprises a downtime server and an available server; each health examination server is deployed at different service nodes in the form of plug-ins;
Under the condition that a downtime server exists in each health inspection server, a target client connected with the downtime server acquires a service port address of an available server, and establishes a standby inspection channel with the available server based on the service port address of the available server; the target client is a health check client for establishing a standby check channel in the first health check clients connected with the downtime server;
The target client updates the available identifier of the available server so that each non-target client obtains the service port address of the available server and establishes a standby check channel with the available server based on the service port address of the available server; the non-target clients are health check clients except the target clients in the health check clients connected with the downtime server.
12. The system according to any one of claims 7 to 10, characterized in that: the system also comprises a health examination configuration end which is connected with the health examination service end and the health examination client end;
The health check configuration end is used for responding to the working parameter configuration event and configuring working parameters for the health check service end and the health check client.
13. A micro-service health inspection device, the device comprising:
the acquisition module is used for acquiring the service port address distributed by the service node; the service port address is distributed from available server ports according to the port occupation condition of the service node under the condition that the service node calls the health check service end;
The health examination object determining module is used for determining the micro service as a health examination object when the micro service in the application node calls the health examination client;
The connection module is used for establishing an inspection channel between the health inspection client and the health inspection client based on the service port address;
and the health check module is used for communicating with the health check client based on the check channel, and carrying out health check on the micro service through the health check client to obtain a health check result of the micro service.
14. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
15. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
16. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310355931.2A CN118694651A (en) | 2023-03-23 | 2023-03-23 | Microservice health check method, device, system and computer equipment |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310355931.2A CN118694651A (en) | 2023-03-23 | 2023-03-23 | Microservice health check method, device, system and computer equipment |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN118694651A true CN118694651A (en) | 2024-09-24 |
Family
ID=92776231
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310355931.2A Pending CN118694651A (en) | 2023-03-23 | 2023-03-23 | Microservice health check method, device, system and computer equipment |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN118694651A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119201503A (en) * | 2024-11-29 | 2024-12-27 | 珠海宇信易诚科技有限公司 | A system for microservice management |
-
2023
- 2023-03-23 CN CN202310355931.2A patent/CN118694651A/en active Pending
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119201503A (en) * | 2024-11-29 | 2024-12-27 | 珠海宇信易诚科技有限公司 | A system for microservice management |
| CN119201503B (en) * | 2024-11-29 | 2025-03-14 | 珠海宇信易诚科技有限公司 | A system for microservice management |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11856065B2 (en) | Data transmission for service integration between a virtual private cloud and an intranet | |
| CN110647559B (en) | Data processing method, related node and system | |
| CN112035276B (en) | A cross-platform and extensible RPC framework design method based on Java | |
| US7518983B2 (en) | Proxy response apparatus | |
| CN110389815A (en) | Task processing method, apparatus and system | |
| CN104199957A (en) | Redis universal agent implementation method | |
| CN106293887A (en) | Data base processing method and device | |
| CN112118315A (en) | Data processing system, method, apparatus, electronic device and storage medium | |
| US11153173B1 (en) | Dynamically updating compute node location information in a distributed computing environment | |
| CN102340410A (en) | Cluster management system and method | |
| CN113965576B (en) | Container-based big data acquisition method, device, storage medium and equipment | |
| CN112218342A (en) | A method, device and system for realizing core network sub-slice disaster tolerance | |
| KR102423812B1 (en) | Enabling stable decentralized M2M/IoT services | |
| CN112953982A (en) | Service processing method, service configuration method and related device | |
| CN118694651A (en) | Microservice health check method, device, system and computer equipment | |
| CN111641664B (en) | A crawler device service request method, device, system and storage medium | |
| CN113660121B (en) | Information management method and device based on distributed system and computer storage medium | |
| CN111385324A (en) | Data communication method, device, equipment and storage medium | |
| CN113157441A (en) | Distributed decentralized load balancing method and system | |
| CN117879955A (en) | Micro-service communication method, micro-service communication device, computer equipment and storage medium | |
| CN114915545B (en) | Application scheduling deployment management method based on DHCP network cluster | |
| CN114143730B (en) | Signaling processing method, communication system, electronic device and storage medium | |
| CN117155762A (en) | Fault isolation method and related device | |
| US9841929B1 (en) | Distributed system software infrastructure | |
| CN101997704A (en) | Method, device and network management server for realizing element location link state polling |
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 |