CN115134412A - Service calling method and device, electronic equipment and computer readable storage medium - Google Patents

Service calling method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN115134412A
CN115134412A CN202210742658.4A CN202210742658A CN115134412A CN 115134412 A CN115134412 A CN 115134412A CN 202210742658 A CN202210742658 A CN 202210742658A CN 115134412 A CN115134412 A CN 115134412A
Authority
CN
China
Prior art keywords
service
service provider
target
determining
current load
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210742658.4A
Other languages
Chinese (zh)
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210742658.4A priority Critical patent/CN115134412A/en
Publication of CN115134412A publication Critical patent/CN115134412A/en
Pending legal-status Critical Current

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/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload

Abstract

The application discloses a service calling method and device, electronic equipment and a computer readable storage medium, and relates to the technical field of cloud computing. Wherein, the method comprises the following steps: receiving a service calling request sent by a service consumer; determining a first service provider from a plurality of service providers in response to the service invocation request; detecting whether the current load rate of a first service provider is greater than a preset threshold value or not; determining the first service provider as a target service provider under the condition that the current load rate of the first service provider is smaller than a preset threshold; and determining a second service provider as a target service provider from the plurality of service providers when the current load rate of the first service provider is greater than or equal to a preset threshold, wherein the second service provider is located in a different area from the first service provider. The method and the device solve the technical problem that in the prior art, the service calling request of the micro-service cannot be processed across areas, so that the service calling efficiency is low.

Description

