CN115037803B - Service calling method, electronic equipment and storage medium - Google Patents

Service calling method, electronic equipment and storage medium Download PDF

Info

Publication number
CN115037803B
CN115037803B CN202210649261.0A CN202210649261A CN115037803B CN 115037803 B CN115037803 B CN 115037803B CN 202210649261 A CN202210649261 A CN 202210649261A CN 115037803 B CN115037803 B CN 115037803B
Authority
CN
China
Prior art keywords
request
service
target
micro
policy
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210649261.0A
Other languages
Chinese (zh)
Other versions
CN115037803A (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.)
Information Center of Yunnan Power Grid Co Ltd
Original Assignee
Information Center of Yunnan Power Grid 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 Information Center of Yunnan Power Grid Co Ltd filed Critical Information Center of Yunnan Power Grid Co Ltd
Priority to CN202210649261.0A priority Critical patent/CN115037803B/en
Publication of CN115037803A publication Critical patent/CN115037803A/en
Application granted granted Critical
Publication of CN115037803B publication Critical patent/CN115037803B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a micro-service calling method, electronic equipment and a storage medium, which are characterized in that service calling requests from all clients are received in a preset time interval, the number of the received service calling requests in the time interval, the service type of micro-service pointed by the service calling requests, and original request paths and original request parameters contained in the service calling requests are recorded, then the service calling requests and various service calling strategies are matched according to the number of the requests, the service type, the original request paths and the original request parameters, the service calling requests are responded according to the successfully matched target service calling strategies, the micro-service is called for the clients from the server, the service calling efficiency for the clients is improved, and the accuracy of data transmission among the clients, gateways and the server in the service calling process is ensured.

Description

