CN111405029B - Request processing method and device - Google Patents

Request processing method and device Download PDF

Info

Publication number
CN111405029B
CN111405029B CN202010170105.7A CN202010170105A CN111405029B CN 111405029 B CN111405029 B CN 111405029B CN 202010170105 A CN202010170105 A CN 202010170105A CN 111405029 B CN111405029 B CN 111405029B
Authority
CN
China
Prior art keywords
information
request
client
request information
protocol
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010170105.7A
Other languages
Chinese (zh)
Other versions
CN111405029A (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.)
Douyin Vision Co Ltd
Douyin Vision Beijing Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010170105.7A priority Critical patent/CN111405029B/en
Publication of CN111405029A publication Critical patent/CN111405029A/en
Application granted granted Critical
Publication of CN111405029B publication Critical patent/CN111405029B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • H04L67/63Routing a service request depending on the request content or context
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • 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/56Provisioning of proxy services
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The disclosure provides a request processing method and device, wherein the method comprises the following steps: receiving request information sent by a client; extracting packaging protocol information corresponding to the request information from the request information; if the packaging protocol information accords with a preset condition, extracting a corresponding method name from the request information, and searching at least one server address corresponding to the method name from a stored routing information table; and sending the request information to a target server corresponding to the server address.

Description

Request processing method and device
Technical Field
The disclosure relates to the technical field of internet communication, in particular to a request processing method and device.
Background
The remote procedure call (Remote Procedure Call, RPC) protocol is a computer communication protocol that allows a program running on one computer to call a program on another computer, making the call of the remote program as convenient as the local program, and not losing the semantic simplicity of the local call while providing a powerful remote call capability, making the construction of a distributed system more convenient and faster, saving the work of a service programmer for a large number of codec, serialization and deserialization, data verification, etc., and making the whole interactive process more reliable on the aspect of the service.
The request of the client is generally sent to the server providing the service through the reverse proxy server, however, the reverse proxy server cannot proxy the request of the client based on the thread RPC protocol at present, if the client is a request initiated based on the thread RPC protocol, the reverse proxy server can reject the request, so that the server providing the service cannot normally receive the request of the client, and service loss is caused.
Disclosure of Invention
The embodiment of the disclosure at least provides a request processing method and device.
In a first aspect, an embodiment of the present disclosure provides a method for processing a request, where the method is applied to a reverse proxy server, the method includes:
receiving request information sent by a client;
extracting packaging protocol information corresponding to the request information from the request information;
if the packaging protocol information accords with a preset condition, extracting a corresponding method name from the request information, and searching at least one server address corresponding to the method name from a stored routing information table;
and sending the request information to a target server corresponding to the server address.
In an alternative embodiment, the wrapper protocol information includes protocol version information and request type information;
The extracting the packaging protocol information corresponding to the request information from the request information comprises the following steps:
searching a first field positioned at a first preset position from a plurality of fields corresponding to the request information, and determining the information of the first field as the protocol version information; searching a second field positioned at a second preset position, and determining the information of the second field as the request type information;
determining that the packaging protocol information meets preset conditions comprises the following steps:
if the searched protocol version information is preset target protocol version information and the searched request type information is preset target request type information, determining that the packaging protocol information accords with preset conditions.
In an optional embodiment, the extracting the corresponding method name from the request information includes:
searching a third field positioned at a third preset position from a plurality of fields corresponding to the request information to obtain the length of the method name;
and extracting the corresponding method name from the request information based on the length of the method name and the preset initial position of the method name in the request information.
In an alternative embodiment, the method further comprises:
Periodically acquiring service registration information of each server from a service management end;
and generating the routing information table based on the acquired service registration information.
In an optional embodiment, after sending the request information to the target server corresponding to the server address, the method further includes:
and after receiving the request response information sent by the target server, sending the request response information to the client.
In an alternative embodiment, the method further comprises:
if the packaging protocol information does not meet the preset condition, or if at least one server address corresponding to the method name is not found in the routing information table, generating refusing request feedback information corresponding to the request information;
and sending the feedback information of the refusal request to the client.
In an alternative embodiment, receiving request information sent by a client includes:
receiving request information sent by a client through long connection;
the sending the request response information to the client includes:
the request response information is sent to the client through long connection;
the method further comprises the steps of:
And if the connection disconnection request sent by the client is received and/or if the request information sent by the client is not received after a preset time interval, disconnecting the long connection between the reverse proxy server and the client.
In a second aspect, an embodiment of the present disclosure further provides a request processing apparatus, including:
the receiving module is used for receiving the request information sent by the client;
the extraction module is used for extracting packaging protocol information corresponding to the request information from the request information;
the server address module is used for extracting a corresponding method name from the request information if the packaging protocol information accords with a preset condition, and searching at least one server address corresponding to the method name from a stored routing information table;
and the sending module is used for sending the request information to a target server corresponding to the server address.
In an alternative embodiment, the wrapper protocol information includes protocol version information and request type information;
the extracting module is configured to, in a case where the packaging protocol information corresponding to the request information is extracted from the request information:
Searching a first field positioned at a first preset position from a plurality of fields corresponding to the request information, and determining the information of the first field as the protocol version information; searching a second field positioned at a second preset position, and determining the information of the second field as the request type information;
the server address module is configured to, when determining that the packaging protocol information meets a preset condition:
if the searched protocol version information is preset target protocol version information and the searched request type information is preset target request type information, determining that the packaging protocol information accords with preset conditions.
In an alternative embodiment, the server address module is configured to, in a case where a corresponding method name is extracted from the request information:
searching a third field positioned at a third preset position from a plurality of fields corresponding to the request information to obtain the length of the method name;
and extracting the corresponding method name from the request information based on the length of the method name and the preset initial position of the method name in the request information.
In an alternative embodiment, the apparatus further comprises:
The service registration information acquisition module is used for periodically acquiring the service registration information of each server from the service management end;
and the routing information table generation module is used for generating the routing information table based on the acquired service registration information.
In an alternative embodiment, the apparatus further comprises:
and the request response information sending module is used for sending the request response information to the client after receiving the request response information sent by the target server.
In an alternative embodiment, the apparatus further comprises:
the refusing request feedback information generating module is used for generating refusing request feedback information corresponding to the request information if the packaging protocol information does not meet a preset condition or if at least one server address corresponding to the method name is not found in the routing information table;
and the refusal request feedback information sending module is used for sending the refusal request feedback information to the client.
In an optional implementation manner, the receiving module is configured to, when receiving the request information sent by the client,:
receiving request information sent by a client through long connection;
The request response information sending module is configured to, when the request response information is sent to the client, send the request response information to the client:
the request response information is sent to the client through long connection;
the apparatus further comprises:
and the disconnection module is used for disconnecting the long connection between the reverse proxy server and the client if the connection disconnection request sent by the client is received and/or if the request information sent by the client is not received after a preset time interval.
In a third aspect, embodiments of the present application further provide an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the steps of the request processing method of the first aspect, or any of the possible implementations of the first aspect.
In a fourth aspect, the embodiments of the present application further provide a computer readable storage medium, on which a computer program is stored, which when executed by a processor performs the steps of the request processing method described in the first aspect, or any possible implementation manner of the first aspect.
According to the request processing method and device, through receiving request information sent by a client, when packaging protocol information included in the request information accords with preset conditions, a corresponding method name is extracted from the request information, and at least one server address corresponding to the method name is searched from a stored routing information table; the request information is sent to a target server corresponding to the searched server address; therefore, after receiving the request information initiated based on the packaging protocol information meeting the preset conditions, for example, after receiving the request information initiated based on the thread RPC protocol information meeting the preset conditions, the reverse proxy server can realize the proxy of the request information of the client based on the method, thereby avoiding the condition that the request information of the client is discarded abnormally, avoiding service loss and improving the reliability of request processing.
The foregoing objects, features and advantages of the disclosure will be more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for the embodiments are briefly described below, which are incorporated in and constitute a part of the specification, these drawings showing embodiments consistent with the present disclosure and together with the description serve to illustrate the technical solutions of the present disclosure. It is to be understood that the following drawings illustrate only certain embodiments of the present disclosure and are therefore not to be considered limiting of its scope, for the person of ordinary skill in the art may admit to other equally relevant drawings without inventive effort.
FIG. 1 illustrates a flow chart of a request processing method provided by an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating a method for extracting a corresponding method name from request information in a request processing method according to an embodiment of the present disclosure;
FIG. 3 illustrates a schematic diagram of a request processing apparatus provided by an embodiment of the present disclosure;
fig. 4 shows a schematic diagram of an electronic device provided by an embodiment of the disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only some embodiments of the present disclosure, but not all embodiments. The components of the embodiments of the present disclosure, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the disclosure, as claimed, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be made by those skilled in the art based on the embodiments of this disclosure without making any inventive effort, are intended to be within the scope of this disclosure.
In general, the reverse proxy server may support an http protocol proxy, a TCP protocol proxy, or a gRPC protocol proxy, but does not support a thread RPC protocol proxy, that is, the reverse proxy server cannot proxy a request initiated by a client based on the thread RPC protocol, if the client is a request initiated by the thread RPC protocol, the reverse proxy server processes the request as a transport layer protocol and forwards the received request to a preset server, or cannot proxy the request, and then refuses the request, so that the server cannot normally receive the request of the client.
Therefore, in order to implement the proxy of the reverse proxy server to the thread RPC protocol, the embodiment of the disclosure proposes a request processing method, which may enable the improved reverse proxy server to implement the proxy of the reverse proxy server to the thread RPC protocol, that is, implement the processing of the request of the thread RPC protocol type, based on the request processing method proposed by the embodiment of the disclosure by improving the reverse proxy server. The improvement process of the reverse proxy server is the same as the implementation process of the request processing method proposed in the present disclosure.
For ease of understanding the embodiments of the present disclosure, a detailed description of a request processing method disclosed in the embodiments of the present disclosure is first provided.
Example 1
Referring to fig. 1, a flowchart of a request processing method according to an embodiment of the present disclosure is provided, where the method is applied to a reverse proxy server, for example, the reverse proxy server may be a nginx, a haproxy, a fabio, etc. The method comprises the steps of S101 to S104, wherein:
s101, receiving request information sent by a client.
In the embodiment of the disclosure, the client may generate the request information in response to the operation of the user, and send the generated request information to the reverse proxy server. Here, the operation of the user may be an operation of the user logging in the client, an operation of the user viewing information in the client, or the like.
S102, extracting packaging protocol information corresponding to the request information from the request information.
For example, the wrapper protocol information may include protocol version information and request type information. The protocol version information may be determined according to the protocol type of the generation request information, for example, the protocol version information may be hexadecimal number 8001 (i.e. 0x 8001), and the like. The request type information may be determined according to the type of the request message sent by the client, for example, if the request message is a call message, the request type message may be hexadecimal 0001 (i.e. 0x 0001), if the request message is a response message, the request type message may be 0x0002, if the request message is an exception message, the request type message may be 0x 0003, if the request type message is a unidirectional message (belonging to the call message, but not requiring a response), the request type message may be 0x0004, etc. Further, the obtained package protocol information may be 0x80010001, or 0x80010002, or 0x80010003, or 0x80010004, etc.
In an alternative embodiment, when the packaging protocol information includes protocol version information and request type information, extracting packaging protocol information corresponding to the request information from the request information includes:
searching a first field positioned at a first preset position from a plurality of fields corresponding to the request information, and determining the information of the first field as protocol version information; and searching a second field positioned at a second preset position, and determining the information of the second field as request type information.
Generally, the request information includes a plurality of fields, for example, the request information may include a field corresponding to protocol version information version, a field corresponding to request type information type, a field corresponding to method name, and the like.
In general, the serialization protocol type corresponding to the serialization protocol layer TProtoco of the thread RPC protocol may be TBinary, compact, JSON, header, etc., and the transmission protocol type corresponding to the transmission layer TTransport may be stream, famed, buffer, http, etc.
The method is applicable to a speed RPC protocol with a binary TBinary type corresponding to TProtoco and a stream type corresponding to TTransport, and the obtained speed RPC type request information. For example, in the thread RPC type request information obtained in the above manner, the information of the first field at the initial position (i.e., the first preset position) of the request information may be protocol version information version, and the binary data length occupied by the information (version) of the first field may be 2B; the information of the second field at the second preset position adjacent to the protocol version information may be request type information type, and the binary data length occupied by the information (type) of the second field may be 2B; the information of the third field at the third preset position adjacent to the request type information may be the length of the method name, and the binary data length occupied by the information of the third field (the length of the method name) may be 4B; the field corresponding to the preset position adjacent to the length of the method name may be the method name, and the binary data length occupied by the information (method name) of the field may be determined according to the actual situation. Other information, such as, a strut begin, fields, a strut end, a message end, etc., is also included in the request information, and the above information is not needed to be searched in the present embodiment, so the details will not be described here.
Generally, after receiving the request information, the reverse proxy server needs to analyze the request information to obtain all the information included in the request information, obtain server address information from all the analyzed information, package all the analyzed information, and send the packaged information to the corresponding server, and the information obtaining mode is complicated, so that the efficiency of the request processing process is lower. In order to solve the above problems, in a specific implementation, the package protocol information, the length of the method name, the method name and other information can be searched from the position corresponding to the request information through the peek operation, for example, the protocol version information is searched from the first field at the first preset position, and the request type information is searched from the second field at the second preset position, so that the request information does not need to be analyzed, the integrity of the request information is not damaged, the process is simple, and the efficiency of the request processing process can be improved.
S103, if the packaging protocol information meets the preset condition, extracting a corresponding method name from the request information, and searching at least one server address corresponding to the method name from the stored routing information table.
In the embodiment of the disclosure, whether the packaging protocol information accords with a preset condition can be judged, if so, the corresponding method name is extracted from the request information, and at least one server address corresponding to the method name can be searched from a stored routing information table; if not, rejecting the request information. The server address corresponding to the searched method name is the address of the server providing service for the client.
In an alternative embodiment, the method further comprises: if the packaging protocol information does not meet the preset condition, or if at least one server address corresponding to the method name is not found in the routing information table, generating refusing request feedback information corresponding to the request information; and sending the refusal request feedback information to the client.
In the implementation, if the packaging protocol information does not meet the preset condition, the reverse proxy server can reject the request information, generate reject request feedback information corresponding to the request information, and send the reject request feedback information to the client. And/or if the method name is not found from the routing information table, and then at least one server address corresponding to the method name is not found, the reverse proxy server can reject the request information, generate reject request feedback information corresponding to the request information, and send the reject request feedback information to the client.
Accepting S102, in an optional implementation manner, determining that the packaging protocol information meets a preset condition includes:
if the searched protocol version information is preset target protocol version information and the searched request type information is set target request type information, determining that the packaging protocol information meets preset conditions. Otherwise, if the searched protocol version information is not in accordance with the preset target protocol version information and/or the searched request type information is not in accordance with the preset target request type information, determining that the packaging protocol information is not in accordance with the preset condition.
For example, the target protocol version information may be 0x8001, and the target request type information may be 0x0001 and 0x0004, and if the found protocol version information is 0x8001, and the found request type information is 0x0001 or 0x0004, determining that the packaging protocol information meets the preset condition; otherwise, if the found protocol version information is 0x7001 and/or the found request type information is 0x0002 or 0x0003, determining that the packaging protocol information does not meet the preset condition. Namely, when the found packaging protocol information is 0x80010001 or 0x80010004, the packaging protocol information accords with preset conditions; otherwise, if the found packaging protocol information is 0x80010002 or 0x70010004, the packaging protocol information does not meet the preset condition. The target protocol version information and the target request type information may be set according to actual situations, and the embodiments of the present disclosure are merely exemplary illustrations.
In an alternative embodiment, extracting the corresponding method name from the request information includes:
s201, searching a third field positioned at a third preset position from a plurality of fields corresponding to the request information to obtain the length of the method name;
s202, extracting the corresponding method name from the request information based on the length of the method name and the preset initial position of the method name in the request information.
Illustratively, the method name len (length of method name) is determined according to the corresponding method name, and the lengths corresponding to different method names are different. Each server cluster may correspond to a plurality of method names, and each method name may be defined by a developer according to actual needs.
Here, the initial position of the method name in the request information is determined, and after determining the length of the method name, a fourth field corresponding to the method name len may be selected from a preset initial position in the request information, and information corresponding to the selected fourth field may be determined as the method name. For example, taking table 1 as an example, if the determined length corresponding to the method name is 4B, the information from the 9 th byte to the 12 th byte (including the 9 th byte and the 12 th byte) is acquired, and the acquired information is determined as the method name; if the determined method name corresponds to the length of 2B, information from the 9 th byte to the 10 th byte (including the 9 th byte and the 10 th byte) is acquired, and the acquired information is determined as a method name.
And S104, sending the request information to a target server corresponding to the server address.
In a specific implementation, after sending the request information to the target server corresponding to the server address, the method further includes: and after receiving the request response information sent by the target server, sending the request response information to the client.
In the embodiment of the disclosure, after determining at least one server address corresponding to the request information, the request information may be sent to a target server corresponding to the at least one server address. And receiving request response information corresponding to the request information sent by the target server, and forwarding the request response information to the client.
In an alternative embodiment, the method further comprises:
periodically acquiring service registration information of each server from a service management end;
and generating the routing information table based on the acquired service registration information.
In the embodiment of the disclosure, a service management end receives service registration information sent by each server in real time, and stores the received service registration information, wherein the service registration information comprises information such as a server name, a server address, a server port, a server weight, at least one method name corresponding to the server, and the like. The service management end may be condul, nacos, etc.
The reverse proxy server can periodically acquire the service registration information stored by the service management end, generate a routing information table based on the acquired service registration information, and store the routing information table. If the service registration information received by the service management end is changed in transmission (for example, if the server a is damaged, the server a does not transmit the service registration information to the service management end), the service registration information acquired by the reverse proxy server is correspondingly updated, and a new routing information table can be generated and stored based on the updated service registration information. The period for acquiring the service registration information may be set according to actual needs.
For example, the routing information table may include a name, a method name, an IP address of a server, port information, a weight, and the like of each server in the server cluster corresponding to each service. Specifically, the information content included in the routing information table may be set according to actual needs.
In specific implementation, the receiving request information sent by the client may be: and receiving the request information sent by the client through the long connection. The sending of the request response information to the client may be: and sending the request response information to the client through the long connection.
The method for carrying out the embodiment further comprises:
and if the connection disconnection request sent by the client is received and/or if the request information sent by the client is not received after the preset time interval, disconnecting the long connection between the reverse proxy server and the client.
For example, a long connection may be established between the client and the reverse proxy server such that the reverse proxy server may receive request information over the long connection and may send request response information to the client over the long connection. After the request response information is sent to the client, the long connection with the client can not be disconnected, so that the reverse proxy server can continuously receive the request information sent again by the client based on the established long connection, further the time for establishing the long connection can be saved, and the efficiency of request processing is improved.
Illustratively, the reverse proxy server disconnects the long connection between the reverse proxy server and the client after receiving the connection disconnection request sent by the client and/or after not receiving the request information sent by the client for a preset time period. The preset time of the interval may be set according to practical situations, for example, the preset time of the interval may be 3 seconds, 5 seconds, or the like.
For example, a short connection may be established between the reverse proxy server and the server, and if the server address corresponding to the request information sent by the client at this time is the same as the server address corresponding to the request information sent next time, the short connection established between the reverse proxy server and the server is not disconnected; if the server address corresponding to the request information sent by the client at this time is different from the server address corresponding to the request information sent next time, for example, the server address corresponding to the request information at this time corresponds to the server a, and the server address corresponding to the request information at next time corresponds to the server B, the short connection between the reverse proxy server and the server a is disconnected first, and then the short connection between the reverse proxy server and the server B is established.
In the embodiment of the disclosure, by receiving request information sent by a client, when packaging protocol information included in the request information accords with a preset condition, extracting a corresponding method name from the request information, and searching at least one server address corresponding to the method name from a stored routing information table; the request information is sent to a target server corresponding to the searched server address; therefore, after receiving the request information initiated based on the packaging protocol information meeting the preset conditions, for example, after receiving the request information initiated based on the thread RPC protocol information meeting the preset conditions, the reverse proxy server can realize the proxy of the request information of the client based on the method, thereby avoiding the condition that the request information of the client is discarded abnormally, avoiding service loss and improving the reliability of request processing.
It will be appreciated by those skilled in the art that in the above-described method of the specific embodiments, the written order of steps is not meant to imply a strict order of execution but rather should be construed according to the function and possibly inherent logic of the steps.
Based on the same inventive concept, the embodiments of the present disclosure further provide a request processing device corresponding to the request processing method, and since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to that of the request processing method in the embodiments of the present disclosure, the implementation of the device may refer to the implementation of the method, and the repetition is omitted.
Example two
Based on the same conception, the embodiment of the present disclosure provides a request processing apparatus, referring to a schematic structural diagram of a request processing apparatus shown in fig. 3, the apparatus includes:
a receiving module 301, configured to receive request information sent by a client;
an extracting module 302, configured to extract, from the request information, packaging protocol information corresponding to the request information;
a server address module 303, configured to extract a corresponding method name from the request information if the packaging protocol information meets a preset condition, and search at least one server address corresponding to the method name from a stored routing information table;
And a sending module 304, configured to send the request information to a target server corresponding to the server address.
In an alternative embodiment, the wrapper protocol information includes protocol version information and request type information;
the extracting module is configured to, in a case where the packaging protocol information corresponding to the request information is extracted from the request information:
searching a first field positioned at a first preset position from a plurality of fields corresponding to the request information, and determining the information of the first field as the protocol version information; searching a second field positioned at a second preset position, and determining the information of the second field as the request type information;
the server address module is configured to, when determining that the packaging protocol information meets a preset condition:
if the searched protocol version information is preset target protocol version information and the searched request type information is preset target request type information, determining that the packaging protocol information accords with preset conditions.
In an alternative embodiment, the server address module is configured to, in a case where a corresponding method name is extracted from the request information:
Searching a third field positioned at a third preset position from a plurality of fields corresponding to the request information to obtain the length of the method name;
and extracting the corresponding method name from the request information based on the length of the method name and the preset initial position of the method name in the request information.
In an alternative embodiment, the apparatus further comprises:
the service registration information acquisition module is used for periodically acquiring the service registration information of each server from the service management end;
and the routing information table generation module is used for generating the routing information table based on the acquired service registration information.
In an alternative embodiment, the apparatus further comprises:
and the request response information sending module is used for sending the request response information to the client after receiving the request response information sent by the target server.
In an alternative embodiment, the apparatus further comprises:
the refusing request feedback information generating module is used for generating refusing request feedback information corresponding to the request information if the packaging protocol information does not meet a preset condition or if at least one server address corresponding to the method name is not found in the routing information table;
And the refusal request feedback information sending module is used for sending the refusal request feedback information to the client.
In an optional implementation manner, the receiving module is configured to, when receiving the request information sent by the client,:
receiving request information sent by a client through long connection;
the request response information sending module is configured to, when the request response information is sent to the client, send the request response information to the client:
the request response information is sent to the client through long connection;
the apparatus further comprises:
and the disconnection module is used for disconnecting the long connection between the reverse proxy server and the client if the connection disconnection request sent by the client is received and/or if the request information sent by the client is not received after a preset time interval.
In some embodiments, the functions or templates included in the apparatus provided by the embodiments of the present disclosure may be used to perform the methods described in the foregoing method embodiments, and specific implementations thereof may refer to descriptions of the foregoing method embodiments, which are not repeated herein for brevity.
The request processing device provided in the embodiment of the present disclosure has the same technical characteristics as the request processing method provided in the first embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
Example III
Based on the same technical concept, the embodiment of the disclosure also provides electronic equipment. Referring to fig. 4, a schematic structural diagram of an electronic device 400 according to an embodiment of the disclosure includes a processor 401, a memory 402, and a bus 403. The memory 402 is configured to store execution instructions, including a memory 4021 and an external memory 4022; the memory 4021 is also referred to as an internal memory, and is used for temporarily storing operation data in the processor 401 and data exchanged with the external memory 4022 such as a hard disk, the processor 401 exchanges data with the external memory 4022 through the memory 4021, and when the electronic device 400 operates, the processor 401 and the memory 402 communicate with each other through the bus 403, so that the processor 401 executes the following instructions:
receiving request information sent by a client;
extracting packaging protocol information corresponding to the request information from the request information;
if the packaging protocol information accords with a preset condition, extracting a corresponding method name from the request information, and searching at least one server address corresponding to the method name from a stored routing information table;
and sending the request information to a target server corresponding to the server address.
In one possible design, the instructions that may be executed by the processor 401 further include:
the packaging protocol information comprises protocol version information and request type information;
the extracting the packaging protocol information corresponding to the request information from the request information comprises the following steps:
searching a first field positioned at a first preset position from a plurality of fields corresponding to the request information, and determining the information of the first field as the protocol version information; searching a second field positioned at a second preset position, and determining the information of the second field as the request type information;
determining that the packaging protocol information meets preset conditions comprises the following steps:
if the searched protocol version information is preset target protocol version information and the searched request type information is preset target request type information, determining that the packaging protocol information accords with preset conditions.
In one possible design, the instructions that may be executed by the processor 401 further include:
the extracting the corresponding method name from the request information comprises the following steps:
searching a third field positioned at a third preset position from a plurality of fields corresponding to the request information to obtain the length of the method name;
And extracting the corresponding method name from the request information based on the length of the method name and the preset initial position of the method name in the request information.
In one possible design, the instructions that may be executed by the processor 401 further include:
periodically acquiring service registration information of each server from a service management end;
and generating the routing information table based on the acquired service registration information.
In one possible design, the instructions that may be executed by the processor 401 further include:
and after receiving the request response information sent by the target server, sending the request response information to the client.
In one possible design, the instructions that may be executed by the processor 401 further include:
if the packaging protocol information does not meet the preset condition, or if at least one server address corresponding to the method name is not found in the routing information table, generating refusing request feedback information corresponding to the request information;
and sending the feedback information of the refusal request to the client.
In one possible design, the instructions that may be executed by the processor 401 further include:
receiving request information sent by a client, including:
Receiving request information sent by a client through long connection;
the sending the request response information to the client includes:
the request response information is sent to the client through long connection;
the method further comprises the steps of:
and if the connection disconnection request sent by the client is received and/or if the request information sent by the client is not received after a preset time interval, disconnecting the long connection between the reverse proxy server and the client.
Example IV
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the request processing method described in the above method embodiments. Wherein the storage medium may be a volatile or nonvolatile computer readable storage medium.
The computer program product of the request processing method provided in the embodiments of the present disclosure includes a computer readable storage medium storing program codes, where the instructions included in the program codes may be used to execute the steps of the request processing method described in the above method embodiments, and specifically, reference may be made to the above method embodiments, which are not described herein.
The disclosed embodiments also provide a computer program which, when executed by a processor, implements any of the methods of the previous embodiments. The computer program product may be realized in particular by means of hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied as a computer storage medium, and in another alternative embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), or the like.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in essence or a part contributing to the prior art or a part of the technical solution, or in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present disclosure. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the foregoing examples are merely specific embodiments of the present disclosure, and are not intended to limit the scope of the disclosure, but the present disclosure is not limited thereto, and those skilled in the art will appreciate that while the foregoing examples are described in detail, it is not limited to the disclosure: any person skilled in the art, within the technical scope of the disclosure of the present disclosure, may modify or easily conceive changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features thereof; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the disclosure, and are intended to be included within the scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (10)

