CN113765805A - Call-based communication method, device, storage medium and equipment - Google Patents

Call-based communication method, device, storage medium and equipment Download PDF

Info

Publication number
CN113765805A
CN113765805A CN202111015022.1A CN202111015022A CN113765805A CN 113765805 A CN113765805 A CN 113765805A CN 202111015022 A CN202111015022 A CN 202111015022A CN 113765805 A CN113765805 A CN 113765805A
Authority
CN
China
Prior art keywords
server
information
calling
target
rule
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111015022.1A
Other languages
Chinese (zh)
Other versions
CN113765805B (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.)
Shanghai Perfect Time And Space Software Co ltd
Original Assignee
Shanghai Perfect Time And Space Software 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 Shanghai Perfect Time And Space Software Co ltd filed Critical Shanghai Perfect Time And Space Software Co ltd
Priority to CN202111015022.1A priority Critical patent/CN113765805B/en
Publication of CN113765805A publication Critical patent/CN113765805A/en
Application granted granted Critical
Publication of CN113765805B publication Critical patent/CN113765805B/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
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/54Organization of routing tables
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/133Protocols for remote procedure calls [RPC]
    • 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
    • H04L67/63Routing a service request depending on the request content or context

Abstract

The invention discloses a calling-based communication method and device, relates to the technical field of communication, and mainly solves the problem that the existing calling-based communication mode is difficult to meet the requirement of a forwarding function when facing complex environments and scenes. The method comprises the following steps: acquiring calling information, wherein the calling information is obtained after analysis based on a calling request; determining a target server according to the calling information and a route forwarding strategy, wherein the route forwarding strategy comprises at least one forwarding rule, each forwarding rule is used for selecting the target server from a plurality of servers based on the calling information, and the calling information comprises information for selecting the route forwarding strategy; and sending the calling information to the target server. The invention is used for call-based communication procedures.

Description