Service calling method, electronic equipment and storage medium
Technical Field
The present invention relates to the field of service invocation technologies, and in particular, to a service invocation method, an electronic device, and a storage medium.
Background
The rapid growth of the internet has led to an increasing use of micro-service architecture. In a system of a micro-service architecture, each service module is divided into a plurality of micro-services which are independently developed, deployed and operated, and the micro-services are mutually called and matched through RESTful interfaces to complete various functions. While services are typically running in clusters, and there may be multiple running instances of a service.
In the micro-service system, the gateway is used as a unified entry of the micro-service system and is responsible for receiving call requests from all clients, and performing operations such as authentication, forwarding and the like on the call requests, so that the micro-service call is completed one by one for each call request.
However, when the gateway is used as a flow entry of a client request in a micro-service system and faces to high concurrent requests of a complex environment, a single service call strategy is usually implemented for each call request from the client, that is, each call request is used for completing micro-service call one by one, when the gateway faces to different types and numbers of call requests, flexible processing is difficult, and results such as call request response delay and data packet loss of the client are easily caused.
Disclosure of Invention
The invention provides a micro-service calling method, electronic equipment and a storage medium, which are used for solving the problem that a single calling strategy cannot meet a high-concurrency service calling request and delay micro-service calling.
According to an aspect of the present invention, there is provided a micro service invocation method including:
receiving service call requests from all clients in a preset time interval;
recording the request quantity of the service call requests received in the time interval;
Identifying a service type of the micro-service to which the service invocation request is directed;
acquiring an original request path and original request parameters included in the service call request;
matching the service call request with a plurality of service call policies according to the request quantity, the service type, the original request path and the original request parameters;
if the service call request is successfully matched with the service call policy, determining that the service call policy is a target service call policy;
and responding to the service call request according to the target service call strategy, and calling micro-service for the client from the server.
According to another aspect of the present invention, there is provided a micro service invocation apparatus including:
the request receiving module is used for receiving service calling requests from all clients in a preset time interval;
the request recording module is used for recording the request quantity of the service call requests received in the time interval;
the service type identification module is used for identifying the service type of the micro service pointed by the service calling request;
the path parameter acquisition module is used for acquiring an original request path and original request parameters included in the service call request;
The policy matching module is used for matching the service call request with a plurality of service call policies according to the request quantity, the service type, the original request path and the original request parameters;
the policy determining module is used for determining the service calling policy as a target service calling policy if the service calling request is successfully matched with the service calling policy;
and the micro-service calling module is used for responding to the service calling request according to the target service calling strategy and calling micro-service for the client from the server.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the micro service invocation method of any of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement the micro service invocation method according to any of the embodiments of the present invention when executed.
According to the technical scheme, the gateway receives service call requests from all clients in a preset time interval, records the request quantity of the service call requests, identifies the service types of the services pointed by the service call requests and the original request parameters included in the service call requests, matches the service call requests with various service call strategies stored in the gateway according to the request quantity, the service types, the original request paths and the original request parameters, determines that the service call strategy is a target service call strategy when the service call requests are successfully matched with any service call strategy, and then calls the service for the clients according to the target service call strategy.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a micro service invocation method provided according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a service call request transmission adapted according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating service invocation request fusion as applied in accordance with one embodiment of the present invention;
fig. 4 is a schematic structural diagram of a micro service invocation apparatus according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device implementing a micro service invocation method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," 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.
Example 1
Fig. 1 is a flowchart of a micro service invocation method according to an embodiment of the present invention, where the method may be performed by a micro service invocation device, and the micro service invocation device may be implemented in hardware and/or software, and the micro service invocation device may be configured in an electronic device. As shown in fig. 1, the method includes:
s110, receiving service call requests from all clients in a preset time interval.
In this embodiment, the gateway, the client and the server together form a micro service system to which the micro service calling method is applied. The client side can also be called as a user side, and corresponds to the service side, so as to provide local micro-service for the client. In this embodiment, the client may be represented as a mobile application, a desktop application, a browser, and the like. In this embodiment, a plurality of micro services are stored in the server, and when the client sends a service call request, the service call request is forwarded to the server through the gateway, and the server responds to the service call request to provide the micro services. In this embodiment, the micro service refers to a micro service architecture system, where each service module is divided into micro services that can be independently developed, deployed and operated, and the micro services can be mutually called through RESTful interfaces, so that the micro services can mutually cooperate and call to complete various functions.
The gateway in this embodiment may be a micro-service gateway based on Spring Cloud Gateway, spring Cloud Gateway is implemented based on WebFlux framework, and the WebFlux framework bottom layer uses a high-performance Reactor mode communication framework Netty, so as to provide a simple and effective unified API routing management manner for the micro-service architecture. The protocol between the server and the client is realized very efficiently and conveniently with the help of Netty, the network programming of TCP or UDP sockets is greatly simplified, and the programs developed by using Netty have very high performance and maintainability.
In this embodiment, the gateway is used as a unified portal of the micro service system, after all service call requests sent by clients enter the gateway, the Spring Cloud Gateway request access module is responsible for processing, spring Cloud Gateway can use few threads to asynchronously process a large number of connections without blocking, then perform security authentication operations such as routing, authentication and the like on the service call requests, and after the security authentication passes, the service call requests can be matched with a plurality of service call policies stored in the gateway, for example, according to the number of the service call requests, the parameters such as call service types and the like, the corresponding service call policies are selected, so that dynamic coordination of the service call policies is realized, and the delay of micro service call is reduced by integrating the operation of the service call requests, thereby improving the accuracy of micro service call. The service invocation policy in this embodiment includes a request office and policy, a request cache policy, a request balancing policy, and a request fusion policy. As shown in fig. 2, the client sends a service call request to the gateway, and after the gateway makes a request for access, the service call request is forwarded to the server after being processed by each service call policy.
S120, recording the request quantity of the service call requests received in the time interval.
In this embodiment, the time interval is used to measure the state of the service call request received by the gateway, and by recording the number of the service call requests received by the gateway in the time interval, it can be determined whether the service call request is in a high concurrency state. When the service call request is in a high concurrency state, the gateway is used as an entrance of the service call request flow, and huge load is borne, so that the load pressure of the gateway for receiving and transmitting the service call request can be relieved by applying a corresponding service call strategy, and the delay of micro service call is reduced.
S130, identifying the service type of the micro service pointed by the service calling request.
In this embodiment, the service end stores micro-services with multiple service types, different service call requests may point to the same micro-service or point to different micro-services, and an appropriate service call policy is selected to call the micro-service of the service end by identifying the service type of the micro-service to which the service call request points.
S140, acquiring an original request path and original request parameters included in the service call request.
In this embodiment, the service call request includes an original request path and an original request parameter, where the original request path and the original request parameter may be combined to identify, in a cache of the gateway, service data corresponding to the service call request and stored in the cache in advance.
S150, matching the service call request with various service call strategies according to the number of requests, the service type, the original request path and the original request parameters.
In this embodiment, after receiving the service call request, the gateway may match the service call policy according to the number of requests of the service call request, the type of the micro service pointed to, and the original request path and the original request parameter included, and call the micro service to the server according to the service call policy that is successfully matched. Specifically, in this embodiment, the service call request and request aggregation policy and request fusion policy may be matched according to the service type,
in this embodiment, the matching service call request and the request aggregation policy may be expressed as that if there are two or more service types of the micro services pointed by the service call request as sub-services for implementing the same target micro service, it may be determined that the service call request and the request aggregation policy are successfully matched, and the plurality of sub-services together form the target micro service. For example, when the user's request is to implement a function or load a page without considering the UI logic of the client, the client will initiate a plurality of service call requests, each service call request points to a micro-service that is the sub-service, and the implemented function or load page may be the target micro-service.
In this embodiment, the process of matching the service call request and the request fusion policy is expressed in that if there are two or more micro services of which the service call requests point to a preset specific service type, it is determined that the service call request and the request fusion policy are successfully matched, and the specific service type includes query service. Because the micro-service architecture is generally realized through remote call, the remote call has the limitation of network consumption and network connection quantity, and in the state of high concurrency of service call requests, when the gateway forwards the service call requests to the server, the communication times are greatly increased, so that the call time is prolonged, and the communication resource consumption is more. Therefore, in this embodiment, the service call requests of the plurality of micro services which are received by the gateway in the same time interval and are directed to the same specific service type can be integrated through the request integration policy, so that the communication times are reduced, and the communication resources are saved. The micro-services of the specific service type in this embodiment may be micro-services of a query class, such as multiple books with different query numbers. It is also possible to do a micro-service such as acquisition for a single parameter.
In this embodiment, matching the service call request and the request cache policy may be performed by matching the service call request and the request cache policy according to the original request path and the original request parameter.
The method specifically comprises the following steps: the pre-stored preparation request path and preparation request parameters in the gateway are obtained, and in this embodiment the gateway comprises a storage unit, where the storage unit is used to store the preparation request path and the preparation request parameters. The preparation request path and the preparation request parameter may be a time interval before the current time interval of the gateway, and the original request path and the original request parameter of the service call request are received.
That is, in this embodiment, after forwarding a service call request sent by a client to a server, the gateway may store an original request path and an original request parameter of the service call request as a preparation request path and a preparation request parameter, and may store service data returned by the server and the preparation request path and the preparation request parameter in a storage unit of the gateway correspondingly. Then matching the original request path with the preparation request path, the original request parameter and the preparation request parameter, and if the preparation request path consistent with the original request path exists and the preparation request parameter consistent with the original request parameter exists, determining that the service call request and the request cache strategy are successfully matched.
In this embodiment, the process of matching the service call request and the request balancing policy may be expressed by comparing the number of requests of the service call request received in the time interval with a preset number threshold, and if the number of requests is greater than the preset number threshold, determining that the service call request and the request balancing policy are successfully matched. In this embodiment, because each server has limited performance, when the server is determined to have insufficient performance based on the number of requests, the request balancing policy can split the plurality of service call requests to different servers, so as to reduce the response pressure of a single server.
S160, if the service call request is successfully matched with the service call policy, determining the service call policy as a target service call policy.
In this embodiment, when the service call request and the service call policy are successfully matched, it may be determined that the service call policy successfully matched is a target service call policy, where the target service call policy is used to instruct the gateway to process the service call request matched with the target service call policy, and forward the service call request to the server after processing.
S170, responding to the service call request according to the target service call strategy, and calling the micro service for the client from the server.
In this embodiment, after determining the target service invocation policy of the service invocation request, the service invocation request may be responded according to the target service invocation policy, and after processing the service invocation request, the processed service invocation request may be forwarded to the server to invoke the micro-service for the client.
Specifically, in this embodiment, when the destination service invocation policy is a request aggregation policy, the micro service invocation procedure may be expressed as: extracting a plurality of service call requests matched with a request aggregation policy as first target requests, acquiring original request paths included in the plurality of first target requests as first request paths, and then aggregating the plurality of first request paths as target request paths. The service invocation request matched with the request aggregation policy as described above is directed to a plurality of micro services that can collectively implement functions such as loading one page by coaction. After the target request path is obtained through aggregation, first service data is requested in the server according to the target request path, so that call is initiated to a plurality of micro services pointed by a plurality of first target requests at the same time, and finally, the first service data formed after the requested micro services are called is returned to the client.
Specifically, in this embodiment, when the destination service invocation policy is a request cache policy, the micro service invocation process may be expressed as: and extracting the service call request matched with the request caching strategy as a second target request, and then acquiring an original request path and an original request parameter included in the second target request as a second request path and a second request parameter.
According to the second request path and the second request parameter, the gateway queries the preliminary service data as the second service data, where the preliminary service data in this embodiment may be the second service data previously stored in the gateway and returned when the service is called in the server according to the preliminary request path and the preliminary request parameter consistent with the second request path and the second request parameter.
In this embodiment, the frequency of each micro-service call may be recorded, the original request path and the original request parameter in the service call request corresponding to the micro-service with higher call frequency and the service data acquired at the server according to the original request parameter and the original request path are stored in the storage unit of the gateway, and are used as the preparation request path, the preparation request parameter and the preparation request data, and the preparation request path, the preparation request parameter and the preparation request data which are directed to the same micro-service in the storage unit are in one-to-one correspondence.
Furthermore, in this embodiment, considering that the storage amount of the storage unit is limited, the preparation request path, the preparation request parameter and the preparation request data may be buffered in a limited time, that is, a buffer validity period is set in advance for the related data of a certain micro service in the storage unit, and after the buffer validity period, the related data is automatically cleared from the storage unit.
Therefore, in this embodiment, the gateway may directly return the second service data to the client through querying the preparation request path consistent with the second request path of the second target request in the gateway, that is, the preparation service data corresponding to the preparation request path and the preparation request parameter stored in the gateway in advance, by omitting the step of forwarding the service call request to the server by the gateway, the communication times are reduced, and thus the communication resource consumption is reduced, and the gateway directly returns the service data to the client, thereby accelerating the response time of the service call request.
Specifically, in this embodiment, when the destination service invocation policy is a request balancing policy, the micro service invocation process may be expressed as: the service call request matched with the request balancing policy is extracted as a third target request, and it can be known that when the target service call policy is the request balancing policy, the number of the service call requests received by a single service end is in an excessive state, so that a plurality of third target requests can be divided into a plurality of service call groups, the number of the third target requests in the service call groups is smaller than a preset number threshold, and different service call groups call micro-services from different service ends, so that the corresponding pressure of the single service end is reduced. In this embodiment, the third target request may be divided by methods such as random load balancing, minimum active number load balancing, consistent hash load balancing, and the like.
And then requesting third service data at the target service end according to the original request path and the original request parameters included in the third target request, wherein the target service end in the embodiment is the service end pointed by the service calling group where the third target request is positioned, and finally returning the third service data generated by micro service calling at the target service section to the client.
Specifically, in this embodiment, when the target service invocation policy is a request fusion policy, the micro service invocation process may be expressed as: and extracting the service call request matched with the request fusion strategy as a fourth target request.
Then fusing the plurality of fourth target requests into a single fused target request, wherein the fused target request comprises a fused request path and fused request parameters.
After the fusion is finished, fourth service data can be requested at the server according to the fusion request path and the fusion request parameters, the fourth target request can be a micro-service pointing to the query class, for example, a plurality of fourth target requests are query BOOKs, the process of service call requests, namely, the fourth target requests are fused is shown in fig. 3, the plurality of fourth target requests can be shown as GET/BOOK/1, GET/BOOK/2, GET/BOOK/3 and GET/BOOK/4, and after the fourth target requests are processed through a request fusion strategy, the obtained fusion target requests can be shown as GET/BOOK/1, 2, 3 and 4, and then micro-service call is carried out according to the fusion target requests.
In this embodiment, after the micro service is called to the server according to the converged target request to obtain fourth service data, the fourth service data is returned to the client.
According to the technical scheme, the gateway receives service call requests from all clients in a preset time interval, records the request quantity of the service call requests, identifies the service types of the services pointed by the service call requests and the original request parameters included in the service call requests, matches the service call requests with various service call strategies stored in the gateway according to the request quantity, the service types, the original request paths and the original request parameters, determines that the service call strategy is a target service call strategy when the service call requests are successfully matched with any service call strategy, and then calls the service for the clients according to the target service call strategy.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Example two
Fig. 4 is a schematic structural diagram of a micro service call device according to a second embodiment of the present invention. As shown in fig. 4, the apparatus includes:
a request receiving module 410, configured to receive service call requests from each client in a preset time interval;
a request recording module 420, configured to record the number of requests of the service call request received in the time interval;
a service type identifying module 430, configured to identify a service type of the micro service to which the service call request is directed;
a path parameter obtaining module 440, configured to obtain an original request path and an original request parameter included in the service call request;
a policy matching module 450, configured to match the service call request with a plurality of service call policies according to the number of requests, the service type, the original request path, and the original request parameters;
a policy determining module 460, configured to determine the service call policy as a target service call policy if the service call request matches the service call policy successfully;
And the micro service calling module 470 is configured to respond to the service calling request according to the target service calling policy, and call a micro service for the client from the server.
Optionally, the policy matching module 450 includes:
the request aggregation/fusion policy matching module is used for matching the service call request, the request aggregation policy and the request fusion policy according to the service type;
the request cache policy matching module is used for matching the service call request and the request cache policy according to the original request path and the original request parameters;
the request quantity comparison module is used for comparing the request quantity with a preset quantity threshold value;
and the equalization strategy matching module is used for determining that the service call request is successfully matched with the request equalization strategy if the number of the requests is larger than a preset number threshold.
Optionally, the request aggregation/fusion policy matching module includes:
a request aggregation policy determining module, configured to determine that the service call request and the request aggregation policy are successfully matched if the service types of the micro-services pointed by the two or more service call requests are sub-services for implementing the same target micro-service, where a plurality of sub-services together form the target micro-service;
And the request fusion strategy determining module is used for determining that the service calling request is successfully matched with the request fusion strategy if two or more micro services with the service calling request pointing to the preset specific service types exist, wherein the specific service types comprise query service.
Optionally, the request cache policy matching module includes:
a preparation path parameter acquisition module, configured to acquire a preparation request path and a preparation request parameter pre-stored in the gateway;
a path parameter matching module, configured to match the original request path and the preparation request path, the original request parameter and the preparation request parameter;
and the cache policy determining module is used for determining that the service call request is successfully matched with the request cache policy if the preparation request path consistent with the original request path exists and the preparation request parameter consistent with the original request parameter exists.
Optionally, the micro service invocation module 470 includes:
the first target request determining module is used for extracting a plurality of service call requests matched with the request aggregation policy as first target requests;
the first request path acquisition module is used for acquiring original request paths included in a plurality of first target requests as first request paths;
The path aggregation module is used for aggregating a plurality of first request paths as target request paths;
the first service data request module is used for requesting first service data in the service end according to the target request path;
and the first service data return module is used for returning the first service data requested to the client.
Optionally, the micro service invocation module 470 includes:
the second target request determining module is used for extracting the service call request matched with the request caching strategy as a second target request;
the second request path/parameter acquisition module is used for acquiring an original request path and original request parameters included in the second target request as a second request path and second request parameters;
the second service data query module is used for querying the preparation service data in the gateway as second service data according to the second request path and the second request parameter, wherein the preparation service data is stored in the gateway in advance, and the second service data returned when the service is called according to the preparation request path and the preparation request parameter consistent with the second request path and the second request parameter in the service end;
And the second service data return module is used for returning the second service data to the client.
Optionally, the micro service invocation module 470 includes:
a third target request determining module, configured to extract, as a third target request, the service call request that matches the request balancing policy;
the third target request dividing module is used for dividing a plurality of third target requests into a plurality of service call groups, the number of the third target requests in the service call groups is smaller than a preset number threshold, and different service call groups call micro-services from different service ends;
the third service data request module is configured to request third service data at the target server according to the original request path and the original request parameter included in the third target request, where the target server is the server pointed by the service call group where the third target request is located;
and the third service data return module is used for returning the third service data to the client.
Optionally, the micro service invocation module 470 includes:
the fourth target request determining module is used for extracting the service call request matched with the request fusion strategy to serve as a fourth target request;
A fourth target request fusion module, configured to fuse a plurality of fourth target requests into a single fusion target request, where the fusion target request includes a fusion request path and a fusion request parameter;
a fourth service data request module, configured to request fourth service data at the server according to the fusion request path and the fusion request parameter;
and the fourth service data return module is used for returning the fourth service data to the client. The micro-service calling device provided by the embodiment of the invention can execute the micro-service calling method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example III
Fig. 5 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. 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. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 5, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the micro service invocation method.
In some embodiments, the micro service invocation method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the micro-service invocation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the micro-service invocation method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device 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) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (7)