Service calling method and device, electronic equipment and computer readable storage medium
Technical Field
The application relates to the technical field of cloud computing, in particular to a service calling method and device, electronic equipment and a computer readable storage medium.
Background
The micro-services are a set of small-sized services developed by adopting a single application program, each application program runs in a respective process and communicates with a lightweight mechanism, and the micro-services are constructed around business functions and are independently deployed and managed in a centralized manner through a full-automatic deployment mechanism.
In the existing large-scale distributed cluster scene, the micro-service usually adopts deployment modes such as remote multi-activity, same-city multi-activity, unitization and the like to ensure the high availability of the system and the continuity of the service. That is, the same microservice may be deployed in multiple regions simultaneously.
However, in the prior art, a micro-service invocation request initiated by one service consumer generally only supports processing by a service provider located in one fixed area, in other words, even if the load of the service provider in the fixed area is insufficient, the micro-service invocation request initiated by the service consumer cannot be processed by the service providers in other areas, thereby causing a problem of low service invocation efficiency.
Disclosure of Invention
The embodiment of the application provides a service calling method, a service calling device, electronic equipment and a computer readable storage medium, so as to at least solve the technical problem that in the prior art, a service calling request of a micro service cannot be processed across areas, so that the service calling efficiency is low.
According to an aspect of an embodiment of the present application, there is provided a service invocation method, including: receiving a service calling request sent by a service consumer, wherein the service calling request at least comprises a target area identifier and a target service identifier, the target area identifier is used for representing an area where the service consumer is located, and the target service identifier is used for representing a target service which is requested to be called by the service consumer; responding to the service calling request, determining a first service provider from a plurality of service providers, wherein the service provider is used for providing services for a service consumer, the first service provider and the service consumer are located in the same area, and a target service runs on the first service provider; detecting whether the current load rate of a first service provider is greater than a preset threshold value; under the condition that the current load rate of the first service provider is smaller than a preset threshold value, determining that the first service provider is a target service provider, wherein the target service provider is used for providing target services for service consumers; and under the condition that the current load rate of the first service provider is greater than or equal to a preset threshold value, determining a second service provider as a target service provider from a plurality of service providers, wherein the second service provider is located in a different area from the first service provider, the current load rate of the second service provider is smaller than the preset threshold value, and the target service is operated on the second service provider.
Further, the service calling method further comprises the following steps: the method comprises the steps of obtaining an area identifier and a service identifier of each service provider, wherein the area identifier is used for representing the area where each service provider is located, and the service identifier is used for representing the service running on each service provider; determining at least two third service providers from the plurality of service providers according to the target service identifier, wherein the service identifier of the third service provider is the target service identifier, and the at least two third service providers are located in different areas; and determining a first service provider from at least two third service providers according to the target area identifier, wherein the area identifier of the first service provider is the target area identifier.
Further, the service calling method further comprises: determining at least one candidate service provider from at least two third service providers under the condition that the current load rate of a first service provider is greater than or equal to a preset threshold, wherein the current load rate of the candidate service provider is less than the preset threshold, and the candidate service provider and the first service provider are located in different areas; and determining a second service provider from the at least one candidate service provider according to the current load rate of the candidate service provider, and determining the second service provider as the target service provider.
Further, the service calling method further comprises: sequencing the current load rate of at least one candidate service provider to obtain a sequencing result; and determining the candidate service provider with the minimum current load rate as a second service provider according to the sequencing result.
Further, the service calling method further comprises: acquiring a current load rate corresponding to a candidate service provider at each moment in a preset time period, wherein the preset time period comprises a plurality of moments; determining the median of a plurality of current load rates of the candidate service providers in a preset time period according to the current load rate corresponding to the candidate service providers at each moment; and determining the candidate service provider with the minimum median as the second service provider.
Further, the service calling method further comprises the following steps: determining the area of the service consumer according to the target area identification; determining the area of the candidate service provider according to the area identification of the candidate service provider; determining a distance between the candidate service provider and the service consumer based on the area where the service consumer is located and the area where the candidate service provider is located; and determining the candidate service provider with the shortest distance as a second service provider.
Further, the service calling method further comprises the following steps: after the first service provider is determined to be the target service provider, acquiring a call success rate when a service consumer calls a target service from the first service provider; and under the condition that the calling success rate is smaller than the preset success rate, determining the second service provider as a target service provider from the plurality of service providers.
According to another aspect of the embodiments of the present application, there is also provided a service invocation device, including: the system comprises a receiving module, a service calling module and a service calling module, wherein the receiving module is used for receiving a service calling request sent by a service consumer, the service calling request at least comprises a target area identifier and a target service identifier, the target area identifier is used for representing an area where the service consumer is located, and the target service identifier is used for representing a target service which the service consumer requests to call; the service calling module is used for calling a service calling request to a service provider, and determining the service provider from a plurality of service providers, wherein the service provider is used for providing services for a service consumer, the first service provider and the service consumer are located in the same area, and a target service runs on the first service provider; the detection module is used for detecting whether the current load rate of the first service provider is greater than a preset threshold value; the second determining module is used for determining the first service provider as a target service provider under the condition that the current load rate of the first service provider is smaller than a preset threshold value, wherein the target service provider is used for providing target services for a service consumer; and a third determining module, configured to determine, when the current load rate of the first service provider is greater than or equal to a preset threshold, that a second service provider is a target service provider from multiple service providers, where the second service provider and the first service provider are located in different areas, the current load rate of the second service provider is smaller than the preset threshold, and the second service provider also runs a target service.
According to another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the service invocation method when running.
According to another aspect of embodiments of the present application, there is also provided an electronic device, including one or more processors; a memory for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method for running a program, wherein the program is arranged to perform the above-mentioned service invocation method when running.
In the embodiment of the application, a method of determining a target service provider providing a target service for a service consumer according to a location area and a current load rate of the service provider is adopted, firstly, after a service calling request sent by the service consumer is received, a first service provider is determined from a plurality of service providers in response to the service calling request, wherein the service provider is used for providing the service for the service consumer, the service calling request at least comprises a target area identifier and a target service identifier, the target area identifier is used for representing the location area of the service consumer, and the target service identifier is used for representing the target service requested to be called by the service consumer; the first service provider is located in the same area as the service consumption direction, and the target service runs on the first service provider. Then, detecting whether the current load rate of the first service provider is greater than a preset threshold value; under the condition that the current load rate of the first service provider is smaller than a preset threshold value, determining that the first service provider is a target service provider, wherein the target service provider is used for providing target services for service consumers; and under the condition that the current load rate of the first service provider is greater than or equal to a preset threshold value, determining a second service provider as a target service provider from a plurality of service providers, wherein the second service provider is located in a different area from the first service provider, the current load rate of the second service provider is smaller than the preset threshold value, and the target service is operated on the second service provider.
As can be seen from the above, according to the present application, after receiving a service invocation request sent by a service consumer, a first service provider located in the same area as the service consumer is first used as a preferred service provider for processing the service invocation request, and as the distance between the service provider and the service consumer is longer, the network resource consumption is larger, therefore, the first service provider is selected as the preferred service provider, which can reduce unnecessary network resource consumption, thereby improving the network resource utilization rate. In addition, the current load rate of the first service provider is detected, and if the current load rate of the first service provider is too high (greater than or equal to a preset threshold), the second service provider with the lower current load rate in other areas is selected as the target service provider for providing the target service for the service consumer, so that the problem of poor service calling stability caused by forcibly using the first service provider to provide the target service for the service consumer can be avoided, and the service calling efficiency is improved.
Therefore, through the technical scheme of the application, the purpose of flexibly selecting the service providers in different areas to provide the target service for the service consumers is achieved, the effect of improving the service calling stability is achieved, and the technical problem that the service calling efficiency is low due to the fact that the service calling request of the micro-service cannot be processed across areas in the prior art is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a flow diagram of an alternative service invocation method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an alternative service invocation device according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an alternative electronic device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In addition, it should be noted that the relevant information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for presentation, analyzed data, etc.) referred to in the present disclosure are information and data authorized by the user or sufficiently authorized by each party. For example, an interface is provided between the system and the relevant user or organization, before obtaining the relevant information, an obtaining request needs to be sent to the user or organization through the interface, and after receiving the consent information fed back by the user or organization, the relevant information is obtained.
Example 1
In accordance with an embodiment of the present application, there is provided an embodiment of a service invocation method, it should be noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than here.
It should be noted that, in the embodiment of the present application, an Eureka registry, which is a registry of a service discovery framework employing an application-level service discovery mode, may be selected as an execution subject of the service invocation method in the embodiment of the present application.
Fig. 1 is a flowchart of an alternative service invocation method according to an embodiment of the present application, as shown in fig. 1, the method includes the following steps:
step S101, receiving a service calling request sent by a service consumer.
In step S101, the service invocation request at least includes a target area identifier and a target service identifier, where the target area identifier is used to characterize an area where the service consumer is located, and the target service identifier is used to characterize a target service that the service consumer requests to invoke.
Specifically, the target service may be a micro service, and the service consumer may be a device for invoking the micro service, where the device for invoking the micro service may be a terminal device such as a smart phone, a notebook computer, a desktop computer, a smart tablet, and a smart wearable device, and may also be a server device such as a local server and a cloud server. For example, the service consumer may send a service invocation request to the Eureka registry, where the service invocation request includes a target area identifier, e.g., region a, and the service invocation request also includes a target service identifier, e.g., serviceA.
It should be noted that the area range represented by the target area identifier may be set in a customized manner, for example, the area range may be a city, such as area a representing beijing city and area B representing shanghai city. The region scope may also characterize different regions of a city, such as region C characterizing the great happy region of beijing city and region D characterizing the sunny region of beijing city. The size of the area range can be determined according to actual conditions.
In an alternative embodiment, before receiving the service invocation request sent by the service consumer, the Eureka registry registers the respective feature attributes as metadata information to the Eureka registry, where the service provider may be understood as an application providing a micro service for the service provider, for example, the service provider may be a server or a server cluster running the micro service; the characteristic attribute includes at least the region information of each service provider, for example, the geographical region, administrative region, and data center location where the service provider is located.
Optionally, each service provider registers, in addition to the feature attribute in the Eureka registration center, service instance information in the Eureka registration center, where the service instance information at least includes a service identifier of a microservice running on the service provider, an IP address of the service provider, and a data communication port. The service identification may also be understood as a service name of the microservice.
Step S102, responding to the service calling request, and determining a first service provider from a plurality of service providers.
In step S102, the service provider is configured to provide a service for the service consumer, the first service provider is located in the same area as the service consumer, and the target service runs on the first service provider.
Specifically, after receiving the service invocation request, the Eureka registration center first obtains an area identifier and a service identifier of each service provider, where the area identifier is used to characterize an area where each service provider is located, and the service identifier is used to characterize a service running on each service provider. Then, the Eureka registry determines at least two third service providers from the plurality of service providers according to the target service identifier, wherein the service identifier of the third service provider is the target service identifier, and the at least two third service providers are located in different regions. Finally, the Eureka registry determines the first service provider from the at least two third service providers according to the target area identifier, wherein the area identifier of the first service provider is the target area identifier.
As can be seen from the content introduced in step S101, the Eureka registry has registered the feature attribute and the service instance information of each service provider in advance, and the feature attribute includes the location area information of each service provider, and the service instance information includes the service identifier of the micro service running on the service provider, so that the Eureka registry can directly obtain the location area identifier and the service identifier of each service provider. On the basis, the Eureka registration center firstly screens out at least two third service providers from the plurality of service providers according to the target service identifier in the service invocation request, wherein the service identifier of the third service provider is the target service identifier. For example, the service name of the micro service requested to be called by the service consumer is serviceA (i.e., the target service identifier is serviceA), and after receiving the target service identifier identifying serviceA, the Eureka registry generates a service information list, where all of the plurality of service providers (i.e., third service providers) in the service information list run the micro service of serviceA. It should be noted that the plurality of service providers in the service information list are located in different areas.
In addition, after obtaining the at least two third service providers, the Eureka registry further determines the first service provider from the at least two third service providers according to the target area identifier, wherein the area identifier of the first service provider is the target area identifier. Still taking the generated service information list as an example, the service information list further includes an area identifier of each third service provider, and on this basis, by comparing the area identifier of each third service provider with the target area identifier of the service consumer, the Eureka registry can determine from the service information list which third service provider is located in the same area as the service consumer, and determine the third service provider located in the same area as the service consumer as the first service provider.
Step S103, detecting whether the current load rate of the first service provider is greater than a preset threshold.
In step S103, the current load rate of the service provider may be determined according to the current free memory size of the service provider, the current CPU operating speed, and the current network bandwidth, for example, in general, the larger the current free memory of the service provider is, the lower the current load rate of the service provider is; the faster the current CPU running speed of the service provider is, the lower the current load rate of the service provider is; the larger the current network bandwidth of the service provider, the lower the current load rate of the service provider. On the basis, the Eureka registry can respectively give different weights to the current free memory size, the current CPU operating speed and the current network bandwidth of the service provider, and calculate to obtain a weighting result, and finally, the Eureka registry determines the current load rate of the service provider according to the weighting result.
And step S104, determining the first service provider as a target service provider under the condition that the current load rate of the first service provider is smaller than a preset threshold value.
In step S104, the target service provider is used to provide the target service for the service consumer. The preset threshold value can be set by self-definition. After determining the first service provider, the Eureka registry does not directly provide the target service for the service consumer with the first service provider as the target service provider, but first detects the current load rate of the first service provider, and then determines the first service provider as the target service provider only if the current load rate of the first service provider is smaller than a preset threshold.
It should be noted that, the farther the distance between the service consumer and the service provider is, the larger the network resource to be consumed between the service consumer and the service provider is, and the more unexpected factors exist in the communication process, the problem of poor communication quality is likely to occur. For example, if a service consumer located in Beijing requests to invoke a microservice, the optimal way to invoke is to have the microservice provided by the service provider also located in Beijing. However, since the service providers are selected in a random distribution manner in the prior art, the prior art is likely to select service providers in other areas to provide micro-services for the service consumers, such as the service providers located in shanghai. In order to solve the problem in the prior art, the method and the device design a policy with the priority of the same region, and preferentially select the first service provider as the target service provider under the condition that the current load rate of the first service provider located in the same region as the service consumption direction is smaller than a preset threshold value, so that unnecessary network resource consumption is reduced to the maximum extent on the premise that the first service provider can stably provide micro services for the service consumer, and the utilization rate of network resources is improved.
And step S105, determining a second service provider as a target service provider from a plurality of service providers under the condition that the current load rate of the first service provider is greater than or equal to a preset threshold value.
In step S105, the second service provider is located in a different area from the first service provider, a current load rate of the second service provider is smaller than a preset threshold, and the second service provider also runs a target service.
Specifically, when the current load rate of the first service provider is greater than or equal to the preset threshold, it indicates that the first service provider is not suitable for providing the target service for the service consumer at the current time, and if the first service provider is forcibly used as the target service provider to provide the target service for the service consumer, problems of slow target service invocation speed, and jamming or even breakdown in the invocation process may occur, and further increase of the load rate of the first service provider may also cause an influence on a process already running in the first service provider. Therefore, in order to avoid this problem, when the current load rate of the first service provider is greater than or equal to a preset threshold, the Eureka registry may select a second service provider as a target service provider from service providers in other areas, and the current load rate of the second service provider is less than the preset threshold.
In an alternative embodiment, in an area where a service consumer is located, multiple first service providers capable of providing a target service for the service consumer may exist at the same time, on this basis, the Eureka registry may obtain a current load rate of each first service provider respectively, rank all the current load rates, determine, if all the current load rates are greater than or equal to a preset threshold, a second service provider in another area as a target service provider, and if at least one first service provider whose current load rate is less than the preset threshold exists, determine, by the Eureka registry, a first service provider whose current load rate is the smallest as a target service provider.
For example, a service consumer a is located in beijing, the micro-service requested by the service consumer a is serviceB, and 3 service providers in a machine room in beijing can provide the micro-service of serviceB for the service consumer a. On the basis that all the 3 service providers can serve as first service providers corresponding to the service consumer a, the Eureka registration center can respectively obtain current load rates of the 3 service providers, so as to obtain 3 current load rates, and when all the 3 current load rates are greater than or equal to a preset threshold, the Eureka registration center determines a second service provider as a target service provider from other areas; when at least one current load rate is smaller than the preset threshold value in the 3 current load rates, the Eureka registration center ranks the at least one current load rate, and takes the first service provider with the smallest current load rate as the target service provider.
Based on the contents of the above steps S101 to S105, in the embodiment of the present application, a method of determining a target service provider providing a target service for a service consumer according to a location area and a current load rate of the service provider is adopted, and first, after receiving a service invocation request sent by the service consumer, determining a first service provider from a plurality of service providers in response to the service invocation request, where the service invocation request at least includes a target area identifier and a target service identifier, the target area identifier is used for characterizing the location area of the service consumer, and the target service identifier is used for characterizing a target service requested to be invoked by the service consumer; the first service provider is located in the same area as the service consumption direction, and the target service runs on the first service provider. Then, detecting whether the current load rate of the first service provider is greater than a preset threshold value; determining the first service provider as a target service provider under the condition that the current load rate of the first service provider is smaller than a preset threshold, wherein the target service provider is used for providing target services for service consumers; and under the condition that the current load rate of the first service provider is greater than or equal to a preset threshold value, determining a second service provider as a target service provider from a plurality of service providers, wherein the second service provider and the first service provider are located in different areas, the current load rate of the second service provider is smaller than the preset threshold value, and the target service is operated on the second service provider.
As can be seen from the above, according to the present application, after receiving a service invocation request sent by a service consumer, a first service provider belonging to the same area as the service consumer is first used as a preferred service provider for processing the service invocation request, and as the distance between the service provider and the service consumer is longer, the network resource consumption is larger, therefore, the first service provider is selected as the preferred service provider, which can reduce unnecessary network resource consumption, thereby improving the network resource utilization rate. In addition, the current load rate of the first service provider is detected, and if the current load rate of the first service provider is too high (greater than or equal to a preset threshold), the second service provider with the lower current load rate in other areas is selected as the target service provider for providing the target service for the service consumer, so that the problem of poor service calling stability when the first service provider is forcibly used for providing the target service for the service consumer can be avoided, and the service calling efficiency is improved.
Therefore, through the technical scheme of the application, the purpose of flexibly selecting the service providers in different areas to provide the target service for the service consumers is achieved, the effect of improving the service calling stability is achieved, and the technical problem that the service calling efficiency is low due to the fact that the service calling request of the micro-service cannot be processed across areas in the prior art is solved.
In an alternative embodiment, in the case that the current load rate of the first service provider is greater than or equal to the preset threshold, the Eureka registry first determines at least one candidate service provider from among the at least two third service providers, then determines the second service provider from among the at least one candidate service provider according to the current load rate of the candidate service provider, and determines the second service provider as the target service provider. And the current load rate of the candidate service provider is smaller than a preset threshold, and the candidate service provider and the first service provider are located in different areas.
Optionally, the at least two third service providers at least include a first service provider and other service providers, where the other service providers and the first service provider are located in different areas, and when the current load rate of the first service provider is greater than or equal to a preset threshold, the Eureka registration center detects the current load rate of the other service providers, and selects a service provider whose current load rate is less than the preset threshold as a candidate service provider. Since there may be a plurality of candidate service providers, the Eureka registry further selects a second service provider according to the current load rate of the candidate service provider, and determines the second service provider as the target service provider.
In an alternative embodiment, the Eureka registry may rank the current load rates of at least one candidate service provider to obtain a ranking result, and then the Eureka registry determines the candidate service provider with the smallest current load rate as the second service provider according to the ranking result. The candidate service provider with the minimum current load rate is selected as the second service provider, and the service provider with the minimum load rate at the current time can be ensured to be selected to provide target service for the service consumer, so that the response efficiency of the service call request of the service consumer is improved.
In an alternative embodiment, the Eureka registry obtains the current load rate corresponding to the candidate service provider at each time within a preset time period, where the preset time period includes multiple times. And then the Eureka registration center determines the median of a plurality of current load rates of the candidate service providers in a preset time period according to the current load rate corresponding to the candidate service providers at each moment, and finally determines the candidate service provider with the minimum median as a second service provider.
Optionally, the preset time period may be set in a self-defined manner, for example, the preset time period may be half an hour, and the Eureka registration center may obtain the current load rate of each candidate service provider per minute within half an hour, that is, each candidate service provider correspondingly obtains 30 current load rates, and the Eureka registration center may select a median according to the 30 current load rates. In the case of multiple candidate service providers, the Eureka registry will obtain multiple medians, each corresponding to one candidate service provider. Finally, the Eureka registry determines the candidate service provider with the smallest median as the second service provider. It should be noted that the median may characterize the load rate change of one candidate service provider in a preset time period to a certain extent, and therefore, selecting the candidate service provider with the smallest median as the second service provider may ensure that the service provider with a smaller load rate and a smaller load rate change fluctuation is selected to provide the target service for the service consumer.
In an alternative embodiment, the Eureka registry may further determine the area where the service consumer is located according to the target area identifier, determine the area where the candidate service provider is located according to the area identifier of the candidate service provider, and then determine the distance between the candidate service provider and the service consumer based on the area where the service consumer is located and the area where the candidate service provider is located, and determine the candidate service provider with the shortest distance as the second service provider.
Optionally, the present application further provides another way to select the second service provider, that is, the second service provider is determined according to the distance between the candidate service provider and the service consumer. Since the target area identifier represents the area where the service consumer is located, and the area identifier of the candidate service provider represents the area where the candidate service provider is located, the Eureka registry can determine the area where the service consumer is located and the area where the candidate service provider is located according to the target area identifier and the area identifier of the candidate service provider. On this basis, the Eureka registry can also determine the distance between the service consumer's location and the candidate service provider's location. Since the longer the communication distance between the service consumer and the service provider, the larger the network resources it consumes, the Eureka registry will determine the candidate service provider with the shortest distance to the service consumer as the second service provider.
In an alternative embodiment, after determining that the first service provider is the target service provider, the Eureka registry further obtains a call success rate when the service consumer calls the target service from the first service provider, and in a case that the call success rate is less than a preset success rate, the Eureka registry determines that the second service provider is the target service provider from the plurality of service providers.
Optionally, in an actual application, a first service provider located in the same area as the service consumption may have a call exception, for example, the first service provider suddenly fails, so that the call is not possible. In order to avoid the problem that no other service provider provides target service for the service consumer when the first service provider is abnormal, the method monitors the calling success rate of the service consumer calling the target service from the first service provider in real time after the first service provider is determined to be the target service provider, and if the calling success rate is smaller than the preset success rate, the Eureka registration center determines the second service provider as the target service provider from a plurality of service providers. The selection process of the second service provider is already described in the above, and will not be described in detail herein.
It should be noted that, if there are a plurality of first service providers in the area where the service consumer is located, the current load rate of which is less than the preset threshold, the Eureka registry may determine that the first service provider with the smallest current load rate is the target service provider, and when the call success rate of the target service provider is less than the preset success rate, the Eureka registration center determines the first service provider as an abnormal service provider, and then re-detecting the current load rate of each first service provider, if there is at least one first service provider whose current load rate is less than a preset threshold, the Eureka registry will re-determine the first service provider with the smallest current load rate as the new target service provider, if the current load rates of all the first service providers are greater than or equal to the preset threshold, the Eureka registry determines the second service provider as the target service provider from the plurality of service providers.
Therefore, according to the technical scheme, the target service provider is determined according to the call success rate, the purpose that service providers in other areas are reselected as the target service provider when the first service provider is abnormal is achieved, and therefore the stability of service call is improved.
Example 2
According to an embodiment of the present application, there is further provided an embodiment of a service invocation device, where fig. 2 is a schematic diagram of an optional service invocation device according to the embodiment of the present application, and as shown in fig. 2, the device includes: a receiving module 201, a first determining module 202, a detecting module 203, a second determining module 204 and a third determining module 205.
The receiving module 201 is configured to receive a service invocation request sent by a service consumer, where the service invocation request at least includes a target area identifier and a target service identifier, where the target area identifier is used to characterize an area where the service consumer is located, and the target service identifier is used to characterize a target service that the service consumer requests to invoke; a first determining module 202, configured to determine, in response to a service invocation request, a first service provider from a plurality of service providers, where the service provider is configured to provide a service for a service consumer, the first service provider and the service consumer are located in the same area, and a target service is run on the first service provider; the detecting module 203 is configured to detect whether a current load rate of the first service provider is greater than a preset threshold; a second determining module 204, configured to determine that the first service provider is a target service provider when a current load rate of the first service provider is smaller than a preset threshold, where the target service provider is used to provide a target service for a service consumer; a third determining module 205, configured to determine, when a current load rate of the first service provider is greater than or equal to a preset threshold, a second service provider as a target service provider from among multiple service providers, where the second service provider and the first service provider are located in different areas, the current load rate of the second service provider is smaller than the preset threshold, and the target service is also running on the second service provider.
It should be noted that the receiving module 201, the first determining module 202, the detecting module 203, the second determining module 204, and the third determining module 205 correspond to steps S101 to S105 in the foregoing embodiment, and the five modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure in embodiment 1.
Optionally, the first determining module includes: the device comprises a first acquisition unit, a first determination unit and a second determination unit, wherein the first acquisition unit is used for acquiring an area identifier and a service identifier of each service provider, the area identifier is used for representing the area where each service provider is located, and the service identifier is used for representing the service running on each service provider; the first determining unit is used for determining at least two third service providers from the plurality of service providers according to the target service identifier, wherein the service identifier of the third service provider is the target service identifier, and the at least two third service providers are located in different areas; and the second determining unit is used for determining the first service provider from at least two third service providers according to the target area identifier, wherein the area identifier of the first service provider is the target area identifier.
Optionally, the third determining module further includes: a third determining unit and a fourth determining unit. The third determining unit is used for determining at least one candidate service provider from at least two third service providers under the condition that the current load rate of a first service provider is greater than or equal to a preset threshold, wherein the current load rate of the candidate service provider is smaller than the preset threshold, and the candidate service provider and the first service provider are located in different areas; and the fourth determining unit is used for determining the second service provider from the at least one candidate service provider according to the current load rate of the candidate service provider and determining the second service provider as the target service provider.
Optionally, the fourth determining unit further includes: a sorting subunit and a first determining subunit. The sorting subunit is used for sorting the current load rate of at least one candidate service provider to obtain a sorting result; and the first determining subunit is used for determining the candidate service provider with the minimum current load rate as the second service provider according to the sorting result.
Optionally, the fourth determining unit further includes: the device comprises an acquisition subunit, a second determination subunit and a third determination subunit. The acquisition subunit is configured to acquire a current load rate corresponding to the candidate service provider at each time within a preset time period, where the preset time period includes multiple times; the second determining subunit is used for determining the median of a plurality of current load rates of the candidate service providers in a preset time period according to the current load rate corresponding to the candidate service provider at each moment; and the third determining subunit is used for determining the candidate service provider with the minimum median as the second service provider.
Optionally, the service invoking device further includes: the device comprises a fourth determination module, a fifth determination module, a sixth determination module and a seventh determination module. The fourth determining module is used for determining the area where the service consumer is located according to the target area identification; the fifth determining module is used for determining the area of the candidate service provider according to the area identification of the candidate service provider; a sixth determining module, configured to determine a distance between the candidate service provider and the service consumer based on the area where the service consumer is located and the area where the candidate service provider is located; and the seventh determining module is used for determining the candidate service provider with the shortest distance as the second service provider.
Optionally, the service invoking device further includes: the device comprises an acquisition module and an eighth determination module. The acquisition module is used for acquiring the calling success rate when the service consumer calls the target service from the first service provider; and the eighth determining module is used for determining the second service provider as the target service provider from the plurality of service providers under the condition that the calling success rate is less than the preset success rate.
Example 3
According to another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the service invoking method when running.
Example 4
According to another aspect of the embodiments of the present application, there is also provided an electronic device, where fig. 3 is a schematic diagram of an alternative electronic device according to the embodiments of the present application, and as shown in fig. 3, the electronic device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor executes the program to implement the following steps:
receiving a service calling request sent by a service consumer, wherein the service calling request at least comprises a target area identifier and a target service identifier, the target area identifier is used for representing the area where the service consumer is located, and the target service identifier is used for representing the target service which the service consumer requests to call; responding to the service calling request, determining a first service provider from a plurality of service providers, wherein the service providers are used for providing services for the service consumers, the first service provider and the service consumers are located in the same area, and the first service provider runs a target service; detecting whether the current load rate of a first service provider is greater than a preset threshold value or not; determining the first service provider as a target service provider under the condition that the current load rate of the first service provider is smaller than a preset threshold, wherein the target service provider is used for providing target services for service consumers; and under the condition that the current load rate of the first service provider is greater than or equal to a preset threshold value, determining a second service provider as a target service provider from a plurality of service providers, wherein the second service provider and the first service provider are located in different areas, the current load rate of the second service provider is smaller than the preset threshold value, and the target service is operated on the second service provider.
Optionally, the processor executes the program to further implement the following steps: the method comprises the steps of obtaining an area identifier and a service identifier of each service provider, wherein the area identifier is used for representing the area where each service provider is located, and the service identifier is used for representing the service running on each service provider; determining at least two third service providers from the plurality of service providers according to the target service identifier, wherein the service identifier of the third service provider is the target service identifier, and the at least two third service providers are located in different areas; and determining a first service provider from at least two third service providers according to the target area identifier, wherein the area identifier of the first service provider is the target area identifier.
Optionally, the processor executes the program to further implement the following steps: determining at least one candidate service provider from the at least two third service providers under the condition that the current load rate of the first service provider is greater than or equal to a preset threshold, wherein the current load rate of the candidate service provider is less than the preset threshold; and determining a second service provider from the at least one candidate service provider according to the current load rate of the candidate service provider, and determining the second service provider as the target service provider.
Optionally, the processor executes the program to further implement the following steps: sequencing the current load rate of at least one candidate service provider to obtain a sequencing result; and determining the candidate service provider with the minimum current load rate as a second service provider according to the sorting result.
Optionally, the following steps are also implemented when the processor executes the program: acquiring a current load rate corresponding to a candidate service provider at each moment in a preset time period, wherein the preset time period comprises a plurality of moments; determining the median of a plurality of current load rates of the candidate service providers in a preset time period according to the current load rate corresponding to the candidate service providers at each moment; and determining the candidate service provider with the minimum median as the second service provider.
Optionally, the processor executes the program to further implement the following steps: determining the area of the service consumer according to the target area identification; determining the area of the candidate service provider according to the area identification of the candidate service provider; determining a distance between the candidate service provider and the service consumer based on the area in which the service consumer is located and the area in which the candidate service provider is located; and determining the candidate service provider with the shortest distance as a second service provider.
Optionally, the processor executes the program to further implement the following steps: after the first service provider is determined to be the target service provider, acquiring a call success rate when a service consumer calls a target service from the first service provider; and determining the second service provider as a target service provider from the plurality of service providers under the condition that the calling success rate is less than the preset success rate.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, a division of a unit may be a division of a logic function, and an actual implementation may have another division, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or may not be executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be an indirect coupling or communication connection through some interfaces, units or modules, and may be electrical or in other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a service provider, or a network device) to execute all or part of the steps of the method of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (10)