Call-based communication method, device, storage medium and equipment
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a communication method and apparatus based on invocation.
Background
With the continuous development of the technology, the communication technology also advances. Currently, there are situations in some cases where remote calls need to be used, i.e. when RPC calls are used. Wherein, the RPC Call is a Remote Procedure Call (RPC for short). Some services internal to the remote server are typically called through an interface to perform local functions, such as calling standard functions or custom functions of the remote server and obtaining data returned by the functions for processing, display or printing.
Currently, remote calling is often performed through a gRPC calling framework developed by ***, or a swift calling framework developed by facebook is used. However, in practical applications, the two communication methods for remote invocation do not support the forwarding function, that is, when the forwarding requirements in different scenarios are met, it is difficult for the conventional communication method based on invocation to meet the communication requirements based on the forwarding function.
Disclosure of Invention
In view of the foregoing problems, the present invention provides a call-based communication method and apparatus, and mainly aims to solve the problem that the existing call-based communication method is difficult to meet the requirement of the forwarding function when facing a complex environment and scene.
To solve the above technical problem, in a first aspect, the present invention provides a call-based communication method, including:
acquiring calling information, wherein the calling information is obtained after analysis based on a calling request;
determining a target server according to the calling information and a route forwarding strategy, wherein the route forwarding strategy comprises at least one forwarding rule, each forwarding rule is used for selecting the target server from a plurality of servers based on the calling information, and the calling information comprises information for selecting the route forwarding strategy;
and sending the calling information to the target server.
Optionally, the route forwarding policy includes a forced routing rule, where the forced routing rule is used to preferentially use a server corresponding to the forced routing information when the call information includes the forced routing information;
the determining a target server according to the calling information and the route forwarding policy includes:
judging whether the calling information contains the forced routing information or not;
and if so, determining the server corresponding to the forced routing information as the target server according to the forced routing rule.
Optionally, the route forwarding policy further includes a binding server rule, where the binding server rule is used to preferentially use a server corresponding to the binding server information when the calling information has the binding server information and the forced route information does not exist;
the determining the target server according to the calling information and the route forwarding strategy comprises:
if the calling information is determined not to have the forced routing information, judging whether the calling information contains the binding server information;
and if so, determining the server corresponding to the binding server information as the target server according to the binding server rule.
Optionally, the route forwarding policy further includes a load balancing rule, where the load balancing rule is used to select a server based on a load state in the plurality of servers when the forced route information and the binding server information do not exist in the call information;
the determining the target server according to the calling information and the route forwarding strategy comprises:
and if the calling information is determined not to have the forced routing information and the binding server information, determining a server which accords with the load balancing rule from the plurality of servers as the target server.
Optionally, the determining, from the plurality of servers, a server that meets the load balancing rule as the target server includes:
determining a server weight of each server, wherein the server weight is determined according to server parameters of each server, the server parameters at least comprise one of server hardware performance parameters, server throughput parameters, server load parameters and distance parameters, the distance parameters are used for representing topological distances from each server, the server weights are positively correlated with the server hardware performance parameters and the server throughput parameters respectively, and the server weights are negatively correlated with the server load parameters and the distance parameters respectively;
accumulating according to the weight of each server to obtain a total weight;
and randomly selecting a target weight according to the total weight, and determining the target server from the plurality of servers according to a binary search rule.
Optionally, after determining, from the plurality of servers, a server that meets the load balancing rule as the target server, the method further includes:
if it is determined that a server meeting the load balancing rule does not exist in the plurality of servers, acquiring a topological network, wherein the topological network is a network comprising all the servers;
determining the position of each server according to the topological network, and calculating the path weight according to the position and the server weight of each server;
determining a target path from a plurality of path weights through a preset path algorithm;
and sending the calling information according to the target path.
Optionally, before the acquiring the topological network, the method further includes:
judging whether the target path exists or not;
and if so, determining a target server according to the target path.
Optionally, the calling information further includes a calling content parameter, where the calling content parameter is used to characterize data that needs to execute a calling operation;
before the determining a target server according to the invocation information and the route forwarding policy, the method further comprises:
calculating the calling content parameter through a Hash algorithm to obtain a corresponding target Hash value;
judging whether cache data corresponding to the target hash value exist in a local cache according to the target hash value and a preset hash value mapping relation, wherein the preset hash value mapping relation comprises cache data corresponding to each hash value, and the cache data are calling results corresponding to the calling content parameters;
if so, responding to the calling request according to the cache data;
the determining a target server according to the calling information and the route forwarding policy includes:
and if the local cache is determined not to have cache data corresponding to the target hash value, determining a target server according to the calling information and the route forwarding strategy.
Optionally, the call information further includes interface information;
after determining whether cache data corresponding to the target hash value exists in a local cache according to the target hash value and a preset hash value mapping relationship, the method further includes:
if the local cache does not have cache data corresponding to the target hash value, determining whether a processing interface corresponding to the calling information is an RPC interface according to the interface information, and judging whether a target process corresponding to the processing interface is a local process;
if the processing interface is not an RPC interface and the target process corresponding to the processing interface is a local process, calling the processing interface according to a preset calling mode and acquiring target data based on the processing interface;
the processing interface comprises a synchronous interface and an asynchronous interface, and the preset calling mode comprises a first calling mode, a second calling mode and a third calling mode;
the first calling mode is used for calling the processing interface in a synchronous calling mode when the processing interface is a synchronous interface;
the second calling mode is used for directly calling the processing interface in an asynchronous calling mode when the processing interface is an asynchronous interface;
and the third calling mode is used for calling the processing interface through a working thread when the processing interface is a synchronous interface and is an input/output interface or a calculation-intensive interface.
Optionally, the call information further includes a transmission protocol parameter;
the method further comprises the following steps:
if a preset transmission protocol is determined to exist according to the transmission protocol parameters, the calling information is sent according to the preset transmission protocol;
if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters, sending the calling information according to the established long connection;
if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters and the long connection is not established, establishing the long connection according to a built-in protocol rule and sending the calling information according to the long connection, wherein the built-in protocol rule is used for selecting a transmission protocol according to the sequence of the priority of the preset protocol to construct the long connection;
and if it is determined that the preset transmission protocol does not exist according to the transmission protocol parameters, the long connection is not established, and it is determined that the client does not meet the establishment requirement of the long connection according to the built-in protocol rule, the calling information is sent according to the hypertext transmission protocol.
Optionally, the calling information includes a calling information transmission protocol, where the calling information transmission protocol includes at least one of a tcp protocol, an http protocol, a websocket protocol, an http2 protocol, and a quic protocol.
Optionally, the call information is binary information converted by a protobuf conversion algorithm after being compiled based on typescript language.
In a second aspect, the present invention further provides a call-based communication device, including:
the analysis unit is used for acquiring calling information, wherein the calling information is acquired after analysis based on the calling request;
a determining unit, configured to determine a target server according to the call information and a route forwarding policy, where the route forwarding policy includes at least one forwarding rule, each forwarding rule is used to select the target server from multiple servers based on the call information, and the call information includes information for selecting a route forwarding policy;
and the sending unit is used for sending the calling information to the target server.
In a third aspect, an embodiment of the present invention further provides a storage medium, where the storage medium includes a stored program, and when the program runs, a device in which the storage medium is located is controlled to execute the call-based communication method in any one of the first aspect or the second aspect.
In a fourth aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes at least one processor, and at least one memory and a bus connected to the processor; the processor and the memory complete mutual communication through the bus; the processor is configured to call program instructions in the memory to perform the call-based communication method according to any one of the first aspect or the second aspect.
By means of the technical scheme, the call-based communication method, the call-based communication device, the call-based storage medium and the call-based communication equipment provided by the invention solve the problem that the existing call-based communication mode is difficult to meet the requirement of a forwarding function in the current complex environment and scene. In the above scheme, since the route forwarding policy includes at least one forwarding rule, each forwarding rule is used to select the target server from the plurality of servers based on the calling information, and the calling information includes information for selecting the route forwarding policy, that is, when the calling information is forwarded to the target server through the route forwarding policy, it can be ensured that the target server can be determined based on the route forwarding policy when facing different service scenes, so as to implement a communication function based on remote invocation based on the target server.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart illustrating a call-based communication method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating specific steps executed by a call-based communication method according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating specific steps executed by a call-based communication method according to an embodiment of the present invention;
fig. 4 is a flowchart illustrating specific steps executed by a call-based communication method according to an embodiment of the present invention;
FIG. 5 is a block diagram illustrating components of a call-based communication device provided by an embodiment of the present invention;
fig. 6 is a block diagram illustrating components of a call-based communication device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
In order to solve the problem that the existing call-based communication method is rigid and is difficult to meet the requirement of a forwarding function when facing a complex environment and a scene, an embodiment of the present invention provides a call-based communication method, as shown in fig. 1, the method includes:
101. and acquiring calling information.
And the calling information is obtained after analysis based on the calling request.
It should be noted that, in this embodiment, the actual application scenario may be a remote invocation network formed by the client server, the forwarding server and the target server, or a remote invocation network directly formed by the client server and the target server, and a specific remote invocation network belonging to the above-mentioned scenario may be determined based on the actual situation. Based on the difference of the execution main body of the method described in this embodiment, there is a certain difference in the specific implementation manner of this step.
On one hand, when the method of this embodiment is executed as the client server in the remote call network, the manner of obtaining the call information in this step may be:
first, it is detected whether there is a call request. The call request may be understood as a request for triggering a remote call function. Specifically, the process of detecting whether there is a call request includes, but is not limited to, the following methods: whether the request is a call request is determined through the call characteristics in the request, the specific judgment mode can be determined through whether the call is an RPC interface and/or whether a local process is a process required by a remote call function, and if the call is made to the RPC interface and/or the required process is not a local process, the request is determined to be the call request. And then, carrying out analysis operation based on the calling request to obtain corresponding calling information. The call information may be understood as indication information for determining a remote call service or a remote call function, which may contain data or functions that need to be called specifically.
On the other hand, when the method of the present embodiment is executed as the forwarding server in the remote call network, the manner of obtaining the call information in this step may be by receiving the call information parsed by the client server from the client server.
It should be noted that, when this step is executed specifically, the execution manner may be determined based on the specific type of the execution subject.
102. And determining a target server according to the calling information and the route forwarding strategy.
The route forwarding strategy comprises at least one forwarding rule, each forwarding rule is used for selecting the target server from a plurality of servers based on the calling information, and the calling information comprises information for selecting the route forwarding strategy.
After parsing out the invocation information, the server required for subsequently executing the invocation function, i.e., the target server, may be determined based on the route forwarding policy.
The route forwarding strategy comprises one or more forwarding rules, and each forwarding rule can be used for determining a selection mode of a target server. In the communication process, different service scenarios need to be faced, and the execution requirements of remote invocation required by different service scenarios are different, for example, whether the forwarding process is directly connected with the target server, the number of servers during forwarding, the delay condition during remote invocation, and the like. Therefore, in the present embodiment, the target server executing the invocation information needs to be determined based on the route forwarding policy.
In a specific application, the call information may be an RPC call packet, and the RPC call packet may include: information such as RPC command codes, communication protocols, application data, state data, RPC configuration options and the like, wherein the RPC command codes contain specific service calling information; the communication protocol specifies the transmission mode of the data packet on the network link; the application data is application specific data which comprises data of which the coding information is encrypted; RPC configuration options-containing all options required to use RPC.
Since the route forwarding policy includes at least one forwarding rule, after the invocation information is parsed, it can be determined, based on the invocation information and the forwarding rule, which server performs the remote invocation function corresponding to the invocation information is, that is, the target server.
It should be noted that, in practical application of the method described in this embodiment, the specific manner and the number of the specific forwarding rules included in the route forwarding policy may be selected and set based on the actual remote invoking process of the user, which is not limited herein, and may be selected according to the actual requirements of the user.
103. And sending the calling information to the target server.
After the target server is determined, the server when the remote calling function corresponding to the subsequent calling information is executed is also determined, and the calling information can be sent to the target server, so that the target server can remotely call some data or service functions based on the calling information.
Based on the foregoing step 101, since the method of executing the present embodiment may be a client or a forwarding server, after the target server is determined in this step, a remote invocation network for executing the remote invocation function is actually determined. When the execution subject of the above steps is the client, it may be determined that the network formed in this embodiment is both the client and the target server; when the execution main body of the above steps is the forwarding server, it means that after the calling information is obtained by analyzing based on the calling request, the forwarding server obtains the calling information and executes the subsequent determination process of the target server, and the remote calling network is formed by the client, the forwarding server and the target server.
In the above scheme, since the route forwarding policy includes at least one forwarding rule, each forwarding rule is used to select the target server from the plurality of servers based on the calling information, and the calling information includes information for selecting the route forwarding policy, that is, when the calling information is forwarded to the target server through the route forwarding policy, it can be ensured that the target server can be determined based on the route forwarding policy when facing different service scenes, so as to implement a communication function based on remote invocation based on the target server.
In some embodiments, since a rule for forcibly selecting a certain server as a target server may be set in the route forwarding policy, that is, a route-related condition for executing the remote invocation function may have been set in advance in the remote invocation process, the route forwarding policy in the foregoing step may include a forced routing rule, and the forced routing rule may be understood as that a server corresponding to the forced routing information is preferentially used when the forced routing information exists in the invocation information;
based on this, the determining the target server according to the invocation information and the route forwarding policy in step 102 may include, when executed:
judging whether the calling information contains the forced routing information or not;
and if so, determining the server corresponding to the forced routing information as the target server according to the forced routing rule.
In this real-time example, the forced routing may be understood as a server that is preset and adapted to the remote call function when forwarding the call information. Specifically, it is determined whether the call information includes the forced routing information or not by determining a server identifier corresponding to the forced routing in the call information, that is, determining whether a server identifier corresponding to the forced routing exists or not, and when the server identifier corresponding to the forced routing exists, it is determined that the remote call function corresponding to the call information has a set special server, so that the server corresponding to the forced routing information can be determined as the target server.
By judging whether the calling information contains the forced routing information or not and determining the server corresponding to the forced routing information as the target server according to the forced routing rule when the calling information is determined to contain the forced routing information, the direct determination based on the forced routing rule in the process of determining the target server can be ensured.
In some embodiments, the route forwarding policy in the foregoing embodiments may further include a binding server rule, where the binding server rule may be understood as that when the calling information has binding server information and the forced route information does not exist, a server corresponding to the binding server information is preferentially used. That is, when there is no mandatory routing information in the invocation information, it needs to be determined whether the invocation information needs to be sent according to the rule of the binding server.
Based on this, in the foregoing embodiment 102, determining the target server according to the invocation information and the route forwarding policy, and when executing, may include:
if the calling information is determined not to have the forced routing information, judging whether the calling information contains the binding server information;
and if so, determining the server corresponding to the binding server information as the target server according to the binding server rule. It should be noted that the binding server information may be obtained from the summary data in the call information, and of course, the binding server information may also be added to other data besides the summary data in the process of generating the call information, and the specific location and setting manner of the binding server information are not limited here and may be determined according to the actual call information generation process.
In practical application, some remote invocation functions have strict requirements on servers, and any server cannot be realized, so that when it is determined that no mandatory routing information exists, it is further required to determine whether a binding server is set in advance. In addition, the number of the servers corresponding to the binding server information may be one or more, and when there are a plurality of servers, one of the servers may be selected optionally or selected as a target server according to a preset rule.
The method is executed under the condition that whether forced routing is adopted for calling information forwarding is determined in the executing process, so that when the calling information does not have the forced routing information and contains binding server information, the target server can be determined according to the binding server rule, and therefore when some special scenes and requirements exist, the target server is determined directly according to the binding server information, the remote calling function is realized according to the bound server, and the condition that the selected server is determined to be possibly not in accordance with some special requirements of remote calling through other modes is avoided.
In some embodiments, since the calling information may not have forced routing information nor binding server information, at this time, it needs to consider selecting a target server according to a certain load condition, so the routing forwarding policy in the foregoing embodiment further includes a load balancing rule, and the load balancing rule may be understood as selecting a server based on a load state in a plurality of servers when the calling information does not have the forced routing information and the binding server information;
based on this, in the foregoing embodiment 102, determining the target server according to the invocation information and the route forwarding policy, where the execution may specifically be:
and if the calling information is determined not to have the forced routing information and the binding server information, determining a server which accords with the load balancing rule from the plurality of servers as the target server.
Since the target server in this embodiment is determined based on the load balancing rule, a most suitable server can be selected from the plurality of servers according to the load condition as the server for executing the remote call function corresponding to the subsequent call information. Therefore, the problem that the remote calling function is influenced by using a server with a large load as a target server in the calling-based communication process is solved on the whole by determining the server with a proper load as the target server under the condition that a plurality of servers can execute the remote calling function and a forced routing and binding server are not arranged.
In some embodiments, the step of the foregoing embodiment of determining, from a plurality of servers, a server meeting the load balancing rule as the target server may be as shown in fig. 2 when executed specifically, where the step includes:
201. a server weight for each of the servers is determined.
The server weight is determined according to server parameters of each server, the server parameters at least comprise one of server hardware performance parameters, server throughput parameters, server load parameters and distance parameters, the distance parameters are used for representing topological distances between the server weight and each server, the server weight is positively correlated with the server hardware performance parameters and the server throughput parameters respectively, and the server weight is negatively correlated with the server load parameters and the server throughput parameters respectively.
It should be noted that, in practical application, in the process of determining the weight of the server, the performance parameters may be calculated through the processor performance, the memory performance, the network card performance, and the like of the server, and the better the performance, the higher the weight is; the server throughput parameter is determined based on the current real-time data processing condition of the server, and the higher the throughput, the higher the weight; the server load parameters can be determined based on the current real-time load condition of the server, and the weight is lower when the load is larger; the distance parameter is determined according to the topological distance between the server and the server of the executing subject currently executing the method of the embodiment, and the larger the distance, the lower the weight.
202. And accumulating according to the weight of each server to obtain the total weight.
After the server weights in each server are determined, an accumulation calculation may be performed to obtain the sum of the weights, i.e., the total weight.
203. And randomly selecting a target weight according to the total weight, and determining the target server from the plurality of servers according to a binary search rule.
The basic idea of binary search is to divide n elements into two parts which are approximately equal, compare a [ n/2] with x, if x is a [ n/2], find x, and terminate the algorithm; if x < a [ n/2], then only x continues to be searched in the left half of array a, if x > a [ n/2], then only x is searched in the right half of array a. The additional time complexity is the number of cycles of the above process. For example, there are n elements in total, and the above process is performed sequentially so that n, n/2, n/4,. . . . n/2^ k (the remaining number of the next operation elements), where k is the number of cycles, and since n/2^ k is rounded > 1, i.e. let n/2^ k be 1, k may be log2n (base 2, logarithm of n), the time complexity may be expressed as O (h) O (log2 n).
Thus, since the randomly selected target weight is between 1 and the total weight, the binary search rule must match a server in the total weight. Because the proportion of each server is consistent with the proportion of the weight, the probability of each server being selected is the same as the proportion of the weight, that is, the probability of the server with larger weight being selected is higher, and the size of the weight can reflect the current forwarding efficiency (based on performance, throughput, load and distance) of the server, that is, the server with higher forwarding efficiency can be selected based on the method, so that the method can select a more suitable server as a target server, and therefore, the method can be executed based on the server with better overall performance in the implementation process of the remote call function, and the efficiency of the remote call function can be improved.
In addition, after the target server is determined based on the weight based on the method, the target server and the calling information can be bound, and corresponding bound server information is generated, that is, when the calling function corresponding to the calling information is executed again next time, the target server can be directly determined to serve as a server for subsequently executing the remote calling function when the calling information is detected to include the bound server information based on the method of the foregoing embodiment, so that the target server is directly utilized for forwarding when a subsequent communication process requiring remote calling again is performed, and the forwarding efficiency is improved.
In the above process, no matter in the process of selecting the target server by the forced routing rule, the binding server rule or the load balancing rule, there may exist a plurality of servers meeting the condition under a certain rule, for example, there may be multiple eligible servers under the load balancing rules, and when a target server is determined from the multiple eligible servers, the selection can be carried out based on the actual service scene corresponding to the calling information, the specific mode can be determined based on the scene information in the calling information, wherein, since the scene information is used as the concrete data embodying the service scene, after the service scene is determined based on the scene information, the forwarding requirement corresponding to the current service scenario can be determined through the corresponding relationship between the service scenario and the corresponding forwarding requirement included in the preset selection rule. The forwarding requirement may be understood as a screening condition or a sorting condition for selecting a most suitable target server from the plurality of servers, so that it may be determined which server of the plurality of servers is the server that best meets the forwarding requirement as the target server based on the forwarding requirement.
For example, the service scenario may include a timeout sensitive scenario, a delay sensitive scenario, a high frequency communication scenario, and a large data volume scenario; meanwhile, the forwarding requirements corresponding to the forwarding requirements are respectively as follows: in a scene sensitive to overtime, the forwarding requirement is that the time required for forwarding is lower than the overtime time and the request priority is higher than a certain level; in a delay sensitive scene, the forwarding requirement is that the priority of the forwarding request is higher than a certain level; in a high-frequency communication scene, the forwarding requirement is that long connection communication is preferentially used; in a scenario with a large data volume, the forwarding requirement is the forwarding hop count as small as possible.
In this embodiment, since a specific forwarding requirement can be determined based on a service scenario and a preset selection rule, and the forwarding requirement directly reflects a requirement for a forwarding condition of a forwarding node in different scenarios, the first server can be determined based on the forwarding requirement through the above steps, so that a function of selecting a corresponding forwarding node based on actual forwarding requirements in different scenarios is realized, forwarding requirements in different scenarios can be met, and applicability of the method in the embodiment of the present invention is improved.
In some embodiments, since all the processes of determining the target server through the forced routing rule, the binding server rule, or the load balancing rule are the case that the server currently executing the method of this embodiment is directly connected to the target server, that is, the method of the foregoing embodiment may directly send the call information to the target server after determining the target server, and the target server may directly respond to the remote call function corresponding to the call information after receiving the call information, in an actual application, there may also be a case that the server currently executing the method is not directly connected to the target server, and at least one relay server may be needed to forward the remote call network, that is, the formed remote call network may be: client server-forwarding server-transit server-target server. In this case, since the number of transit servers is not determined, it is important to select a relatively suitable path to the destination server.
Based on this, after the determining, from the plurality of servers, the server that meets the load balancing rule as the target server in the foregoing steps is executed, the method further includes:
the method may also be as shown in fig. 3, which includes:
301. and if the server meeting the load balancing rule does not exist in the plurality of servers, acquiring the topological network.
Wherein, the topological network is a network containing all servers. Since the topological network can embody the topological connection relationship between all the servers executing the method of the present embodiment and the target server, the network connection condition between the server executing the method of the present embodiment and the target server can be determined more intuitively after the topological network is acquired.
302. And determining the position of each server according to the topological network, and calculating the path weight according to the position and the server weight of each server.
The manner of determining the weight of each path in this step may be to determine the weight in each server based on the number of forwarding times in the distance server, and to determine the path weight of each path based on the weight in each server on each path.
303. And determining a target path from the plurality of path weights through a preset path algorithm.
After the path weight of each path is determined, a plurality of forwarding lines corresponding to the paths from the client to the target server are actually determined, and each path weight is a score of each forwarding line.
Of course, the selection of the preset path algorithm in this step corresponds to the calculation method of the path weight in the previous step, and when the server weight in each server in the weight calculation method adopted in the previous step is determined according to the method in the previous embodiment, the method of selecting the target path in this step may be such that the larger the path weight is, the more suitable the target path is. It should be noted that the two manners are only exemplary, and the specific selection manner may be selected according to the actual setting requirement of the user, which is not limited herein.
304. And sending the calling information according to the target path.
After the target path is determined, a forwarding route most suitable for transferring the call information is actually determined, and therefore, the call information can be directly transmitted based on the target path.
In the method, the path weight of each corresponding path can be calculated based on the position in each server in the topological network and the server weight, and the target path is determined by the path weight and the preset path algorithm, so that the most suitable path can be selected from the topological network among a plurality of nodes in a manner of forwarding a line, the forwarding efficiency of calling information in the subsequent forwarding process is ensured, and the efficiency of the called communication method is ensured as a whole.
It should be noted that, after the target path is determined by the server currently executing the method, the target path may be stored in the local server, and after the call information is obtained again, when it is determined that there is no target server directly connected to the current server based on the method, that is, when it is determined that no suitable server is determined as the target server based on the three rules in the route forwarding policy, it may be detected whether there is a target path in the local server, and if there is a target path corresponding to the call information, the call information may be directly forwarded based on the target path.
Based on this, in some embodiments, before the acquiring the topological network in the foregoing embodiments, the method may further include:
judging whether the target path exists or not;
and if so, determining a target server according to the target path.
In this embodiment, when it is determined that the target server cannot be determined based on the forced routing rule, the binding server rule, and the load balancing rule, it is described that there is no target server directly connected to the server currently executing the method of this embodiment, and at this time, forwarding is required according to a path, but based on the foregoing description, in a process of forwarding the call information to the target server according to the path, a most suitable path, that is, a target path, may have been determined in a previous process of implementing the remote call function. Therefore, in this embodiment, before the topology path is obtained to determine the appropriate path, the target path may be detected locally by the server, and when it is determined that the target path corresponding to the invocation information exists, it is described that the remote invocation has been performed before, and an appropriate forwarding path, that is, the target path, has been selected, and then the remote invocation process at this time may directly utilize the target path. This saves time for determining the target path again based on the topology network, and thus can improve the execution efficiency in call-based communication as a whole.
It should be noted that, in some embodiments, when the server serves as a transit server in the remote call network in the foregoing example, after the server acquires the call information, the determination of the target server may also be performed based on the route forwarding policy according to the method of the foregoing embodiment. However, since the forwarding server sending the call information is actually located at a different position and a different distance from the relay server in the topology network, the forwarding server cannot determine that a suitable server may be able to determine the target server on the relay server based on the load balancing rule, for example, the forwarding server is connected to the target server through one relay server, so that the relay server does not determine the target server directly connected to the forwarding server based on the rule, but the relay server is actually directly connected to the target server, and therefore, the relay server can determine the target server and send the call information according to the load balancing rule. In this case, it is known from practical applications that the forwarding server in the foregoing steps has already determined the target path, and the target path is actually determined based on the topology network, that is, the target server in the target path is consistent with the target server determined by the forwarding server based on the foregoing method. Therefore, in the real-time application, after the transfer server receives the call information, the target server can be determined according to two ways:
in one aspect, the target server may be determined by the route forwarding policy based on the method of the foregoing embodiment, that is, the target server is determined by the route forwarding policy and the invocation information, and the invocation information is sent to the target server. This process is similar to the process from 101 to 104 in the previous embodiment, and is not described herein. Based on the method of the step, it can be determined that each server in the network can determine the target server and forward the call information according to the method after obtaining the call information, so that the servers in the whole network can be used as control points of the forwarding process, especially when the network is unstable, the forwarding process can be adjusted in real time, and then the realization of the remote call function is ensured.
On the other hand, the target server can be determined based on the target path in the forwarding server, namely the target path is obtained; and determining a target server in the topological network according to the target path. The method for obtaining the target path may be obtained by an upstream server, that is, a forwarding server, in a request manner, and after receiving a response to obtain the target path, the corresponding target server is determined in the topology network according to the target path. In the step, the target server can be determined directly based on the target path, so that the time for determining the target server by the server is saved, and the efficiency of the communication process based on calling can be improved.
In some embodiments, since any server may be a server conforming to the remotely called function, when forwarding is performed based on the calling information, it may also be determined first locally at the server that obtained the calling information whether the current server conforms to the remotely called function. Therefore, the calling information may further include a calling content parameter, where the calling content parameter is used to represent data that needs to execute a calling operation;
before determining the target server according to the invocation information and the route forwarding policy in the foregoing embodiment 102, the method further includes:
401. and calculating the calling content parameter through a hash algorithm to obtain a corresponding target hash value.
402. And judging whether cache data corresponding to the target hash value exist in a local cache or not according to the target hash value and a preset hash value mapping relation.
The preset hash value mapping relation comprises cache data corresponding to each hash value, and the cache data are calling results corresponding to the calling content parameters.
403. And if so, responding to the calling request according to the cache data.
On the other hand, when it is determined that there is no data meeting the condition in the local server, that is, the server currently executing the method is not the target server, or the current server is the target server but the cache data corresponding to the invocation request is deleted, or the current server has not processed a similar invocation request, based on this, the step of determining the target server according to the invocation information and the route forwarding policy may be executed as follows:
404. and if the routing forwarding strategy does not exist, determining a target server according to the calling information and the routing forwarding strategy.
Based on the method of the embodiment, because the hash algorithm can enable the data to obtain the unique hash value after being processed by the hash algorithm, the hash value based on the content parameter can be compared with the data in the local cache after any server obtains the calling information, so that whether the data in the local cache meets the requirement of the remote calling function or not, namely corresponds to the calling information, when the target server is determined, the current server can be directly determined as the target server, the process of determining the target server based on the route forwarding strategy is saved, and the problem that the calling communication efficiency is influenced by the execution of other servers under the condition that the local data meets the remote calling function can be avoided.
In some embodiments, since the local cache only includes part of data obtained by the current server, if there is no data corresponding to the target hash value, it does not mean that the current server is not the target server, and therefore, when determining the processing mode of the call request, it is necessary to perform a determination by combining with other information, and based on this, the call information further includes interface information;
in the foregoing steps, after determining whether cache data corresponding to the target hash value exists in a local cache according to the target hash value and a preset hash value mapping relationship, the method further includes:
if the local cache does not have cache data corresponding to the target hash value, determining whether a processing interface corresponding to the calling information is an RPC interface according to the interface information, and judging whether a target process corresponding to the processing interface is a local process;
if the processing interface is not an RPC interface and the target process corresponding to the processing interface is a local process, calling the processing interface according to a preset calling mode and acquiring target data based on the processing interface;
the processing interface comprises a synchronous interface and an asynchronous interface, and the preset calling mode comprises a first calling mode, a second calling mode and a third calling mode;
the first calling mode is used for calling the processing interface in a synchronous calling mode when the processing interface is a synchronous interface;
the second calling mode is used for directly calling the processing interface in an asynchronous calling mode when the processing interface is an asynchronous interface;
and the third calling mode is used for calling the processing interface through a working thread when the processing interface is a synchronous interface and is an input/output interface or a calculation-intensive interface.
Because the types of the processing interfaces are different, the modes in the calling process are different, and the calling modes corresponding to different processing interfaces are selected to be executed in the steps, so that the realization of the calling function is ensured, and the integral failure of the calling-based communication method caused by calling failure is avoided.
In order to ensure the stability and efficiency of sending the calling information, the calling information also comprises a transmission protocol parameter; based on this, when the foregoing embodiments are executed, the following aspects may be further implemented when the invocation information is sent, where the following aspects include:
on one hand, if the preset transmission protocol is determined to exist according to the transmission protocol parameters, the calling information is sent according to the preset transmission protocol, so that the right preset transmission protocol can be directly sent when being detected, the protocol for transmitting the calling information can be rapidly determined on the premise of ensuring correct receiving of the target server, and the transmission efficiency is integrally improved.
On the other hand, if the preset transmission protocol does not exist according to the transmission protocol parameters, the calling information is sent according to the established long connection, the calling information is sent through the established long connection, the calling information can be sent correctly, meanwhile, the existing communication channel can be used for transmission, and time consumption when the transmission channel is established again is avoided.
On the other hand, if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters and it is determined that the long connection is not established, establishing the long connection according to a built-in protocol rule and sending the calling information according to the long connection, wherein the built-in protocol rule is used for selecting a transmission protocol according to the sequence of the preset protocol priority to establish the long connection; in this embodiment, the order of the preset protocol priority is, from high to low, a quic protocol, a tcp protocol, a websocket protocol, and an http2 protocol. Therefore, under the condition that the long connection does not exist, the proper protocol is selected according to the priority through the protocols to establish the long connection, so that the dependence on the long connection in the transmission process can be ensured, and the process of independently establishing the connection during each communication is avoided.
On the other hand, if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters, the long connection is not established, and it is determined that the client does not meet the establishment requirement of the long connection according to the built-in protocol rule, the calling information is sent according to a hypertext transfer protocol, namely an http protocol. When the requirement of long connection establishment is determined not to be met, the information is sent through the hypertext transfer protocol, and the information sending function can be ensured to be called when long connection communication cannot be carried out between the forwarding node and the client in the sending process, so that the method disclosed by the embodiment has better adaptability.
In some embodiments, the calling information includes a calling information transmission protocol, and the calling information transmission protocol includes at least one of a tcp protocol, an http protocol, a websocket protocol, an http2 protocol, and a quic protocol, so that by supporting multiple transmission protocols, the calling-based communication method described in this embodiment can be ensured to be capable of adapting to more communication modes, and the adaptation range is improved.
It should be noted that, in a specific application of the method according to any of the above embodiments, the call information may be an RPC call packet, and the RPC call packet may include: information such as RPC command codes, communication protocols, application data, state data, RPC configuration options and the like, wherein the RPC command codes contain specific service calling information; the communication protocol specifies the transmission mode of the data packet on the network link; the application data is application specific data which comprises data of which the coding information is encrypted; RPC configuration options-containing all options required to use RPC.
Wherein, RPC command code includes: server information, service type, and service interface, the relevant information of the target server in the foregoing embodiments may be added to the RPC command code;
the communication protocol comprises the following steps: the method includes the steps of specifying a transmission mode of a data packet on a network link, and supporting switching transmission of the data packet among multiple protocols, wherein the supported protocols specifically include a tcp protocol, an http protocol, a websocket protocol, an http2 protocol, and a quic protocol, and the transmission protocol parameters in the foregoing embodiment may also be determined in the communication protocol.
The status data includes: the codes used for identifying the uniqueness of the request, namely RPC id, cookie information and session abstract, the session abstract provides necessary information for request processing quickly, and the io frequency, transmission state and other system states in the routing process are reduced.
The RPC configuration options include: forced routing information; caching options, request timeout time limit, forwarding times threshold, network protocol setting, built-in protocol priority and other framework or service options.
In some embodiments, the call information is binary information that is converted by a protobuf conversion algorithm after being compiled based on typescript language.
Specifically, the step may be performed in the following manner in the process:
first, the structure of the RPC interface and the call information in the incoming call information is described using typescript. The RPC interface is described by using function, and the relevant information of the RPC request response and the relevant information of the RPC control option are described by using interface.
Then, converting the typescript code into a protobuf code by using a conversion algorithm, and directly performing serialization and deserialization by using protobuf during data transmission.
And finally, packaging and issuing typescript into each program frame, wherein each program frame can carry out typed RPC calling through the typescript package.
By compiling the call information using typescript, the information related to the protocol in the call information can be highly typed. The method supports the mutual conversion of the protobuf and the typescript, fully utilizes the advantages of the expandability of the protobuf type and the typescript protocol typing, can enable the method to be compatible with more program frames, and has better adaptability.
In addition, in order to ensure timeliness of forwarding the calling information in the execution process, whether each calling information is overtime or not can be determined based on a preset request pool in the process of forwarding the calling information, and the calling information is fed back to a sender of the calling information in the case of overtime. The specific implementation manner may be:
receiving an RPC response packet (namely feedback information), and finding a corresponding request from a request pool according to an RPC id (a preset identifier in the calling information);
removing the request from the request pool, recording cache and executing some request post-processing operations;
according to the RPC request information, responding an RPC response packet to a requester on the upper layer;
if the RPC request is overtime, the overtime request will automatically pop out of the request pool and answer the overtime to the upper layer requester (i.e. the sender of the call message).
Further, as an implementation of the method shown in fig. 1 and various embodiments related thereto, an embodiment of the present invention further provides a call-based communication device, which is used for implementing the method shown in fig. 1 and various embodiments described above. The embodiment of the apparatus corresponds to the embodiment of the method, and for convenience of reading, details in the embodiment of the apparatus are not repeated one by one, but it should be clear that the apparatus in the embodiment can correspondingly implement all the contents in the embodiment of the method. As shown in fig. 5, the apparatus includes:
the parsing unit 51 may be configured to obtain call information, where the call information is obtained by parsing based on a call request;
a determining unit 52, configured to determine a target server according to the calling information obtained by the analyzing unit 51 and a route forwarding policy, where the route forwarding policy includes at least one forwarding rule, each forwarding rule may be used to select the target server from multiple servers based on the calling information, and the calling information includes information of selecting a route forwarding policy;
the sending unit 55 may be configured to send the invocation information to the target server determined by the determining unit 52.
With the above technical solutions in mind, embodiments of the present invention provide a call-based communication method, device, storage medium, and apparatus, which are currently facing complex environments and scenes
The invention solves the problem that the existing communication mode based on calling is difficult to meet the requirement of a forwarding function, and realizes the communication method based on calling with the forwarding function by acquiring calling information, wherein the calling information is obtained after being analyzed based on a calling request, then determining a target server according to the calling information and a route forwarding strategy, and finally sending the calling information to the target server. In the above scheme, since the route forwarding policy includes at least one forwarding rule, each forwarding rule is used to select the target server from the plurality of servers based on the calling information, and the calling information includes information for selecting the route forwarding policy, that is, when the calling information is forwarded to the target server through the route forwarding policy, it can be ensured that the target server can be determined based on the route forwarding policy when facing different service scenes, so as to implement a communication function based on remote invocation based on the target server.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the call-based communication method is automatically realized by adjusting kernel parameters so as to solve the problem that the existing call-based communication mode is difficult to meet the requirement of a forwarding function.
An embodiment of the present invention provides a storage medium on which a program is stored, the program implementing the call-based communication method when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the calling-based communication method is executed when the program runs.
An embodiment of the present invention provides an apparatus 60, as shown in fig. 6, the apparatus includes at least one processor 601, at least one memory 602 connected to the processor, and a bus 603; the processor 601 and the memory 602 complete communication with each other through the bus 603; processor 601 is used to call program instructions in memory to perform the call-based communication methods described above.
The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device: acquiring calling information, wherein the calling information is obtained after analysis based on a calling request; determining a target server according to the calling information and a route forwarding strategy, wherein the route forwarding strategy comprises at least one forwarding rule, each forwarding rule is used for selecting the target server from a plurality of servers based on the calling information, and the calling information comprises information for selecting the route forwarding strategy; and sending the calling information to the target server.
Further, the route forwarding policy includes a forced routing rule, and the forced routing rule is used to preferentially use a server corresponding to the forced routing information when the call information includes the forced routing information;
the determining a target server according to the calling information and the route forwarding policy includes:
judging whether the calling information contains the forced routing information or not;
and if so, determining the server corresponding to the forced routing information as the target server according to the forced routing rule.
Further, the route forwarding policy further includes a binding server rule, where the binding server rule is used to preferentially use a server corresponding to the binding server information when the calling information has the binding server information and the mandatory route information does not exist;
the determining the target server according to the calling information and the route forwarding strategy comprises:
if the calling information is determined not to have the forced routing information, judging whether the calling information contains the binding server information;
and if so, determining the server corresponding to the binding server information as the target server according to the binding server rule.
Further, the route forwarding policy further includes a load balancing rule, where the load balancing rule is used to select a server based on a load state in the plurality of servers when the forced route information and the binding server information do not exist in the calling information;
the determining the target server according to the calling information and the route forwarding strategy comprises:
and if the calling information is determined not to have the forced routing information and the binding server information, determining a server which accords with the load balancing rule from the plurality of servers as the target server.
Further, the determining, from the plurality of servers, a server that meets the load balancing rule as the target server includes:
determining a server weight of each server, wherein the server weight is determined according to server parameters of each server, the server parameters at least comprise one of server hardware performance parameters, server throughput parameters, server load parameters and distance parameters, the distance parameters are used for representing topological distances from each server, the server weights are positively correlated with the server hardware performance parameters and the server throughput parameters respectively, and the server weights are negatively correlated with the server load parameters and the distance parameters respectively;
accumulating according to the weight of each server to obtain a total weight;
and randomly selecting a target weight according to the total weight, and determining the target server from the plurality of servers according to a binary search rule.
Further, after determining, from the plurality of servers, a server that meets the load balancing rule as the target server, the method further includes:
if it is determined that a server meeting the load balancing rule does not exist in the plurality of servers, acquiring a topological network, wherein the topological network is a network comprising all the servers;
determining the position of each server according to the topological network, and calculating the path weight according to the position and the server weight of each server;
determining a target path from a plurality of path weights through a preset path algorithm;
and sending the calling information according to the target path.
Further, before the acquiring the topological network, the method further includes:
judging whether the target path exists or not;
and if so, determining a target server according to the target path.
Furthermore, the calling information also comprises calling content parameters, and the calling content parameters are used for representing data needing to execute calling operation;
before the determining a target server according to the invocation information and the route forwarding policy, the method further comprises:
calculating the calling content parameter through a Hash algorithm to obtain a corresponding target Hash value;
judging whether cache data corresponding to the target hash value exist in a local cache according to the target hash value and a preset hash value mapping relation, wherein the preset hash value mapping relation comprises cache data corresponding to each hash value, and the cache data are calling results corresponding to the calling content parameters;
if so, responding to the calling request according to the cache data;
the determining a target server according to the calling information and the route forwarding policy includes:
and if the local cache is determined not to have cache data corresponding to the target hash value, determining a target server according to the calling information and the route forwarding strategy.
Further, the calling information also comprises interface information;
after determining whether cache data corresponding to the target hash value exists in a local cache according to the target hash value and a preset hash value mapping relationship, the method further includes:
if the local cache does not have cache data corresponding to the target hash value, determining whether a processing interface corresponding to the calling information is an RPC interface according to the interface information, and judging whether a target process corresponding to the processing interface is a local process;
if the processing interface is not an RPC interface and the target process corresponding to the processing interface is a local process, calling the processing interface according to a preset calling mode and acquiring target data based on the processing interface;
the processing interface comprises a synchronous interface and an asynchronous interface, and the preset calling mode comprises a first calling mode, a second calling mode and a third calling mode;
the first calling mode is used for calling the processing interface in a synchronous calling mode when the processing interface is a synchronous interface;
the second calling mode is used for directly calling the processing interface in an asynchronous calling mode when the processing interface is an asynchronous interface;
and the third calling mode is used for calling the processing interface through a working thread when the processing interface is a synchronous interface and is an input/output interface or a calculation-intensive interface.
Further, the calling information further includes a transmission protocol parameter;
the method further comprises the following steps:
if a preset transmission protocol is determined to exist according to the transmission protocol parameters, the calling information is sent according to the preset transmission protocol;
if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters, sending the calling information according to the established long connection;
if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters and the long connection is not established, establishing the long connection according to a built-in protocol rule and sending the calling information according to the long connection, wherein the built-in protocol rule is used for selecting a transmission protocol according to the sequence of the priority of the preset protocol to construct the long connection;
and if it is determined that the preset transmission protocol does not exist according to the transmission protocol parameters, the long connection is not established, and it is determined that the client does not meet the establishment requirement of the long connection according to the built-in protocol rule, the calling information is sent according to the hypertext transmission protocol.
Further, the calling information comprises a calling information transmission protocol, and the calling information transmission protocol comprises at least one of a tcp protocol, an http protocol, a websocket protocol, an http2 protocol, and a quic protocol.
Furthermore, the calling information is binary information which is converted by a protobuf conversion algorithm after being compiled based on typescript language.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a device includes one or more processors (CPUs), memory, and a bus. The device may also include input/output interfaces, network interfaces, and the like.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that 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 the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (14)