1. The utility model provides a micro-service calling method, which is characterized in that the method is applied to a gateway, a plurality of service calling strategies are stored in the gateway, the service calling strategies comprise at least one of a request aggregation strategy, a request caching strategy, a request balancing strategy and a request fusion strategy, the gateway obtains micro-services from a plurality of service ends, and the service ends store a plurality of micro-services, the method comprises the following steps:
Receiving service call requests from all clients in a preset time interval;
recording the request quantity of the service call requests received in the time interval;
identifying a service type of the micro-service to which the service invocation request is directed;
acquiring an original request path and original request parameters included in the service call request;
matching the service call request with a plurality of service call policies according to the request quantity, the service type, the original request path and the original request parameters;
if the service call request is successfully matched with the service call policy, determining that the service call policy is a target service call policy;
responding to the service call request according to the target service call strategy, and calling micro-service for the client from the server;
said matching said service invocation request with a plurality of said service invocation policies according to said number of requests, said service type, said original request path, and said original request parameters, comprising:
matching the service call request with the request aggregation policy and the request fusion policy according to the service type;
Matching the service call request with the request caching strategy according to the original request path and the original request parameters;
comparing the request quantity with a preset quantity threshold value;
if the number of the requests is larger than a preset number threshold, determining that the service call request and the request balancing strategy are successfully matched;
the matching the service call request with the request aggregation policy and the request fusion policy according to the service type comprises the following steps:
if the service types of the micro-services pointed by two or more service call requests are sub-services for realizing the same target micro-service, determining that the service call requests are successfully matched with the request aggregation policy, wherein a plurality of sub-services jointly form the target micro-service;
if two or more micro services of which the service call requests point to a preset specific service type exist, determining that the service call requests are successfully matched with the request fusion strategy, wherein the specific service type comprises query service;
the matching the service call request with the request cache policy according to the original request path and the original request parameters includes:
Acquiring a pre-stored preparation request path and preparation request parameters in the gateway;
matching the original request path and the preparation request path, the original request parameters and the preparation request parameters;
and if the preparation request path consistent with the original request path exists and the preparation request parameter consistent with the original request parameter exists, determining that the service call request is successfully matched with the request caching strategy.
2. The method of claim 1, wherein if the target service invocation policy includes a request aggregation policy, the invoking the micro-service for the client in response to the service invocation request according to the target service invocation policy comprises:
extracting a plurality of service call requests matched with the request aggregation policy as first target requests;
acquiring original request paths included in a plurality of first target requests as first request paths;
aggregating a plurality of the first request paths as target request paths;
requesting first service data in the server according to the target request path;
and returning the requested first service data to the client.
3. The method of claim 1, wherein if the target service invocation policy includes the request cache policy, the invoking the micro-service for the client in response to the service invocation request according to the target service invocation policy comprises:
extracting the service call request matched with the request caching strategy as a second target request;
acquiring an original request path and original request parameters included in the second target request as a second request path and second request parameters;
inquiring preliminary service data in the gateway as second service data according to the second request path and the second request parameter, wherein the preliminary service data is stored in the gateway in advance, and the second service data returned when the service is called according to the preliminary request path and the preliminary request parameter consistent with the second request path and the second request parameter is in the service end;
and returning the second service data to the client.
4. The method of claim 1, wherein if the target service invocation policy includes the request balancing policy, the invoking the micro-service for the client in response to the service invocation request according to the target service invocation policy comprises:
Extracting the service call request matched with the request balancing strategy as a third target request;
dividing a plurality of third target requests into a plurality of service call groups, wherein the number of the third target requests in the service call groups is smaller than a preset number threshold, and different service call groups call micro-services from different service ends;
requesting third service data at a target server according to the original request path and the original request parameters included in the third target request, wherein the target server is the server pointed by the service calling group where the third target request is located;
and returning the third service data to the client.
5. The method of claim 1, wherein if the target service invocation policy includes the request fusion policy, the invoking the micro-service for the client in response to the service invocation request according to the target service invocation policy comprises:
extracting the service call request matched with the request fusion strategy as a fourth target request;
fusing a plurality of fourth target requests into a single fused target request, wherein the fused target request comprises a fused request path and fused request parameters;
Requesting fourth service data at the server according to the fusion request path and the fusion request parameters;
and returning the fourth service data to the client.
6. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the micro service invocation method of any of claims 1-5.
7. A computer readable storage medium storing computer instructions for causing a processor to implement the micro service invocation method of any of claims 1-5 when executed.
CN202210649261.0A 2022-06-09 2022-06-09 Service calling method, electronic equipment and storage medium Active CN115037803B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210649261.0A CN115037803B (en) 2022-06-09 2022-06-09 Service calling method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210649261.0A CN115037803B (en) 2022-06-09 2022-06-09 Service calling method, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115037803A CN115037803A (en) 2022-09-09
CN115037803B true CN115037803B (en) 2024-03-22

