CN107181675B - Service calling method and device - Google Patents

Service calling method and device Download PDF

Info

Publication number
CN107181675B
CN107181675B CN201710469894.2A CN201710469894A CN107181675B CN 107181675 B CN107181675 B CN 107181675B CN 201710469894 A CN201710469894 A CN 201710469894A CN 107181675 B CN107181675 B CN 107181675B
Authority
CN
China
Prior art keywords
service
calling
request
identifier
invocation
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
CN201710469894.2A
Other languages
Chinese (zh)
Other versions
CN107181675A (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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201710469894.2A priority Critical patent/CN107181675B/en
Publication of CN107181675A publication Critical patent/CN107181675A/en
Application granted granted Critical
Publication of CN107181675B publication Critical patent/CN107181675B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention provides a service calling method and a device, wherein a service gateway receives a service calling request and sends the service calling request to a corresponding service providing terminal; and the service gateway returns the response result returned by the service providing terminal to the service calling terminal. The service calling request comprises a calling identifier which uniquely marks the current calling link, and the calling identifier is transmitted among service providing ends in the whole calling link. Each service call request and call result need to be forwarded through the service gateway, so that the service gateway can obtain call information corresponding to all service calls. Therefore, the service calling link corresponding to the calling identification is searched from the calling information. The method only needs to set the buried points on the service gateway for sampling, and does not need to set the buried points on both the client and the server, so that the development and deployment costs of the client and the server of the service are greatly reduced.

Description

Service calling method and device
Technical Field
The invention belongs to the field of computers, and particularly relates to a service calling method and device.
Background
Currently, the system of the internet company is generally composed of a large number of subsystems providing different functions and adopting a micro-service architecture. Micro-services refer to the development of multiple independent small, but fully functional services, each with its own processing and communication mechanisms, that can be deployed on a single or multiple servers.
The micro-service architecture has a large number of micro-services, and complex calling relations exist among the micro-services, so that developers are difficult to know the calling relations among the micro-services included in the whole system, and when a performance bottleneck occurs in the whole calling chain, the developers are difficult to locate the service components with problems.
In view of the above problems, the conventional solutions are: and (2) performing embedded point sampling on the client and the server of each micro service respectively, and finally, synthesizing all sampled data to analyze and obtain a service call link of the system, but the mode brings development and deployment pressure to the client and the server of each micro service, and different micro service providers are difficult to coordinate a uniform embedded point sampling scheme.
Disclosure of Invention
In view of this, the present invention provides a service invoking method and device, so as to solve the technical problems that development and deployment of a client and a server of a micro service are difficult and that it is difficult for different service providers to perform uniform buried point sampling in the conventional solution. The technical scheme of the invention is as follows:
in a first aspect, the present application provides a service invoking method, which is applied in a service gateway, and the method includes:
receiving a service calling request, wherein the service calling request comprises a service calling end identifier, a service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
sending the service calling request to a corresponding service provider according to the service name;
receiving a calling result returned by the service providing terminal, and sending the calling result to a service calling terminal;
and acquiring the calling information corresponding to the service calling request so that a calling analysis end analyzes the service calling end identification, the service providing end identification and the calling identification in the calling information to obtain a service calling link corresponding to the calling identification.
Optionally, the calling information further includes calling time information, and the calling time information includes calling time consumption; the process of obtaining the call time consumption comprises the following steps:
recording a first time stamp of the received service calling request and a second time stamp of a calling result corresponding to the received calling request;
and calculating the time difference between the second time stamp and the first time stamp to obtain the calling time consumption of each service.
Optionally, the receiving a service invocation request includes:
receiving the service calling request sent by the client;
or,
and receiving a service calling request for calling the second service provider, which is sent by the first service provider.
In a second aspect, the present application further provides another service invoking method, which is applied to a service provider, and the method includes:
a first service provider receives a first calling request forwarded by a service gateway, wherein the first calling request comprises a first service calling end identifier, a first service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
the first service providing terminal analyzes the first calling request to obtain a second service name required to be called by the first calling request and the calling identifier;
the first service providing terminal generates a second calling request according to the second service name, wherein the second calling request comprises a second service calling terminal identification, a second service name and the calling identification;
the first service provider sends the second calling request to the service gateway so that the service gateway forwards the second calling request to a second service provider, and the second service provider provides a service corresponding to the second service name; and enabling the service gateway to obtain calling information, and obtaining a service calling link corresponding to the calling identifier by a calling analysis end according to the calling information.
Optionally, the method further comprises:
the first service provider receives a second calling result returned by the second service provider through the service gateway, and the second calling result is obtained by the second service provider responding to the second calling request;
and the first service providing terminal responds to the first calling request according to the second calling result to generate a first calling result, and forwards the first calling result to the first service calling terminal initiating the first calling request through the service gateway.
In a third aspect, the present application provides a service invoking device, which is applied in a service gateway, and the device includes:
the first receiving unit is used for receiving a service calling request, wherein the service calling request comprises a service calling end identifier, a service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
the first sending unit is used for sending the service calling request to a corresponding service provider according to the service name;
the second receiving unit is used for receiving a calling result returned by the service providing end;
the second sending unit is used for sending the calling result to a service calling end;
and the obtaining unit is used for obtaining the calling information corresponding to the service calling request so that the calling analysis end analyzes the service calling end identifier, the service providing end identifier and the calling identifier in the calling information to obtain a service calling link corresponding to the calling identifier.
Optionally, the calling information further includes calling time information, the calling time information includes calling time consumption, and the obtaining unit includes:
the first recording subunit is used for recording a first timestamp of the received service calling request;
the second recording subunit is used for recording a second timestamp of the calling result corresponding to the received calling request;
and the calculating subunit is configured to calculate a time difference between the second timestamp and the first timestamp, so as to obtain a call time consumption corresponding to each service.
Optionally, the first receiving unit is specifically configured to:
receiving the service calling request sent by the client;
or,
and receiving a service calling request for calling the second service provider, which is sent by the first service provider.
In a fourth aspect, the present application provides a service invoking device, which is applied to a service providing end, and the device includes:
the first receiving unit is used for enabling a first service providing end to receive a first calling request forwarded by a service gateway, wherein the first calling request comprises a first service calling end identifier, a first service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
a first parsing unit, configured to enable the first service providing end to parse the first invocation request to obtain a second service name to be invoked by the first invocation request and the invocation identifier;
a request generating unit, configured to enable the first service provider to generate a second call request according to the second service name, where the second call request includes a second service call end identifier, a second service name, and the call identifier;
a first sending unit, configured to enable the first service provider to send the second invocation request to the service gateway, so that the service gateway forwards the second invocation request to a second service provider, where the second service provider provides a service corresponding to the second service name; and enabling the service gateway to obtain calling information, and obtaining a service calling link corresponding to the calling identifier by a calling analysis end according to the calling information.
Optionally, the apparatus further comprises:
a second receiving unit, configured to enable the first service provider to receive, through the service gateway, a second invocation result returned by the second service provider, where the second invocation result is obtained by the second service provider in response to the second invocation request;
and the response unit is used for enabling the first service providing end to respond to the first calling request according to the second calling result, generating a first calling result and forwarding the first calling result to the first service calling end initiating the first calling request through the service gateway.
In the service invocation method provided by this embodiment, the service gateway receives a service invocation request, the service gateway sends the service invocation request to a corresponding service provider according to a service name, the service invocation request includes an invocation identifier uniquely identifying a current invocation link, and the invocation identifier is transmitted between the service providers in the whole invocation link; each service call request and call result need to be forwarded through the gateway, so that the service gateway can obtain call information corresponding to all service calls. The calling information comprises a service calling end identifier, a service providing end identifier, a calling identifier and calling time information, so that the service calling link corresponding to the calling identifier can be obtained by searching the service calling end identifier and the service providing end identifier corresponding to the calling identifier from the calling information. The method only needs to set the buried points on the service gateway for sampling, and does not need to set the buried points on both the client and the server, so that the development and deployment costs of the client and the server of each service are greatly reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 illustrates a schematic diagram of a typical microservice architecture;
FIG. 2 is a schematic diagram of a service invocation system according to an embodiment of the invention;
FIG. 3 is a flow chart illustrating a method for service invocation in accordance with an embodiment of the present invention;
FIG. 4 is a flow diagram illustrating another method for service invocation in accordance with an embodiment of the present invention;
FIG. 5 is a block diagram of a service invocation device according to an embodiment of the present application;
FIG. 6 is a block diagram of an acquisition unit according to an embodiment of the present application;
fig. 7 is a block diagram illustrating another service invocation device according to an embodiment of the present application.
Detailed Description
Before the technical scheme of the invention is described in detail, the following micro-service framework is introduced:
micro-services refer to the development of multiple independent small services with complete business functions, each service having its own processing and communication mechanism and being deployed on a single or multiple servers. The idea and concept of the microservice architecture are as follows: decoupling the system into smaller units; each unit has its own responsibilities; each unit is exposed through an Application Programming Interface (API), and the specific implementation of the unit is not required to be concerned by the outside; all units are independent and can be independently developed, deployed, expanded and monitored; the units may interact with each other through a Remote Procedure Call Protocol (RPC) request.
In the micro-service architecture, a client and a server need a service gateway device for interaction, and the service gateway is used as an entrance of a system and is responsible for service request routing, combination, protocol conversion and the like. In addition, there is a need for identity authentication for access clients, protection against message replay and data tampering, service authentication for function calls, desensitization of response data, flow and concurrency control, and even metering or charging based on API calls.
As shown in fig. 1, a typical micro-service architecture is shown, and the micro-service system includes six micro-services: A. b, C, D, E and F. For example, the microservice system includes 3 microservice routes: the registration of the new user is realized by micro-services A, B, C and E, wherein the calling relationship among the micro-services is that A calls B, B calls C and C calls E; the order placing is realized by micro-services A, B, C and D; payment is effected by microservices A, B, C, D and F.
In the micro-service architecture, complex calling relations exist among micro-services, so that developers of the system are difficult to find out the calling relations among the micro-services in the whole micro-service system, and when a performance bottleneck occurs in a whole calling link, the nodes where problems appear are difficult to locate. According to the service calling method, the buried point sampling is set in the service gateway, the service gateway is responsible for service request routing, and each service calling needs to pass through the service gateway, so that the service gateway can sample calling information of each service calling, such as calling relation, calling time consumption and the like. Then, the calling information collected by the service gateway is analyzed.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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 invention.
Referring to fig. 2, a schematic diagram of a service invocation system according to an embodiment of the present invention is shown, and as shown in fig. 2, the system includes a service invocation end 1, a service gateway 2, a service provider end 3, a log collector 4, and an invocation analysis end 5.
And the service calling terminal 1 is used for sending a service calling request to the service gateway, and each service calling request contains a calling identifier for uniquely marking the current calling link.
And the service gateway 2 is used for routing the service call to a correct service provider and recording the call information of the call, wherein the call information comprises a call identifier, a service call identifier and a service provider identifier.
And the service provider 3 is configured to receive and process the first service invocation request, generate a second service invocation request if the service provider needs to initiate service invocation again, where the second service invocation request carries the invocation identifier included in the first service invocation request, and the invocation identifiers are sequentially passed until a last service provider invoked this time.
And the log collector 4 is used for collecting the calling information sampled by the service gateway and sending the calling information to the calling analysis terminal 5.
In a possible implementation manner of the present invention, the log collector 4 may be deployed in a device in which the service gateway is located;
in another possible implementation manner of the present invention, the log collector 4 may be deployed in a device other than the service gateway, and in this application scenario, the log collector 4 needs to know the address of the service gateway and obtain the call information from the service gateway.
And the call analysis end 5 analyzes the call information collected by the log collector, determines that all call requests containing the same call identifier belong to the same call link, and obtains the service topology of the service system according to different call links. And acquiring the corresponding calling time consumption of each calling request, and determining the performance bottleneck of the service system according to the calling time consumption. The time consumed for calling refers to the time required from the initiation of the service call to the obtaining of the response of the service.
Referring to fig. 3, a flowchart of a service invocation method according to an embodiment of the present invention is shown, where the method is applied in a service gateway, and as shown in fig. 3, the method may include:
s110, the service gateway receives the service calling request.
The service gateway receives a service calling request sent by a service calling terminal, wherein the service calling request comprises a service calling terminal identifier, a service name and a calling identifier, and the calling identifier is used for uniquely marking a calling link corresponding to the service calling request.
The service invocation end is a party initiating the service invocation request, and the service invocation end identifier may be identification information capable of uniquely identifying the service invocation end, for example, a Media Access Control (MAC) address.
In a possible implementation manner of the present invention, the service invocation end may be a client, that is, the client initiates an application scenario of a service invocation request to the service gateway;
in another possible implementation manner of the present invention, the service invocation end may be a service provider, that is, when the service provider implements a certain service, it needs to invoke another service, and therefore, it needs to send a service invocation request to another service provider.
With the example of the micro-service framework shown in fig. 1, when a client initiates a new user registration request, the client sends a service invocation request of "new user registration" to the service gateway, and in this application scenario, a service caller (i.e., the party sending the service invocation request) is the client; for example, the new user registration service is realized by four micro-services A-B-C-E, and when the micro-service A calls the micro-service B, the service calling end is the service provider of the micro-service A.
The calling identifier is used for uniquely marking the identifier of the current calling link, is generated by the client initiating the service calling, and is continuously transmitted in the service calling link for realizing the service.
And S120, the service gateway sends the service calling request to the corresponding service provider according to the service name.
The service gateway finds a service provider providing the service corresponding to the service name according to the service name contained in the service calling request, and sends the service calling request to the service provider.
S130, the service gateway receives the calling result returned by the service providing terminal and sends the calling result to the service calling terminal.
And after receiving the service calling request, the service provider responds to the service calling request to generate a calling result if other services are not required to be called, the calling result is returned to the service gateway, and the service gateway returns the received calling result to the service calling end.
S140, the service gateway obtains the calling information corresponding to the service calling request, so that the calling analysis end obtains the service calling link corresponding to the calling identifier according to the calling information, wherein the calling information comprises the service calling end identifier, the service providing end identifier, the calling identifier and the calling time information.
The service gateway is internally provided with a buried point for sampling the whole service calling process to obtain calling information, wherein the calling information comprises a service calling end identifier, a service providing end identifier, a calling identifier and calling time information.
And the calling analysis end analyzes the calling information obtained by the service gateway to obtain calling data corresponding to the calling identification, and finally obtains the whole service calling link called by the service.
Optionally, the current call time consumption can be obtained according to the call time information included in the call information, and the process of obtaining the call time consumption includes:
the service gateway records a first time stamp of the received call request, records a second time stamp of the call result corresponding to the received call request, and calculates the time difference between the second time stamp and the first time stamp to obtain the call time consumption of each service call.
And calculating the calling time consumption of the whole calling link according to the calling time consumption corresponding to each calling in the current calling link, and analyzing the performance bottleneck of the service system according to the calling time consumption.
In the service tracking method provided by this embodiment, the service gateway receives a service invocation request, and the service gateway sends the service invocation request to a corresponding service provider according to a service name, where the service invocation request includes an invocation identifier uniquely identifying a current invocation link, and the invocation identifier is transmitted between service providers in the entire invocation link; each service call request and call result need to be forwarded through the gateway, so that the service gateway can obtain call information corresponding to all service calls. The calling information comprises a service calling end identifier, a service providing end identifier, a calling identifier and calling time information, so that the service calling link corresponding to the calling identifier can be obtained by searching the service calling end identifier and the service providing end identifier corresponding to the calling identifier from the calling information. According to the method, the calling information is obtained by sampling of the service gateway, and finally calling link tracking is achieved, so that only the buried point is required to be arranged on the service gateway for sampling, and the buried point is not required to be arranged on both the client and the server, so that the development and deployment cost of the client and the server of each service is greatly reduced.
Referring to fig. 4, a flowchart of another service invocation method according to an embodiment of the present invention is shown, where the method is applied to the system shown in fig. 2, and as shown in fig. 4, the method includes the following steps:
s210, the client sends a first service calling request to the service gateway.
The first service calling request comprises a client identifier, first service name information and a calling identifier, wherein the calling identifier is used for uniquely marking a current calling link.
S220, the service gateway determines a corresponding first service providing terminal according to the service name information, forwards the first service calling request to the first service providing terminal, and records calling related information of the first service calling request.
In an embodiment of the present application, the call related information may include: the service calling terminal identifier, the service providing terminal identifier, the calling identifier and the calling time information, such as the receiving time of the calling request and the receiving time of the corresponding calling result.
S230, the first service providing terminal receives the first service calling request and determines whether other services need to be called; if yes, executing S240-S280; if not, S290 is performed.
After receiving the first service call request, the first service provider analyzes the first service call request, and determines whether to call other services again in response to the first service call request.
If no other service is needed to be called, directly responding to the first service calling request; if the other service needs to be called, the other service is continuously called.
S240, the first service providing terminal generates a second service calling request and sends the second service calling request to the service gateway.
The second service invocation request carries the invocation identification contained in the first service invocation request, and comprises the information of the first service providing end and the second service name information.
And if the first service providing end needs to call other services when responding to the first service call request, generating a second service call request for calling the other services, and writing a call identifier contained in the first service call request into the second service call request when generating the second service call request. That is, the invocation identification is passed on through the service invocation link.
And S250, the service gateway receives the second service calling request, determines a second service provider corresponding to the second service name information, sends the second service calling request to the second service provider, and records calling related information of the second service calling request.
And S260, the second service provider responds to the second service calling request to obtain a second calling result, and sends the second calling result to the service gateway.
S270, the service gateway returns the second calling result to the first service providing end, and records the calling related information of the second calling result.
S280, the first service providing terminal obtains a first calling result according to the second calling result and sends the first calling result to the service gateway.
After execution of S240 to S280, S2100 to S2120 are executed in sequence.
S290, the first service providing terminal responds to the first service calling request, generates a first calling result and sends the first calling result to the service gateway.
After executing S290, executing S2100-S2120 in sequence;
s2100, the service gateway returns the first calling result to the client side, and records calling related information of the first calling result.
S2110, the log collector collects the recorded call related information from the service gateway.
And S2120, the calling analysis end analyzes data in the log collector to obtain a service calling link corresponding to the calling identifier.
And processing data in the log collector by the calling analysis end to obtain a calling request containing the same calling identifier, and determining a calling relation according to the service calling end identifier and the service providing end identifier so as to obtain a service calling link corresponding to the calling identifier. By using the method, different service call links can be obtained, so that the service topological structure of the whole micro-service structure is obtained.
And when the calling relation is obtained, the calling analysis end determines the calling time consumption between services according to the calling time information collected by the log collector, namely the difference value between the time of receiving a certain calling request by the service gateway and the time of receiving a calling result corresponding to the calling request.
By utilizing the service topological structure and the time consumption for calling among the services, the performance bottleneck in the whole micro-service architecture can be analyzed.
The call analysis end can be implemented based on a text retrieval system, and by inputting details of a call link to be viewed according to a screening condition, for example, a time period can be input to screen a time period in which a call to be viewed occurs, and all relevant information of service calls in the time period, such as a service call end identifier, a service provider end identifier, call delay and the like, is retrieved from log data of the log collector.
In the service invocation method provided by this embodiment, a buried point is set in a service gateway to sample and record each invocation in a microservice architecture, where a service invocation request includes an invocation identifier of a current invocation link, and the invocation identifier is transmitted all the time in the entire invocation link. The log collector can collect the call related information collected by the service gateway and provide the call related information to the call analysis end, and the call analysis end analyzes the call related information and searches for the service call end identifier and the service providing end identifier corresponding to the call identifier so as to obtain the service call link corresponding to the call identifier. According to the method, the calling information is obtained by sampling of the service gateway, and finally calling link tracking is achieved, so that only a buried point is required to be arranged on the service gateway for sampling, and the buried point is not required to be arranged on both the client and the server, so that the development and deployment cost of the client and the server of each service is greatly reduced.
While, for purposes of simplicity of explanation, the foregoing method embodiments have been described as a series of acts or combination of acts, it will be appreciated by those skilled in the art that the present invention is not limited by the illustrated ordering of acts, as some steps may occur in other orders or concurrently with other steps in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Corresponding to the service calling method embodiment, the application also provides a service calling device embodiment.
Referring to fig. 5, a block diagram of a service invocation device applied in a service gateway according to an embodiment of the present application is shown. The device includes: a first receiving unit 110, a first transmitting unit 120, a second receiving unit 130, a second transmitting unit 140 and an obtaining unit 150;
the first receiving unit 110 is configured to receive a service invocation request, where the service invocation request includes a service invocation end identifier, a service name, and an invocation identifier, and the invocation identifier is used to uniquely identify a service invocation link corresponding to the service invocation request.
The service invocation end is a party initiating the service invocation request, and the service invocation end identifier may be identification information capable of uniquely identifying the service invocation end, such as a MAC address.
In a possible implementation manner of the present invention, the service invocation end may be a client, that is, the client initiates an application scenario of a service invocation request to the service gateway;
in another possible implementation manner of the present invention, the service invocation end may be a service provider, that is, when the service provider implements a certain service, it needs to invoke another service, and therefore, it needs to send a service invocation request to another service provider.
A first sending unit 120, configured to send the service invocation request to a corresponding service provider according to the service name.
The service gateway finds a service provider providing a service corresponding to the service name according to the service name included in the service calling request, and sends the service calling request to the service provider through the first sending unit.
A second receiving unit 130, configured to receive a call result returned by the service provider.
After receiving the service calling request, the service provider responds to the service calling request to generate a calling result if other services are not required to be called, and returns the calling result to the service gateway, and the service gateway receives the calling result through the second receiving unit.
A second sending unit 140, configured to send the call result to the service call end.
An obtaining unit 150, configured to obtain the call information corresponding to the service call request, so that the call analysis end analyzes the call information to obtain a service call link corresponding to the call identifier.
The service gateway is internally provided with a buried point for sampling the whole service calling process to obtain calling information, wherein the calling information comprises a service calling end identifier, a service providing end identifier, a calling identifier and calling time information.
And analyzing the calling information obtained by the service gateway to obtain calling data corresponding to the calling identifier, and finally obtaining the whole service calling link called by the service.
Optionally, the performance bottleneck of the service system may also be determined according to a call time consumption, where the call time consumption refers to a time elapsed from the initiation of the service call to the obtaining of the service response.
As shown in fig. 6, the acquisition unit 150 includes a first recording subunit 151, a second recording subunit 152, and a calculation subunit 153.
A first recording subunit 151, configured to record a first timestamp of receiving the service invocation request.
And a second recording subunit 152, configured to record a second timestamp of the call result corresponding to the received call request.
And the calculating subunit 153 is configured to calculate a time difference between the second timestamp and the first timestamp, so as to obtain a call time consumption corresponding to each service.
In the service invocation device provided in this embodiment, the service gateway receives a service invocation request, and the service gateway sends the service invocation request to a corresponding service provider according to a service name, where the service invocation request includes an invocation identifier uniquely identifying a current invocation link, and the invocation identifier is transmitted between the service providers in the entire invocation link; each service call request and call result need to be forwarded through the gateway, so that the service gateway can obtain call information corresponding to all service calls. The calling information comprises a service calling end identifier, a service providing end identifier, a calling identifier and calling time information, so that the service calling link corresponding to the calling identifier can be obtained by searching the service calling end identifier and the service providing end identifier corresponding to the calling identifier from the calling information. The device only needs to set the buried points on the service gateway for sampling, and does not need to set the buried points on the client and the server, so that the development and deployment costs of the client and the server of each service are greatly reduced.
Referring to fig. 7, a block diagram of another service invocation device according to an embodiment of the present application is shown, where the device is applied to a service provider, and as shown in fig. 7, the device may include: a first receiving unit 210, a first parsing unit 220, a request generating unit 230, a first sending unit 240, a second receiving unit 250, and a responding unit 260.
The first receiving unit 210 is configured to enable the first service provider to receive the first invocation request forwarded by the service gateway.
The first calling request comprises a first service calling end identifier, a first service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request.
A first parsing unit 220, configured to enable the first service providing end to parse the first invocation request to obtain a second service name that needs to be invoked by the first invocation request, and the invocation identifier.
After receiving the first service call request, the first service provider analyzes the first service call request, and determines a second service name to be called in response to the first service call request.
A request generating unit 230, configured to enable the first service provider to generate a second call request according to the second service name, where the second call request includes a second service caller id, a second service name, and the call id.
And the calling identifier contained in the second calling request generated by the first service calling end is the same as the calling identifier in the first calling request.
A first sending unit 240, configured to enable the first service provider to send the second invocation request to the service gateway;
the service gateway forwards the second calling request to a second service provider, and the second service provider provides a service corresponding to the second service name; and enabling the service gateway to obtain calling information, and obtaining a service calling link corresponding to the calling identifier by a calling analysis end according to the calling information.
A second receiving unit 250, configured to enable the first service provider to receive, through the service gateway, a second invocation result returned by the second service provider, where the second invocation result is obtained by the second service provider in response to the second invocation request.
A responding unit 260, configured to enable the first service providing end to respond to the first invocation request according to the second invocation result, generate a first invocation result, and forward the first invocation result to the first service invocation end that initiates the first invocation request through the service gateway.
And processing data in the log collector by the calling analysis end to obtain calling requests containing the same calling identifier, and determining a calling relationship according to the service calling end identifier and the service providing end identifier contained in each calling request so as to obtain a service calling link corresponding to the calling identifier. By using the method, different service call links can be obtained, so that the service topological structure of the whole micro-service structure is obtained.
And when the calling relation is obtained, the calling analysis end determines the calling time consumption between services according to the calling time information collected by the log collector, namely the difference value between the time of receiving a certain calling request by the service gateway and the time of receiving a calling result corresponding to the calling request.
By utilizing the service topological structure and the time consumption for calling among the services, the performance bottleneck in the whole micro-service architecture can be analyzed.
The call analysis end can be implemented based on a text retrieval system, and by inputting details of a call link to be viewed according to a screening condition, for example, a time period can be input to screen a time period in which a call to be viewed occurs, and all relevant information of service calls in the time period, such as a service call end identifier, a service provider end identifier, call delay and the like, is retrieved from log data of the log collector.
In the service invocation apparatus provided in this embodiment, a buried point is set in a service gateway to sample and record each invocation in a microservice architecture, where a service invocation request includes an invocation identifier of a current invocation link, and the invocation identifier is transmitted all the time in the entire invocation link. Therefore, the service calling end identifier and the service providing end identifier corresponding to the calling identifier are searched from the service gateway calling information, so that the service calling link corresponding to the calling identifier can be obtained. The device only needs to set the buried points on the service gateway for sampling, and does not need to set the buried points on the client and the server, so that the development and deployment costs of the client and the server of each service are greatly reduced.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the device-like embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A service calling method is applied to a service gateway, and comprises the following steps:
receiving a service calling request, wherein the service calling request comprises a service calling end identifier, a service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
sending the service calling request to a corresponding service provider according to the service name;
receiving a calling result returned by the service providing terminal, and sending the calling result to a service calling terminal;
and acquiring the calling information corresponding to the service calling request so that a calling analysis end analyzes the service calling end identification, the service providing end identification and the calling identification in the calling information to obtain a service calling link corresponding to the calling identification.
2. The method of claim 1, wherein the invocation information further includes invocation time information, the invocation time information including invocation time; the process of obtaining the call time consumption comprises the following steps:
recording a first time stamp of the received service calling request and a second time stamp of a calling result corresponding to the received calling request;
and calculating the time difference between the second time stamp and the first time stamp to obtain the calling time consumption of each service.
3. The method of claim 1, wherein receiving the service invocation request comprises:
receiving the service calling request sent by the client;
or,
and receiving a service calling request for calling the second service provider, which is sent by the first service provider.
4. A service calling method is applied to a service provider, and comprises the following steps:
a first service provider receives a first calling request forwarded by a service gateway, wherein the first calling request comprises a first service calling end identifier, a first service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
the first service providing terminal analyzes the first calling request to obtain a second service name required to be called by the first calling request and the calling identifier;
the first service providing terminal generates a second calling request according to the second service name, wherein the second calling request comprises a second service calling terminal identification, a second service name and the calling identification;
the first service provider sends the second calling request to the service gateway so that the service gateway forwards the second calling request to a second service provider, and the second service provider provides a service corresponding to the second service name; and enabling the service gateway to obtain calling information, and obtaining a service calling link corresponding to the calling identifier by a calling analysis end according to the calling information.
5. The method of claim 4, further comprising:
the first service provider receives a second calling result returned by the second service provider through the service gateway, and the second calling result is obtained by the second service provider responding to the second calling request;
and the first service providing terminal responds to the first calling request according to the second calling result to generate a first calling result, and forwards the first calling result to the first service calling terminal initiating the first calling request through the service gateway.
6. A service invocation device, applied in a service gateway, the device comprising:
the first receiving unit is used for receiving a service calling request, wherein the service calling request comprises a service calling end identifier, a service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
the first sending unit is used for sending the service calling request to a corresponding service provider according to the service name;
the second receiving unit is used for receiving a calling result returned by the service providing end;
the second sending unit is used for sending the calling result to a service calling end;
and the obtaining unit is used for obtaining the calling information corresponding to the service calling request so that the calling analysis end analyzes the service calling end identifier, the service providing end identifier and the calling identifier in the calling information to obtain a service calling link corresponding to the calling identifier.
7. The apparatus according to claim 6, wherein the call information further includes call time information, the call time information includes call elapsed time, and the obtaining unit includes:
the first recording subunit is used for recording a first timestamp of the received service calling request;
the second recording subunit is used for recording a second timestamp of the calling result corresponding to the received calling request;
and the calculating subunit is configured to calculate a time difference between the second timestamp and the first timestamp, so as to obtain a call time consumption corresponding to each service.
8. The apparatus of claim 6, wherein the first receiving unit is specifically configured to:
receiving the service calling request sent by the client;
or,
and receiving a service calling request for calling the second service provider, which is sent by the first service provider.
9. A service invoking device is applied to a service provider, and the device comprises:
the first receiving unit is used for enabling a first service providing end to receive a first calling request forwarded by a service gateway, wherein the first calling request comprises a first service calling end identifier, a first service name and a calling identifier, and the calling identifier is used for uniquely marking a service calling link corresponding to the service calling request;
a first parsing unit, configured to enable the first service providing end to parse the first invocation request to obtain a second service name to be invoked by the first invocation request and the invocation identifier;
a request generating unit, configured to enable the first service provider to generate a second call request according to the second service name, where the second call request includes a second service call end identifier, a second service name, and the call identifier;
a first sending unit, configured to enable the first service provider to send the second invocation request to the service gateway, so that the service gateway forwards the second invocation request to a second service provider, where the second service provider provides a service corresponding to the second service name; and enabling the service gateway to obtain calling information, and obtaining a service calling link corresponding to the calling identifier by a calling analysis end according to the calling information.
10. The apparatus of claim 9, further comprising:
a second receiving unit, configured to enable the first service provider to receive, through the service gateway, a second invocation result returned by the second service provider, where the second invocation result is obtained by the second service provider in response to the second invocation request;
and the response unit is used for enabling the first service providing end to respond to the first calling request according to the second calling result, generating a first calling result and forwarding the first calling result to the first service calling end initiating the first calling request through the service gateway.
CN201710469894.2A 2017-06-20 2017-06-20 Service calling method and device Active CN107181675B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710469894.2A CN107181675B (en) 2017-06-20 2017-06-20 Service calling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710469894.2A CN107181675B (en) 2017-06-20 2017-06-20 Service calling method and device

Publications (2)

Publication Number Publication Date
CN107181675A CN107181675A (en) 2017-09-19
CN107181675B true CN107181675B (en) 2020-03-03

Family

ID=59844243

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710469894.2A Active CN107181675B (en) 2017-06-20 2017-06-20 Service calling method and device

Country Status (1)

Country Link
CN (1) CN107181675B (en)

Families Citing this family (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107741885B (en) * 2017-10-09 2020-12-01 用友网络科技股份有限公司 Transaction and service association method and system based on CS framework
CN107766164A (en) * 2017-11-17 2018-03-06 深圳市泉眼网络科技有限公司 Data calling method and device
CN107944295B (en) * 2017-11-28 2020-04-03 中国农业银行股份有限公司 Sensitive information desensitization method and system for transaction message
CN108199876A (en) * 2017-12-29 2018-06-22 北京奇艺世纪科技有限公司 A kind of daily record data store method, device and distribution service
CN108415925B (en) * 2018-01-10 2020-11-24 平安科技(深圳)有限公司 Electronic device, data call log generation and query method and storage medium
CN108600045A (en) * 2018-04-05 2018-09-28 厦门快商通信息技术有限公司 A kind of service link monitoring method and device
CN108901022B (en) * 2018-06-28 2021-08-20 深圳云之家网络有限公司 Micro-service unified authentication method and gateway
CN108847989B (en) * 2018-06-29 2021-07-06 杭州安恒信息技术股份有限公司 Log processing method based on micro-service architecture, service system and electronic equipment
CN109672662B (en) * 2018-10-11 2021-03-26 中山大学 Method for constructing service dependency relationship in micro-service environment
CN109412944B (en) * 2018-10-16 2023-05-12 深圳壹账通智能科技有限公司 Request forwarding method and device based on micro-service and server
CN109508431A (en) * 2018-11-15 2019-03-22 北京芯盾时代科技有限公司 Bury point code method for implanting, device, electronic equipment and computer storage medium
CN113169900B (en) * 2018-11-29 2022-12-27 华为技术有限公司 Method and device for tracking service execution process in distributed system
CN110138741B (en) * 2019-04-15 2022-06-17 平安科技(深圳)有限公司 Micro-service management method and device based on unified management platform and computer equipment
CN110213240A (en) * 2019-05-09 2019-09-06 国电南瑞科技股份有限公司 A kind of electric power dispatching system and its transregional service calling method of routing self-adaption
CN110445667B (en) * 2019-05-29 2021-10-26 北京大米科技有限公司 Link delay detection method, device, storage medium and terminal
CN110262889A (en) * 2019-06-27 2019-09-20 深圳前海微众银行股份有限公司 A kind of link tracing method and device
CN110807050B (en) * 2019-09-25 2023-05-30 平安科技(深圳)有限公司 Performance analysis method, device, computer equipment and storage medium
CN111163063B (en) * 2019-12-12 2022-07-12 万翼科技有限公司 Edge application management method and related product
CN111343242B (en) * 2020-02-13 2022-09-02 北京奇艺世纪科技有限公司 Information collection method, device, equipment, storage medium and distributed system
CN111580896B (en) * 2020-05-04 2023-07-07 武汉众邦银行股份有限公司 Link calling method based on atomization service
CN111897604B (en) * 2020-07-30 2023-08-11 北京百度网讯科技有限公司 Service call data processing method and device
CN113868345B (en) * 2021-10-11 2024-05-28 支付宝(杭州)信息技术有限公司 Method and device for classifying business data in main body
CN117194176B (en) * 2023-11-03 2024-06-04 中国电子科技集团公司第十五研究所 Non-invasive operation monitoring method, device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101252443A (en) * 2008-03-20 2008-08-27 华为技术有限公司 Apparatus and method for detecting message security
CN104348650A (en) * 2013-08-05 2015-02-11 腾讯科技(深圳)有限公司 Website monitoring method, business device and website monitoring system
CN105577710A (en) * 2014-10-09 2016-05-11 阿里巴巴集团控股有限公司 Service providing method, service acquiring method, devices and system
CN106790718A (en) * 2017-03-16 2017-05-31 北京搜狐新媒体信息技术有限公司 Service call link analysis method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130138768A1 (en) * 2011-11-30 2013-05-30 Vincent Huang Method and System for Dynamic Service Creation on Sensor Gateways

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101252443A (en) * 2008-03-20 2008-08-27 华为技术有限公司 Apparatus and method for detecting message security
CN104348650A (en) * 2013-08-05 2015-02-11 腾讯科技(深圳)有限公司 Website monitoring method, business device and website monitoring system
CN105577710A (en) * 2014-10-09 2016-05-11 阿里巴巴集团控股有限公司 Service providing method, service acquiring method, devices and system
CN106790718A (en) * 2017-03-16 2017-05-31 北京搜狐新媒体信息技术有限公司 Service call link analysis method and system

Also Published As

Publication number Publication date
CN107181675A (en) 2017-09-19

Similar Documents

Publication Publication Date Title
CN107181675B (en) Service calling method and device
CN109639782B (en) Message sending platform and method
CN108400909B (en) Traffic statistical method, device, terminal equipment and storage medium
CN106375458B (en) Service calling system, method and device
CN111176941B (en) Data processing method, device and storage medium
US20220337487A1 (en) Network entity for determining a model for digitally analyzing input data
US20050044213A1 (en) Network traffic measurement system
US20130191890A1 (en) Method and system for user identity recognition based on specific information
CN112840691B (en) Apparatus and method for discovering collectable data and analyzing data in network
CN112448969A (en) Link tracking method, device, system, equipment and readable storage medium
US10616378B2 (en) Adaptive session intelligence extender
CN106603582A (en) Network microservice discovery method
CN102904774B (en) Terminal, server and server performance test methods
CN109639767A (en) A kind of Service Gateway data processing method, device, equipment
CN108876608B (en) Block chain application method and system
CN116244339A (en) Method, device, terminal and medium for fusing operation service monitoring data of business center
US10419351B1 (en) System and method for extracting signatures from controlled execution of applications and application codes retrieved from an application source
US20110276444A1 (en) Method and devices for service rating
CN115412592B (en) Service processing system and method
JP2014523671A (en) Assessing the overall performance of interactive application services
CN109729123A (en) The monitoring method and device of region are launched in a kind of advertisement
US20130064108A1 (en) System and Method for Relating Internet Usage with Mobile Equipment
KR20060067035A (en) Url service apparatus and method for rfid lookup based object information
CN107483294B (en) Method and device for monitoring network request
US20190318036A1 (en) Topic Based Publish and Parametric Subscribe Pattern

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