1. A call-based communication method, comprising:
acquiring calling information, wherein the calling information is obtained after analysis based on a calling request;
determining a target server according to the calling information and a route forwarding strategy, wherein the route forwarding strategy comprises at least one forwarding rule, each forwarding rule is used for selecting the target server from a plurality of servers based on the calling information, and the calling information comprises information for selecting the route forwarding strategy;
and sending the calling information to the target server.
2. The method according to claim 1, wherein the route forwarding policy includes a forced routing rule, and the forced routing rule is configured to preferentially use a server corresponding to the forced routing information when the forced routing information exists in the invocation information;
the determining a target server according to the calling information and the route forwarding policy includes:
judging whether the calling information contains the forced routing information or not;
and if so, determining the server corresponding to the forced routing information as the target server according to the forced routing rule.
3. The method according to claim 2, wherein the route forwarding policy further includes a binding server rule, and the binding server rule is configured to preferentially use a server corresponding to the binding server information when the calling information has the binding server information and the mandatory routing information does not exist;
the determining the target server according to the calling information and the route forwarding strategy comprises:
if the calling information is determined not to have the forced routing information, judging whether the calling information contains the binding server information;
and if so, determining the server corresponding to the binding server information as the target server according to the binding server rule.
4. The method of claim 3, wherein the route forwarding policy further comprises a load balancing rule, and the load balancing rule is configured to select a server based on a load status of the plurality of servers when the forced routing information and the binding server information do not exist in the invocation information;
the determining the target server according to the calling information and the route forwarding strategy comprises:
and if the calling information is determined not to have the forced routing information and the binding server information, determining a server which accords with the load balancing rule from the plurality of servers as the target server.
5. The method of claim 4, wherein the determining a server from the plurality of servers that meets the load balancing rule as the target server comprises:
determining a server weight of each server, wherein the server weight is determined according to server parameters of each server, the server parameters at least comprise one of server hardware performance parameters, server throughput parameters, server load parameters and distance parameters, the distance parameters are used for representing topological distances from each server, the server weights are positively correlated with the server hardware performance parameters and the server throughput parameters respectively, and the server weights are negatively correlated with the server load parameters and the distance parameters respectively;
accumulating according to the weight of each server to obtain a total weight;
and randomly selecting a target weight according to the total weight, and determining the target server from the plurality of servers according to a binary search rule.
6. The method of claim 4, further comprising:
if it is determined that a server meeting the load balancing rule does not exist in the plurality of servers, acquiring a topological network, wherein the topological network is a network comprising all the servers;
determining the position of each server according to the topological network, and calculating the path weight according to the position and the server weight of each server;
determining a target path from a plurality of path weights through a preset path algorithm;
and sending the calling information according to the target path.
7. The method of claim 6, wherein prior to said obtaining a topological network, the method further comprises:
judging whether the target path exists or not;
and if so, determining a target server according to the target path.
8. The method according to any one of claims 1-7, wherein the calling information further includes a calling content parameter, and the calling content parameter is used for characterizing data required to execute a calling operation;
before the determining a target server according to the invocation information and the route forwarding policy, the method further comprises:
calculating the calling content parameter through a Hash algorithm to obtain a corresponding target Hash value;
judging whether cache data corresponding to the target hash value exist in a local cache according to the target hash value and a preset hash value mapping relation, wherein the preset hash value mapping relation comprises cache data corresponding to each hash value, and the cache data are calling results corresponding to the calling content parameters;
and if so, responding to the calling request according to the cache data.
9. The method of claim 8, wherein the call information further includes interface information;
after determining whether cache data corresponding to the target hash value exists in a local cache according to the target hash value and a preset hash value mapping relationship, the method further includes:
if the local cache does not have cache data corresponding to the target hash value, determining whether a processing interface corresponding to the calling information is an RPC interface according to the interface information, and judging whether a target process corresponding to the processing interface is a local process;
and if the processing interface is not an RPC interface and the target process corresponding to the processing interface is a local process, calling the processing interface according to a preset calling mode, and acquiring target data based on the processing interface.
10. The method of claim 1, wherein the invocation information further includes transport protocol parameters;
the method further comprises the following steps:
if a preset transmission protocol is determined to exist according to the transmission protocol parameters, the calling information is sent according to the preset transmission protocol;
if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters, sending the calling information according to the established long connection;
if it is determined that a preset transmission protocol does not exist according to the transmission protocol parameters and the long connection is not established, establishing the long connection according to a built-in protocol rule and sending the calling information according to the long connection, wherein the built-in protocol rule is used for selecting a transmission protocol according to the sequence of the priority of the preset protocol to construct the long connection;
and if the preset transmission protocol does not exist according to the transmission protocol parameters, the long connection is not established, and the client-side is determined to be not in accordance with the establishment requirement of the long connection according to the built-in protocol rule, the calling information is sent according to the hypertext transmission protocol.
11. The method according to claim 1, wherein the call information is binary information that is converted by a protobuf conversion algorithm after being compiled based on typescript language.
12. A call-based communication device, comprising:
the analysis unit is used for acquiring calling information, wherein the calling information is acquired after analysis based on the calling request;
a determining unit, configured to determine a target server according to the call information and a route forwarding policy, where the route forwarding policy includes at least one forwarding rule, each forwarding rule is used to select the target server from multiple servers based on the call information, and the call information includes information for selecting a route forwarding policy;
and the sending unit is used for sending the calling information to the target server.
13. A storage medium comprising a stored program, wherein the program, when executed, controls an apparatus on which the storage medium is located to perform the call-based communication method of any of claims 1-11.
14. An apparatus comprising at least one processor, and at least one memory, bus connected to the processor; the processor and the memory complete mutual communication through the bus; the processor is configured to invoke program instructions in the memory to perform the call-based communication method of any of claims 1-11.
CN202111015022.1A 2021-08-31 2021-08-31 Calling-based communication method, device, storage medium and equipment Active CN113765805B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111015022.1A CN113765805B (en) 2021-08-31 2021-08-31 Calling-based communication method, device, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111015022.1A CN113765805B (en) 2021-08-31 2021-08-31 Calling-based communication method, device, storage medium and equipment