Family

ID=83122087

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210649261.0A Active CN115037803B (en) 2022-06-09 2022-06-09 Service calling method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115037803B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014005455A1 (en) * 2012-04-12 2014-01-09 华为技术有限公司 Policy control method, device, and system for data service
CN104780184A (en) * 2014-01-09 2015-07-15 华耀(中国)科技有限公司 Method of using geographical location information for load balancing
CN111600930A (en) * 2020-04-09 2020-08-28 网宿科技股份有限公司 Micro-service request traffic management method, device, server and storage medium
WO2020211365A1 (en) * 2019-04-19 2020-10-22 平安科技(深圳)有限公司 Flow load balancing method and apparatus, computer device and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10742506B2 (en) * 2018-05-29 2020-08-11 University-Industry Cooperation Group Of Kyung-Hee University Policy-based storage service federation method and apparatus

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014005455A1 (en) * 2012-04-12 2014-01-09 华为技术有限公司 Policy control method, device, and system for data service
CN104780184A (en) * 2014-01-09 2015-07-15 华耀(中国)科技有限公司 Method of using geographical location information for load balancing
WO2020211365A1 (en) * 2019-04-19 2020-10-22 平安科技(深圳)有限公司 Flow load balancing method and apparatus, computer device and storage medium
CN111600930A (en) * 2020-04-09 2020-08-28 网宿科技股份有限公司 Micro-service request traffic management method, device, server and storage medium

