Note: Descriptions are shown in the official language in which they were submitted.
CA 03168289 2022-07-18
METHOD AND SYSTEM FOR MONITORING MICROSERVICES
BACKGROUND OF THE INVENTION
Technical Field
[0001] The present invention relates to the technical field of microservices,
and more particularly
to a method and a system for monitoring microservices.
Description of Related Art
[0002] Microservices refer to sets of small services developed from individual
applications.
Therein, every application runs in its own process, and communicates with a
lightweight
mechanism (usually an HTTP resource API). These services are constructed
around
business functions and can be separately deployed through a fully automatic
deployment
mechanism. Essentially, microservices are distributed applications. They
usually operate
on a cluster, and the cluster carries service instances.
[0003] Since microservices feature numerous individuals and various deployment
ways,
problems can raise everywhere, making monitoring of service statuses
particularly
difficult. In a conventional system for monitoring microservices, whenever a
new service
instance is added, a monitoring program has to be simultaneously deployed for
that
service instance, so that the monitoring program can collect monitoring data
as scheduled
and upload the data to a monitoring center where monitoring is performed.
[0004] However, the conventional system for monitoring microservices have the
following
shortcomings:
[0005] 1. The system has complicated configuration and is unable to do
monitoring automatically:
every time a service instance is added or gets offline, the corresponding
monitoring
program has to be configured, activated, or destroyed, and the system is
unable to sense
the need automatically; and
[0006] 2. The system takes resources and is less timely: a configuration
program is an
1
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
independent progress, which consumes certain machine resources, and due to a
scheduled
reporting mechanism it adopts, the system is unable to acquire the latest
service statuses
of microservices, making the monitoring less timely.
SUMMARY OF THE INVENTION
[0007] The objective of the present invention is to at least solve one of
technical problems of the
prior art or related arts. To this end, the present invention provides a
method and a system
for monitoring microservices.
[0008] Embodiments of the present invention provide the following technical
schemes.
[0009] In a first aspect, the present invention provides a method for
monitoring microservices,
the method comprises:
[0010] registering, by a service registering center, service instances of
microservices;
[0011] sending, by a monitoring center, a status acquiring request to a
service gateway;
[0012] receiving, by the service gateway, the status acquiring request, and
acquiring registering
record of the service instance designated by the status acquiring request from
the service
registering center;
[0013] the service gateway according to the registering record, checking
service status of the
designated service instance, and sending a query result of the service status
to the
monitoring center; and
[0014] receiving, by the monitoring center, the query result of the service
status and performing
a corresponding operation.
[0015] Further, after the step of registering, by a service registering
center, service instances of
microservices, the method further comprises:
[0016] maintaining, by the service registering center, communication with the
service instances
using a heartbeat mechanism, and when the communication has been interrupted
longer
than a predetermined time period, cancelling, by the service registering
center, the service
instances.
[0017] Further, the service gateway, according to the registering records,
queries service status
2
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
of the designated service instances through:
[0018] retrieving a network address of the designated service instance from
the registering record;
and
[0019] according to the network address, sending a querying request for the
service status to the
designated service instance, and receiving the query result of the service
status of the
designated service instance.
[0020] Further, the service status comprises one or more of a CPU utilization
rate, a memory
utilization rate, disk reading and writing, network connectivity, heapSize
information, and
heapUsedSize information.
[0021] Further, the corresponding operation comprises:
[0022] storing the query result of the service status; and/or
[0023] displaying the query result of the service status on a page; and/or
[0024] according to the query result of the service status, warning of the
service instance having
the abnormal service status.
[0025] In a second aspect, the present invention provides a system for
monitoring microservices.
The system comprises a service registering center, a monitoring center, and a
service
gateway, therein:
[0026] the service registering center, for registering service instances of
microservices;
[0027] the monitoring center, for sending a status acquiring request to the
service gateway;
[0028] the service gateway comprising:
[0029] a pre-filter, for receiving the status acquiring request;
[0030] a route filter, for acquiring registering record of the service
instance designated by the
status acquiring request from the service registering center, and according to
the
registering record, checking service status of the designated service
instance;
[0031] a post-filter, for sending a query result of the service status to the
monitoring center; and
[0032] the monitoring center, further for receiving the query result of the
service status and
performing a corresponding operation.
[0033] Further, the service registering center is further for:
[0034] maintaining communication with the service instances using a heartbeat
mechanism, and
3
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
when the communication has been interrupted longer than a predetermined time
period,
cancelling the service instances.
[0035] Further, the route filter comprises:
[0036] a service processor, for retrieving a network address of the designated
service instance
from the registering record; and
[0037] a broadcasting plug-in, for according to the network address, sending a
querying request
for the service status to the designated service instance, and receiving the
query result of
the service status of the designated service instance.
[0038] Further, the service status comprises one or more of a CPU utilization
rate, a memory
utilization rate, disk reading and writing, network connectivity, heapSize
information, and
heapUsedSize information.
[0039] Further, the monitoring center is specifically for:
[0040] storing the query result of the service status;
[0041] displaying the query result of the service status on a page;
[0042] according to the query result of the service status, warning of the
service instance having
the abnormal service status.
[0043] The technical schemes provided in the embodiments of the present
invention have the
following beneficial effects:
[0044] 1. Scaling-up or scaling-down of microservices requires no manual
configuration, and
service instances of microservices can be dynamically acquired through a
service
registering center, thereby accomplishing automatic sensing of service
instances and in
turn enhancing convenience of microservice monitoring; and
[0045] 2. Different from the conventional approach where service statuses are
uploaded in a
scheduled manner, embodiments of the present invention allow a monitoring
center to
acquire the latest service statuses of service instances in a real-time manner
through a
service gateway, and are therefore more features high timeliness without using
any
monitoring program that consumes resources.
4
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
BRIEF DESCRIPTION OF THE DRAWINGS
[0046] To better illustrate the technical schemes as disclosed in the
embodiments of the present
invention, accompanying drawings referred in the description of the
embodiments below
are introduced briefly. It is apparent that the accompanying drawings as
recited in the
following description merely provide a part of possible embodiments of the
present
invention, and people of ordinary skill in the art would be able to obtain
more drawings
according to those provided herein without paying creative efforts, wherein:
[0047] FIG. 1 is a flowchart of a method for monitoring microservices
according to Embodiment
1 of the present invention; and
[0048] FIG. 2 is a block diagram of a system for monitoring microservices
according to
Embodiment 2 of the present invention.
DETAILED DESCRIPTION OF THE INVENTION
[0049] To make the foregoing objectives, features, and advantages of the
present invention
clearer and more understandable, the following description will be directed to
some
embodiments as depicted in the accompanying drawings to detail the technical
schemes
disclosed in these embodiments. It is, however, to be understood that the
embodiments
referred herein are only a part of all possible embodiments and thus not
exhaustive. Based
on the embodiments of the present invention, all the other embodiments can be
conceived
without creative labor by people of ordinary skill in the art, and all these
and other
embodiments shall be encompassed in the scope of the present invention.
[0050] It is to be understood that, in the disclosure, the terms "first,"
"second," and the like are
merely descriptive and not intended to suggest or imply relative importance.
Additionally,
in the disclosure, whenever "plural" is used, it means that the described
object comes in
two or more than two unless the context indicates otherwise.
[0051] FIG. 1 is a flowchart of a method for monitoring microservices
according to Embodiment
1 of the present invention. As shown, the method may comprise the following
steps.
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
[0052] At the step 101, a service registering center registers service
instances of microservices.
[0053] Specifically, the service registering center receives registering
information of the service
instances that sent actively when the microservices are activated, and
registers the service
instances according to the registering information of the service instances.
[0054] Therein, the registering information includes microservice names,
network addresses,
ports, and service instances.
[0055] After the service registering center registers the service instances of
the microservices, it
generates and stores registering records of the service instances, for a
service gateway to
call and use the registering information of the service instances later.
[0056] In an exemplificative implementation, after the step 101, the method
further comprises:
[0057] maintaining, by the service registering center, communication with the
service instances
using a heartbeat mechanism, and when the communication has been interrupted
longer
than a predetermined time period, cancelling the service instance.
[0058] Specifically, after the microservices are activated, heartbeats are
sent to the service
registering center at a predetermined cycle (for example, 30 seconds). If the
service
registering center has not received the heartbeat of a service instance of the
microservice
by the end of a predetermined time period (for example, 90 seconds), it
cancels that
service instance.
[0059] In the embodiment of the present invention, with the service
registering center registering
the service instances of microservices, the present invention can enhance
convenience of
monitoring. Particularly, scaling-up or scaling-down of microservices requires
no manual
configuration, and service instances of microservices can be dynamically
acquired
through a service registering center, thereby accomplishing automatic sensing
of service
instances and in turn enhancing convenience of microservice monitoring.
[0060] At the step 102, a monitoring center sends a status acquiring request
to a service gateway.
[0061] In the present embodiment, the status acquiring request may be an http
request, and the
status acquiring request may contain the network address of the designated
service
instance. The designated service instance may be a single service instance, or
may be
plural service instances. In addition, when there is not a certain service
instance
6
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
designated, the service instance designated in the status acquiring request
includes all
service instances that have been registered in the service registering center.
[0062] Therein, the service gateway is a distributed service gateway
configured using
SpringCloud+Zuul.
[0063] In the embodiment of the present invention, the service gateway employs
a distributed,
decentralized deployment architecture, thereby eliminating the need of
deploying
monitoring programs for individual service instances as required in the prior
art. This in
turn prevent system crashes that might otherwise be caused by monitoring
programs and
in turn prevents single point problems, thereby providing good availability.
[0064] At the step 103, the service gateway receives the status acquiring
request, and acquires
registering records of the service instances as designated in the status
acquiring request
from the service registering center.
[0065] Therein, the service gateway comprises internal components such as pre-
filters, route
filters, and post-filters. Therein, the route filter further comprises a
broadcasting plug-in
and a service processor.
[0066] Specifically, the process may comprise the following steps.
[0067] First, the pre-filter in the service gateway receives the status
acquiring request, and pre-
processes the status acquiring request. Further, before pre-processing the
status acquiring
request, the pre-filter may verify the status acquiring request.
[0068] Then the service processor in the route filter acquires registering
records of the service
instances designated by the status acquiring request from the service
registering center
according to a load balancing strategy, and receives the registering records
of the service
instances designated by the status acquiring request from the service
registering center.
[0069] It is to be noted that if the status acquiring request designates a
service instance that is not
registered in the service registering center, the service gateway generates a
request failure
message to indicate that the service instance designated in the status
acquiring request
has not been registered and send the request failure information to the
monitoring center.
[0070] At the step 104, the service gateway queries a service status of the
designated service
instance according to the registering records, and sends a query result of the
service status
7
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
to the monitoring center.
[0071] Specifically, the process may comprise the following steps.
[0072] First, the broadcasting plug-in in the route filter acquires the
network address of the
designated service instance from the registering record, and broadcasts the
status
acquiring request to the service instance designated in the status acquiring
request. It
subsequently receives the query result of the service status sent back by the
designated
service instance.
[0073] Then the post-filter in the service gateway packages the query result
of the service status
and sends it to the monitoring center.
[0074] Therein, the service status comprises one or more of a CPU utilization
rate, a memory
utilization rate, disk reading and writing, network connectivity, heapSize
information, and
heapUsedSize information.
[0075] At the step 105, receiving, by the monitoring center, the query result
of the service status
and performing a corresponding operation.
[0076] Specifically, the corresponding operation the monitoring center
performs on the query
result of the service status may include:
[0077] storing the query result of the service status; and/or
[0078] displaying the query result of the service status on a page; and/or
[0079] according to the query result of the service status, warning of the
service instance having
the abnormal service status.
[0080] Specifically, the query result of the service status is analyzed to
determine whether the
service status of the service instance is normal or not. In the event of
abnormality, a
warning is given to inform the user timely, thereby allowing the user to take
action for
the abnormal service instance timely.
[0081] In the embodiment of the present invention, the monitoring center may
use the "service
broadcasting function" of the service gateway to acquire the service
status(es) of the
designated service instance or of all the service instances that have been
registered in the
service registering center in a real-time manner, thereby realizing real-time
acquisition of
the latest service statuses of the service instances. As compared to the
conventional
8
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
approach where service statuses are uploaded as scheduled, the present
invention can
significantly enhance monitoring in terms of timeliness.
[0082] FIG. 2 is a block diagram of a system for monitoring microservices
according to
Embodiment 2 of the present invention. The system comprises a service
registering center
21, a monitoring center 22, and a service gateway 23.
[0083] The service registering center 21 is for registering service instances
of microservices.
[0084] The monitoring center 22 is for sending a status acquiring request for
a target service
instance to the service gateway.
[0085] The service gateway 23 comprises:
[0086] a pre-filter 231, for receiving the status acquiring request;
[0087] a route filter 232, for acquiring the registering record of the service
instance designated
in the status acquiring request from the service registering center, and
according to
registering records, checking the service status of the designated service
instance; and
[0088] a post-filter 233, for sending the query result of the service status
of the target service
instance to the monitoring center 22; and
[0089] the monitoring center 22, further for receiving the query result of the
service status and
performing a corresponding operation.
[0090] Further, service registering center 21 is further for:
[0091] maintaining communication with the service instances using a heartbeat
mechanism, and
when the communication has been interrupted longer than a predetermined time
period,
cancelling the service instances.
[0092] Further, the route filter 232 comprises:
[0093] a service processor, for acquiring the network address of the
designated service instance
from the registering record; and
[0094] a broadcasting plug-in, for according to network address, sending a
request for checking
the service status to the designated service instance, and receiving the query
result of the
service status from the designated service instance.
[0095] Further, service status comprises one or more of a CPU utilization
rate, a memory
utilization rate, disk reading and writing, network connectivity, heapSize
information, and
9
Date Regue/Date Received 2022-07-18
CA 03168289 2022-07-18
heapUsedSize information.
[0096] Further, the monitoring center 22 is specifically for:
[0097] storing the query result of the service status;
[0098] displaying the query result of the service status on a page; and
[0099] according to the query result of the service status, warning of the
service instance having
the abnormal service status.
[0100] It is to be noted that work division among the foregoing functional
modules for the system
for monitoring microservices of the present embodiment is merely exemplary. In
practical
implementations, the work division may be made among different functional
modules. In
other words, the internal architecture of the system for monitoring
microservices may be
reconfigured with different functional modules to perform all or a part of the
functions as
described previously. In addition, since the system for monitoring
microservices of the
present embodiment and the disclosed method for monitoring microservices in
the
previous embodiment stem from the same conception, the details of its
implementation
can be learned from the description made to the method of the previous
embodiment, and
no repetition is made herein.
[0101] People of ordinary skill in the art would appreciate that all or part
of the steps as described
in the foregoing embodiments may be implemented using hardware, or may
alternatively
be implemented using a program that instructs relevant hardware. The program
may be
stored in a computer readable storage medium, and the storage medium may be a
read-
only storage, a magnetic disk, an optical disk, or the like.
[0102] The present invention has been described with reference to the
preferred embodiments
and it is understood that the embodiments are not intended to limit the scope
of the present
invention. Moreover, as the contents disclosed herein should be readily
understood and
can be implemented by a person skilled in the art, all equivalent changes or
modifications
which do not depart from the concept of the present invention should be
encompassed by
the appended claims. Hence, the scope of the present invention shall only be
defined by
the appended claims.
Date Regue/Date Received 2022-07-18