Publications (2)

Publication Number Publication Date
CN113765805A true CN113765805A (en) 2021-12-07
CN113765805B CN113765805B (en) 2023-10-20

Family

ID=78792245

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111015022.1A Active CN113765805B (en) 2021-08-31 2021-08-31 Calling-based communication method, device, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN113765805B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102222108A (en) * 2011-06-28 2011-10-19 用友软件股份有限公司 Scripting method and device
US20170034311A1 (en) * 2015-07-30 2017-02-02 Netapp, Inc. Method for selecting between multiple RPC frameworks during a TCP/IP session
CN106657287A (en) * 2016-11-30 2017-05-10 广州市千钧网络科技有限公司 Data access method and system
US20180091420A1 (en) * 2016-09-26 2018-03-29 Juniper Networks, Inc. Distributing service function chain data and service function instance data in a network
CN108289060A (en) * 2017-01-09 2018-07-17 腾讯科技(深圳)有限公司 A kind of data processing method and device based on RPC service
CN109218181A (en) * 2018-10-30 2019-01-15 北京大米科技有限公司 A kind of method, apparatus and electronic equipment of data transmission
CN109542641A (en) * 2018-11-14 2019-03-29 中国联合网络通信集团有限公司 Service calling method, apparatus and system
US20190166048A1 (en) * 2017-11-30 2019-05-30 Cisco Technology, Inc. Dynamic next-hop selection for routes in a network fabric
US20200076672A1 (en) * 2018-08-31 2020-03-05 Subcom, Llc Techniques for interfacing between web services and interface description language (idl)-based remote procedure call (rpc) services and an optical communication system implementing same
US20210029035A1 (en) * 2019-05-31 2021-01-28 Adva Optical Networking Se Transparent Multiplexing of IP Endpoints

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102222108A (en) * 2011-06-28 2011-10-19 用友软件股份有限公司 Scripting method and device
US20170034311A1 (en) * 2015-07-30 2017-02-02 Netapp, Inc. Method for selecting between multiple RPC frameworks during a TCP/IP session
US20180091420A1 (en) * 2016-09-26 2018-03-29 Juniper Networks, Inc. Distributing service function chain data and service function instance data in a network
CN106657287A (en) * 2016-11-30 2017-05-10 广州市千钧网络科技有限公司 Data access method and system
CN108289060A (en) * 2017-01-09 2018-07-17 腾讯科技(深圳)有限公司 A kind of data processing method and device based on RPC service
US20190166048A1 (en) * 2017-11-30 2019-05-30 Cisco Technology, Inc. Dynamic next-hop selection for routes in a network fabric
US20200076672A1 (en) * 2018-08-31 2020-03-05 Subcom, Llc Techniques for interfacing between web services and interface description language (idl)-based remote procedure call (rpc) services and an optical communication system implementing same
CN109218181A (en) * 2018-10-30 2019-01-15 北京大米科技有限公司 A kind of method, apparatus and electronic equipment of data transmission
CN109542641A (en) * 2018-11-14 2019-03-29 中国联合网络通信集团有限公司 Service calling method, apparatus and system
US20210029035A1 (en) * 2019-05-31 2021-01-28 Adva Optical Networking Se Transparent Multiplexing of IP Endpoints