1. A method of request processing, the method being applied to a reverse proxy server, the method comprising:
receiving request information sent by a client; the request information is generated based on a thread RPC protocol;
extracting packaging protocol information corresponding to the request information from the request information; the packaging protocol information comprises protocol version information and request type information;
If the packaging protocol information accords with a preset condition, extracting a corresponding method name from the request information, and searching at least one server address corresponding to the method name from a stored routing information table;
and sending the request information to a target server corresponding to the server address.
2. The method according to claim 1, wherein extracting the packaging protocol information corresponding to the request information from the request information comprises:
searching a first field positioned at a first preset position from a plurality of fields corresponding to the request information, and determining the information of the first field as the protocol version information; searching a second field positioned at a second preset position, and determining the information of the second field as the request type information;
determining that the packaging protocol information meets preset conditions comprises the following steps:
if the searched protocol version information is preset target protocol version information and the searched request type information is preset target request type information, determining that the packaging protocol information accords with preset conditions.
3. The method according to claim 1 or 2, wherein the extracting the corresponding method name from the request information comprises:
Searching a third field positioned at a third preset position from a plurality of fields corresponding to the request information to obtain the length of the method name;
and extracting the corresponding method name from the request information based on the length of the method name and the preset initial position of the method name in the request information.
4. The method according to claim 1, wherein the method further comprises:
periodically acquiring service registration information of each server from a service management end;
and generating the routing information table based on the acquired service registration information.
5. The method of claim 1, further comprising, after sending the request information to the target server corresponding to the server address:
and after receiving the request response information sent by the target server, sending the request response information to the client.
6. The method of claim 5, wherein the method further comprises:
if the packaging protocol information does not meet the preset condition, or if at least one server address corresponding to the method name is not found in the routing information table, generating refusing request feedback information corresponding to the request information;
And sending the feedback information of the refusal request to the client.
7. The method of claim 5, wherein receiving the request information sent by the client comprises:
receiving request information sent by a client through long connection;
the sending the request response information to the client includes:
the request response information is sent to the client through long connection;
the method further comprises the steps of:
and if the connection disconnection request sent by the client is received and/or if the request information sent by the client is not received after a preset time interval, disconnecting the long connection between the reverse proxy server and the client.
8. A request processing apparatus, the apparatus comprising:
the receiving module is used for receiving the request information sent by the client; the request information is generated based on a thread RPC protocol;
the extraction module is used for extracting packaging protocol information corresponding to the request information from the request information; the packaging protocol information comprises protocol version information and request type information;
the server address module is used for extracting a corresponding method name from the request information if the packaging protocol information accords with a preset condition, and searching at least one server address corresponding to the method name from a stored routing information table;
And the sending module is used for sending the request information to a target server corresponding to the server address.
9. An electronic device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating over the bus when the electronic device is running, said machine readable instructions when executed by said processor performing the steps of the request processing method according to any of claims 1 to 7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the request processing method according to any of claims 1 to 7.
CN202010170105.7A 2020-03-12 2020-03-12 Request processing method and device Active CN111405029B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010170105.7A CN111405029B (en) 2020-03-12 2020-03-12 Request processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010170105.7A CN111405029B (en) 2020-03-12 2020-03-12 Request processing method and device