1. A service invocation method, characterized by comprising:
receiving a service calling request sent by a service consumer, wherein the service calling request at least comprises a target area identifier and a target service identifier, the target area identifier is used for representing an area where the service consumer is located, and the target service identifier is used for representing a target service which the service consumer requests to call;
determining a first service provider from a plurality of service providers in response to the service calling request, wherein the service provider is used for providing services for the service consumer, the first service provider and the service consumer are located in the same area, and the target service runs on the first service provider;
detecting whether the current load rate of the first service provider is greater than a preset threshold value;
determining that the first service provider is a target service provider under the condition that the current load rate of the first service provider is smaller than the preset threshold, wherein the target service provider is used for providing the target service for the service consumer;
and when the current load rate of the first service provider is greater than or equal to the preset threshold value, determining a second service provider as the target service provider from the plurality of service providers, wherein the second service provider is located in a different area from the first service provider, the current load rate of the second service provider is less than the preset threshold value, and the target service is operated on the second service provider.
2. The method of claim 1, wherein determining a first service provider from a plurality of service providers in response to the service invocation request comprises:
acquiring an area identifier and a service identifier of each service provider, wherein the area identifier is used for representing the area of each service provider, and the service identifier is used for representing the service operated on each service provider;
determining at least two third service providers from the plurality of service providers according to the target service identifier, wherein the service identifier of the third service provider is the target service identifier, and the at least two third service providers are located in different areas;
and determining the first service provider from the at least two third service providers according to the target area identifier, wherein the area identifier of the first service provider is the target area identifier.
3. The method of claim 2, wherein determining a second service provider as the target service provider from the plurality of service providers if the current load rate of the first service provider is greater than or equal to the preset threshold comprises:
determining at least one candidate service provider from the at least two third service providers when the current load rate of the first service provider is greater than or equal to the preset threshold, wherein the current load rate of the candidate service provider is less than the preset threshold, and the candidate service provider is located in a different area from the first service provider;
determining the second service provider from the at least one candidate service provider according to the current load rate of the candidate service provider, and determining the second service provider as the target service provider.
4. The method of claim 3, wherein determining the second service provider from the at least one candidate service provider based on the current load rate of the candidate service provider comprises:
sequencing the current load rate of the at least one candidate service provider to obtain a sequencing result;
and determining the candidate service provider with the minimum current load rate as the second service provider according to the sorting result.
5. The method of claim 3, wherein determining the second service provider from the at least one candidate service provider based on the current load rate of the candidate service provider comprises:
acquiring a current load rate corresponding to the candidate service provider at each moment in a preset time period, wherein the preset time period comprises a plurality of moments;
determining the median of a plurality of current load rates of the candidate service provider in the preset time period according to the current load rate corresponding to the candidate service provider at each moment;
and determining the candidate service provider with the minimum median as the second service provider.
6. The method of claim 3, further comprising:
determining the area of the service consumer according to the target area identification;
determining the area of the candidate service provider according to the area identification of the candidate service provider;
determining a distance between the candidate service provider and the service consumer based on the area of the service consumer and the area of the candidate service provider;
and determining the candidate service provider with the shortest distance as the second service provider.
7. The method of claim 1, wherein after determining that the first service provider is a target service provider, the method further comprises:
acquiring a calling success rate when the service consumer calls the target service from the first service provider;
and determining the second service provider as the target service provider from the plurality of service providers under the condition that the calling success rate is smaller than a preset success rate.
8. A service invocation apparatus, characterized by comprising:
the system comprises a receiving module, a sending module and a processing module, wherein the receiving module is used for receiving a service calling request sent by a service consumer, the service calling request at least comprises a target area identifier and a target service identifier, the target area identifier is used for representing an area where the service consumer is located, and the target service identifier is used for representing a target service which the service consumer requests to call;
a first determining module, configured to determine, in response to the service invocation request, a first service provider from a plurality of service providers, where the service provider is configured to provide a service for the service consumer, the first service provider and the service consumer are located in a same area, and the target service is run on the first service provider;
the detection module is used for detecting whether the current load rate of the first service provider is greater than a preset threshold value;
a second determining module, configured to determine that the first service provider is a target service provider when a current load rate of the first service provider is smaller than the preset threshold, where the target service provider is configured to provide the target service for the service consumer;
a third determining module, configured to determine, when a current load rate of the first service provider is greater than or equal to the preset threshold, a second service provider as the target service provider from the multiple service providers, where the second service provider is located in a different area from the first service provider, the current load rate of the second service provider is less than the preset threshold, and the target service is also running on the second service provider.
9. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is arranged to execute the service invocation method according to any one of claims 1 to 7 when executed.
10. An electronic device, wherein the electronic device comprises one or more processors; memory for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement for running a program, wherein the program is arranged to perform the service invocation method of any of claims 1 to 7 when run.
CN202210742658.4A 2022-06-28 2022-06-28 Service calling method and device, electronic equipment and computer readable storage medium Pending CN115134412A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210742658.4A CN115134412A (en) 2022-06-28 2022-06-28 Service calling method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210742658.4A CN115134412A (en) 2022-06-28 2022-06-28 Service calling method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN115134412A true CN115134412A (en) 2022-09-30

Family

ID=83379843

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210742658.4A Pending CN115134412A (en) 2022-06-28 2022-06-28 Service calling method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN115134412A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108427581A (en) * 2018-02-07 2018-08-21 平安普惠企业管理有限公司 System micro services method and terminal device
CN111464592A (en) * 2020-03-09 2020-07-28 平安科技(深圳)有限公司 Load balancing method, device, equipment and storage medium based on microservice
CN114048046A (en) * 2021-11-08 2022-02-15 马上消费金融股份有限公司 Service calling method and device and load balancing equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108427581A (en) * 2018-02-07 2018-08-21 平安普惠企业管理有限公司 System micro services method and terminal device
CN111464592A (en) * 2020-03-09 2020-07-28 平安科技(深圳)有限公司 Load balancing method, device, equipment and storage medium based on microservice
CN114048046A (en) * 2021-11-08 2022-02-15 马上消费金融股份有限公司 Service calling method and device and load balancing equipment

Similar Documents

Publication Publication Date Title
CN105979007B (en) Method and device for accelerating resource processing and network function virtualization system
US9122560B2 (en) System and method of optimization for mobile apps
CN109936613B (en) Disaster recovery method and device applied to server
WO2020244233A1 (en) Data storage method and apparatus
CN111953541A (en) Alarm information processing method and device, computer equipment and storage medium
WO2020108443A1 (en) Virtualization management method and device
US20210203714A1 (en) System and method for identifying capabilities and limitations of an orchestration based application integration
CN106034138A (en) Remote service calling method and remote service calling device
CN114172966B (en) Service calling method, service processing method and device under unitized architecture
CN110677475A (en) Micro-service processing method, device, equipment and storage medium
CN107426323A (en) One kind is based on distributed resource service and Visualized Monitoring System and method
CN110868339A (en) Node distribution method and device, electronic equipment and readable storage medium
US10970309B2 (en) Data storage method and apparatus
EP4369181A1 (en) Node for running container group, and management system and method of container group
CN108604996A (en) A kind of strategy transmission method and apparatus in NFV systems
US10979327B2 (en) Monitoring cloud computing
Golla et al. T4: A highly threaded server-on-a-chip with native support for heterogeneous computing
CN115134412A (en) Service calling method and device, electronic equipment and computer readable storage medium
CN114363233A (en) Packet routing method, device, electronic equipment and storage medium
CN111338710A (en) Application program control method and device, electronic equipment and storage medium
CN111198756A (en) Application scheduling method and device of kubernets cluster
CN114268799A (en) Streaming media transmission method and device, electronic equipment and medium
CN114201293A (en) Kafka middleware cluster parameter modification method and device and storage medium
CN114461424A (en) Inter-unit service discovery method, device and system under unitized deployment architecture
CN108920277B (en) Service execution system, method and device and service isolation system

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