Also Published As

Publication number Publication date
CN115037803A (en) 2022-09-09

Similar Documents

Publication Publication Date Title
US20190196875A1 (en) Method, system and computer program product for processing computing task
CN113259415B (en) Network message processing method and device and network server
WO2016127796A1 (en) Information interaction method and server
CN114500633B (en) Data forwarding method, related device, program product and data transmission system
CN115037803B (en) Service calling method, electronic equipment and storage medium
CN116126916A (en) Data query method, device and equipment based on intelligent network card
CN114390239B (en) Communication method, device, system, electronic device, and storage medium
CN115599571A (en) Data processing method and device, electronic equipment and storage medium
CN115658290A (en) Message processing method, device, equipment and storage medium
CN114827159A (en) Network request path optimization method, device, equipment and storage medium
CN114793234B (en) Message processing method, device, equipment and storage medium
CN112306695A (en) Data processing method and device, electronic equipment and computer storage medium
CN114466079B (en) Request processing method, device, proxy server and storage medium
CN116991562B (en) Data processing method and device, electronic equipment and storage medium
CN114553894B (en) Data synchronization method, device, system and storage medium
CN115525415B (en) Data processing method, device, equipment and medium
CN115499373B (en) Network traffic distribution system, method, equipment and medium applied to backbone network
CN116389458A (en) Cloud file management method, device, equipment and storage medium
EP3993366A2 (en) Network load balancer, request message distribution method, program product and system
CN116112382A (en) Network data capturing method and device, electronic equipment and storage medium
CN118245445A (en) Log query method, device, electronic equipment, storage medium and program product
CN118055068A (en) Message processing method, device, equipment and medium based on DPDK
CN113452721A (en) Network interaction function optimization system, method, computer equipment and medium
CN117827458A (en) Resource matching method and device, electronic equipment and storage medium
CN116647450A (en) Modification method, device, equipment and medium of Nginx configuration information

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