Publications (2)

Publication Number Publication Date
CN111405029A CN111405029A (en) 2020-07-10
CN111405029B true CN111405029B (en) 2023-06-02

Family

ID=71428770

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010170105.7A Active CN111405029B (en) 2020-03-12 2020-03-12 Request processing method and device

Country Status (1)

Country Link
CN (1) CN111405029B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103546557A (en) * 2013-10-22 2014-01-29 乐视致新电子科技(天津)有限公司 Data interaction method of platform-level services, service platform and systems
WO2015158064A1 (en) * 2014-04-18 2015-10-22 中兴通讯股份有限公司 Communication protocol conversion method, device and storage media
US9203931B1 (en) * 2013-04-01 2015-12-01 Amazon Technologies, Inc. Proxy server testing
CN105141567A (en) * 2014-05-26 2015-12-09 腾讯科技(深圳)有限公司 Interactive data processing method and system of terminal application and service end and interaction method
CN109714332A (en) * 2018-12-26 2019-05-03 北京字节跳动网络技术有限公司 The method for converting protocol and device parsed based on Thrift and syntax tree
CN109862438A (en) * 2019-02-19 2019-06-07 普联技术有限公司 A kind of method and apparatus of agency's forwarding real-time streaming protocol stream medium data

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3267633B1 (en) * 2015-03-02 2019-12-25 Nec Corporation Information processing system, proxy server, address duplication prevention method, and computer-readable recording medium
CN105978950A (en) * 2016-04-27 2016-09-28 努比亚技术有限公司 Server resource distribution method, apparatus and system thereof
CN106648940B (en) * 2017-03-13 2020-05-22 北京百悟科技有限公司 Remote procedure calling method and device
CN107301098B (en) * 2017-06-15 2020-09-08 搜易贷(北京)金融信息服务有限公司 Remote procedure calling device, method and system based on Thrift protocol
CN108038796B (en) * 2017-12-11 2021-02-26 厦门亿力吉奥信息科技有限公司 C + + based GIS service operation method and storage medium
CN110519380B (en) * 2019-08-29 2022-06-21 北京旷视科技有限公司 Data access method and device, storage medium and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9203931B1 (en) * 2013-04-01 2015-12-01 Amazon Technologies, Inc. Proxy server testing
CN103546557A (en) * 2013-10-22 2014-01-29 乐视致新电子科技(天津)有限公司 Data interaction method of platform-level services, service platform and systems
WO2015158064A1 (en) * 2014-04-18 2015-10-22 中兴通讯股份有限公司 Communication protocol conversion method, device and storage media
CN105141567A (en) * 2014-05-26 2015-12-09 腾讯科技(深圳)有限公司 Interactive data processing method and system of terminal application and service end and interaction method
CN109714332A (en) * 2018-12-26 2019-05-03 北京字节跳动网络技术有限公司 The method for converting protocol and device parsed based on Thrift and syntax tree
CN109862438A (en) * 2019-02-19 2019-06-07 普联技术有限公司 A kind of method and apparatus of agency's forwarding real-time streaming protocol stream medium data