Also Published As

Publication number Publication date
CN113765805B (en) 2023-10-20

Similar Documents

Publication Publication Date Title
CN105099989A (en) Service request processing and service processing result acquiring method, device and system
CN112367259B (en) Internet of things data message distribution method and device
CN113259479B (en) Data processing method and equipment
WO2023221452A1 (en) Packet processing system and method, device, and storage medium
CN113612686A (en) Traffic scheduling method and device and electronic equipment
CN116055524A (en) Interaction method, processor and device for Internet platform and Internet of things equipment
CN114500633B (en) Data forwarding method, related device, program product and data transmission system
CN112104679B (en) Method, apparatus, device and medium for processing hypertext transfer protocol request
CN113986811A (en) High-performance kernel-mode network data packet acceleration method
CN108924773B (en) Message processing method and device
CN115174472B (en) Message forwarding processing method and related device
CN111147385A (en) Method and system for forwarding data plane of software defined data center network
CN113765805B (en) Calling-based communication method, device, storage medium and equipment
CN110661895A (en) Network address mapping method and network address mapping equipment of server
CN112202914B (en) Message pushing method and device
CN112104566B (en) Processing method and device for load balancing
CN113687940B (en) Load balancing method and device and physical machine
KR102526770B1 (en) Electronic device providing fast packet forwarding with reference to additional network address translation table
CN113992644A (en) Internet of things gateway system based on non-service technology and data processing method thereof
CN114374649A (en) Hybrid routing method, device and network equipment
CN113271305B (en) Attack detection method and device and web application level intrusion prevention system WAF
WO2016197995A1 (en) Method and device for realizing stateful operation in stateless network protocol
CN115174581B (en) Load balancing method and router
CN113973086B (en) Data transmission method, device and storage medium
CN112532534B (en) Data transmission method, device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant