CN113726902B - Micro-service calling method, system, server, equipment and storage medium - Google Patents
Micro-service calling method, system, server, equipment and storage medium Download PDFInfo
- Publication number
- CN113726902B CN113726902B CN202111028725.8A CN202111028725A CN113726902B CN 113726902 B CN113726902 B CN 113726902B CN 202111028725 A CN202111028725 A CN 202111028725A CN 113726902 B CN113726902 B CN 113726902B
- Authority
- CN
- China
- Prior art keywords
- micro
- service
- list
- rewrite
- instance
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 99
- 230000015654 memory Effects 0.000 claims abstract description 29
- 238000012545 processing Methods 0.000 claims abstract description 20
- 230000004044 response Effects 0.000 claims abstract description 19
- 238000013507 mapping Methods 0.000 claims description 50
- 230000005012 migration Effects 0.000 claims description 23
- 238000013508 migration Methods 0.000 claims description 23
- 230000000694 effects Effects 0.000 abstract description 10
- 230000007547 defect Effects 0.000 abstract description 4
- 238000010586 diagram Methods 0.000 description 23
- 238000004590 computer program Methods 0.000 description 11
- 230000008569 process Effects 0.000 description 6
- 238000004891 communication Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 238000010276 construction Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 239000004973 liquid crystal related substance Substances 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000009466 transformation Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- 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/50—Network services
- H04L67/51—Discovery or management thereof, e.g. service location protocol [SLP] or web services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The embodiment of the application provides a micro-service calling method and a micro-service calling system, when the method is applied to a registry server, the method comprises the following steps: in response to a micro-service acquisition request initiated by a host, determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, wherein the micro-service list is used for indicating to call the micro-service, and performing rewrite processing on the acquired micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment, the micro-service rewrite list is fed back to the host, and the micro-service rewrite list is used for calling the micro-service based on gateway equipment without storing the information of the full micro-service through a registry server in a local memory of the host, so that the defect of consumption of storage resources is avoided, the technical effects of reducing call duration and improving call efficiency are realized.
Description
Technical Field
The embodiment of the application relates to the technical field of cloud computing, in particular to a micro-service calling method and a micro-service calling system.
Background
The micro-service is a service obtained by splitting a system according to business capability on the basis of a traditional software application architecture, one micro-service corresponds to a plurality of examples, one micro-service can be an independent applicable scheme, different micro-services can be mutually called, and the call between the micro-services is realized based on flow control (such as flow forwarding).
In the prior art, the method for calling the micro service comprises the following steps: when the source micro-service of the source host needs to call the target micro-service on the target host, the source host reads the local cache, queries and targets the address and port number and other calling address information of the target micro-service in the registered micro-service list stored in the source host, and executes remote call to the target micro-service based on the calling address information.
However, with the above method, the consumption of the storage resource of the source host is relatively large, and especially when the scale of the micro-service number is relatively large, the technical problems of long calling time and low efficiency are easily caused.
Disclosure of Invention
The embodiment of the application provides a micro-service calling method and a micro-service calling system, which are used for solving the technical problem of high consumption of storage resources.
In a first aspect, an embodiment of the present application provides a method for calling a micro service, applied to a registry server, where the method includes:
responding to a micro-service acquisition request initiated by a host, determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, wherein the micro-service list is used for indicating to call the micro-service;
performing rewrite processing on the obtained micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment;
And feeding back the micro-service rewrite list to the host, wherein the micro-service rewrite list is used for calling the micro-service based on the gateway equipment.
In some embodiments, the rewriting processing is performed on the obtained micro service list to obtain a micro service rewriting list, including:
acquiring the micro service list from a registry server in response to the rewrite information corresponding to the micro service acquisition request, wherein the rewrite information is information for indicating that a micro service is callable based on the gateway device, the micro service being requested by the micro service request;
and carrying out rewrite processing on the micro-service list to obtain the micro-service rewrite list.
In some embodiments, the overwrite information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a micro-service, a value of the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the overwrite information is generated based on a registration request for the micro-service.
In some embodiments, further comprising:
and receiving a registration request for the micro service forwarded by the gateway equipment, and determining and storing a micro service list of the micro service according to the registration request.
In a second aspect, an embodiment of the present application provides a method for calling a micro service, which is applied to a gateway device, where the method includes:
receiving a micro-service rewrite list sent by a host, wherein the micro-service rewrite list is obtained after a micro-service list is rewritten, the micro-service list is determined based on a micro-service acquisition request initiated by the host, and corresponds to the micro-service requested by the micro-service acquisition request, and the micro-service list is used for indicating to call micro-service;
and calling the micro service according to the micro service rewrite list, wherein the micro service rewrite list can be directly analyzed by gateway equipment.
In some embodiments, further comprising:
and generating rewriting information in response to the acquisition of the registration request for the micro service, and storing the rewriting information to a preset cluster device, wherein the rewriting information is information for indicating that the micro service can be called based on the gateway device.
In some embodiments, the overwrite information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a micro-service, a value of the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the micro-service includes a plurality of micro-service instances, and the micro-service rewrite list includes a call address for each of the micro-service instances; calling the micro service according to the micro service rewrite list, including:
performing flow distribution on each micro-service instance to obtain flow distribution information of each micro-service instance;
and forwarding the traffic to at least one micro-service instance according to the call address of each micro-service instance and the traffic allocation information of each micro-service instance so as to call the micro-service.
In some embodiments, performing traffic distribution on each of the micro service embodiments to obtain traffic distribution information of each of the micro service embodiments, including:
determining an instance tag of each micro-service instance, and performing flow distribution on each micro-service instance according to the obtained total flow for calling the micro-service and the first mapping relation to obtain flow distribution information of each micro-service instance; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
In some embodiments, further comprising:
Acquiring a registration request aiming at the micro service, and configuring an instance tag for each micro service instance in the micro service according to the first mapping relation;
and forwarding the registration request to the registration center server, wherein the registration request is used for completing registration of the micro service.
In some embodiments, further comprising:
and responding to the migration indication of the micro service, and updating the first mapping relation according to the migration indication.
In some embodiments, further comprising:
determining a micro service list of the micro service according to a registration request aiming at the micro service, and constructing a second mapping relation between the micro service list and the micro service rewrite list according to the micro service list and the rewrite information;
and invoking the micro service according to the micro service rewrite list, including: and calling the micro service according to the micro service rewrite list and the second mapping relation.
In a third aspect, an embodiment of the present application provides a method for calling a micro service, where the method is applied to a host, and the method includes:
sending a micro-service acquisition request to a registry server, wherein the micro-service acquisition request is used for determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, and the micro-service list is used for indicating to call the micro-service;
Receiving a micro-service rewrite list sent by the registry server, wherein the micro-service rewrite list is obtained by rewriting the micro-service list, and the micro-service rewrite list can be directly analyzed by gateway equipment;
and sending the micro-service rewrite list to gateway equipment, wherein the micro-service rewrite list is used for calling the micro-service based on the gateway equipment.
In some embodiments, the list of micro-service rewrites is: and responding to the rewriting information corresponding to the micro-service acquisition request, acquiring the micro-service list from a registry server, and performing rewriting processing on the micro-service list, wherein the rewriting information is used for indicating that the micro-service can be invoked based on the gateway device, and the micro-service is requested by the micro-service request.
In some embodiments, the overwrite information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a micro-service, a value of the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the micro service includes a plurality of micro service instances, and the micro service list includes a call address for each of the micro service instances; the micro service is to perform flow distribution on each micro service instance to obtain flow distribution information of each micro service instance, and forward flow call to at least one micro service instance according to the call address of each micro service instance and the flow distribution information of each micro service instance.
In some embodiments, the traffic allocation information for each of the micro service instances is: determining an instance label of each micro-service instance, and distributing the flow of each micro-service instance according to the obtained total flow for calling the micro-service and the first mapping relation; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
In a fourth aspect, embodiments of the present application provide a registry server, including:
a first determining unit, configured to determine a micro-service list corresponding to a micro-service requested by a micro-service acquisition request in response to the micro-service acquisition request initiated by a host, where the micro-service list is used to indicate that the micro-service is invoked;
the rewrite unit is used for performing rewrite processing on the obtained micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment;
and the feedback unit is used for feeding back the micro-service rewrite list to the host, and the micro-service rewrite list is used for calling the micro-service based on the gateway equipment.
In some embodiments, the writing unit includes:
An acquisition subunit, configured to acquire, from a registry server, the micro service list in response to rewrite information corresponding to the micro service acquisition request, where the rewrite information is information for indicating that a micro service can be invoked based on the gateway device, and the micro service is requested by the micro service request;
and the rewriting subunit is used for rewriting the micro-service list to obtain the micro-service rewriting list.
In some embodiments, the overwrite information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a micro-service, a value of the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the overwrite information is generated based on a registration request for the micro-service.
In some embodiments, further comprising:
a first receiving unit, configured to receive a registration request for the micro service forwarded by the gateway device;
and the second determining unit is used for determining and storing a micro service list of the micro service according to the registration request.
In a fifth aspect, embodiments of the present application provide a gateway device, including:
The second receiving unit is used for receiving a micro-service rewrite list sent by the host, wherein the micro-service rewrite list is obtained after the micro-service rewrite list is rewritten, the micro-service list is determined based on a micro-service acquisition request initiated by the host, and the micro-service list corresponds to the micro-service requested by the micro-service acquisition request and is used for indicating to call the micro-service;
and the calling unit is used for calling the micro service according to the micro service rewrite list, wherein the micro service rewrite list can be directly analyzed by gateway equipment.
In some embodiments, further comprising:
a generation unit configured to generate, in response to acquiring a registration request for the micro service, rewrite information indicating that the micro service is callable based on the gateway device;
and the storage unit is used for storing the rewriting information to preset cluster equipment.
In some embodiments, the overwrite information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a micro-service, a value of the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the micro-service includes a plurality of micro-service instances, and the micro-service rewrite list includes a call address for each of the micro-service instances; the calling unit comprises:
the allocation subunit is used for carrying out flow allocation on each micro-service example to obtain flow allocation information of each micro-service example;
and the calling subunit is used for forwarding the traffic to at least one micro-service embodiment according to the calling address of each micro-service embodiment and the traffic distribution information of each micro-service embodiment so as to call the micro-service.
In some embodiments, the invoking subunit is configured to determine an instance tag of each micro service instance, and perform traffic distribution on each micro service instance according to the obtained total traffic for invoking the micro service and the first mapping relationship, to obtain traffic distribution information of each micro service instance; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
In some embodiments, further comprising:
an acquisition unit configured to acquire a registration request for the micro service;
the configuration unit is used for configuring an instance tag for each micro-service instance in the micro-service according to the first mapping relation;
And the forwarding unit is used for forwarding the registration request to the registration center server, wherein the registration request is used for finishing registration of the micro service.
In some embodiments, the calling unit further comprises:
and the updating subunit is used for responding to the migration instruction of the micro service and updating the first mapping relation according to the migration instruction.
In some embodiments, further comprising:
a third determining unit configured to determine a micro service list of the micro service according to a registration request for the micro service;
a construction unit, configured to construct a second mapping relationship between the micro service list and the micro service rewrite list according to the micro service list and the rewrite information;
and the calling unit is used for calling the micro service according to the micro service rewriting list and the second mapping relation.
In a sixth aspect, embodiments of the present application provide a host, including:
a first sending unit, configured to send a micro-service acquisition request to a registry server, where the micro-service acquisition request is used to determine a micro-service list corresponding to a micro-service requested by the micro-service acquisition request, and the micro-service list is used to indicate that the micro-service is invoked;
The third receiving unit is used for receiving a micro-service rewrite list sent by the registry server, wherein the micro-service rewrite list is obtained by rewriting the micro-service list, and the micro-service rewrite list can be directly analyzed by gateway equipment;
and the second sending unit is used for sending the micro-service rewrite list to gateway equipment, and the micro-service rewrite list is used for calling the micro-service based on the gateway equipment.
In some embodiments, the list of micro-service rewrites is: and responding to the rewriting information corresponding to the micro-service acquisition request, acquiring the micro-service list from a registry server, and performing rewriting processing on the micro-service list, wherein the rewriting information is used for indicating that the micro-service can be invoked based on the information called by the gateway device, and the micro-service is requested by the micro-service request.
In some embodiments, the overwrite information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a micro-service, a value of the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the micro service includes a plurality of micro service instances, and the micro service list includes a call address for each of the micro service instances; the micro service is to perform flow distribution on each micro service instance to obtain flow distribution information of each micro service instance, and forward flow call to at least one micro service instance according to the call address of each micro service instance and the flow distribution information of each micro service instance.
In some embodiments, the traffic allocation information for each of the micro service instances is: determining an instance label of each micro-service instance, and distributing the flow of each micro-service instance according to the obtained total flow for calling the micro-service and the first mapping relation; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
In a seventh aspect, embodiments of the present application provide an electronic device, including: a memory, a processor;
a memory; a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method of the first aspect; alternatively, the processor is configured to perform the method as described in the second aspect; alternatively, the processor is configured to perform the method as described in the third aspect.
In an eighth aspect, embodiments of the present application provide a computer-readable storage medium having stored therein computer-executable instructions for implementing the method according to the first aspect when executed by a processor; alternatively, the computer-executable instructions, when executed by a processor, are for implementing a method as described in the second aspect; alternatively, the computer-executable instructions, when executed by a processor, are for implementing a method as described in the third aspect.
In a ninth aspect, embodiments of the present application provide a computer program product comprising a computer program which, when executed by a processor, implements the method according to the first aspect; alternatively, the computer program, when executed by a processor, implements the method according to the second aspect; alternatively, the computer program, when executed by a processor, implements the method according to the third aspect.
In a tenth aspect, an embodiment of the present application provides a micro-service invocation system, including:
the registry server of the fourth aspect;
the gateway device of the fifth aspect;
the host of the sixth aspect.
The method and the system for calling the micro service provided by the embodiment of the application, when the method is applied to the registry server, comprise the following steps: in response to a micro-service acquisition request initiated by a host, determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, wherein the micro-service list is used for indicating to call the micro-service, and performing rewrite processing on the acquired micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment, the micro-service rewrite list is fed back to the host, and the micro-service rewrite list is used for calling the micro-service based on the gateway equipment, and in the embodiment, the method comprises the following steps: the registry server rewrites the micro-service list and transmits the rewritten micro-service rewrite list to the host, so that the host can realize the technical characteristics of calling the micro-service based on the micro-service rewrite list, the host does not need to store the information of the whole micro-service passing through the registry server in the local memory of the host, the defect of storage resource consumption is avoided, the technical effects of reducing calling time and improving calling efficiency are realized.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
Fig. 1 is an application scenario schematic diagram of a micro service calling method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a method of invoking a micro service according to one embodiment of the present application;
FIG. 3 is a schematic diagram of a method of invoking a micro service according to another embodiment of the present application;
FIG. 4 is a schematic diagram of a method of invoking a micro-service according to another embodiment of the present application;
FIG. 5 is a schematic diagram of a method of invoking a micro-service according to another embodiment of the present application;
FIG. 6 is a schematic diagram of a registry server according to one embodiment of the present application;
FIG. 7 is a schematic diagram of a registry server according to another embodiment of the present application;
fig. 8 is a schematic diagram of a gateway device according to an embodiment of the present application;
fig. 9 is a schematic diagram of a gateway device according to another embodiment of the present application;
FIG. 10 is a schematic diagram of a host according to one embodiment of the present application;
FIG. 11 is a block diagram of an electronic device for a method of invoking a micro service according to an embodiment of the present application;
FIG. 12 is a schematic diagram of a invocation system of a micro service according to an embodiment of the present application.
Specific embodiments thereof have been shown by way of example in the drawings and will herein be described in more detail. These drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
With the rapid development of the internet, better requirements are put forward on the high availability and service continuity of an Internet Technology (IT) system, and the IT system of a single room is gradually converted into the IT systems of a plurality of internet data center (Internet Data Center, IDC) rooms such as 'same city double activity', 'different places double activity', even 'different places multiple activities', and the like, so that the high availability of the IT system is better ensured.
The micro service calling method of the embodiment can be applied to a scenario of an IT system of a single machine room, for example, the micro service calling method of the embodiment can be applied to a scenario of calling micro services deployed on different hosts in the same machine room.
The micro service calling method of the embodiment can also be applied to scenes of the IT systems of a plurality of machine rooms, for example, the micro service calling method of the embodiment can be applied to scenes of calling micro services deployed on hosts of different machine rooms in different machine rooms.
Exemplary, fig. 1 is a schematic diagram of a scenario in which a micro service invocation method according to an embodiment of the present application may be applied to IT systems of a plurality of machine rooms.
As shown in fig. 1, the machine room N and the machine room M are two different machine rooms, and the machine room N and the machine room M may be two machine rooms deployed in the same city or two machine rooms deployed in different places.
The machine room N comprises N1 to Nn hosts. The machine room M includes M1 to Mm hosts.
The micro-service deployed on any host in the machine room N may be invoked. Similarly, the micro-service deployed on any host in the machine room M may also be invoked.
The application understands that the micro-service needs to be formed through registration, the registration of the micro-service is completed through a registration center server (Eurekaserver), and the registration center server can store information of the micro-service when registering the micro-service, so that a micro-service list is obtained.
In the related art, each host may obtain a micro service list from the registry server, and store the micro service list into the local memory. That is, in the related art, information of the full-volume micro service that has been registered is stored in each host.
When a micro service deployed on a certain host (may be referred to as a source host) needs to call a micro service deployed on another host (may be referred to as a target host), the corresponding call address information may be determined by querying a micro service list in a local memory of the source host, and call of the micro service deployed on the target host is achieved based on the call address information.
However, when the micro service is called by adopting the method in the related technology, each host needs to store the micro service list, so that the consumption of storage resources of each host is relatively large, and especially when the number of micro services (i.e. the scale of the micro service) is relatively large, the technical problems of long calling time and low efficiency are easily caused.
In order to solve the above technical problems, the inventors of the present application have creatively worked to obtain the inventive concept of the present application: the registry server supports the rewriting function to rewrite the micro-service list, and sends the micro-service rewriting list obtained by rewriting to the host, so that the host can realize the call of the corresponding micro-service through the gateway device based on the micro-service rewriting list, and the micro-service rewriting list can be directly analyzed by the gateway device.
The following describes the technical solutions of the present application and how the technical solutions of the present application solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Referring to fig. 2, fig. 2 is a schematic diagram of a method for calling a micro service according to an embodiment of the present application.
As shown in fig. 2, the method includes:
s201: in response to a micro-service acquisition request initiated by a host, a micro-service list corresponding to the micro-service requested by the micro-service acquisition request is determined, the micro-service list being used to indicate invocation of the micro-service.
For example, the execution body of the embodiment may be a registry server (hereinafter referred to as a server), and the server may be a local server, a cloud server, a computer with a registration function, a terminal device, or the like, which is not limited in this embodiment.
The host may be a server as shown in he 1, or may be a computer device, or other processing device, etc.
S202: and carrying out rewrite processing on the obtained micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment.
Wherein, the micro service list and the micro service rewrite list are relative concepts, and the micro service list comprises: when the micro service is registered by the registry server, the registry server stores a list of information related to the call address of the micro service. The micro service rewrite list refers to a list that rewrites the micro service list so that the micro service list can be directly parsed by the gateway device.
S203: and feeding back the micro-service rewrite list to the host, wherein the micro-service rewrite list is used for invoking the micro-service based on the gateway device.
For example, the registry server sends a micro-service rewrite list to the host; the host sends the micro-service rewrite list to the gateway device to request a call to the micro-service; the gateway device can directly analyze the micro-service rewrite list, thereby realizing the call to the micro-service.
Based on the above analysis, the embodiment of the application provides a micro-service calling method, which is applied to a registry server, and the method comprises the following steps: in response to a micro-service acquisition request initiated by a host, determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, wherein the micro-service list is used for indicating to call the micro-service, and performing rewrite processing on the acquired micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment, the micro-service rewrite list is fed back to the host, and the micro-service rewrite list is used for calling the micro-service based on the gateway equipment, and in the embodiment, the method comprises the following steps: the registry server rewrites the micro-service list and transmits the rewritten micro-service rewrite list to the host, so that the host can realize the technical characteristics of calling the micro-service based on the micro-service rewrite list, the host does not need to store the information of the whole micro-service passing through the registry server in the local memory of the host, the defect of storage resource consumption is avoided, the technical effects of reducing calling time and improving calling efficiency are realized.
Referring to fig. 3, fig. 3 is a schematic diagram of a method for calling a micro service according to another embodiment of the present application.
As shown in fig. 3, the method includes:
s301: the gateway device generates, in response to obtaining the registration request for the micro-service, rewrite information indicating that the micro-service may be invoked based on the gateway device.
S302: the gateway device transmits the overwrite information to the cluster device.
The cluster device may be a zookeeper cluster.
The rewrite information includes a key-value pair (key) for representing a name of the micro service, a value in the key-value pair for representing a call address of the micro service, the call address being stored in the registry server.
S303: the host sends a micro-service acquisition request to the registry server.
For example, when a host has a need to invoke a micro service, a micro service acquisition request may be sent to a registry server.
S304: the registry server determines whether the zookeeper cluster includes a key value of the micro service, if yes, S305 is executed, and if not, S311 is executed.
S305: the registry server obtains a micro service list corresponding to the micro service from the local memory.
S306: and the registry server rewrites the micro-service list to obtain a micro-service rewrite list.
Wherein the micro-service rewrite list may be parsed directly by the gateway device.
In some embodiments, the call address in the micro-service rewrite list is a call address that includes four levels of domain name information, see Table 1. I.e. the modification based on domain name can make the calling address in the micro-service rewrite list directly transferred to the gateway device and directly resolved by the gateway device.
Table 1:
micro service list | Microservice rewrite list |
1.1.1.1:8080 | 1-1-1-1-8080-b.xxx.lo |
1.1.1.2:8080 | 1-1-1-2-8080-b.xxx.lo |
Wherein, a generic domain name is preset, and the generic domain name can be resolved to a virtual IP address of gateway equipment.
S307: the registry server sends a micro-service rewrite list to the host.
S308: the host sends a micro-service rewrite list to the gateway device.
Based on the analysis, the micro-service rewrite list may include a plurality of call addresses, and the host may send the micro-service rewrite list to the gateway device, or may send at least one call address in the micro-service rewrite list to the gateway device.
It should be noted that, in this embodiment, in combination with the above analysis, it is known that the storage resources of the host computer can be saved, the efficiency of calling the micro service is improved, and by generating the micro service rewrite list by the registry server, transformation, upgrading and updating of the host computer can be avoided, the transformation, upgrading and updating costs of the host computer are saved, the resources are saved, and the risk of calling the micro service caused by micro service migration and the like is reduced.
S309: and the gateway equipment performs flow distribution on each micro-service instance in the micro-service according to the micro-service rewrite list to obtain flow distribution information of each micro-service instance.
In some embodiments, S309 may include the steps of:
a first step of: an instance tag for each microservice instance is determined.
In some embodiments, the gateway device may configure an instance tag for each micro-service instance in the micro-service according to a first mapping relationship between a preset instance tag and a traffic allocation weight when acquiring a registration request for the micro-service.
That is, when the micro service is registered with the registry server through the gateway device, the gateway device may configure an instance tag for each micro service instance to determine forwarding traffic for the corresponding micro service instance through the instance tag, thereby implementing call to different micro service instances.
In some embodiments, the gateway device may carry an instance tag in the registration request of the microservice when forwarding the registration request to the registry server.
Accordingly, the micro service list stored by the registry server includes both the call address of the micro service instance and the instance tag of the micro service instance.
And a second step of: and according to the first mapping relation and the obtained total flow for calling the micro service, carrying out flow distribution on each micro service instance to obtain flow distribution information of each micro service instance.
For example, after the gateway device obtains the total flow for calling the micro service, the gateway device uses the first mapping relationship as the basis for distributing the flow, and performs flow distribution for each micro service example in a load balancing manner, so as to realize flexibility and reliability of micro service calling and improve the technical effect of efficiency of micro service calling.
In some embodiments, in response to the migration indication of the micro-service, the first mapping relationship is updated according to the migration indication.
That is, the gateway device may allocate an instance tag for each micro service instance based on the first mapping relationship, so as to achieve flexibility and diversity of calling different micro service instances, and the gateway device may also adjust the instance tag of the micro service instance based on migration of the micro service, so as to achieve meeting the call requirement of the host on the micro service.
In other embodiments, the running information of the migrated micro service instance on the forwarding traffic may be determined based on the micro service discovery, so as to verify the performance of the migrated micro service instance that is invoked, and if it is determined that the migrated micro service instance invokes no problem, the forwarding of the traffic to the micro service instance before the migration is stopped.
In still other embodiments, the weight may be set by a worker for the migrated micro-service instance, and the initial value of the weight is typically set to 0, so that traffic is not forwarded to the micro-service instance when the micro-service is discovered. When the worker determines that the newly added micro-service example starts normally, the initial value of the weight is manually modified, and the process of gradually modifying is performed, for example, the initial value 0 of the weight is gradually modified to be 1, and the forwarding flow is monitored by the worker in the process to determine that the forwarding flow is normal. The weight of the micro service instance before migration is set to 0 by the staff member so that the traffic for calling the micro service is forwarded to the micro service instance after migration.
Specifically, the micro-service embodiment has a start-up parameter, and in combination with the above embodiment, the start-up parameter may include an instance tag and may also include a weight.
In contrast, if the starting parameter includes a weight, after the micro service instance completes migration, the weight in the starting parameter is deleted, so that after the micro service instance is restarted, the traffic of calling the micro service is prevented from being forwarded to the micro service instance before migration.
If the starting parameter includes the instance tag, deleting the instance tag is not needed, so that deleted operation resources can be saved, and the forwarding of the flow for calling the micro-service has the technical effects of higher accuracy and reliability.
In some embodiments, the gateway device may construct a second mapping relationship between the micro service list and the micro service rewrite list, and the second mapping relationship may be a mapping table, see table 2. Still further, the mapping table may include instance tags for micro service instances in the mapping relationship.
Table 2:
micro service list | Microservice rewrite list | Instance tags |
1.1.1.1:8080 | 1-1-1-1-8080-b.xxx.lo | Without any means for |
1.1.1.2:8080 | 1-1-1-2:8080-b.xxx.lo | Without any means for |
3.3.3.3:8080 | 3-3-3-3-8080-b.xxx.lo | Example Label 1 |
4.4.4.4:8080 | 4-4-4-4-8080-b.xxx.lo | Example Label 2 |
Wherein, some micro service instances may have no instance tags, such as micro service instances before migration have no instance tags.
S310: and the gateway equipment forwards the traffic to at least one micro-service instance according to the call address of each micro-service instance and the traffic distribution information of each micro-service instance so as to call the micro-service.
Illustratively, as can be seen in conjunction with table 2, the gateway device may determine that call addresses of the forwardable traffic are 3-3-3-3-8080-b.xxx.lo and 4-4-4-8080-b.xxx.lo, then the gateway device may determine traffic forwarded to 3-3-3-8080-b.xxx.lo based on instance tag 1, and may determine traffic forwarded to 4-4-4-4-8080-b.xxx.lo based on instance tag 2, and implement call to micro-services through forwarding of traffic.
Whereas 1-1-1-8080-b.xxx.lo and 1-1-1-2:8080-b.xxx.lo for no instance tags no longer forward traffic. By the scheme provided by the implementation of the application, the defect that micro service cannot be called during micro service migration can be avoided, and the technical effect of the reliability of micro service call is ensured.
S311: the registry server obtains a micro service list corresponding to the micro service from the local memory.
S312: the registry server sends a list of to-be-micro services to the host.
S313: the host sends a list of micro services to the gateway device.
S314: the gateway device performs a call to the micro service based on the micro service list.
Similarly, in this embodiment, the gateway device may parse the micro service list to obtain a call address of the micro service, and call the micro service based on the call address.
Referring to fig. 4, fig. 4 is a schematic diagram of a method for calling a micro service according to another embodiment of the present application.
As shown in fig. 4, the method includes:
s401: and receiving the micro-service rewrite list sent by the host.
The micro-service rewrite list is obtained after the micro-service rewrite process is performed on the micro-service list, the micro-service list is determined based on a micro-service acquisition request initiated by a host, and the micro-service list corresponds to the micro-service requested by the micro-service acquisition request and is used for indicating to call the micro-service.
Illustratively, the execution body of the present embodiment may be a gateway device.
For the technical features in this embodiment that are the same as those in the foregoing embodiment, and the implementation principles of the corresponding schemes, reference may be made to the foregoing embodiment, which is not repeated herein.
In some embodiments, in response to obtaining a registration request for a micro-service, generating and storing, to a preset cluster device, rewrite information, the rewrite information being information indicating that the micro-service may be invoked based on a gateway device.
In some embodiments, the overwrite information comprises a key-value pair, a key in the key-value pair being used to characterize a name of the micro-service, a value in the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
S402: and calling the micro service according to the micro service rewrite list, wherein the micro service rewrite list can be directly analyzed by the gateway device.
In this embodiment, the micro service rewrite list is combined to be directly parsed by the gateway device, so that call addresses in the micro service rewrite list are all converged to the gateway device, and the technical effects of accuracy and reliability of micro service call can be achieved.
In some embodiments, the micro-service includes a plurality of micro-service instances, and the micro-service rewrite list includes a call address for each micro-service instance; s402 may include the steps of:
a first step of: and carrying out flow distribution on each micro service instance to obtain flow distribution information of each micro service instance.
In some embodiments, the first step may include: determining an instance tag of each micro service instance, and performing flow distribution on each micro service instance according to the obtained total flow for calling the micro service and a first mapping relation, so as to obtain flow distribution information of each micro service instance, wherein the first mapping relation is used for indicating the relation between a preset instance tag and flow distribution weights.
In some embodiments, the gateway device may obtain a registration request for the micro service, configure an instance tag for each micro service instance in the micro service according to the first mapping relationship, and forward the registration request to a registry server, where the registration request is used to complete registration for the micro service.
In some embodiments, the gateway device may update the first mapping relationship according to the acquired migration indication of the micro service.
And a second step of: and forwarding the traffic to at least one micro-service embodiment according to each call address and each traffic allocation information so as to call the micro-service.
In some embodiments, the gateway device may determine a micro service list of the service according to the registration request for the micro service, construct a second mapping relationship between the micro service list and the micro service rewrite list according to the micro service list and the rewrite information, and invoke the micro service according to the micro service rewrite list and the second mapping relationship.
Referring to fig. 5, fig. 5 is a schematic diagram of a method for calling a micro service according to another embodiment of the present application.
As shown in fig. 5, the method includes:
s501: and sending a micro-service acquisition request to the registry server, wherein the micro-service acquisition request is used for determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, and the micro-service list is used for indicating to call the micro-service.
Illustratively, the execution body of the present embodiment may be a host.
For the technical features in this embodiment that are the same as those in the foregoing embodiment, and the implementation principles of the corresponding schemes, reference may be made to the foregoing embodiment, which is not repeated herein.
S502: and receiving a micro-service rewrite list sent by the registry server, wherein the micro-service rewrite list is obtained by rewriting the micro-service list, and the micro-service rewrite list can be directly analyzed by gateway equipment.
Wherein the micro-service rewrite list is: and responding to the rewriting information corresponding to the micro-service acquisition request, acquiring a micro-service list from the registry server, and performing rewriting processing on the micro-service list, wherein the rewriting information is used for indicating that the micro-service can be called based on the gateway device, and the micro-service is requested by the micro-service request.
In some embodiments, the overwrite information comprises a key-value pair, a key in the key-value pair being used to characterize a name of the micro-service, a value in the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the micro-service includes a plurality of micro-service instances, and the micro-service list includes a call address for each micro-service instance; the micro service is to perform flow distribution on each micro service instance to obtain flow distribution information of each micro service instance, and forward flow call to at least one micro service instance according to call address of each micro service instance and flow distribution information of each micro service instance.
In some embodiments, the traffic allocation information for each micro service instance is: determining an instance tag of each micro service instance, and performing flow distribution on each micro service instance according to the obtained total flow for calling the micro service and a first mapping relation, wherein the first mapping relation is used for indicating the relation between a preset instance tag and a flow distribution weight.
S503: and sending the micro-service rewrite list to the gateway device, wherein the micro-service rewrite list is used for invoking the micro-service based on the gateway device.
Referring to fig. 6, fig. 6 is a schematic diagram of a registry server according to an embodiment of the present application.
As shown in fig. 6, the registry server 600 includes:
a first determining unit 601, configured to determine, in response to a micro service acquisition request initiated by a host, a micro service list corresponding to a micro service requested by the micro service acquisition request, where the micro service list is used to indicate that a micro service is invoked.
And the rewriting unit 602 is configured to perform rewriting processing on the obtained micro service list, so as to obtain a micro service rewriting list, where the micro service rewriting list can be directly parsed by the gateway device.
A feedback unit 603, configured to feed back the micro service rewrite list to the host, where the micro service rewrite list is used to invoke the micro service based on the gateway device.
Referring to fig. 7, fig. 7 is a schematic diagram of a registry server according to another embodiment of the present application.
As shown in fig. 7, the registry server 700 includes:
a first receiving unit 701, configured to receive a registration request for a micro service forwarded by a gateway device.
The second determining unit 702 is configured to determine and store a micro service list of the micro service according to the registration request.
A first determining unit 703, configured to determine, in response to a micro service acquisition request initiated by the host, a micro service list corresponding to a micro service requested by the micro service acquisition request, where the micro service list is used to indicate that the micro service is invoked.
And a rewriting unit 704, configured to rewrite the acquired micro service list to obtain a micro service rewrite list, where the micro service rewrite list can be directly parsed by the gateway device.
As can be seen in conjunction with fig. 7, in some embodiments, the writing unit 704 includes:
the obtaining subunit 7041 is configured to obtain, from the registry server, a micro service list in response to the rewrite information corresponding to the micro service obtaining request, where the rewrite information is information for indicating that the micro service can be invoked based on the gateway device, and the micro service is requested by the micro service request.
The rewriting subunit 7042 is configured to rewrite the micro service list to obtain a micro service rewrite list.
In some embodiments, the overwrite information comprises a key-value pair, a key in the key-value pair being used to characterize a name of the micro-service, a value in the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the overwrite information is generated based on a registration request for the micro-service.
The feedback unit 705 is configured to feed back a micro service rewrite list to the host, where the micro service rewrite list is used to invoke the micro service based on the gateway device.
Referring to fig. 8, fig. 8 is a schematic diagram of a gateway device according to an embodiment of the present application.
As shown in fig. 8, the gateway apparatus 800 includes:
the second receiving unit 801 is configured to receive a micro service rewrite list sent by a host, where the micro service rewrite list is obtained after a micro service list is rewritten, the micro service list is determined based on a micro service acquisition request initiated by the host, and corresponds to a micro service requested by the micro service acquisition request, and the micro service list is used to instruct to call a micro service.
And a calling unit 802, configured to call the micro service according to the micro service rewrite list, where the micro service rewrite list can be directly parsed by a gateway device.
Referring to fig. 9, fig. 9 is a schematic diagram of a gateway device according to another embodiment of the present application.
As shown in fig. 9, the gateway apparatus 900 includes:
a generating unit 901, configured to generate, in response to acquiring a registration request for a micro service, rewrite information, which is information for indicating that the micro service can be invoked based on a gateway device.
In some embodiments, the overwrite information comprises a key-value pair, a key in the key-value pair being used to characterize a name of the micro-service, a value in the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
The storage unit 902 is configured to store the rewrite information to a preset cluster device.
An obtaining unit 903, configured to obtain a registration request for a micro service.
A configuration unit 904, configured to configure an instance tag for each micro service instance in the micro service according to the first mapping relationship.
A forwarding unit 905, configured to forward a registration request to a registry server, where the registration request is used to complete registration of the micro service.
The second receiving unit 906 is configured to receive a micro service rewrite list sent by the host, where the micro service rewrite list is obtained after a micro service list is rewritten, the micro service list is determined based on a micro service acquisition request initiated by the host, and the micro service list corresponds to a micro service requested by the micro service acquisition request, and is used to instruct to invoke a micro service.
And a calling unit 907 for calling the micro service according to the micro service rewrite list, wherein the micro service rewrite list can be directly parsed by the gateway device.
In some embodiments, the micro-service includes a plurality of micro-service instances, and the micro-service rewrite list includes a call address for each micro-service instance; a calling unit 907, comprising:
the allocation subunit 9071 is configured to perform flow allocation on each micro service instance, so as to obtain flow allocation information of each micro service instance.
The call subunit 9072 is configured to forward, according to each call address and each traffic allocation information, traffic to at least one micro service embodiment, so as to call the micro service.
The updating subunit 9073 is configured to respond to the migration instruction of the micro service, and update the first mapping relationship according to the migration instruction.
In some embodiments, the invoking subunit 9072 is configured to determine an instance tag of each microservice instance, and perform flow distribution on each microservice instance according to the obtained total flow for invoking the microservice and the first mapping relationship, to obtain flow distribution information of each microservice instance; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
In some embodiments, as can be seen in conjunction with fig. 9, gateway device 900 may further include:
a third determining unit 908 is configured to determine a micro service list of the micro service according to the registration request for the micro service.
And a construction unit 909 for constructing a second mapping relationship between the micro service list and the micro service rewrite list according to the micro service list and the rewrite information.
And a calling unit 907 for calling the micro service according to the micro service rewrite list and the second mapping relation.
Referring to fig. 10, fig. 10 is a schematic diagram of a host according to an embodiment of the present application.
As shown in fig. 10, the host 1000 includes:
a first sending unit 1001, configured to send a micro service acquisition request to a registry server, where the micro service acquisition request is used to determine a micro service list corresponding to a micro service requested by the micro service acquisition request, where the micro service list is used to indicate that a micro service is invoked.
And a third receiving unit 1002, configured to receive a micro service rewrite list sent by the registry server, where the micro service rewrite list is obtained by performing a rewrite process on the micro service list, and the micro service rewrite list may be directly parsed by a gateway device.
A second sending unit 1003, configured to send the micro service rewrite list to a gateway device, where the micro service rewrite list is used to invoke the micro service based on the gateway device.
In some embodiments, the list of micro-service rewrites is: and responding to the rewriting information corresponding to the micro-service acquisition request, acquiring the micro-service list from a registry server, and performing rewriting processing on the micro-service list, wherein the rewriting information is used for indicating that the micro-service can be called based on the gateway equipment, and the micro-service is requested by the micro-service request.
In some embodiments, the overwrite information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a micro-service, a value of the key-value pair being used to characterize a call address of the micro-service, the call address being stored in the registry server.
In some embodiments, the micro service includes a plurality of micro service instances, and the micro service list includes a call address for each of the micro service instances; the micro service is to perform flow distribution on each micro service instance to obtain flow distribution information of each micro service instance, and forward flow call to at least one micro service instance according to the call address of each micro service instance and the flow distribution information of each micro service instance.
In some embodiments, the traffic allocation information for each of the micro service instances is: determining an instance label of each micro-service instance, and distributing the flow of each micro-service instance according to the obtained total flow for calling the micro-service and the first mapping relation; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
According to embodiments of the present application, an electronic device and a readable storage medium are also provided.
According to an embodiment of the present application, there is also provided a computer program product comprising: a computer program stored in a readable storage medium, from which at least one processor of an electronic device can read, the at least one processor executing the computer program causing the electronic device to perform the solution provided by any one of the embodiments described above.
As shown in fig. 11, a block diagram of an electronic device of a micro service calling method according to an embodiment of the present application is shown. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the application described and/or claimed herein.
As shown in fig. 11, the electronic device includes: one or more processors 1101, memory 1102, and interfaces for connecting the various components, including a high speed interface and a low speed interface. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the electronic device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In other embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). In fig. 11, a processor 1101 is taken as an example.
The memory 1102 is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the calling method of the micro service in the embodiments of the present application. The processor 1101 executes various functional applications of the server and data processing, i.e., implements the calling method of the micro service in the above-described method embodiment, by running non-transitory software programs, instructions, and modules stored in the memory 1102.
The electronic device of the calling method of the micro service may further include: an input device 1103 and an output device 1104. The processor 1101, memory 1102, input device 1103 and output device 1104 may be connected by a bus or other means, for example in fig. 11.
The input device 1103 may receive input numeric or character information, as well as key signal inputs related to user settings and function control of the electronic device for invoking methods of micro-services, such as input devices for a touch screen, a keypad, a mouse, a track pad, a touch pad, a joystick, one or more mouse buttons, a track ball, a joystick, etc. The output device 1104 may include a display device, auxiliary lighting (e.g., LEDs), and haptic feedback (e.g., a vibration motor), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device may be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASIC (application specific integrated circuit), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
These computing programs (also referred to as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented in a high-level procedural and/or object-oriented programming language, and/or in assembly/machine language. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to another aspect of the embodiment of the present application, the embodiment of the present application further provides a micro-service invocation system, including:
A registry server as in any above embodiment;
a gateway device as in any above embodiments;
a host as in any above embodiment.
In some embodiments, the invocation system of the micro-service may further include a cluster device for storing the overwrite information. The cluster device may be a zookeeper cluster.
Illustratively, as shown in fig. 12, the invocation system 1200 of the micro service includes:
gateway device 1201 is configured to receive a registration request initiated by a micro service, generate a key value pair corresponding to the micro service, and transmit the key value pair to zookeeper cluster 1202.
The zookeeper cluster 1202 stores key-value pairs.
The host 1203 is configured to send a micro service acquisition request to the registry server 1204 to invoke a micro service.
Illustratively, at least one micro-service may be deployed in the host 1203, and for any micro-service deployed in the host 1203, other micro-services may be invoked, and other micro-services may be other micro-services deployed in the host 1203 or other micro-services deployed in other hosts.
For example, as shown in connection with fig. 12, at least one micro-service may be deployed in the first host, and with respect to any micro-service deployed in the host 1203, the at least one micro-service deployed in the first host may be another micro-service, that is, any micro-service in the host 1203 may call the micro-service deployed in the first host.
As another example, as shown in connection with fig. 12, at least one micro-service may be deployed in the second host, and relative to any micro-service deployed in the host 1203, the at least one micro-service deployed in the second host may be another micro-service, that is, any micro-service in the host 1203 may call the micro-service deployed in the second host.
As another example, referring to fig. 12, the second host is a host after the migration of the first host, and at least part of the micro services deployed in the first host are migrated to the second host. Accordingly, if all the micro services deployed in the first host migrate to the second host, any micro service in the host 1203 may call the micro services migrated to the second host; if a portion of the micro-services deployed in the first host migrates to the second host, any micro-services in host 1203 may make calls to portions of the first host that have not migrated, as well as portions that have migrated to the second host.
The registry server 1204 is configured to determine whether a key value pair corresponding to a micro service exists in the zookeeper cluster 1202, and if so, acquire a micro service list corresponding to the micro service stored in advance in a local memory of the zookeeper cluster, and rewrite the micro service list to obtain a micro service rewrite list, so that the micro service rewrite list can be directly parsed by the gateway device 1201.
Wherein gateway device 1201 may send a registration request to registry server 1204 and accordingly registry server 1204 may determine a list of micro services based on the registration request.
Gateway device 1201 is also configured to invoke a micro service based on the micro service rewrite list.
If the micro service includes a plurality of micro service instances, and the plurality of micro service instances are deployed on different hosts, as shown in fig. 12, a part of the micro service instances in the plurality of micro service instances are deployed on a first host, and a part of the micro service instances are deployed on a second host, the gateway device may call at least one micro service instance based on an instance tag of each micro service instance, thereby completing the call to the micro service.
For example, in combination with the above embodiment, if the first host is a host before micro service migration and the second host is a host after micro service migration, the gateway device 1201 may forward the traffic to the second host to implement the call to the micro service instance deployed on the second host, thereby implementing the call to the micro service.
It should be understood that, regarding the principle that each component in the micro-service invocation system cooperates with to implement micro-service invocation, reference may be made to the above embodiment, which is not repeated herein.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.
Claims (24)
1. A method for invoking a micro service, applied to a registry server, the method comprising:
responding to a micro-service acquisition request initiated by a host, determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, wherein the micro-service list is used for indicating to call the micro-service;
Performing rewrite processing on the obtained micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment;
and feeding back the micro-service rewrite list to the host, wherein the micro-service rewrite list is used for calling the micro-service based on the gateway equipment, the micro-service rewrite list comprises a call address corresponding to the micro-service, the call address comprises a first domain name, and the first domain name is resolved to an IP address of the gateway equipment.
2. The method of claim 1, wherein the rewriting the acquired micro service list to obtain a micro service rewrite list comprises:
acquiring the micro service list from a registry server in response to the rewrite information corresponding to the micro service acquisition request, wherein the rewrite information is information for indicating that a micro service is callable based on the gateway device, the micro service being requested by the micro service request;
and carrying out rewrite processing on the micro-service list to obtain the micro-service rewrite list.
3. The method of claim 2, wherein the overwrite information comprises a key-value pair, a key in the key-value pair being used to characterize a name of a micro-service, a value in the key-value pair being used to characterize a call address of a micro-service, the call address being stored in the registry server.
4. The method of claim 2, wherein the overwrite information is generated based on a registration request of a micro service.
5. The method of any one of claims 1 to 4, further comprising:
and receiving a registration request for the micro service forwarded by the gateway equipment, and determining and storing a micro service list of the micro service according to the registration request.
6. A method for invoking micro services, applied to a gateway device, the method comprising:
receiving a micro-service rewrite list sent by a host, wherein the micro-service rewrite list is obtained after a micro-service list is rewritten, the micro-service list is determined based on a micro-service acquisition request initiated by the host, and corresponds to the micro-service requested by the micro-service acquisition request, and the micro-service list is used for indicating to call micro-service;
and calling the micro service according to the micro service rewrite list, wherein the micro service rewrite list can be directly analyzed by gateway equipment, the micro service rewrite list comprises call addresses corresponding to the micro service, the call addresses comprise first domain names, and the first domain names are analyzed to IP addresses of the gateway equipment.
7. The method of claim 6, further comprising:
and generating rewriting information in response to the acquisition of the registration request for the micro service, and storing the rewriting information to a preset cluster device, wherein the rewriting information is information for indicating that the micro service can be called based on the gateway device.
8. The method of claim 7, wherein the overwrite information comprises a key-value pair, a key in the key-value pair being used to characterize a name of a micro-service, a value in the key-value pair being used to characterize a call address of a micro-service, the call address being stored in the registry server.
9. The method of any of claims 6 to 8, wherein the micro-service comprises a plurality of micro-service instances, the micro-service rewrite list comprising a call address for each of the micro-service instances; calling the micro service according to the micro service rewrite list, including:
performing flow distribution on each micro-service instance to obtain flow distribution information of each micro-service instance;
and forwarding the traffic to at least one micro-service instance according to the call address of each micro-service instance and the traffic allocation information of each micro-service instance so as to call the micro-service.
10. The method of claim 9, wherein performing traffic distribution on each of the micro service instances to obtain traffic distribution information of each of the micro service instances comprises:
determining an instance tag of each micro-service instance, and performing flow distribution on each micro-service instance according to the obtained total flow for calling the micro-service and the first mapping relation to obtain flow distribution information of each micro-service instance; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
11. The method of claim 10, further comprising:
acquiring a registration request aiming at the micro service, and configuring an instance tag for each micro service instance in the micro service according to the first mapping relation;
and forwarding the registration request to the registration center server, wherein the registration request is used for completing registration of the micro service.
12. The method of claim 10, further comprising:
and responding to the migration indication of the micro service, and updating the first mapping relation according to the migration indication.
13. The method of claim 7 or 8, further comprising:
Determining a micro service list of the micro service according to a registration request aiming at the micro service, and constructing a second mapping relation between the micro service list and the micro service rewrite list according to the micro service list and the rewrite information;
and invoking the micro service according to the micro service rewrite list, including: and calling the micro service according to the micro service rewrite list and the second mapping relation.
14. A method for invoking a micro-service, applied to a host, the method comprising:
sending a micro-service acquisition request to a registry server, wherein the micro-service acquisition request is used for determining a micro-service list corresponding to the micro-service requested by the micro-service acquisition request, and the micro-service list is used for indicating to call the micro-service;
receiving a micro-service rewrite list sent by the registry server, wherein the micro-service rewrite list is obtained by rewriting the micro-service list, and the micro-service rewrite list can be directly analyzed by gateway equipment;
and sending the micro-service rewrite list to gateway equipment, wherein the micro-service rewrite list is used for calling the micro-service based on the gateway equipment, the micro-service rewrite list comprises a call address corresponding to the micro-service, the call address comprises a first domain name, and the first domain name is resolved to an IP address of the gateway equipment.
15. The method of claim 14, wherein the micro-service rewrite list is: and responding to the rewriting information corresponding to the micro-service acquisition request, acquiring the micro-service list from a registry server, and performing rewriting processing on the micro-service list, wherein the rewriting information is used for indicating that the micro-service can be invoked based on the gateway device, and the micro-service is requested by the micro-service request.
16. The method of claim 14, wherein the overwrite information comprises a key-value pair, a key in the key-value pair being used to characterize a name of a micro-service, a value in the key-value pair being used to characterize a call address of a micro-service, the call address being stored in the registry server.
17. The method of claim 14, wherein the micro service comprises a plurality of micro service instances, the micro service list comprising a call address for each of the micro service instances; the micro service is to perform flow distribution on each micro service instance to obtain flow distribution information of each micro service instance, and forward flow call to at least one micro service instance according to the call address of each micro service instance and the flow distribution information of each micro service instance.
18. The method of claim 14, wherein the traffic allocation information for each of the micro service instances is: determining an instance label of each micro-service instance, and distributing the flow of each micro-service instance according to the obtained total flow for calling the micro-service and the first mapping relation; the first mapping relationship is used for indicating a relationship between a preset instance tag and a traffic distribution weight.
19. A registry server, comprising:
a first determining unit, configured to determine a micro-service list corresponding to a micro-service requested by a micro-service acquisition request in response to the micro-service acquisition request initiated by a host, where the micro-service list is used to indicate that the micro-service is invoked;
the rewrite unit is used for performing rewrite processing on the obtained micro-service list to obtain a micro-service rewrite list, wherein the micro-service rewrite list can be directly analyzed by gateway equipment;
the micro-service rewrite list is used for calling the micro-service based on the gateway equipment, the micro-service rewrite list comprises a call address corresponding to the micro-service, the call address comprises a first domain name, and the first domain name is resolved to an IP address of the gateway equipment.
20. A gateway device, comprising:
the second receiving unit is used for receiving a micro-service rewrite list sent by the host, wherein the micro-service rewrite list is obtained after the micro-service rewrite list is rewritten, the micro-service list is determined based on a micro-service acquisition request initiated by the host, and the micro-service list corresponds to the micro-service requested by the micro-service acquisition request and is used for indicating to call the micro-service;
and the calling unit is used for calling the micro service according to the micro service rewrite list, wherein the micro service rewrite list can be directly analyzed by gateway equipment, the micro service rewrite list comprises calling addresses corresponding to the micro service, the calling addresses comprise first domain names, and the first domain names are analyzed to the IP addresses of the gateway equipment.
21. A host, comprising:
a first sending unit, configured to send a micro-service acquisition request to a registry server, where the micro-service acquisition request is used to determine a micro-service list corresponding to a micro-service requested by the micro-service acquisition request, and the micro-service list is used to indicate that the micro-service is invoked;
the third receiving unit is used for receiving a micro-service rewrite list sent by the registry server, wherein the micro-service rewrite list is obtained by rewriting the micro-service list, and the micro-service rewrite list can be directly analyzed by gateway equipment;
The second sending unit is used for sending the micro-service rewrite list to gateway equipment, wherein the micro-service rewrite list is used for calling the micro-service based on the gateway equipment, the micro-service rewrite list comprises calling addresses corresponding to the micro-service, the calling addresses comprise first domain names, and the first domain names are resolved to IP addresses of the gateway equipment.
22. An electronic device, comprising: a memory, a processor;
a memory; a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method of any one of claims 1 to 5; alternatively, the processor is configured to perform the method of any one of claims 6 to 13; alternatively, the processor is configured to perform the method of any of claims 14 to 18.
23. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are for implementing the method of any one of claims 1 to 5; alternatively, the computer-executable instructions, when executed by a processor, are for implementing the method of any one of claims 6 to 13; alternatively, the computer-executable instructions, when executed by a processor, are for implementing the method of any one of claims 14 to 18.
24. A micro-service invocation system, comprising:
the registry server of claim 19;
the gateway device of claim 20;
the host of claim 21.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111028725.8A CN113726902B (en) | 2021-09-02 | 2021-09-02 | Micro-service calling method, system, server, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111028725.8A CN113726902B (en) | 2021-09-02 | 2021-09-02 | Micro-service calling method, system, server, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113726902A CN113726902A (en) | 2021-11-30 |
CN113726902B true CN113726902B (en) | 2023-05-23 |
Family
ID=78681252
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111028725.8A Active CN113726902B (en) | 2021-09-02 | 2021-09-02 | Micro-service calling method, system, server, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113726902B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114785861B (en) * | 2022-06-22 | 2022-12-13 | 飞狐信息技术(天津)有限公司 | Service request forwarding system, method, computer equipment and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106375102B (en) * | 2015-07-22 | 2019-08-27 | 华为技术有限公司 | A kind of service registration method, application method and relevant apparatus |
CN108390766A (en) * | 2017-10-25 | 2018-08-10 | 国云科技股份有限公司 | A kind of service register and discovery method suitable for micro services |
CN108712464A (en) * | 2018-04-13 | 2018-10-26 | 中国科学院信息工程研究所 | A kind of implementation method towards cluster micro services High Availabitity |
CN109257440A (en) * | 2018-10-29 | 2019-01-22 | 南京南瑞信息通信科技有限公司 | A kind of service discovery and client load equalization methods based on service register center |
CN112579698B (en) * | 2020-12-02 | 2024-06-18 | 京东科技控股股份有限公司 | Data synchronization method, device, gateway equipment and storage medium |
-
2021
- 2021-09-02 CN CN202111028725.8A patent/CN113726902B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN113726902A (en) | 2021-11-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111327720B (en) | Network address conversion method, device, gateway equipment and storage medium | |
US20210208951A1 (en) | Method and apparatus for sharing gpu, electronic device and readable storage medium | |
CN110765024B (en) | Simulation test method, simulation test device, electronic equipment and computer readable storage medium | |
CN111666585B (en) | Method and device for accessing sub-application, electronic equipment and readable storage medium | |
CN112988499B (en) | Data processing method and device, electronic equipment and storage medium | |
US8290998B2 (en) | Systems and methods for generating cloud computing landscapes | |
CN107277029B (en) | Remote procedure call method and device and computer equipment | |
CN116018788A (en) | Configuring service grid networking resources for dynamically discovered peers or network functions | |
US10924590B1 (en) | Virtual workspace experience visualization and optimization | |
US11615159B2 (en) | Data processing method for mini app, apparatus, device and medium | |
KR20220151585A (en) | Business data processing method, apparatus, electronic apparatus, storage media and computer program | |
CN112000880B (en) | Push message processing method and device, electronic equipment and readable storage medium | |
CN113726902B (en) | Micro-service calling method, system, server, equipment and storage medium | |
CN111770176A (en) | Traffic scheduling method and device | |
CN111770211B (en) | SNAT method, SNAT device, electronic equipment and storage medium | |
KR20210040322A (en) | Scheduling method and apparatus, device and storage medium | |
EP4106293A2 (en) | Network configuring method and apparatus for cloud mobile phone, device and storage medium | |
CN115576565A (en) | Application program deployment method and device, electronic equipment and storage medium | |
CN111416860B (en) | Transaction processing method and device based on block chain, electronic equipment and medium | |
CN111177558A (en) | Channel service construction method and device | |
US20240020080A1 (en) | Handling local application events while working on remote desktops | |
CN111614494B (en) | Network resource simulation method and device, electronic equipment and computer readable storage medium | |
CN111597226B (en) | Data mining system, method, device, electronic equipment and storage medium | |
CN112035279B (en) | Service calling method and device and electronic equipment | |
CN114579146A (en) | Software installation 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 |