CN113726902A - Calling method and system of microservice - Google Patents

Calling method and system of microservice Download PDF

Info

Publication number
CN113726902A
CN113726902A CN202111028725.8A CN202111028725A CN113726902A CN 113726902 A CN113726902 A CN 113726902A CN 202111028725 A CN202111028725 A CN 202111028725A CN 113726902 A CN113726902 A CN 113726902A
Authority
CN
China
Prior art keywords
micro
service
list
rewriting
microservice
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111028725.8A
Other languages
Chinese (zh)
Other versions
CN113726902B (en
Inventor
熊志祥
赵国庆
蒋宁
吴海英
曾琳铖曦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mashang Xiaofei Finance Co Ltd
Original Assignee
Mashang Xiaofei Finance Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mashang Xiaofei Finance Co Ltd filed Critical Mashang Xiaofei Finance Co Ltd
Priority to CN202111028725.8A priority Critical patent/CN113726902B/en
Publication of CN113726902A publication Critical patent/CN113726902A/en
Application granted granted Critical
Publication of CN113726902B publication Critical patent/CN113726902B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Abstract

The embodiment of the application provides a method and a system for calling micro-services, wherein when the method is applied to a registration center server, the method comprises the following steps: the method comprises the steps of 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, rewriting the acquired micro-service list to obtain a micro-service rewriting list, the micro-service rewriting list can be directly analyzed by gateway equipment, and the micro-service rewriting list is fed back to the host, and is used for calling the micro-service based on the gateway equipment without storing the information of the full amount of micro-service of a registered center server in a local memory of the host, so that the defect of storage resource consumption is avoided, the calling time length is reduced, and the calling efficiency is improved.

Description

Calling method and system of microservice
Technical Field
The embodiment of the application relates to the technical field of cloud computing, in particular to a method and a system for calling micro-services.
Background
The micro-service is a service obtained by splitting a system into service capabilities according to service capabilities on the basis of a traditional software application architecture, one micro-service corresponds to a plurality of instances, one micro-service can be an independently applicable scheme, different micro-services can be mutually called, and calling among the micro-services is realized on the basis of flow control (such as flow forwarding).
In the prior art, a calling method of a microservice includes: 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 of the source host, inquires and calls address information such as the address, the port number and the like of the target micro service in a registered micro service list stored in the source host, and executes remote call of the target micro service based on the call address information.
However, the above method consumes a large amount of storage resources of the source host, and particularly when the scale of the number of micro-services is large, the technical problems of long call time and low efficiency are easily caused.
Disclosure of Invention
The embodiment of the application provides a method and a system for calling a micro service, which are used for solving the technical problem of high storage resource consumption.
In a first aspect, an embodiment of the present application provides a method for invoking a microservice, which is applied to a registry server, and the method includes:
responding to a micro-service acquisition request initiated by a host, and 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;
rewriting the acquired micro-service list to obtain a micro-service rewriting list, wherein the micro-service rewriting list can be directly analyzed by gateway equipment;
and feeding back the micro-service rewriting list to the host, wherein the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
In some embodiments, rewriting the obtained micro service list to obtain a micro service rewriting list includes:
acquiring the micro service list from a registration center server in response to rewriting information corresponding to the micro service acquisition request, wherein the rewriting information is information indicating that a micro service can be called based on the gateway device, and the micro service is requested by the micro service request;
and rewriting the micro-service list to obtain the micro-service rewriting list.
In some embodiments, the rewriting information includes a key value pair, a key in the key value pair is used for representing a name of the micro service, a value in the key value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
In some embodiments, the override information is generated based on a registration request of a microservice.
In some embodiments, further comprising:
and receiving a registration request aiming at 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 invoking a microservice, which is applied to a gateway device, and the method includes:
receiving a micro-service rewriting list sent by a host, wherein the micro-service rewriting list is obtained after rewriting the micro-service list, 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 for indicating to call the micro-service;
and calling the micro service according to the micro service rewriting list, wherein the micro service rewriting list can be directly analyzed by gateway equipment.
In some embodiments, further comprising:
and in response to acquiring the registration request for the micro service, generating rewriting information, and storing the rewriting information to a preset cluster device, wherein the rewriting information is information used for indicating that the micro service can be called based on the gateway device.
In some embodiments, the rewriting information includes a key value pair, a key in the key value pair is used for representing a name of the micro service, a value in the key value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice rewrite list comprising a call address for each of the microservice instances; according to the micro-service rewriting list, calling the micro-service, including:
carrying out flow distribution on each micro-service instance to obtain flow distribution information of each micro-service instance;
and forwarding the flow to at least one micro service instance according to the calling address of each micro service instance and the flow distribution information of each micro service instance so as to call the micro service.
In some embodiments, performing traffic distribution on each of the microservice instances to obtain traffic distribution information of each of the microservice instances includes:
determining an instance tag of each micro-service instance, and performing traffic distribution on each micro-service instance according to the obtained total traffic for calling the micro-service and the first mapping relation to obtain traffic distribution information of each micro-service instance; the first mapping relation is used for indicating the relation between preset instance labels and traffic distribution weights.
In some embodiments, further comprising:
acquiring a registration request aiming at the micro-service, and configuring an instance label for each micro-service instance in the micro-service according to the first mapping relation;
forwarding the registration request to the registry server, the registration request being used to complete registration of the microservice.
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 the registration request aiming at the micro service, and constructing a second mapping relation between the micro service list and the micro service rewriting list according to the micro service list and the rewriting information;
and calling the micro service according to the micro service rewriting list, wherein the calling comprises the following steps: and calling the micro service according to the micro service rewriting list and the second mapping relation.
In a third aspect, an embodiment of the present application provides a method for calling a microservice, which 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 rewriting list sent by the registration center server, wherein the micro-service rewriting list is obtained by rewriting the micro-service list, and the micro-service rewriting list can be directly analyzed by gateway equipment;
and sending the micro-service rewriting list to gateway equipment, wherein the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
In some embodiments, the micro-service rewrite list is: and acquiring the micro service list from a registration center server in response to rewriting information corresponding to the micro service acquisition request, and performing rewriting processing on the micro service list, wherein the rewriting information is information used for indicating that a 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 rewriting information includes a key value pair, a key in the key value pair is used for representing a name of the micro service, a value in the key value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice list comprising a call address for each of the microservice instances; the micro service allocates the flow of each micro service instance to obtain the flow allocation information of each micro service instance, and forwards the flow call to at least one micro service instance according to the call address of each micro service instance and the flow allocation information of each micro service instance.
In some embodiments, the traffic allocation information for each said microservice instance is: determining an instance label 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; the first mapping relation is used for indicating the relation between preset instance labels and traffic distribution weights.
In a fourth aspect, an embodiment of the present application provides a registry server, including:
the device comprises a first determining unit, a second determining unit and a third determining unit, wherein the first determining unit is used for responding to a micro-service obtaining request initiated by a host, and determining a micro-service list corresponding to the micro-service requested by the micro-service obtaining request, and the micro-service list is used for indicating to call the micro-service;
the rewriting unit is used for rewriting the acquired micro-service list to obtain a micro-service rewriting list, and the micro-service rewriting list can be directly analyzed by gateway equipment;
and the feedback unit is used for feeding the micro-service rewriting list back to the host, and the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
In some embodiments, the rewrite unit includes:
an obtaining subunit, configured to obtain the microservice list from a registry server in response to rewrite information corresponding to the microservice obtaining request, where the rewrite information is information indicating that a microservice can be invoked based on the gateway apparatus, and the microservice is requested by the microservice request;
and the rewriting subunit is used for rewriting the micro-service list to obtain the micro-service rewriting list.
In some embodiments, the rewriting information includes a key value pair, a key in the key value pair is used for representing a name of the micro service, a value in the key value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
In some embodiments, the override information is generated based on a registration request of a microservice.
In some embodiments, further comprising:
a first receiving unit, configured to receive a registration request for the microservice 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, an embodiment of the present application provides a gateway device, including:
a second receiving unit, configured to receive a micro-service rewrite list sent by a host, where the micro-service rewrite list is obtained by rewriting a micro-service list, the micro-service rewrite 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 rewrite list is used to instruct to invoke the micro-service;
and the calling unit is used for calling the micro service according to the micro service rewriting list, wherein the micro service rewriting list can be directly analyzed by gateway equipment.
In some embodiments, further comprising:
a generation unit configured to generate rewriting information in response to acquisition of a registration request for the microservice, the rewriting information being information indicating that the microservice is invokable based on the gateway apparatus;
and the storage unit is used for storing the rewriting information to preset cluster equipment.
In some embodiments, the rewriting information includes a key value pair, a key in the key value pair is used for representing a name of the micro service, a value in the key value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice rewrite list comprising a call address for each of the microservice instances; the calling unit comprises:
the distribution subunit is used for carrying out flow distribution on each micro service instance to obtain flow distribution information of each micro service instance;
and the calling subunit is used for forwarding the flow to at least one micro service instance according to the calling address of each micro service instance and the flow distribution information of each micro service instance 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 allocation on each micro service instance according to the obtained total traffic for invoking the micro service and the first mapping relationship, to obtain traffic allocation information of each micro service instance; the first mapping relation is used for indicating the relation between preset instance labels and traffic distribution weights.
In some embodiments, further comprising:
an acquisition unit configured to acquire a registration request for the microservice;
a configuration unit, configured to configure an instance tag for each micro-service instance in the micro-service according to the first mapping relationship;
and the forwarding unit is used for forwarding the registration request to the registration center server, wherein the registration request is used for finishing the registration of the microservice.
In some embodiments, the calling unit further comprises:
and the updating subunit is used for responding to the migration indication of the microservice and updating the first mapping relation according to the migration indication.
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;
the construction unit is used for constructing a second mapping relation between the micro service list and the micro service rewriting list according to the micro service list and the rewriting 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, an embodiment of the present application provides a host, including:
the system comprises a first sending unit, a registration center server and a second sending unit, wherein the first sending unit is used for sending a micro-service obtaining request to the registration center server, the micro-service obtaining request is used for determining a micro-service list corresponding to a micro-service requested by the micro-service obtaining request, and the micro-service list is used for indicating to call the micro-service;
a third receiving unit, configured to receive a micro-service rewrite list sent by the registry server, where the micro-service rewrite list is obtained by performing rewrite processing on the micro-service rewrite list, and the micro-service rewrite list can be directly parsed by a gateway device;
and the second sending unit is used for sending the micro-service rewriting list to gateway equipment, and the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
In some embodiments, the micro-service rewrite list is: and in response to rewriting information corresponding to the microservice obtaining request, obtaining the microservice list from a registry server, and performing rewriting processing on the microservice list, wherein the rewriting information is used for indicating information that the microservice can be called based on the gateway equipment, and the microservice is requested by the microservice request.
In some embodiments, the rewriting information includes a key value pair, a key in the key value pair is used for representing a name of the micro service, a value in the key value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice list comprising a call address for each of the microservice instances; the micro service allocates the flow of each micro service instance to obtain the flow allocation information of each micro service instance, and forwards the flow call to at least one micro service instance according to the call address of each micro service instance and the flow allocation information of each micro service instance.
In some embodiments, the traffic allocation information for each said microservice instance is: determining an instance label 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; the first mapping relation is used for indicating the relation between preset instance labels and traffic distribution weights.
In a seventh aspect, an embodiment of the present application provides 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 of the second aspect; alternatively, the processor is configured to perform the method according to the third aspect.
In an eighth aspect, embodiments of the present application provide a computer-readable storage medium, in which computer-executable instructions are stored, and when executed by a processor, the computer-executable instructions are used to implement the method according to the first aspect; alternatively, the computer executable instructions are for implementing the method of the second aspect when executed by a processor; alternatively, the computer executable instructions are for implementing the method according to the third aspect when executed by a processor.
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; or the computer program, when executed by a processor, implements the method according to the second aspect; alternatively, the computer program realizes the method according to the third aspect when executed by a processor.
In a tenth aspect, an embodiment of the present application provides a system for invoking a microservice, including:
the registry server of the fourth aspect;
the gateway device of the fifth aspect;
the host of the sixth aspect.
When the method is applied to a registration center server, the method and the system for calling the micro service provided by the embodiment of the application comprise the following steps: in response to a micro-service acquisition request initiated by a host, determining a micro-service list corresponding to a micro-service requested by the micro-service acquisition request, where the micro-service list is used to instruct to invoke the micro-service, and performing rewrite processing on the acquired micro-service list to obtain a micro-service rewrite list, where the micro-service rewrite list may be directly analyzed by a gateway device and fed back to the host, and the micro-service rewrite list is used to invoke the micro-service based on the gateway device, and in this embodiment, the following is introduced: the registry server rewrites the micro-service list and transmits the rewritten micro-service rewrite list to the host, so that the host realizes the technical characteristics of calling the micro-service based on the micro-service rewrite list, the information of the whole amount of micro-service passing through the registry server does not need to be stored in the local memory of the host, the defect of storage resource consumption is avoided, and 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 present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic view of an application scenario of a method for invoking a microservice according to an embodiment of the present application;
FIG. 2 is a diagram illustrating a method for invoking a microservice according to one embodiment of the present application;
FIG. 3 is a diagram illustrating a method for invoking a microservice according to another embodiment of the present application;
FIG. 4 is a diagram illustrating a method for invoking a microservice according to another embodiment of the present application;
FIG. 5 is a diagram illustrating a method for invoking a microservice according to another embodiment of the present application;
FIG. 6 is a schematic diagram of a registry server according to an 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 that invokes a method of microservice in accordance with an embodiment of the present application;
fig. 12 is a schematic diagram of a calling system of a microservice according to an embodiment of the present application.
With the above figures, there are shown specific embodiments of the present application, which will be described in more detail below. These drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the inventive concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
With the rapid development of the Internet, better requirements are provided for the high availability and service continuity of an Internet Technology (IT) system, and the IT system of a single machine room is gradually converted into the IT systems of a plurality of Internet Data Center (IDC) machine rooms, such as 'same city double activities', 'different place double activities', even 'different place multiple activities', and the like, so as to better guarantee the high availability of the IT system.
The calling method of the micro service according to this embodiment may be applied to a scenario of an IT system in a single computer room, for example, the calling method of the micro service according to this embodiment may be applied to a scenario in which micro services deployed on different hosts are called in the same computer room.
The calling method of the micro service according to this embodiment may also be applied to a scenario of an IT system in multiple computer rooms, for example, the calling method of the micro service according to this embodiment may be applied to a scenario in which a micro service deployed on a host in different computer rooms is called in different computer rooms.
For example, fig. 1 is a schematic diagram of a scenario in which the method for calling a microservice according to the embodiment of the present application may be applied to an IT system of multiple computer 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 includes N1 to Nn hosts. The machine room M comprises M1-Mm hosts.
The microservice deployed on any host in the machine room N can call the microservice deployed on any host in the machine room M. Similarly, the microservice deployed on any host in the machine room M may also be called.
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 (eurekaserer), and the registration center server can store the information of the micro service when registering the micro service, so as to obtain a micro service list.
In the related art, each host may obtain a micro service list from the registry server, and store the micro service list in the local memory. That is, in the related art, information of the total number of micro services that have been registered is stored in each host.
When a micro service deployed on a host (which may be referred to as a source host) needs to call a micro service deployed on another host (which may be referred to as a target host), the micro service list in the local memory of the source host is queried to determine corresponding call address information, and the micro service deployed on the target host is called based on the call address information.
However, when the method in the related art is used to call the micro-service, each host needs to store the micro-service list, which results in large consumption of storage resources of each host, and especially when the number of micro-services (i.e. the scale of the micro-service) is large, the technical problems of long call time and low efficiency are easily caused.
In order to solve the above technical problems, the inventors of the present application have made creative efforts to obtain the inventive concept of the present application: the registration center server supports a rewriting function to rewrite the micro-service list and sends the rewritten micro-service list to the host, so that the host calls 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 to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated 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 illustrating a method for invoking a microservice according to an embodiment of the present application.
As shown in fig. 2, the method includes:
s201: and responding to the micro-service acquisition request initiated by the host, and 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.
For example, the execution main body of this embodiment may be a registry server (hereinafter referred to as a server), the server may be a local server, and may also be a cloud server, and the server may also be a computer and a terminal device having a registration function, and the embodiment is not limited thereto.
The host may be a server as shown in fig. 1, or may be a computer device, or other processing device, etc.
S202: and rewriting the acquired micro-service list to obtain a micro-service rewriting list, wherein the micro-service rewriting list can be directly analyzed by gateway equipment.
The micro-service list and the micro-service rewriting list are relative concepts, and the micro-service list comprises the following components: when a microservice is registered by a registry server, a list of information relating to the calling address of the microservice, etc. is stored by the registry server. The micro service rewriting list is a list in which the micro service list is rewritten so that the micro service list can be directly analyzed by the gateway device.
S203: and feeding back the micro-service rewriting list to the host, wherein the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
For example, the registry server sends the micro-service rewriting list to the host; the host sends the micro-service rewriting list to the gateway equipment to request for calling the micro-service; the gateway equipment can directly analyze the micro-service rewriting list, thereby realizing the calling of the micro-service.
Based on the above analysis, an embodiment of the present application provides a method for invoking a microservice, which is applied to a registry server, and the method includes: in response to a micro-service acquisition request initiated by a host, determining a micro-service list corresponding to a micro-service requested by the micro-service acquisition request, where the micro-service list is used to instruct to invoke the micro-service, and performing rewrite processing on the acquired micro-service list to obtain a micro-service rewrite list, where the micro-service rewrite list may be directly analyzed by a gateway device and fed back to the host, and the micro-service rewrite list is used to invoke the micro-service based on the gateway device, and in this embodiment, the following is introduced: the registry server rewrites the micro-service list and transmits the rewritten micro-service rewrite list to the host, so that the host realizes the technical characteristics of calling the micro-service based on the micro-service rewrite list, the information of the whole amount of micro-service passing through the registry server does not need to be stored in the local memory of the host, the defect of storage resource consumption is avoided, and the technical effects of reducing calling time and improving calling efficiency are realized.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating a method for invoking a microservice according to another embodiment of the present application.
As shown in fig. 3, the method includes:
s301: the gateway device generates rewrite information indicating that the microservice is invokable based on the gateway device in response to obtaining the registration request for the microservice.
S302: and the gateway equipment transmits the rewriting information to the cluster equipment.
Wherein the cluster device may be a zookeeper cluster.
The rewriting information includes a key-value pair (key-value), a key in the key-value pair is used for representing a name of the micro service, a value in the key-value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
S303: the host sends a microservice acquisition request to the registry server.
For example, when a host has a need to invoke a microservice, a microservice acquisition request may be sent to the registry server.
S304: the registry server determines whether the cookie cluster includes a key value of the microservice, if so, S305 is executed, and if not, S311 is executed.
S305: and the registry server acquires a micro-service list corresponding to the micro-service from the local memory.
S306: and the registration center server rewrites the micro-service list to obtain a micro-service rewrite list.
Wherein, the micro-service rewriting list can be directly analyzed by the gateway device.
In some embodiments, the call address in the micro-service rewrite list is a call address including four levels of domain name information, as can be seen in table 1. That is, the calling address in the micro-service rewrite list can be directly transferred to the gateway device based on the modification of the domain name, and can be directly resolved by the gateway device.
Table 1:
micro service list Microservice rewrite lists
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 domain name b.xxx.lo can be preset, and the domain name can be resolved to the virtual IP address of the gateway device.
S307: the registry server sends a microservice rewrite list to the host.
S308: the host sends a micro-service rewrite list to the gateway device.
Based on the above 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 send at least one call address in the micro-service rewrite list to the gateway device, which is not limited in this embodiment.
It is worth to be noted that, in this embodiment, it can be known by combining the above analysis that storage resources of the host can be saved, efficiency of invoking the micro service can be improved, and by generating the micro service rewrite list by the registration center server, modification, upgrade, and update of the host can be avoided, modification, upgrade, and update costs of the host are saved, resources are saved, and a risk of invoking the micro service due to migration of the micro service 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 rewriting list to obtain flow distribution information of each micro-service instance.
In some embodiments, S309 may include the steps of:
the first step is as follows: an instance tag is determined for each microservice instance.
In some embodiments, the gateway device may configure an instance tag for each microservice instance in the microservice according to a first mapping relationship between a preset instance tag and a traffic assignment weight when acquiring a registration request for the microservice.
That is to say, when the micro service registers with the registry server through the gateway device, the gateway device may configure an instance tag for each micro service instance, so as to determine forwarding traffic of the corresponding micro service instance through the instance tag, thereby implementing invocation of different micro service instances.
In some embodiments, the gateway device may carry the instance tag in the registration request when forwarding the registration request of the microservice to the registry server.
Accordingly, the registry server stores a micro-service list that includes both the calling address of the micro-service instance and the instance tag of the micro-service instance.
The second step is as follows: and carrying out flow distribution on each micro-service instance according to the first mapping relation and the obtained total flow for calling the micro-service to obtain flow distribution information of each micro-service instance.
For example, after acquiring the total traffic for invoking the micro-service, the gateway device performs traffic allocation for each micro-service instance in a load balancing manner based on the first mapping relationship as the traffic allocation basis, thereby achieving flexibility and reliability of micro-service invocation and improving the technical effect of efficiency of micro-service invocation.
In some embodiments, in response to the migration indication of the microservice, the first mapping is updated according to the migration indication.
That is to say, the gateway device may allocate an instance tag to each micro service instance based on the first mapping relationship, so as to implement flexibility and diversity for invoking 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 implement meeting the invocation demand of the host computer for the micro service.
In other embodiments, the operation 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 called performance of the migrated micro service instance, and if it is determined that there is no problem with the call of the migrated micro service instance, the forwarding of the traffic to the pre-migration micro service instance is stopped.
In still other embodiments, a 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 at the time of the micro-service discovery. When the worker determines that the newly added micro-service instance is started normally, the initial value of the weight is modified manually, and the process of gradually modifying is performed, for example, the initial value 0 of the weight is gradually modified to 1, and the worker monitors the forwarding flow in the process to determine that the forwarding flow is normal. And setting the weight of the micro-service instance before the migration to be 0 by the staff, so that the flow for calling the micro-service is forwarded to the micro-service instance after the migration.
Specifically, the micro-service instance has an initiation parameter, and in conjunction with the foregoing embodiments, the initiation parameter may include an instance tag and may also include a weight.
In contrast, if the start parameter includes the weight, the weight in the start parameter is deleted after the migration of the micro-service instance is completed, so that after the restart of the micro-service instance, the flow for calling the micro-service is prevented from being forwarded to the micro-service instance before the migration.
If the starting parameter comprises the instance tag, the instance tag does not need to be deleted, so that the deleted operation resource 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. Further, the mapping table may include an instance tag of the microservice instance in the mapping.
Table 2:
micro service list Microservice rewrite lists Example Label
1.1.1.1:8080 1-1-1-1-8080-b.xxx.lo Is free of
1.1.1.2:8080 1-1-1-2:8080-b.xxx.lo Is free of
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
Some micro-service instances may have no instance tag, such as a micro-service instance before migration has no instance tag.
S310: and the gateway equipment forwards the flow to at least one micro service instance according to the calling address of each micro service instance and the flow distribution information of each micro service instance so as to call the micro service.
Illustratively, as can be seen from table 2, if the gateway device may determine that the call addresses of the forwardable traffic are 3-3-3-3-8080-b.xxx.lo and 4-4-4-4-8080-b.xxx.lo, the gateway device may determine the traffic forwarded to 3-3-3-3-8080-b.xxx.lo based on the instance tag 1, and may determine the traffic forwarded to 4-4-4-4-8080-b.xxx.lo based on the instance tag 2, and implement the call to the micro-service through the forwarding of the traffic.
Whereas no more traffic is forwarded for 1-1-1-1-8080-b.xxx.lo and 1-1-1-2:8080-b.xxx.lo without instance tags. By the scheme, the defect that the micro service cannot be called is avoided when the micro service is migrated, and the technical effect of reliability of calling the micro service is ensured.
S311: and the registry server acquires a micro-service list corresponding to the micro-service from the local memory.
S312: the registry server sends a list of micro-services to the host.
S313: the host sends a micro-service list to the gateway device.
S314: the gateway device performs the invocation of the micro-service based on the micro-service list.
Similarly, in this embodiment, the gateway device may analyze 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 illustrating a method for invoking a microservice according to another embodiment of the present application.
As shown in fig. 4, the method includes:
s401: and receiving the micro-service rewriting list sent by the host.
The micro-service rewriting list is obtained after rewriting the micro-service list, the micro-service list is determined based on a micro-service acquisition request initiated by a 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 the micro-service.
Illustratively, the execution subject of the present embodiment may be a gateway device.
For technical features and implementation principles of corresponding schemes in this embodiment that are the same as those in the above embodiment, reference may be made to the above embodiment, which is not described herein again.
In some embodiments, in response to obtaining the registration request for the microservice, rewrite information is generated and stored to the preset cluster device, the rewrite information being information indicating that the microservice can be invoked based on the gateway device.
In some embodiments, the override information includes a key-value pair, a key in the key-value pair to characterize a name of the microservice, a value in the key-value pair to characterize a calling address of the microservice, the calling address stored in the registry server.
S402: and calling the micro service according to the micro service rewriting list, wherein the micro service rewriting list can be directly analyzed by the gateway equipment.
It should be noted that, in this embodiment, the micro service rewrite list may be directly analyzed by the gateway device, so that all the call addresses in the micro service rewrite list are gathered to the gateway device, and the technical effects of accuracy and reliability of micro service call may be achieved.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice rewrite list comprising the invocation address of each microservice instance; s402 may include the steps of:
the first step is as follows: 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 comprise: determining an instance label of each micro-service instance, and performing traffic distribution on each micro-service instance according to the obtained total traffic for calling the micro-service and a first mapping relation to obtain traffic distribution information of each micro-service instance, wherein the first mapping relation is used for indicating a relation between a preset instance label and a traffic distribution weight.
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 the registry server, where the registration request is used to complete registration of the micro service.
In some embodiments, the gateway device may update the first mapping relationship according to the obtained migration instruction of the microservice.
The second step is as follows: and forwarding the flow to at least one micro-service instance according to each calling address and each flow distribution information so as to call the calling 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 illustrating a method for invoking a microservice 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 subject of the present embodiment may be a host.
For technical features and implementation principles of corresponding schemes in this embodiment that are the same as those in the above embodiment, reference may be made to the above embodiment, which is not described herein again.
S502: and receiving a micro-service rewriting list sent by the registration center server, wherein the micro-service rewriting list is obtained by rewriting the micro-service list, and the micro-service rewriting list can be directly analyzed by the gateway equipment.
Wherein the micro-service rewrite list is: and acquiring a micro service list from the registration center server in response to rewriting information corresponding to the micro service acquisition request, and performing rewriting processing on the micro service list, wherein the rewriting information is information 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 override information includes a key-value pair, a key in the key-value pair to characterize a name of the microservice, a value in the key-value pair to characterize a calling address of the microservice, the calling address stored in the registry server.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice list comprising a call address for each microservice instance; the micro-service allocates the flow of each micro-service instance to obtain the flow allocation information of each micro-service instance, and forwards the flow call to at least one micro-service instance according to the call address of each micro-service instance and the flow allocation information of each micro-service instance.
In some embodiments, the traffic allocation information for each microservice instance is: and determining an instance label of each micro-service instance, and performing traffic distribution on each micro-service instance according to the obtained total traffic for calling the micro-service and a first mapping relation, wherein the first mapping relation is used for indicating a relation between a preset instance label and a traffic distribution weight.
S503: and sending the micro-service rewriting list to the gateway equipment, wherein the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
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.
A rewriting unit 602, configured to rewrite the obtained micro service list to obtain a micro service rewriting list, where the micro service rewriting list may be directly analyzed by a 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 microservice forwarded by a gateway device.
A second determining unit 702, configured to determine and store a micro service list of micro services according to the registration request.
A first determining unit 703, 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 to invoke the micro-service.
A rewriting unit 704, configured to rewrite the obtained micro service list to obtain a micro service rewriting list, where the micro service rewriting list may be directly analyzed by the gateway device.
As can be seen in fig. 7, in some embodiments, the rewriting unit 704 includes:
an obtaining subunit 7041, configured to obtain, from the registry server, a micro-service list in response to rewriting information corresponding to the micro-service obtaining request, where the rewriting information is information indicating that the micro-service is invokable based on the gateway device, and the micro-service is requested by the micro-service request.
Rewriting subunit 7042 is configured to perform rewriting processing on the micro service list to obtain a micro service rewriting list.
In some embodiments, the override information includes a key-value pair, a key in the key-value pair to characterize a name of the microservice, a value in the key-value pair to characterize a calling address of the microservice, the calling address stored in the registry server.
In some embodiments, the override information is generated based on a registration request of the microservice.
A feedback unit 705, configured to feed back the micro service rewriting list to the host, where the micro service rewriting 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:
a second receiving unit 801, configured to receive a micro-service rewriting list sent by a host, where the micro-service rewriting list is obtained by performing rewriting processing on a micro-service list, 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 invoke the micro-service.
A calling unit 802, configured to call the micro service according to the micro service rewrite list, where the micro service rewrite list may 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 rewriting information in response to acquiring a registration request for a microservice, the rewriting information being information indicating that the microservice is invokable based on a gateway device.
In some embodiments, the override information includes a key-value pair, a key in the key-value pair to characterize a name of the microservice, a value in the key-value pair to characterize a calling address of the microservice, the calling address stored in the registry server.
And a storage unit 902, configured to store the rewriting information in a preset cluster device.
An obtaining unit 903, configured to obtain a registration request for a microservice.
A configuring 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 the registration request to the registry server, where the registration request is used to complete registration of the microservice.
A second receiving unit 906, configured to receive a micro-service rewriting list sent by the host, where the micro-service rewriting list is obtained by performing rewriting processing on the micro-service list, 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 invoke the micro-service.
A calling unit 907, configured to call the micro service according to the micro service rewriting list, where the micro service rewriting list may be directly parsed by the gateway device.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice rewrite list comprising the invocation address of each microservice instance; a call unit 907, including:
and the allocating subunit 9071 is configured to perform traffic allocation on each micro service instance to obtain traffic allocation information of each micro service instance.
And the calling subunit 9072 is configured to forward the traffic to the at least one microservice instance according to each calling address and each traffic allocation information, so as to call the microservice.
And the updating subunit 9073 is configured to, in response to the migration instruction of the micro service, 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 micro service instance, and perform traffic allocation on each micro service instance according to the obtained total traffic for invoking the micro service and the first mapping relationship, to obtain traffic allocation information of each micro service instance; the first mapping relationship is used for indicating the relationship between the preset instance label and the traffic distribution weight.
In some embodiments, as can be seen in conjunction with fig. 9, the gateway device 900 may further include:
a third determining unit 908, configured to determine a micro-service list of the micro-service according to the registration request for the micro-service.
A constructing unit 909, 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 907 is configured to call the micro service according to the micro service rewriting list and the second mapping relationship.
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 microservice obtaining request to a registry server, where the microservice obtaining request is used to determine a microservice list corresponding to a microservice requested by the microservice obtaining request, and the microservice list is used to indicate to invoke the microservice.
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 rewrite processing on the micro-service rewrite 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 rewriting list to a gateway device, where the micro-service rewriting list is used to invoke the micro-service based on the gateway device.
In some embodiments, the micro-service rewrite list is: and in response to rewriting information corresponding to the microservice obtaining request, obtaining the microservice list from a registration center server, and rewriting the microservice list, wherein the rewriting information is used for indicating that the microservice can be called based on the gateway equipment, and the microservice is requested by the microservice request.
In some embodiments, the rewriting information includes a key value pair, a key in the key value pair is used for representing a name of the micro service, a value in the key value pair is used for representing a calling address of the micro service, and the calling address is stored in the registry server.
In some embodiments, the microservice comprises a plurality of microservice instances, the microservice list comprising a call address for each of the microservice instances; the micro service allocates the flow of each micro service instance to obtain the flow allocation information of each micro service instance, and forwards the flow call to at least one micro service instance according to the call address of each micro service instance and the flow allocation information of each micro service instance.
In some embodiments, the traffic allocation information for each said microservice instance is: determining an instance label 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; the first mapping relation is used for indicating the relation between preset instance labels and traffic distribution weights.
According to an embodiment of the present application, an electronic device and a readable storage medium are also provided.
There is also provided, in accordance with an embodiment of the present application, a computer program product, including: a computer program, stored in a readable storage medium, from which at least one processor of the electronic device can read the computer program, the at least one processor executing the computer program causing the electronic device to perform the solution provided by any of the embodiments described above.
Fig. 11 is a block diagram of an electronic device for invoking a microservice according to an embodiment of the present application. 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 phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application that are described and/or claimed herein.
As shown in fig. 11, the electronic apparatus includes: one or more processors 1101, a 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 for execution within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input/output apparatus (such as a display device coupled to the interface). In other embodiments, multiple processors and/or multiple buses may be used, along with multiple memories and multiple memories, as desired. Also, multiple electronic devices may be connected, with each device providing portions of the necessary operations (e.g., as a server array, a group of blade servers, or a multi-processor system). In fig. 11, a processor 1101 is taken as an example.
The memory 1102 is a non-transitory computer readable storage medium as provided herein. Wherein the memory stores instructions executable by at least one processor to cause the at least one processor to perform the method for invoking the microservice provided herein. The non-transitory computer-readable storage medium of the present application stores computer instructions for causing a computer to execute the calling method of the microservice provided by the present application.
The memory 1102, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the calling methods of the microservices in the embodiments of the present application. The processor 1101 executes various functional applications of the server and data processing, i.e., a calling method of the microservice in the above-described method embodiment, by running the non-transitory software programs, instructions and modules stored in the memory 1102.
The memory 1102 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the electronic device of the calling method of the microservice, and the like. Further, the memory 1102 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 1102 may optionally include memory located remotely from the processor 1101, which may be connected to the microservice method-calling electronic device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the calling method of the microservice may further include: an input device 1103 and an output device 1104. The processor 1101, the memory 1102, the input device 1103 and the output device 1104 may be connected by a bus or other means, and are exemplified by being connected by a bus in fig. 11.
The input device 1103 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic device of the calling method of the micro-service, such as an input device of a touch screen, a keypad, a mouse, a track pad, a touch pad, a pointer, one or more mouse buttons, a track ball, a joystick, etc. The output devices 1104 may include a display device, auxiliary lighting devices (e.g., LEDs), tactile feedback devices (e.g., vibrating motors), and the like. 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 can be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
These computer programs (also known as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented using high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. 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 a pointing device (e.g., a mouse or a 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 can 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, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end 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 back-end, 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 clients and servers. A client and server are generally 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 embodiments of the present application, there is also provided a system for invoking micro services, including:
the registry server as in any of the above embodiments;
the gateway device as claimed in any one of the above embodiments;
a host as in any preceding embodiment.
In some embodiments, the calling system of the microservice may further include a cluster device for storing the rewriting information. Wherein the cluster device may be a zookeeper cluster.
Illustratively, as shown in fig. 12, the calling system 1200 of the microservice includes:
the gateway device 1201 is configured to receive a registration request initiated by the micro service, generate a key value pair corresponding to the micro service, and transmit the key value pair to the zookeeper cluster 1202.
zookeeper cluster 1202 stores key-value pairs.
The host 1203 is configured to send a micro-service obtaining request to the registry server 1204, so as to call the micro-service.
For example, at least one micro service may be deployed in the host 1203, any micro service deployed in the host 1203 may call other micro services, and the 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 fig. 12, at least one microservice may also be deployed in the first host, and as compared to any microservice deployed in the host 1203, at least one microservice deployed in the first host may be another microservice, that is, any microservice in the host 1203 may call the microservice deployed in the first host.
For another example, as shown in fig. 12, at least one microservice may also be deployed in the second host, and as compared to any microservice deployed in the host 1203, at least one microservice deployed in the second host may be another microservice, that is, any microservice in the host 1203 may call a microservice deployed in the second host.
As shown in fig. 12, the second host is the host after the migration of the first host, and at least part of the microservices deployed in the first host are migrated to the second host. Correspondingly, if all the microservices deployed in the first host are migrated to the second host, any microservices in the host 1203 may call the microservices migrated to the second host; if a portion of the deployed microservices in the first host migrate to the second host, any microservices in the host 1203 may call the portion that was not migrated in the first host and the portion that has migrated to the second host.
The registry server 1204 is configured to determine whether the zookeeper cluster 1202 has a key value pair corresponding to a micro service, and if so, obtain a micro service list corresponding to the micro service and stored in a local memory of the registry server in advance, and rewrite the micro service list to obtain a micro service rewrite list, so that the micro service rewrite list can be directly analyzed by the gateway device 1201.
The gateway device 1201 may send a registration request to the registry server 1204, and accordingly, the registry server 1204 may determine the micro-service list based on the registration request.
The registry server 1204 is also configured to transmit the micro-service rewrite list to the host 1203.
The host 1203 is further configured to transmit the micro-service rewrite list to the gateway device 1201.
The gateway device 1201 is further configured to invoke the micro-service based on the micro-service rewrite list.
If the micro service includes multiple micro service instances, and the multiple micro service instances are deployed on different hosts, as shown in fig. 12, part of the multiple micro service instances are deployed on a first host, and part of the multiple micro service instances are deployed on a second host, then the gateway device may invoke at least one micro service instance based on the instance tag of each micro service instance, thereby completing the invocation of the micro service.
For example, with reference to the foregoing embodiment, if the first host is a host before the migration of the micro service, and the second host is a host after the migration of the micro service, the gateway device 1201 may forward the traffic to the second host, so as to implement the call of the micro service instance deployed in the second host, thereby implementing the call of the micro service.
It should be understood that, with respect to the principle that each component in the calling system of the micro service cooperates to implement the calling of the micro service, reference may be made to the above-mentioned embodiments, and details are not described here.
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 invention 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 invention 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 will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (25)

1. A calling method of micro service is applied to a registry server, and comprises the following steps:
responding to a micro-service acquisition request initiated by a host, and 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;
rewriting the acquired micro-service list to obtain a micro-service rewriting list, wherein the micro-service rewriting list can be directly analyzed by gateway equipment;
and feeding back the micro-service rewriting list to the host, wherein the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
2. The method of claim 1, wherein rewriting the acquired micro-service list to obtain a micro-service rewrite list comprises:
acquiring the micro service list from a registration center server in response to rewriting information corresponding to the micro service acquisition request, wherein the rewriting information is information indicating that a micro service can be called based on the gateway device, and the micro service is requested by the micro service request;
and rewriting the micro-service list to obtain the micro-service rewriting list.
3. The method of claim 2, wherein the override information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a microservice, a value of the key-value pair being used to characterize a calling address of the microservice, the calling address being stored in the registry server.
4. The method of claim 2, wherein the override information is generated based on a registration request of a microservice.
5. The method of any of claims 1 to 4, further comprising:
and receiving a registration request aiming at 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 calling method of micro service is applied to gateway equipment, and the method comprises the following steps:
receiving a micro-service rewriting list sent by a host, wherein the micro-service rewriting list is obtained after rewriting the micro-service list, 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 for indicating to call the micro-service;
and calling the micro service according to the micro service rewriting list, wherein the micro service rewriting list can be directly analyzed by gateway equipment.
7. The method of claim 6, further comprising:
and in response to acquiring the registration request for the micro service, generating rewriting information, and storing the rewriting information to a preset cluster device, wherein the rewriting information is information used for indicating that the micro service can be called based on the gateway device.
8. The method of claim 7, wherein the override information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a microservice, a value of the key-value pair being used to characterize a calling address of the microservice, the calling address being stored in the registry server.
9. The method of any of claims 6 to 8, wherein the microservice comprises a plurality of microservice instances, the microservice rewrite list comprising a calling address for each of the microservice instances; according to the micro-service rewriting list, calling the micro-service, including:
carrying out flow distribution on each micro-service instance to obtain flow distribution information of each micro-service instance;
and forwarding the flow to at least one micro service instance according to the calling address of each micro service instance and the flow distribution 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 microservice instances to obtain traffic distribution information of each of the microservice instances comprises:
determining an instance tag of each micro-service instance, and performing traffic distribution on each micro-service instance according to the obtained total traffic for calling the micro-service and the first mapping relation to obtain traffic distribution information of each micro-service instance; the first mapping relation is used for indicating the relation between preset instance labels and traffic distribution weights.
11. The method of claim 10, further comprising:
acquiring a registration request aiming at the micro-service, and configuring an instance label for each micro-service instance in the micro-service according to the first mapping relation;
forwarding the registration request to the registry server, the registration request being used to complete registration of the microservice.
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 the registration request aiming at the micro service, and constructing a second mapping relation between the micro service list and the micro service rewriting list according to the micro service list and the rewriting information;
and calling the micro service according to the micro service rewriting list, wherein the calling comprises the following steps: and calling the micro service according to the micro service rewriting list and the second mapping relation.
14. A calling method of micro service, which is applied to a host, comprises the following steps:
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 rewriting list sent by the registration center server, wherein the micro-service rewriting list is obtained by rewriting the micro-service list, and the micro-service rewriting list can be directly analyzed by gateway equipment;
and sending the micro-service rewriting list to gateway equipment, wherein the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
15. The method of claim 14, wherein the microservice rewrite list is: and acquiring the micro service list from a registration center server in response to rewriting information corresponding to the micro service acquisition request, and performing rewriting processing on the micro service list, wherein the rewriting information is information used for indicating that a micro service can be called based on the gateway device, and the micro service is requested by the micro service request.
16. The method of claim 14, wherein the override information comprises a key-value pair, a key of the key-value pair being used to characterize a name of a microservice, a value of the key-value pair being used to characterize a calling address of the microservice, the calling address being stored in the registry server.
17. The method of claim 14, wherein the microservice comprises a plurality of microservice instances, the microservice list comprising a calling address for each of the microservice instances; the micro service allocates the flow of each micro service instance to obtain the flow allocation information of each micro service instance, and forwards the flow call to at least one micro service instance according to the call address of each micro service instance and the flow allocation information of each micro service instance.
18. The method of claim 14, wherein the traffic allocation information for each of the microservice instances is: determining an instance label 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; the first mapping relation is used for indicating the relation between preset instance labels and traffic distribution weights.
19. A registry server, comprising:
the device comprises a first determining unit, a second determining unit and a third determining unit, wherein the first determining unit is used for responding to a micro-service obtaining request initiated by a host, and determining a micro-service list corresponding to the micro-service requested by the micro-service obtaining request, and the micro-service list is used for indicating to call the micro-service;
the rewriting unit is used for rewriting the acquired micro-service list to obtain a micro-service rewriting list, and the micro-service rewriting list can be directly analyzed by gateway equipment;
and the feedback unit is used for feeding the micro-service rewriting list back to the host, and the micro-service rewriting list is used for calling the micro-service based on the gateway equipment.
20. A gateway device, comprising:
a second receiving unit, configured to receive a micro-service rewrite list sent by a host, where the micro-service rewrite list is obtained by rewriting a micro-service list, the micro-service rewrite 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 rewrite list is used to instruct to invoke the micro-service;
and the calling unit is used for calling the micro service according to the micro service rewriting list, wherein the micro service rewriting list can be directly analyzed by gateway equipment.
21. A host, comprising:
the system comprises a first sending unit, a registration center server and a second sending unit, wherein the first sending unit is used for sending a micro-service obtaining request to the registration center server, the micro-service obtaining request is used for determining a micro-service list corresponding to a micro-service requested by the micro-service obtaining request, and the micro-service list is used for indicating to call the micro-service;
a third receiving unit, configured to receive a micro-service rewrite list sent by the registry server, where the micro-service rewrite list is obtained by performing rewrite processing on the micro-service rewrite list, and the micro-service rewrite list can be directly parsed by a gateway device;
and the second sending unit is used for sending the micro-service rewriting list to gateway equipment, and the micro-service rewriting list is used for calling the micro-service based on 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 for implementing the method of any one of claims 1 to 5 when executed by a processor; or, 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 of claims 14 to 18.
24. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 5; or, when executed by a processor, implementing the method according to any one of claims 6 to 13; alternatively, the computer program, when executed by a processor, implements the method of any of claims 14 to 18.
25. A calling system for microservices, comprising:
the registry server of claim 19;
the gateway device of claim 20;
the host of claim 21.
CN202111028725.8A 2021-09-02 2021-09-02 Micro-service calling method, system, server, equipment and storage medium Active CN113726902B (en)

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 true CN113726902A (en) 2021-11-30
CN113726902B 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)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114785861A (en) * 2022-06-22 2022-07-22 飞狐信息技术(天津)有限公司 Service request forwarding system, method, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180145890A1 (en) * 2015-07-22 2018-05-24 Huawei Technologies Co., Ltd. Service registration method and usage method, and related 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
CN112579698A (en) * 2020-12-02 2021-03-30 京东数字科技控股股份有限公司 Data synchronization method, device, gateway equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180145890A1 (en) * 2015-07-22 2018-05-24 Huawei Technologies Co., Ltd. Service registration method and usage method, and related 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
CN112579698A (en) * 2020-12-02 2021-03-30 京东数字科技控股股份有限公司 Data synchronization method, device, gateway equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114785861A (en) * 2022-06-22 2022-07-22 飞狐信息技术(天津)有限公司 Service request forwarding system, method, computer equipment and storage medium
CN114785861B (en) * 2022-06-22 2022-12-13 飞狐信息技术(天津)有限公司 Service request forwarding system, method, computer equipment and storage medium

Also Published As

Publication number Publication date
CN113726902B (en) 2023-05-23

Similar Documents

Publication Publication Date Title
US20210208951A1 (en) Method and apparatus for sharing gpu, electronic device and readable storage medium
US11601378B2 (en) Method and apparatus for allocating server resource, electronic device and storage medium
US20220377045A1 (en) Network virtualization of containers in computing systems
CN110765024B (en) Simulation test method, simulation test device, electronic equipment and computer readable storage medium
US9634956B2 (en) Multilevel multipath widely distributed computational node scenarios
US20190089588A1 (en) Network function instance management method and related device
US9576332B1 (en) Systems and methods for remote graphics processing unit service
CN113849312B (en) Data processing task allocation method and device, electronic equipment and storage medium
CN111666585A (en) Method and device for accessing sub-application, electronic equipment and readable storage medium
CN111586128A (en) Method, device and equipment for acquiring applet data and storage medium
EP3869336A1 (en) Method and apparatus for processing development machine operation task, device and storage medium
CN113934464A (en) Method and device for starting android application in Linux system and electronic equipment
EP3358790A1 (en) Network function virtualization resource processing method and virtualized network function manager
CN109995552B (en) VNF service instantiation method and device
US10924590B1 (en) Virtual workspace experience visualization and optimization
US20210117169A1 (en) Code execution method, device, and rendering apparatus
CN113726902B (en) Micro-service calling method, system, server, equipment and storage medium
CN108958933B (en) Configuration parameter updating method, device and equipment of task executor
EP3823253A2 (en) Data processing method for mini app, apparatus, device, medium, and computer program product
CN112596897A (en) Method and system for multi-tenant isolation
CN111770176A (en) Traffic scheduling method and device
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
CN113612643B (en) Network configuration method, device and equipment of cloud mobile phone and storage medium
CN115665231A (en) Service creation method, device and computer-readable 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