CN115190178A - Micro-service distribution method, device and equipment - Google Patents

Micro-service distribution method, device and equipment Download PDF

Info

Publication number
CN115190178A
CN115190178A CN202210958975.XA CN202210958975A CN115190178A CN 115190178 A CN115190178 A CN 115190178A CN 202210958975 A CN202210958975 A CN 202210958975A CN 115190178 A CN115190178 A CN 115190178A
Authority
CN
China
Prior art keywords
service
target service
target
connection
unavailable
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210958975.XA
Other languages
Chinese (zh)
Other versions
CN115190178B (en
Inventor
鲁永泉
卢创
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Chuangyiyun Network Technology Co ltd
Original Assignee
Suzhou Chuangyiyun Network Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Suzhou Chuangyiyun Network Technology Co ltd filed Critical Suzhou Chuangyiyun Network Technology Co ltd
Priority to CN202210958975.XA priority Critical patent/CN115190178B/en
Publication of CN115190178A publication Critical patent/CN115190178A/en
Application granted granted Critical
Publication of CN115190178B publication Critical patent/CN115190178B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0817Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking functioning

Landscapes

  • Engineering & Computer Science (AREA)
  • Environmental & Geological Engineering (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The embodiment of the specification provides a micro-service shunting method, a device and equipment. The method comprises the following steps: responding to a calling request of a calling party, and acquiring micro service requested to be called by the calling request as target service; determining whether the target service meets a preset service exception rule; establishing a connection between the caller and the target service upon determining that the target service satisfies the service exception rule; under the condition that the connection between the calling party and the target service is not successfully established within a preset time, determining that the target service is an unavailable service; and marking the target service as an unavailable service, feeding the unavailable service back to a service discovery center, and suspending the calling of the target service. Based on the method, the service discovery center can know that the called micro service is the unavailable service in real time, so that the service connection efficiency is improved, and the cost for discovering the abnormal service is reduced.

Description

Micro-service distribution method, device and equipment
Technical Field
The present application relates to the field of micro service technologies, and in particular, to a method, an apparatus, and a device for distributing micro services.
Background
Microservices serve a distributed system, being a decentralized system. Service deployment spans hosts, network segments, machine rooms, and even large areas. Calls are made between the services via an RPC (remote procedure call).
When the existing method is used for remotely calling and connecting two micro services, once the called micro service is abnormal, the calling party can only end up with failure, and the service discovery center cannot know that the called service is unavailable at the moment in real time, so that the problems of low service connection efficiency, high service abnormal discovery and the like are caused.
In view of the above technical problems, no effective solution has been proposed.
Disclosure of Invention
Embodiments of the present specification provide a method, an apparatus, and a device for splitting a micro service, which can find whether a called micro service is an unavailable service in time, thereby reducing a cost for discovering an abnormal service and improving connection efficiency between services.
In one aspect, the present application provides a method for offloading a micro-service, including:
responding to a calling request of a calling party, and acquiring micro service requested to be called by the calling request as target service;
determining whether the target service meets a preset service exception rule or not;
establishing a connection between the caller and the target service upon determining that the target service satisfies the service exception rule;
under the condition that the connection between the calling party and the target service is not successfully established within a preset time, determining that the target service is an unavailable service;
and marking the target service as an unavailable service, feeding the unavailable service back to a service discovery center, and suspending the calling of the target service.
Further, the determining that the target service is an unavailable service in the case that the connection between the caller and the target service is not successfully established within a predetermined time period includes:
acquiring an initial weight value of the target service;
dividing the preset time into a plurality of interval periods, and repeatedly executing the following operations until the current weight value of the target service is smaller than a preset weight threshold value, or the caller and the target service successfully establish connection: determining whether the connection between the current interval period caller and the target service is not successfully established; under the condition that the connection is not successfully established, reducing the current weight value of the target service according to a preset proportion;
determining the target service as an unavailable service under the condition that the current weight value is smaller than a preset weight threshold value;
and under the condition that the connection between the caller and the target service is successfully established, completing the establishment of the connection between the caller and the target service, and restoring the weight value of the target service to the initial weight value.
Further, the obtaining the micro service requested to be called by the call request as a target service includes:
acquiring identification information of the micro service requested to be called from the calling request;
determining target address information of the micro service requested to be called from a service list according to the identification information;
and calling the target service according to the target address information.
Further, the determining whether the target service meets a preset service exception rule includes:
determining whether a message returned by the target service comprises an error code, whether the return time of the target service exceeds a preset time threshold value, and whether the network connection of the target service is available;
in the event that it is determined that the target service exists one or more of: the message returned by the target service comprises an error code, the return time of the target service exceeds a preset time threshold value, the network connection of the target service is unavailable, and the target service is determined to meet a preset service exception rule.
Further, the marking the target service as an unavailable service and feeding back the service to a service discovery center, and after suspending the call to the target service, further comprising:
deleting the registration information of the target service in the service discovery center;
performing off-line detection processing on the target service;
after the offline detection processing is passed, receiving a registration request of the target service in the service discovery center;
in response to the registration request, adding registration information for the target service in the service discovery center.
In another aspect, the present application provides a micro-service shunt device, including:
the calling module is used for responding to a calling request of a calling party and acquiring the micro service requested to be called by the calling request as a target service;
the judging module is used for determining whether the target service meets a preset service exception rule or not;
the connection module is used for establishing the connection between the caller and the target service under the condition that the target service is determined to meet the service exception rule;
the unavailability determining module is used for determining that the target service is an unavailable service under the condition that the connection between the calling party and the target service is not successfully established within a preset time period;
and the marking module is used for marking the target service as an unavailable service, feeding the unavailable service back to the service discovery center and suspending the calling of the target service.
Further, the apparatus further comprises:
a deleting module, configured to delete registration information of the target service in the service discovery center;
the off-line detection module is used for carrying out off-line detection processing on the target service;
the registration module is used for receiving a registration request of the target service in the service discovery center after the offline detection processing is passed; in response to the registration request, adding registration information for the target service in the service discovery center.
Further, the apparatus further comprises:
and the service exception rule determining module is used for determining whether the message returned by the target service comprises an error code, whether the return time of the target service exceeds a preset time threshold value, and whether the network connection of the target service is available.
On the other hand, the present application further provides a micro-service offloading device, including a processor and a memory for storing processor-executable instructions, where the processor executes the instructions to implement the steps of any one of the method embodiments in this specification.
In still another aspect, the present application further provides a computer-readable storage medium, on which computer instructions are stored, and when the computer-readable storage medium executes the instructions, the method for distributing microservices is implemented.
The method, the device and the equipment for distributing the micro-services provided by the specification can be used for responding to a calling request of a calling party, acquiring the micro-services requested to be called by the calling request as target services, and then determining whether the target services meet preset service exception rules or not, so that the target services can be preliminarily judged, and a foundation is laid for subsequently determining whether the target services are unavailable services or not. Further, under the condition that the target service is determined to meet the service exception rule, connection between the caller and the target service is established, under the condition that the caller and the target service are not successfully established within a preset time period, the target service is determined to be an unavailable service, the target service is marked as the unavailable service and fed back to a service discovery center, and calling of the target service is suspended. By the scheme, the service discovery center can know whether the invoked micro service is unavailable in real time, so that the condition that the invoker continuously invokes the unavailable service is avoided, the discovery cost of service abnormity can be reduced, and the service connection efficiency is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification, are incorporated in and constitute a part of this specification, and are not intended to limit the specification. In the drawings:
fig. 1 is a schematic flow chart diagram illustrating an embodiment of a micro-service offloading method provided in this specification;
FIG. 2 is a flow diagram illustrating a determination that a target service is an unavailable service in one embodiment of the present description;
fig. 3 is a schematic structural component diagram of a micro service shunt device provided in an embodiment of the present specification;
fig. 4 is a schematic structural component diagram of a micro service shunt device according to another embodiment of the present disclosure;
fig. 5 is a schematic structural component diagram of an electronic device provided in an embodiment of the present specification.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments in the present specification, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on one or more embodiments in the present specification without making any creative effort shall fall within the protection scope of the embodiments in the present specification.
Considering that when the existing method calls the micro-service remotely and performs connection, firstly the micro-service needs to register with the service discovery center, the caller requests the service discovery center for the IP and the port where the service is located according to the request name, and the service discovery center randomly sends one of the qualified service connection modes to the caller according to the requirement. The calling party directly calls and connects after taking the address, at this time, if the called micro-service is abnormal, the calling of the calling party can only end with failure, and the service discovery center cannot know that the micro-service is unavailable in real time, so that service connection failure can be caused, and the service connection efficiency is reduced.
Aiming at the problems of the existing method, the method for shunting the micro service can be introduced, whether the micro service is available or not can be judged in a new mode, and meanwhile, the unavailable micro service is fed back to the service discovery center in time under the condition that the micro service is unavailable, so that the service connection speed can be improved, the abnormal service discovery can be reduced, and the service connection process can be simplified.
Based on the above thought, the present specification provides a micro-service offloading method. Firstly, responding to a calling request of a calling party, and acquiring a micro service requested to be called by the calling request as a target service. Secondly, determining whether the target service meets a preset service exception rule, and establishing the connection between the caller and the target service under the condition that the target service is determined to meet the service exception rule. And finally, under the condition that the connection between the caller and the target service is not successfully established within a preset time, determining that the target service is an unavailable service, marking the target service as the unavailable service, feeding the unavailable service back to a service discovery center, and suspending the call of the target service. Referring to fig. 1, an embodiment of the present disclosure provides a method for offloading micro services. In particular implementations, the method may include the following.
S101: and responding to the calling request of a calling party, and acquiring the micro service requested to be called by the calling request as a target service.
In some embodiments, the obtaining, as the target service, the micro service requested to be called by the call request may include:
s1: acquiring identification information of the micro service requested to be called from the calling request;
s2: determining target address information of the micro service requested to be called from a service list according to the identification information;
s3: and calling the target service according to the target address information.
In some embodiments, the identification information may be a name identification of the micro service, the target Address information may be an IP Address (Internet Protocol Address, colloquially referred to as IP), and the service list may be a database containing network addresses of all service instances (IP addresses corresponding to services and short names of service ports), where the IP Address provides a credential for finding the machine on the Internet, and the service port provides a credential for finding a process providing the service on the machine.
In some embodiments, the service list may be an automatically generated upstream configuration table. When a service instance sends a change, the upstream can be updated according to the automatic update mechanism of the service discovery center. It should be noted that, if the number of the micro-services itself is not huge, a manual configuration service list may be considered instead of an automatic configuration, and this specification is not limited to this. By generating the upstream configuration table, a callable service list can be provided, and meanwhile, when the instance of the called micro-service is changed (service is newly added/deleted), the service list can update the latest state list in time and inform the latest state list to the caller in a proper mode.
In some embodiments, when a service starts, the microservice registers in service discovery, storing its own IP, port, and name information in a service list. When a caller requests to call a micro service (target service) under a certain name identifier, the caller can query the IP and port of the micro service corresponding to the name identifier from the service list according to the name identifier, and then call the target service according to the IP and port of the micro service. It should be noted that if there are multiple IPs and ports for the target service, one of the service instances may be selected to respond to the invocation request based on the load balancing algorithm.
S102: and determining whether the target service meets a preset service exception rule.
In some embodiments, the determining whether the target service satisfies the preset service exception rule may include, in specific implementation:
s1: determining whether a message returned by the target service comprises an error code, whether the return time of the target service exceeds a preset time threshold value, and whether the network connection of the target service is available;
s2: in the event that it is determined that the target service exists one or more of: the message returned by the target service comprises an error code, the return time of the target service exceeds a preset time threshold value, the network connection of the target service is unavailable, and the target service is determined to meet a preset service exception rule.
In some embodiments, if the message returned by the target service includes an error code, it may be understood that the message returned by the target service is abnormal or has an error, and the message returned accordingly includes an error code and/or error information, where the return time of the target service exceeding the preset time threshold may be understood that the target service is not successfully connected or returned within the preset time threshold, and the unavailability of the network connection of the target service may be understood as a network abnormality of the target service. It should be noted that, as long as any one of the above service exception rules exists in the target service, the target service satisfies the service exception rule. By setting the service abnormal rule, whether the micro service has an abnormal phenomenon or not can be preliminarily judged, and a foundation is laid for subsequent right reduction treatment under the condition of meeting the service abnormal rule.
In some embodiments, in addition to determining that the target service satisfies the preset service exception rule, in a specific implementation, the method may further include: in a case that it is determined that the target service does not exist more than: the message returned by the target service comprises an error code, the return time of the target service exceeds a preset time threshold value, the network connection of the target service is unavailable, and the connection between a calling party and the target service can be directly completed if the target service is determined not to meet a preset service exception rule. It should be noted that, when the target service does not satisfy the abnormal service rule, each rule in the abnormal service rule needs to be not satisfied, and if the target service does not satisfy only one of the rules, the rule does not hold, for example: the message returned by the target service does not meet the requirement of the target service comprises an error code, but the return time meeting the requirement of the target service exceeds a preset time threshold value, and the network connection of the target service is unavailable, so that the target service does not belong to the condition of not meeting the service abnormal rule at the moment.
S103: establishing a connection between the caller and the target service upon determining that the target service satisfies the service exception rule.
In some embodiments, the target service meeting the service exception rule is connected with the caller, and whether the target service meeting the service exception rule is an unavailable service can be determined, so that the problems that the efficiency of service connection is too low and the like caused by the connection of the caller and the unavailable service can be avoided. How to determine whether the target service is an unavailable service will be described in detail later, and will not be described herein again.
S104: and under the condition that the connection between the caller and the target service is not successfully established within a preset time, determining that the target service is an unavailable service.
In some embodiments, as shown in fig. 2, the determining that the target service is an unavailable service in the case that the caller and the target service do not successfully establish a connection within a predetermined time period may include:
s1: acquiring an initial weight value of the target service;
s2: dividing the preset time into a plurality of interval periods, and repeatedly executing the following operations until the current weight value of the target service is smaller than a preset weight threshold value, or the caller and the target service successfully establish connection: determining whether the connection between the current interval period caller and the target service is not successfully established; under the condition that the connection is not successfully established, reducing the current weight value of the target service according to a preset proportion;
s3: determining the target service as an unavailable service under the condition that the current weight value is smaller than a preset weight threshold value;
s4: and under the condition that the connection between the caller and the target service is successfully established, completing the establishment of the connection between the caller and the target service, and restoring the weight value of the target service to the initial weight value.
In some embodiments, the initial weight may be a weight value given to the target service before the target service performs the weight reduction; the weight is an important index of whether a service is available or not, and can be simply understood as: the process of weight from minimum to large can be a process of service from unhealthy to invincible. If the weight of a certain micro service is too low (unhealthy), the micro service is informed to be offline and self-checked, the micro service can be online again after the self-check is passed, the weight is reset, and the shunting service operation processing is accepted again. The process of the offline self-test will be further described, and will not be described herein.
In some embodiments, the dividing the predetermined time length into a plurality of interval periods may be understood as dividing the predetermined time length into a plurality of interval periods according to a certain period, for example: the preset time is 10 minutes, the period is 2 minutes, the period can be 5 interval periods, and the right drop operation of the caller and the target service or the right lifting operation after the caller and the target service are successfully connected can be continuously executed in the interval periods by dividing the interval periods. It should be noted that, the unsuccessful connection establishment between the caller and the target service within the predetermined time period may be that the caller and the target service do not establish a connection successfully in multiple interval periods, or that the caller and the target service establish a connection successfully in a certain interval period but do not establish a connection successfully in the next interval period, where the right reduction process needs to be performed continuously in the case that the connection is not established successfully in multiple interval periods, and the right improvement process needs to be performed in the case that the connection is established successfully in an interval period.
In some embodiments, the current weight value of the target service may be understood as a weight of the target service, which is further weighted down on the basis of the initial weight and is temporarily not further weighted down.
In some embodiments, the above-mentioned current weight value of the target service is smaller than a preset weight threshold, and determining that the target service is an unavailable service may be understood as comparing the reduced weight of the target service with a weight threshold (weight threshold), and determining that the target service is an unavailable service when the current weight is smaller than the threshold. The target service is marked as an unavailable service by performing weight reduction processing on the target service, judging whether the target service after the weight reduction processing can be connected with a calling party in the next interval period, and continuing to reduce the weight under the condition that the connection cannot be performed until the reduced weight is smaller than a preset weight threshold value, and performing weight improvement processing under the condition that the connection can be established, so that the service can be ensured to be more efficient. Whether the current target service is unavailable or not can be effectively determined through intelligent power increasing and decreasing processing, so that a foundation is laid for subsequent timely feedback to a service discovery center and avoiding that a large number of call requests are continuously sent to unstable services (unavailable services).
S105: and marking the target service as an unavailable service, feeding the unavailable service back to a service discovery center, and suspending the calling of the target service.
In some embodiments, the marking the target service as an unavailable service and feeding back the service to the service discovery center, and after suspending the call to the target service, in the implementation, the method may further include:
s1: deleting the registration information of the target service in the service discovery center;
s2: performing off-line detection processing on the target service;
s3: after the offline detection processing is passed, receiving a registration request of the target service in the service discovery center;
s4: in response to the registration request, adding registration information for the target service in the service discovery center.
In some embodiments, by marking a target service as an unavailable service and suspending calls to the target service, connection efficiency of the service may be ensured while reducing the cost of discovery of service exceptions.
In some embodiments, after the target service is stopped to be called, the registration information of the target service in the service discovery center is deleted, so that the situation that a calling party wrongly calls an unavailable service can be avoided; and the deleted target service is subjected to offline self-checking to determine whether the unavailable service can be on line again, so that the service acquisition cost is reduced.
The above method is described below with reference to a specific example, however, it should be noted that the specific example is only for better describing the present application and is not to be construed as limiting the present application.
Before specific implementation, firstly, a response caller sends a call request, and secondly, a service requested to be called by the caller is used as a target micro-service, wherein the target service requested to be called by the caller selects an IP address and a port corresponding to a name from a service list according to the name of the target service to call. In specific implementation, firstly, whether a target service meets a preset service exception rule is determined, that is, whether a message returned by the target service meets the target service includes one of an error code, the return time of the target service exceeds a preset time threshold, and the network connection of the target service is unavailable is determined, and under the condition that the target service meets the service exception rule, the connection between a calling party and the target service is established. Secondly, under the condition that the connection between the caller and the target service is not successfully established within the preset time, the weight of the target service is reduced within a certain interval period, the caller and the target service can not be successfully established within the interval period is judged, if the connection can not be successfully established, the weight reduction is continuously performed within the next interval period until the weight is reduced to be less than the critical value of the weight, the target service at the moment is an unavailable service, and if the connection can be successfully established, the weight of the reduced target service is recovered. And finally, feeding back the unavailable service to the service discovery center, and suspending the calling of the target service. By the method, the service discovery center can know whether the called micro service is unavailable or not in time, so that connection failure caused by connection of a calling party and the unavailable service can be avoided, and meanwhile, the connection efficiency of the service can be ensured through the right-to-go-down processing.
Although the present specification provides method steps as described in the examples or flowcharts, additional or fewer steps may be included based on conventional or non-inventive approaches. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an apparatus or client product in practice executes, it may execute sequentially or in parallel (e.g., in a parallel processor or multithreaded processing environment, or even in a distributed data processing environment) according to the embodiments or methods shown in the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, article, or apparatus that comprises the recited elements is not excluded. The terms first, second, etc. are used to denote names, but not any particular order.
Based on the above micro-service offloading method, one or more embodiments of the present specification further provide a micro-service offloading device. The apparatus may include systems (including distributed systems), software (applications), modules, components, servers, clients, etc. that use the methods described in the embodiments of this specification in conjunction with any necessary apparatus to implement the hardware. Based on the same innovative conception, embodiments of the present specification provide an apparatus as described in the following embodiments. Since the implementation scheme of the apparatus for solving the problem is similar to that of the method, the specific implementation of the apparatus in the embodiment of the present specification may refer to the implementation of the foregoing method, and repeated details are not repeated. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Specifically, fig. 3 is a schematic block diagram of an embodiment of a micro service shunt device provided in this specification, and as shown in fig. 3, the micro service shunt device provided in this specification may include: a calling module 301, a judging module 302, a connecting module 303, an unavailable determining module 304 and a marking module 305.
The calling module 301 is configured to respond to a calling request of a calling party, and obtain a micro service requested to be called by the calling request as a target service;
a determining module 302, configured to determine whether the target service meets a preset service exception rule;
a connection module 303, configured to establish a connection between the caller and the target service when it is determined that the target service satisfies the service exception rule;
an unavailable determining module 304, configured to determine that the target service is an unavailable service if the caller and the target service do not successfully establish a connection within a predetermined time period;
a marking module 305, configured to mark the target service as an unavailable service and feed back the service to the service discovery center, and suspend the call to the target service.
In some embodiments, the invoking module 301 may be specifically configured to obtain, from the invoking request, identification information of the micro service requested to be invoked; determining target address information of the micro service requested to be called from a service list according to the identification information; and calling the target service according to the target address information.
In some embodiments, the determining module 302 may be specifically configured to, when it is determined that the target service has one or more of the following: the message returned by the target service comprises an error code, the return time of the target service exceeds a preset time threshold value, the network connection of the target service is unavailable, and the target service is determined to meet a preset service exception rule.
In some embodiments, the unavailability determination module 304 may be specifically configured to obtain an initial weight value of the target service; dividing the preset time into a plurality of interval periods, and repeatedly executing the following operations until the current weight value of the target service is smaller than a preset weight threshold value, or the caller and the target service successfully establish connection: determining whether the connection between the current interval period caller and the target service is not successfully established; under the condition that the connection is not successfully established, reducing the current weight value of the target service according to a preset proportion; determining the target service as an unavailable service under the condition that the current weight value is smaller than a preset weight threshold value; and under the condition that the connection between the caller and the target service is successfully established, completing the establishment of the connection between the caller and the target service, and restoring the weight value of the target service to the initial weight value.
In some embodiments, the apparatus further comprises:
and the service exception rule determining module is used for determining whether the message returned by the target service comprises an error code, whether the return time of the target service exceeds a preset time threshold value, and whether the network connection of the target service is available.
In some embodiments, referring to fig. 4, the apparatus further comprises:
a deleting module 401, configured to delete registration information of the target service in the service discovery center;
an offline detection module 402, configured to perform offline detection processing on the target service;
a registration module 403, configured to receive a registration request of the target service in the service discovery center after the offline detection processing is passed; in response to the registration request, adding registration information for the target service in the service discovery center.
It should be noted that, the units, devices, modules, etc. illustrated in the above embodiments may be implemented by a computer chip or an entity, or implemented by a product with certain functions. For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. It is to be understood that, in implementing the present specification, functions of each module may be implemented in one or more pieces of software and/or hardware, or a module that implements the same function may be implemented by a combination of a plurality of sub-modules or sub-units, or the like. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
As can be seen from the above, based on the micro-service offloading device provided in the embodiments of the present specification, on one hand, a called target service can be divided by setting a service exception rule, that is, divided into two types, that is, a service exception rule is satisfied and a service exception rule is not satisfied, when a target service that does not satisfy the service exception rule is subjected to a power down process, whether the target service is an unavailable service can be determined, the unavailable service is marked and fed back to a service discovery center, and thus a large number of call requests can be sent to the unavailable (unstable) service. On the other hand, for the target service which does not meet the service abnormal rule, the connection between the calling party and the target service is established, and under the condition that the connection is not established successfully in the preset time, whether the connection can be established successfully between the calling party and the target service within a certain interval period is judged, if the connection can be established successfully, the right-lifting processing can be carried out, so that the service can be ensured to be more efficient, and if the connection cannot be established, the right is continuously reduced, so that a foundation is laid for finally determining the unavailable service.
The present application further provides a computer device, including a processor and a memory for storing processor-executable instructions, where the processor, when implemented, may perform the following steps according to the instructions: responding to a calling request of a calling party, and acquiring the micro service requested to be called by the calling request as a target service; determining whether the target service meets a preset service exception rule; establishing a connection between the caller and the target service upon determining that the target service satisfies the service exception rule; determining the target service as an unavailable service under the condition that the connection between the caller and the target service is not successfully established within a preset time; and marking the target service as an unavailable service, feeding the unavailable service back to a service discovery center, and suspending the calling of the target service.
In order to more accurately complete the above instructions, referring to fig. 5, the present specification further provides another specific electronic device, where the electronic device includes a network communication port 501, a processor 502, and a memory 503, and the above structures are connected by an internal cable, so that the structures may perform specific data interaction.
The network communication port 501 may be specifically configured to respond to a call request of a caller, and obtain a micro service requested to be called by the call request as a target service.
The processor 502 specifically determines whether the target service meets a preset service exception rule; under the condition that the target service is determined to meet the service exception rule, establishing connection between the calling party and the target service; determining the target service as an unavailable service under the condition that the connection between the caller and the target service is not successfully established within a preset time; and marking the target service as an unavailable service, feeding the unavailable service back to a service discovery center, and suspending the calling of the target service.
The memory 503 may be specifically configured to store a corresponding instruction program.
In this embodiment, the network communication port 501 may be a virtual port that is bound to different communication protocols, so that different data can be sent or received. For example, the network communication port may be a port responsible for web data communication, a port responsible for FTP data communication, or a port responsible for mail data communication. In addition, the network communication port can also be a communication interface or a communication chip of an entity. For example, it may be a wireless mobile network communication chip, such as GSM, CDMA, etc.; it can also be a Wifi chip; it may also be a bluetooth chip.
In this embodiment, the processor 502 may be implemented in any suitable manner. For example, the processor may take the form of, for example, a microprocessor or processor and a computer-readable medium that stores computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, an embedded microcontroller, and so forth. The description is not intended to be limiting.
In this embodiment, the memory 503 may include multiple layers, and in a digital system, the memory may be any memory as long as binary data can be stored; in an integrated circuit, a circuit without a physical form and with a storage function is also called a memory, such as a RAM, a FIFO and the like; in the system, the storage device in physical form is also called a memory, such as a memory bank, a TF card and the like.
Embodiments of the present specification further provide a computer storage medium for micro service offloading, where the computer storage medium stores computer program instructions, and when the computer program instructions are executed, the computer storage medium implements: responding to a calling request of a calling party, and acquiring the micro service requested to be called by the calling request as a target service; determining whether the target service meets a preset service exception rule; establishing a connection between the caller and the target service upon determining that the target service satisfies the service exception rule; under the condition that the connection between the calling party and the target service is not successfully established within a preset time, determining that the target service is an unavailable service; and marking the target service as an unavailable service, feeding the unavailable service back to a service discovery center, and suspending the calling of the target service.
In this embodiment, the storage medium includes, but is not limited to, a Random Access Memory (RAM), a Read-Only Memory (ROM), a Cache (Cache), a Hard Disk Drive (HDD), or a Memory Card (Memory Card). The memory may be used to store computer program instructions. The network communication unit may be an interface for performing network connection communication, which is set in accordance with a standard prescribed by a communication protocol.
Although the present specification provides method steps as described in the examples or flowcharts, additional or fewer steps may be included based on conventional or non-inventive approaches. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an apparatus or client product in practice executes, it may execute sequentially or in parallel (e.g., in a parallel processor or multithreaded processing environment, or even in a distributed data processing environment) according to the embodiments or methods shown in the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, article, or apparatus that comprises the recited elements is not excluded. The terms first, second, etc. are used to denote names, but not any particular order.
Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may therefore be considered as a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be conceived to be both a software module implementing the method and a structure within a hardware component.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
From the above description of the embodiments, it is clear to those skilled in the art that the present specification can be implemented by software plus necessary general hardware platform. With this understanding, the technical solutions in the present specification may be essentially embodied in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments in the present specification.
The embodiments in the present specification are described in a progressive manner, and the same or similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. The description is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
While the specification has been described with examples, those skilled in the art will appreciate that there are numerous variations and permutations of the specification without departing from the spirit of the specification, and it is intended that the appended claims encompass such variations and modifications without departing from the spirit of the specification.

Claims (10)

1. A method for offloading micro-services, comprising:
responding to a calling request of a calling party, and acquiring micro service requested to be called by the calling request as target service;
determining whether the target service meets a preset service exception rule;
establishing a connection between the caller and the target service upon determining that the target service satisfies the service exception rule;
determining the target service as an unavailable service under the condition that the connection between the caller and the target service is not successfully established within a preset time;
and marking the target service as an unavailable service, feeding the unavailable service back to a service discovery center, and suspending the calling of the target service.
2. The method of claim 1, wherein determining that the target service is an unavailable service in the case that the caller and the target service do not successfully establish a connection within a predetermined time period comprises:
acquiring an initial weight value of the target service;
dividing the preset time into a plurality of interval periods, and repeatedly executing the following operations until the current weight value of the target service is smaller than a preset weight threshold value, or the caller and the target service successfully establish connection: determining whether the connection between the current interval period caller and the target service is not successfully established; under the condition that the connection is not successfully established, reducing the current weight value of the target service according to a preset proportion;
determining the target service as an unavailable service under the condition that the current weight value is smaller than a preset weight threshold value;
and under the condition that the connection between the caller and the target service is successfully established, completing the establishment of the connection between the caller and the target service, and restoring the weight value of the target service to the initial weight value.
3. The method of claim 1, wherein obtaining the micro-service requested to be called by the call request as a target service comprises:
acquiring identification information of the micro service requested to be called from the calling request;
determining target address information of the micro service requested to be called from a service list according to the identification information;
and calling the target service according to the target address information.
4. The method of claim 1, wherein determining whether the target service satisfies a preset service exception rule comprises:
determining whether a message returned by the target service comprises an error code, whether the return time of the target service exceeds a preset time threshold value, and whether the network connection of the target service is available;
in the event that it is determined that one or more of the following exists for the target service: the message returned by the target service comprises an error code, the return time of the target service exceeds a preset time threshold value, the network connection of the target service is unavailable, and the target service is determined to meet a preset service exception rule.
5. The method of claim 1, wherein marking the target service as an unavailable service and feeding back the service to a service discovery center, and after suspending the call to the target service, further comprising:
deleting the registration information of the target service in the service discovery center;
performing off-line detection processing on the target service;
after the offline detection processing is passed, receiving a registration request of the target service in the service discovery center;
in response to the registration request, adding registration information for the target service in the service discovery center.
6. A microservice offload device, comprising:
the calling module is used for responding to a calling request of a calling party and acquiring the micro service requested to be called by the calling request as a target service;
the judging module is used for determining whether the target service meets a preset service abnormity rule or not;
the connection module is used for establishing the connection between the caller and the target service under the condition that the target service is determined to meet the service exception rule;
the unavailability determining module is used for determining that the target service is an unavailable service under the condition that the connection between the calling party and the target service is not successfully established within a preset time period;
and the marking module is used for marking the target service as an unavailable service, feeding the unavailable service back to the service discovery center and suspending the calling of the target service.
7. The apparatus of claim 6, further comprising:
a deleting module, configured to delete registration information of the target service in the service discovery center;
the off-line detection module is used for carrying out off-line detection processing on the target service;
the registration module is used for receiving a registration request of the target service in the service discovery center after the offline detection processing is passed; in response to the registration request, adding registration information for the target service in the service discovery center.
8. The apparatus of claim 6, further comprising:
and the service exception rule determining module is used for determining whether the message returned by the target service comprises an error code, whether the return time of the target service exceeds a preset time threshold value, and whether the network connection of the target service is available.
9. A microservice offload device comprising a processor and a memory for storing processor-executable instructions that, when executed by the processor, perform the steps of the method of any of claims 1-5.
10. A computer-readable storage medium having stored thereon computer instructions which, when executed, implement the steps of the method of any one of claims 1-5.
CN202210958975.XA 2022-08-10 2022-08-10 Micro-service distribution method, device and equipment Active CN115190178B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210958975.XA CN115190178B (en) 2022-08-10 2022-08-10 Micro-service distribution method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210958975.XA CN115190178B (en) 2022-08-10 2022-08-10 Micro-service distribution method, device and equipment

Publications (2)

Publication Number Publication Date
CN115190178A true CN115190178A (en) 2022-10-14
CN115190178B CN115190178B (en) 2024-03-08

Family

ID=83523537

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210958975.XA Active CN115190178B (en) 2022-08-10 2022-08-10 Micro-service distribution method, device and equipment

Country Status (1)

Country Link
CN (1) CN115190178B (en)

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107846295A (en) * 2016-09-19 2018-03-27 华为技术有限公司 Micro services configuration device and method
CN108427581A (en) * 2018-02-07 2018-08-21 平安普惠企业管理有限公司 System micro services method and terminal device
CN108712309A (en) * 2018-06-11 2018-10-26 郑州云海信息技术有限公司 A kind of micro services node means of defence under micro services framework and system
CN109302469A (en) * 2018-09-26 2019-02-01 平安科技(深圳)有限公司 Micro services management method, device, computer equipment and storage medium
CN110275724A (en) * 2019-06-26 2019-09-24 广州小鹏汽车科技有限公司 A kind of Service Instance update method and device
CN111475372A (en) * 2020-03-10 2020-07-31 中国平安人寿保险股份有限公司 Method, device, equipment and storage medium for monitoring service instance of microservice
CN111683109A (en) * 2020-08-17 2020-09-18 烽火通信科技股份有限公司 Micro-service architecture
US20210081197A1 (en) * 2019-09-18 2021-03-18 International Business Machines Corporation Availability level-based service management
CN112799786A (en) * 2021-02-02 2021-05-14 微民保险代理有限公司 Exit method, device, equipment and storage medium of micro-service instance
CN112866379A (en) * 2021-01-15 2021-05-28 浪潮云信息技术股份公司 Access method and device of microservice
CN113452607A (en) * 2020-03-24 2021-09-28 华为技术有限公司 Distributed link acquisition method and device, computing equipment and storage medium
CN113946487A (en) * 2021-10-08 2022-01-18 浪潮云信息技术股份公司 Method and system for realizing autonomous service degradation recovery in fault scene
WO2022042007A1 (en) * 2020-08-28 2022-03-03 苏州浪潮智能科技有限公司 Method, system, and device for locating micro-service fuse anomaly, and medium
US20220094590A1 (en) * 2021-12-07 2022-03-24 Intel Corporation Self-healing network of infrastructure processing units
CN114265760A (en) * 2021-12-30 2022-04-01 中山大学 Micro-service request fault injection method and device based on eBPF

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107846295A (en) * 2016-09-19 2018-03-27 华为技术有限公司 Micro services configuration device and method
CN108427581A (en) * 2018-02-07 2018-08-21 平安普惠企业管理有限公司 System micro services method and terminal device
CN108712309A (en) * 2018-06-11 2018-10-26 郑州云海信息技术有限公司 A kind of micro services node means of defence under micro services framework and system
CN109302469A (en) * 2018-09-26 2019-02-01 平安科技(深圳)有限公司 Micro services management method, device, computer equipment and storage medium
CN110275724A (en) * 2019-06-26 2019-09-24 广州小鹏汽车科技有限公司 A kind of Service Instance update method and device
US20210081197A1 (en) * 2019-09-18 2021-03-18 International Business Machines Corporation Availability level-based service management
CN111475372A (en) * 2020-03-10 2020-07-31 中国平安人寿保险股份有限公司 Method, device, equipment and storage medium for monitoring service instance of microservice
CN113452607A (en) * 2020-03-24 2021-09-28 华为技术有限公司 Distributed link acquisition method and device, computing equipment and storage medium
CN111683109A (en) * 2020-08-17 2020-09-18 烽火通信科技股份有限公司 Micro-service architecture
WO2022042007A1 (en) * 2020-08-28 2022-03-03 苏州浪潮智能科技有限公司 Method, system, and device for locating micro-service fuse anomaly, and medium
CN112866379A (en) * 2021-01-15 2021-05-28 浪潮云信息技术股份公司 Access method and device of microservice
CN112799786A (en) * 2021-02-02 2021-05-14 微民保险代理有限公司 Exit method, device, equipment and storage medium of micro-service instance
CN113946487A (en) * 2021-10-08 2022-01-18 浪潮云信息技术股份公司 Method and system for realizing autonomous service degradation recovery in fault scene
US20220094590A1 (en) * 2021-12-07 2022-03-24 Intel Corporation Self-healing network of infrastructure processing units
CN114265760A (en) * 2021-12-30 2022-04-01 中山大学 Micro-service request fault injection method and device based on eBPF

Also Published As

Publication number Publication date
CN115190178B (en) 2024-03-08

Similar Documents

Publication Publication Date Title
CN110784515B (en) Data storage method based on distributed cluster and related equipment thereof
CN110554927A (en) Micro-service calling method based on block chain
CN107682172B (en) Control center device, service system processing method and medium
CN109785042A (en) Abnormality eliminating method, server, storage medium and the device of distributed deployment
CN113014611B (en) Load balancing method and related equipment
CN107800814B (en) Virtual machine deployment method and device
CN105933271B (en) Data processing method and device based on encryption machine
CN111835797A (en) Data processing method, device and equipment
CN110569124A (en) Task allocation method and device
CN112351077B (en) Application service operation method, system, device and storage medium
CN113242299A (en) Disaster recovery system, method, computer device and medium for multiple data centers
CN113364852A (en) File transmission method and device and server
CN115190178B (en) Micro-service distribution method, device and equipment
CN108874947A (en) A kind of data processing system and data processing method
CN112199176A (en) Service processing method, device and related equipment
CN112416506A (en) Container management method, device and computer storage medium
CN110401708B (en) Session processing system and method based on server load state
CN111064636B (en) Control method, device and system for connection of front-end processor and computer equipment
CN113242302A (en) Data access request processing method and device, computer equipment and medium
CN113238893A (en) Disaster recovery system, method, computer device and medium for multiple data centers
CN113535402A (en) Load balancing processing method and device based on 5G MEC and electronic equipment
CN111641664B (en) Crawler equipment service request method, device and system and storage medium
CN111045778B (en) Virtual machine creation method, device, server and storage medium
CN114816723A (en) Load balancing system, method and computer readable storage medium
CN112799849A (en) Data processing method, device, equipment and storage medium

Legal Events

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