Also Published As

Publication number Publication date
CN111405029A (en) 2020-07-10

Similar Documents

Publication Publication Date Title
US9906630B2 (en) Processing data packets in performance enhancing proxy (PEP) environment
EP3476095B1 (en) Method for multi-path udp communication method between two terminals
CN101997759B (en) Service implementation method and service system
CN103339901A (en) Terminal and intermediate node in content oriented networking environment and communication method of terminal and intermediate node
US8903972B2 (en) Method and apparatus for sharing contents using information of group change in content oriented network environment
CN108156178A (en) A kind of SSL/TLS data monitoring systems and method
EP3739843A1 (en) Udp communication method via multiple paths between two terminals
CN111510476B (en) Communication method, communication device, computer equipment and computer readable storage medium
CN107864101A (en) Load-balancing method and device
CN108880875B (en) Log message transmission method and device
CN102325124A (en) Flow-guiding function-supported application identification equipment and method
CN114153626A (en) Method and device for abstracting service integration process and computer equipment
US20150067066A1 (en) Provisioning Communication Services using Proxy Server in a Cloud
CN114500633B (en) Data forwarding method, related device, program product and data transmission system
US11768759B2 (en) Method and system for automated testing of web service APIs
CN109039687A (en) Load-balancing method, device, system, equipment and the storage medium of request
CN111405029B (en) Request processing method and device
US20190379732A1 (en) Network communication method, peers, and network communication system
CN103220327B (en) user information storage method and device
JP4910542B2 (en) SIP message delivery program
US20220030071A1 (en) Dynamic user plane function (upf) selection based on supported protocol type
CN114124891A (en) Network request processing method and device, storage medium and electronic device
CN113612811A (en) Method, system, equipment and medium for client mounting in multiple channels
FR2915650A1 (en) METHOD AND DEVICE FOR INTERFACE BETWEEN UDP OR TCP PROTOCOLS AND SCTP
CN110071925A (en) Data transmission method and corresponding server, 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
CP01 Change in the name or title of a patent holder

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

CP01 Change in the name or title of a patent holder