CN111586097A - Network request processing method, computing device and storage medium - Google Patents

Network request processing method, computing device and storage medium Download PDF

Info

Publication number
CN111586097A
CN111586097A CN202010250602.8A CN202010250602A CN111586097A CN 111586097 A CN111586097 A CN 111586097A CN 202010250602 A CN202010250602 A CN 202010250602A CN 111586097 A CN111586097 A CN 111586097A
Authority
CN
China
Prior art keywords
network request
micro
service
request
client
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010250602.8A
Other languages
Chinese (zh)
Inventor
吕晨阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CHEZHI HULIAN (BEIJING) SCIENCE & TECHNOLOGY CO LTD
Original Assignee
CHEZHI HULIAN (BEIJING) SCIENCE & 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 CHEZHI HULIAN (BEIJING) SCIENCE & TECHNOLOGY CO LTD filed Critical CHEZHI HULIAN (BEIJING) SCIENCE & TECHNOLOGY CO LTD
Priority to CN202010250602.8A priority Critical patent/CN111586097A/en
Publication of CN111586097A publication Critical patent/CN111586097A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a network request processing method, which is suitable for being executed in computing equipment, wherein the computing equipment is suitable for being connected with a client, and the method comprises the following steps: receiving a network request sent by a client; judging whether the network request is an aggregation request, if so, acquiring at least two micro-service names corresponding to the network request, and forwarding the network request to at least two micro-services corresponding to the micro-service names; and acquiring target data in the return results of the at least two micro services, merging the target data, and sending the merged target data to the client. The invention also discloses corresponding computing equipment and a storage medium.

Description

Network request processing method, computing device and storage medium
Technical Field
The present invention relates to the field of information processing technologies, and in particular, to a network request processing method, a computing device, and a storage medium.
Background
With the continuous development of services and the process of micro-service of a server, the interaction between a client and the server is rapidly increased, and the interaction is simply the communication of a network interface. This growth is evident in the number of client-side interfaces that invoke the server. And the functional interfaces in different micro services are different in domain name, interface address, interface name and the like, and are difficult to unify. Therefore, a technology for uniformly providing the entrance of each micro service through the gateway appears, but the integration of different micro service functions is not performed completely, when the client needs the return data of a plurality of micro services at the same time, the client still needs to send a plurality of requests to the plurality of micro services through the gateway, a large amount of resources are wasted, the performance of the terminal equipment of each client is different, and the user experience is not good when the performance of the terminal equipment is not good.
In the prior art, a way for solving the problem is to couple functions of a plurality of microservices, however, the scheme needs to be realized by hard coding, which not only increases the workload of engineers, but also only changes hardware or recodes when the functions needing to be aggregated are changed, thereby increasing the complexity of a business system.
Disclosure of Invention
To this end, the present invention provides a network request processing method, computing device and storage medium in an effort to solve or at least alleviate at least one of the problems identified above.
According to an aspect of the present invention, there is provided a network request processing method, adapted to be executed in a computing device, the computing device being adapted to connect with a client, the method comprising the steps of: receiving a network request sent by a client; judging whether the network request is an aggregation request or not, and if so, acquiring at least two micro service names corresponding to the network request; forwarding the network request to the micro services corresponding to the at least two micro service names respectively; and acquiring target data in the return results of the at least two micro services, merging the target data, and sending the merged target data to the client.
Optionally, in the network request processing method according to the present invention, the obtaining at least two microservice names corresponding to the network request includes: and reading the routing information of the aggregation request, and acquiring at least two micro service names corresponding to the aggregation request according to the routing information, wherein the routing information comprises the mapping relation between the aggregation request and the micro service names.
Optionally, in the network request processing method according to the present invention, forwarding the network request to the micro services corresponding to the at least two micro service names respectively includes the steps of: and acquiring address information corresponding to each micro-service name, and forwarding the network request to the micro-service corresponding to the micro-service name in the registration center service list according to the address information.
Optionally, in the method for processing a network request according to the present invention, forwarding the network request to a microservice corresponding to a microservice name in a service list of a registry according to address information includes: and judging whether the network request can be read only once, if so, packaging the network request into byte information which can be read for many times.
Optionally, in the network request processing method according to the present invention, obtaining target data in return results of at least two microservices includes: and waiting before obtaining all the request return results, and merging the target data returned currently when the time threshold is exceeded.
Alternatively, in the network request processing method according to the present invention, the time threshold is 500 ms.
Optionally, in the network request processing method according to the present invention, before acquiring at least two micro services corresponding to the network request, the method includes: and creating a mapping relation between the network request and each micro service name.
Optionally, in the network request processing method according to the present invention, when the mapping relationship needs to be modified, the routing information of the network request is modified correspondingly.
Optionally, in the network request processing method according to the present invention, if the network request is not an aggregation request, the routing information of the network request is read; forwarding the network request to a single micro-service in a service list of a registration center according to the routing information; and acquiring target data in a returned result of the micro service according to the network request, and sending the target data to the client.
Optionally, in the network request processing method according to the present invention, the health status of each microservice in the service list of the registry is monitored in real time through a heartbeat mechanism; and if the heartbeat of the micro service in the service list is not detected, sending alarm information, wherein the alarm information comprises the micro service name of the micro service.
According to another aspect of the present invention, there is provided a network request processing system including: a client adapted to issue a network request; the gateway is suitable for receiving a network request from the client, acquiring a micro service name corresponding to the network request, forwarding the network request to a micro service corresponding to the micro service name, acquiring target data in a return result of the micro service, merging the target data and sending the target data to the client; the registration center comprises a service list, the service list comprises micro-service names registered by the same or different servers and micro-service address information corresponding to each micro-service name, and the gateway forwards the network request to the micro-service corresponding to the micro-service name according to the address information; the gateway acquires the micro service name in the service list of the registration center according to the routing information; a server containing a micro-service corresponding to the network request
Optionally, in the network request processing system according to the present invention, the gateway is further adapted to determine whether the network request is an aggregation request, and if so, obtain at least two microservices corresponding to the network request.
According to yet another aspect of the invention, there is provided a computing device comprising at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the network request processing method according to the present invention.
According to still another aspect of the present invention, there is provided a readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to execute the network request processing method of the present invention.
According to the technical scheme of the invention, when the return data of a plurality of micro services are needed at the same time, only one network request needs to be sent, a plurality of micro service names corresponding to the network request are obtained according to the routing information of the network request, and the network request is forwarded to a plurality of micro services corresponding to the micro service names, so that the target data in the return results of the micro services can be obtained and merged and returned to the client, and the influence on the user experience caused by the performance problem of the client terminal equipment is avoided. The complexity of the client is greatly reduced while the resource request of the client is reduced, so that the client is more concise to develop.
The routing information comprises a mapping relation between the aggregation request and the micro service name, and when the mapping relation needs to be modified, the routing information of the network request is correspondingly modified, so that the function needing aggregation can be changed. Furthermore, the configuration center is used for configuring the routing information requested by the network, and when the routing information is modified, the gateway only needs to reread the configuration to realize dynamic routing without interrupting and restarting the system.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a schematic diagram of a network request processing system 100 according to one embodiment of the invention;
FIG. 2 shows a schematic diagram of a computing device 200 according to an embodiment of the invention;
FIG. 3 shows a flow diagram of a network request processing method 300 according to one embodiment of the invention;
fig. 4 shows a schematic diagram of a network request processing module 400 according to one embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may 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 disclosure to those skilled in the art.
FIG. 1 shows a schematic diagram of a network request processing system 100 according to one embodiment of the invention. As shown in fig. 1, a network request processing system 100 includes: client 110, gateway 120, registry 130, configuration center 140, server 150. The number of the server interfaces called by the client according to the requirement is continuously increased, and when the client needs to complete a complete information presentation process, different server interfaces, namely different micro-services, may need to be called at the same time. In the micro-service architecture of the network request processing system 100 according to the present invention, the gateway 120 provides an entry of micro-service resources to implement separation of front and back ends, and when the client 110 needs to request the micro-service in the back-end server 150, the network request sent by the client 110 passes through the gateway 120, and then the gateway 120 forwards the service request to the server 150 where the micro-service is located according to the routing information provided by the configuration center 140.
The service list of the registry 120 contains micro-service names registered from the same or different servers 150, and micro-service address information corresponding to each micro-service name. Specifically, the server 150 may be a single server or a server cluster composed of a plurality of servers, and the present invention does not limit the deployment manner of the servers. According to the technical scheme of the invention, when the return data of a plurality of micro services are needed at the same time, only one network request needs to be sent, a plurality of micro service names corresponding to the network request are obtained according to the routing information of the network request, and the network request is forwarded to a plurality of micro services corresponding to the micro service names, so that the target data in the return results of the micro services can be obtained and merged and returned to the client 110, and the influence on the user experience caused by the performance problem of the client terminal equipment is avoided. The complexity of the client is greatly reduced while the resource request of the client is reduced, so that the client is more concise to develop.
FIG. 2 shows a block diagram of a computing device 200, according to one embodiment of the invention. In a basic configuration 202, the computing device 200 typically includes a system memory 206 and one or more processors 204. A memory bus 208 may be used for communication between the processor 204 and the system memory 206.
Depending on the desired configuration, the processor 204 may be any type of processing, including but not limited to: a microprocessor (μ P), a microcontroller (μ C), a Digital Signal Processor (DSP), or any combination thereof. The processor 204 may include one or more levels of cache, such as a level one cache 210 and a level two cache 212, a processor core 214, and registers 216. Example processor cores 214 may include Arithmetic Logic Units (ALUs), Floating Point Units (FPUs), digital signal processing cores (DSP cores), or any combination thereof. The example memory controller 218 may be used with the processor 204, or in some implementations the memory controller 218 may be an internal part of the processor 204.
Depending on the desired configuration, system memory 206 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 206 may include an operating system 220, one or more applications 222, and program data 226. In some embodiments, application 222 may be arranged to operate with program data 226 on an operating system. In some embodiments, computing device 200 is configured to perform network request processing method 300, and program data 226 includes instructions for performing the method
Computing device 200 may also include an interface bus 240 that facilitates communication from various interface devices (e.g., output devices 242, peripheral interfaces 244, and communication devices 246) to the basic configuration 102 via the bus/interface controller 230. The example output device 242 includes a graphics processing unit 248 and an audio processing unit 250. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 252. Example peripheral interfaces 244 can include a serial interface controller 254 and a parallel interface controller 256, which can be configured to facilitate communications with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 258. An example communication device 246 may include a network controller 260, which may be arranged to facilitate communications with one or more other computing devices 262 over a network communication link via one or more communication ports 264.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes made in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media. In some embodiments, one or more programs are stored in a computer-readable medium, including instructions for performing certain methods, such as by computing device 200 performing network request processing method 300 in accordance with embodiments of the present invention.
The computing device 200 is installed with a mobile APP or client application supporting network file transmission and storage, including a native application or a browser such as IE, Chrome, and Firefox, or a wechat, QQ, and other communication software, and stores various files locally, such as photos, audio, video, and documents (e.g., documents in Word, PDF, and other formats). The application client may run on an operating system such as Windows, MacOS, android, and the like. Computing device 200 may be implemented as part of a small-form factor portable (or mobile) electronic device such as a cellular telephone, a digital camera, a Personal Digital Assistant (PDA), a personal media player device, a wireless web-watch device, a personal headset device, an application specific device, or a hybrid device that include any of the above functions. Computing device 200 may also be implemented as a personal computer including both desktop and notebook computer configurations. When a client needs return data of a plurality of micro services at the same time, for example, in a detail page of a commodity, the commodity detail data and available coupon data are often required to be displayed at the same time, but generally, the two data are in different micro service modules, and the client needs to send two requests to respectively request the commodity module and the coupon module. According to the technical scheme of the invention, different micro service functions with similar request contents are aggregated during gateway routing, and a client can obtain all data only by requesting once.
Fig. 3 shows a flow diagram of a network request processing method 300 according to one embodiment of the invention. The method 200 is suitable for execution in a computing device (such as the computing device 200 described above) that is connected to a client. As shown in fig. 2, the network request processing method starts at step S310.
In step S310, a network request sent by the client is received. The micro-service architecture provides an entrance of micro-service resources through the gateway to realize the separation of the front end and the back end, when the client needs to request the micro-service of the back end, the network request sent by the client passes through the gateway, and then the gateway forwards the service request to the micro-service.
According to one embodiment of the invention, network requests are divided into aggregated requests and non-aggregated requests. The aggregated request corresponds to a plurality of micro-services, and a mapping relationship between the network request and the plurality of micro-services needs to be created before. For example, to implement the function of network request a, micro service a and micro service B need to be called, and a mapping relationship between network request a and micro service B is created, which is represented by the routing information of network request. The distinction between aggregate requests and non-aggregate requests may be made on demand.
In particular, when the function of the network request is to return a page, the search type request does not need to be aggregated, whereas the user type request needs to be configured as an aggregated request. Because the input parameters of the search service are complex, various search conditions exist, the data volume of the returned result set is large, but the types in the result set are the same. The input is complicated, the output type is single, and the aggregation request configuration can be selected not to be carried out. When the request is to return a page corresponding to the user, the user information often exists in a plurality of systems, the input condition is simple, and only one user ID is needed, and the order list of the user, the coupon list of the user and the basic information of the user are required to be inquired. This is present in three different systems, but the input parameters only require one user ID, the return type is different. The input is single, the return types are various and are not in the same system, the aggregation request can be used, and the client aggregates three requests into one request.
Next, in step S320, it is determined whether the network request is an aggregation request, and if so, at least two micro service names corresponding to the network request are obtained, and a mapping relationship between the aggregation request and the micro service names is embodied by the routing information.
According to one embodiment of the invention, the route information of the aggregation request is read, and at least two micro service names corresponding to the aggregation request are obtained according to the route information. The routing information of the network request is realized by the configuration center when the relationship between the network request and the micro service name is established.
It should be noted that, in the existing technology of providing the entries of each microservice collectively through a gateway, the original routing manner for acquiring the network request is to automatically read the routing information from the configuration file depending on the engineering, or to hard-code the routing information into the gateway code.
The invention changes the route mode of obtaining the network request into reading from external information such as a database or other storage media, can flexibly define the route information rule and lays a foundation for the aggregation of the request. Further, the configuration center is used to store routing rules while dynamically loading routes. The load routing mode is read from the configuration center. And when the configuration is released after the configuration center updates and modifies, an update event is sent to the whole gateway so that the re-read routing rule is effective. The configuration center is used for configuring the routing information of the network request, and the gateway only needs to reread the configuration when the routing information is modified, so that the dynamic routing is realized, and the system does not need to be interrupted and restarted.
For example, in an online mall system, the configuration center is partially configured as follows:
routeIds=service-search,service-user
service-search.serviceUrl=lb://TRAVELPLAT-SEARCH-SERVICE
service-search.path=/api/search/**
service-user.serviceUrl=me://TRAVELPLAT-ORDER-SERVICE.TRAVELPLAT-COUPON-SERVICE.TRAVELPLAT-ACCOUNT-SERVICE
service-user.path=/api/user/info
the routing rule SERVICE-SEARCH is a SEARCH type SERVICE, aggregation is not needed, lb:// is a non-aggregation request, and when a client accesses a link contained in www.gateway.com/api/SEARCH/, a microservice name-SEARCH system (TRAVELPLAT-SEARCH-SERVICE) corresponding to a network request is acquired.
The routing rule SERVICE-user is a user type SERVICE, aggregation is needed, me:// is a start request, a plurality of SERVICE names (SERVICE-names) are separated by periods, and when a client accesses www.gateway.com/api/user/info link, a microservice name-ORDER system (TRAVELPLAT-ORDER-SERVICE), a COUPON system (TRAVELPLAT-COUPON-SERVICE) and a user information system (TRAVELPLAT-ACCOUNT-SERVICE) corresponding to a network request are obtained.
Then, in step S330, the network request is forwarded to the micro-service corresponding to each of the at least two micro-service names. Since the network locations of the microservices are dynamically assigned. Moreover, because of the requirements of expansion, invalidation, upgrading and the like, the server where the micro service is located is also changed frequently, and when the micro service is started, the information of the micro service needs to be registered in the registry to generate a service list, and the registry realizes service discovery.
The service list of the registration center comprises micro service names registered from the same or different servers and micro service address information corresponding to each micro service name. According to one embodiment of the invention, address information corresponding to each micro-service name is acquired, and the network request is forwarded to the micro-service corresponding to the micro-service name in the service list of the registration center according to the address information. Specifically, for the aggregate request, a plurality of configured service names are analyzed, addressing is performed simultaneously, and after the addressing is completed, a thread pool is started to perform asynchronous concurrent requests.
It should be noted that the partial stream request has non-readability, for example, when the request parameter is in the request body, the request cannot be forwarded again after the request body fetching parameter is forwarded by means of stream. Therefore, according to an embodiment of the present invention, it is necessary to determine whether a network request can be read only once before forwarding, and if so, encapsulate the network request into byte information that can be read many times. Specifically, whether the POST request exists or not is judged before forwarding, if yes, the flow is copied through the rewritten netyMergeRouteUfUlter, all threads in a thread pool are updated, and the flow information which can be read only once is converted into byte information which can be temporarily stored and read for multiple times. And if the POST request is not the POST request, directly entering a thread pool. The code for this step is as follows:
Figure BDA0002435347590000091
optionally, in this embodiment of the present invention, in order to monitor all the microservices, the method further includes: monitoring the health state of each micro-service in a service list of a registration center in real time through a heartbeat mechanism; and if the heartbeat of the micro service in the service list is not detected, sending alarm information, wherein the alarm information comprises the micro service name of the micro service. Specifically, it may be implemented that each backend service in the service list sends a heartbeat report including its own microservice name at a preset time interval.
Finally, in step S340, the target data in the return results of at least two microservices is obtained, and the target data is merged and sent to the client.
And extracting required target field parameters from each returned result according to the data request, and determining the target field parameters as target data. And performing data conversion on each target data according to a set rule. The set rules may be set by a technician who develops the business system. The data conversion process is a process of converting target data into the same meaning and only representing different ways, such as case conversion and the like. For example, in a user type request of an online mall system, the request is forwarded to an order system to inquire an order list, a coupon list is inquired in the coupon system, basic information such as a nickname and a head portrait of a user is inquired in a user information system, the return of three systems is waited, target data in the three types of results are integrated into a format required by a client, and the target data are returned to the client once.
Further, the asynchronous thread pool is used for obtaining return data, waiting is carried out before the requests of all threads in the thread pool are returned, and when the waiting time threshold value is exceeded, target data which are returned currently are merged. According to an embodiment of the present invention, the threshold may be set to 500ms, and the asynchronous requests for multiple services ideally should be substantially consistent with the efficiency of a single request for a service, and 500ms is the baseline for the efficiency of a service request.
The network request is divided into an aggregation request and a non-aggregation request, for the non-aggregation request, the routing information of the network request is read, the network request is forwarded to a single micro service in a service list of a registration center according to the routing information, target data in a return result of the micro service is obtained according to the network request, and the target data are sent to the client. For example, when a client accesses a link included in www.gateway.com/api/SEARCH/, a SEARCH type request in an online mall system forwards the request to an address corresponding to/api/SEARCH/, which is on a SERVICE named TRAVELPLAT-SEARCH-SERVICE in a registry, and the address can be modified through other configurations, is consistent with a client access address by default, and obtains a plurality of SEARCH results with the same data type and returns the SEARCH results to the client.
Specifically, the step of returning the data to the client includes giving the original request header information to the route for forwarding the data and returning the data to the client. After the single request or the aggregated request is forwarded, the data returned to the client is subjected to subsequent processing, including a series of unified operations such as resource statistics and log arrangement, so that a perfect data statistics and flow analysis function is provided for the invention.
According to the technical scheme of the invention, when the return data of a plurality of micro services are needed at the same time, only one network request needs to be sent, a plurality of micro service names corresponding to the network request are obtained according to the routing information of the network request, and the network request is forwarded to a plurality of micro services corresponding to the micro service names, so that the target data in the return results of the micro services can be obtained and merged and returned to the client, and the influence on the user experience caused by the performance problem of the client terminal equipment is avoided. The complexity of the client is greatly reduced while the resource request of the client is reduced, so that the client is more concise to develop.
The routing information comprises a mapping relation between the aggregation request and the micro service name, and when the mapping relation needs to be modified, the routing information of the network request is correspondingly modified, so that the function needing aggregation can be changed. Furthermore, the configuration center is used for configuring the routing information requested by the network, and when the routing information is modified, the gateway only needs to reread the configuration to realize dynamic routing without interrupting and restarting the system.
To further illustrate the above method in conjunction with the system, fig. 4 shows a schematic diagram of a network request processing module 400 according to another embodiment of the invention. The network request processing module 400 includes: client 410, gateway 420, registry 430, configuration center 440, server 450. When the client 410 needs to request the micro service in the back-end server 450, the network request sent by the client 410 passes through the gateway 420, and the gateway 420 forwards the service request to the server 450 where the micro service is located according to the routing information provided by the configuration center 440.
The client 410 is adapted to issue network requests that are divided into aggregated requests and non-aggregated requests according to one embodiment of the invention. The aggregated request corresponds to a plurality of micro-services, and a mapping relationship between the network request and the plurality of micro-services needs to be created before. For example, to implement the function of network request a, micro service a and micro service B need to be called, and a mapping relationship between network request a and micro service B is created, which is represented by the routing information of network request. The distinction between aggregate requests and non-aggregate requests may be made on demand.
In particular, when the function of the network request is to return a page, the search type request does not need to be aggregated, whereas the user type request needs to be configured as an aggregated request. Because the input parameters of the search service are complex, various search conditions exist, the data volume of the returned result set is large, but the types in the result set are the same.
The gateway 420 is adapted to receive a network request from a client, obtain a micro service name corresponding to the network request, forward the network request to a micro service corresponding to the micro service name, obtain target data in a returned result of the micro service, merge the target data, and send the merged target data to the client 410.
When the gateway 420 receives a network request, it determines whether the network request is an aggregation request, and if so, obtains at least two micro service names corresponding to the network request, where the mapping relationship between the aggregation request and the micro service names is embodied by the routing information. And then forwarding the network request to the micro services corresponding to the at least two micro service names respectively, acquiring the address information corresponding to each micro service name, and forwarding the network request to the micro service corresponding to the micro service name in the service list of the registration center 430 according to the address information. Specifically, for the aggregate request, a plurality of configured service names are analyzed, addressing is performed simultaneously, and after the addressing is completed, a thread pool is started to perform asynchronous concurrent requests. It should be noted that the partial stream request has non-readability, for example, when the request parameter is in the request body, the request cannot be forwarded again after the request body fetching parameter is forwarded by means of stream. Therefore, according to an embodiment of the present invention, it is necessary to determine whether a network request can be read only once before forwarding, and if so, encapsulate the network request into byte information that can be read many times. The specific packaging method is set forth in detail in step S330, and will not be described herein.
After obtaining the target data in the returned results of at least two microservices corresponding to the aggregation request, the gateway 420 merges the target data and sends the merged target data to the client 410. The merging mode can be that required target field parameters are extracted from all returned results according to the data request, the target field parameters are determined to be target data, and data conversion is carried out on all the target data according to set rules. The set rules may be set by a technician who develops the business system. Furthermore, the asynchronous thread pool can obtain the returned data, waits before the requests of all threads in the thread pool are returned, and merges the returned target data when the waiting time threshold is exceeded, so that the influence on user experience caused by the time-out of the requests is avoided.
If the gateway 420 receives the non-aggregation request, the routing information of the network request is read, the network request is forwarded to a single micro service in the service list of the registry 430 according to the routing information, the target data in the returned result of the micro service is obtained according to the network request, and the target data is sent to the client 410.
The registry 430 includes a service list, the service list includes micro-service names registered from the same or different servers and micro-service address information corresponding to each micro-service name, and the gateway forwards the network request to the micro-service corresponding to the micro-service name according to the address information. Since the network locations of the microservices are dynamically assigned. Moreover, because of the requirements of expansion, invalidation, upgrading and the like, the server where the micro service is located is also changed frequently, and when the micro service is started, the information of the micro service needs to be registered in the registration center 430 to generate a service list, and the registration center 430 realizes service discovery.
And the configuration center 440 is suitable for configuring the routing information of the network request, and the gateway acquires the micro service name in the service list of the registration center according to the routing information. The aforementioned routing information embodying the mapping relationship between the network request and the microservice name is implemented by the configuration center 440 when creating the relationship between the network request and the microservice name, and correspondingly, the network request may be an aggregation request or a non-aggregation request, and the mapping relationship is determined by a service scenario according to a more practical situation.
It should be noted that, in the existing technology of uniformly providing the entries of each microservice through a gateway, the original routing manner of acquiring the network request is to automatically read the routing information from the engineering-dependent configuration file or to hard code the routing information into the gateway code, and the flow of the configuration center is not involved. The invention changes the route mode of obtaining the network request into reading from external information such as a database or other storage media, can flexibly define the route information rule and lays a foundation for the aggregation of the request. Further, the configuration center 440 is utilized to store routing rules while dynamically loading routes. The load route is read from the configuration center 440. Each time the configuration center 440 issues a configuration update, an update event is sent to the entire gateway 420 to validate the re-read routing rules. The configuration center 440 is used for configuring the routing information of the network request, and when the routing information is modified, the gateway only needs to reread the configuration to realize dynamic routing without interrupting and restarting the system.
The server 450, contains the microservices corresponding to the network requests because the network locations of the microservices are dynamically assigned. And because the server 450 in which the micro service is located is also changed frequently due to the requirements of expansion, failure, upgrade, and the like, the micro service needs to register its own information in the registry 430 when being enabled.
In the existing micro-service architecture, a technology for uniformly providing an entrance of each micro-service through a gateway is adopted, but the integration of different micro-service functions is not carried out completely, when a client needs return data of a plurality of micro-services at the same time, the client still needs to send a plurality of concurrent requests to the plurality of micro-services through the gateway, a large amount of resources are wasted, the performances of terminal equipment of each client are different, and when the performances of the terminal equipment are not good, the user experience is not good. In the network request processing system, when the return data of a plurality of micro services are needed at the same time, the client only needs to send one network request, the gateway acquires a plurality of micro service names corresponding to the network request according to the routing information of the network request, and forwards the network request to the plurality of micro services corresponding to the micro service names, so that the target data in the return results of the micro services can be acquired, and the target data is merged and returned to the client, thereby avoiding the influence on the user experience caused by the performance problem of the client terminal equipment. The complexity of the client is greatly reduced while the resource request of the client is reduced, so that the client is more concise to develop.
The routing information comprises a mapping relation between the aggregation request and the micro service name, when the mapping relation needs to be modified, the routing information of the network request is modified correspondingly without replacing hardware or recoding, so that the function needing aggregation can be changed, and the complexity of a service system is reduced. Furthermore, the configuration center is used for configuring the routing information requested by the network, and when the routing information is modified, the gateway only needs to reread the configuration to realize dynamic routing without interrupting and restarting the system.
A6, the method of any one of A1-A5, the time threshold being 500 ms.
A8, the method according to any one of A2-A7, when the mapping needs to be modified, correspondingly modifying the routing information of the network request.
A9, the method of A1, further comprising the steps of:
if the network request is not an aggregation request, reading the routing information of the network request;
forwarding the network request to a single micro-service in a registry service list according to the routing information;
and acquiring target data in a return result of the micro service according to the network request, and sending the target data to a client.
A10, the method of any one of A1-A9, further comprising the steps of:
monitoring the health state of each micro-service in a service list of a registration center in real time through a heartbeat mechanism;
and if the heartbeat of the micro service in the service list is not detected, sending alarm information, wherein the alarm information comprises the micro service name of the micro service.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense, and the scope of the present invention is defined by the appended claims.

Claims (10)

1. A network request processing method, the method being adapted to be executed in a computing device, the computing device being adapted to connect with a client, comprising the steps of:
receiving a network request sent by a client;
judging whether the network request is an aggregation request or not, if so, acquiring at least two micro service names corresponding to the network request;
forwarding the network request to the micro services corresponding to the at least two micro service names respectively;
and acquiring target data in the return results of at least two micro services, merging the target data, and sending the merged target data to the client.
2. The method of claim 1, wherein the obtaining at least two micro service names corresponding to the network request comprises:
and reading the routing information of the aggregation request, and acquiring at least two micro service names corresponding to the aggregation request according to the routing information, wherein the routing information comprises the mapping relation between the aggregation request and the micro service names.
3. The method according to claim 1 or 2, wherein said forwarding the network request to the micro-service corresponding to each of the at least two micro-service names comprises the steps of:
and acquiring address information corresponding to each micro-service name, and forwarding the network request to the micro-service corresponding to the micro-service name in the service list of the registration center according to the address information.
4. A method according to any of claims 1-3, said forwarding said network request to a microservice corresponding to a microservice name in a registry service list based on said address information, comprising the steps of:
and judging whether the network request can be read only once, if so, packaging the network request into byte information which can be read for many times.
5. The method of any of claims 1-4, wherein said obtaining target data in returned results of at least two microservices, comprises the steps of:
and waiting before obtaining all the request return results, and merging the target data returned currently when the time threshold is exceeded.
6. The method according to any of claims 1-5, before said obtaining at least two micro services corresponding to said network request, comprising the steps of: and creating a mapping relation between the network request and each micro service name.
7. A network request processing system comprising:
a client adapted to issue a network request;
the gateway is suitable for receiving a network request from a client, acquiring a micro service name corresponding to the network request, forwarding the network request to a micro service corresponding to the micro service name, acquiring target data in a return result of the micro service, merging the target data and sending the target data to the client;
the registration center comprises a service list, the service list comprises micro service names registered by the same or different servers and micro service address information corresponding to each micro service name, and the gateway forwards the network request to the micro service corresponding to the micro service name according to the address information;
the gateway acquires a micro service name in a service list of a registration center according to the routing information;
a server containing a microservice corresponding to the network request.
8. The system of claim 7, wherein the gateway is further adapted to determine whether the network request is an aggregated request, and if so, obtain at least two microservices corresponding to the network request.
9. A computing device, comprising:
at least one processor; and
a memory storing program instructions, wherein the program instructions are configured to be adapted to be executed by the at least one processor, the program instructions comprising instructions for performing the network request processing method of claims 1-6.
10. A readable storage medium storing program instructions which, when read and executed by a client, cause the client to perform the method of any one of claims 1-6.
CN202010250602.8A 2020-04-01 2020-04-01 Network request processing method, computing device and storage medium Pending CN111586097A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010250602.8A CN111586097A (en) 2020-04-01 2020-04-01 Network request processing method, computing device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010250602.8A CN111586097A (en) 2020-04-01 2020-04-01 Network request processing method, computing device and storage medium

Publications (1)

Publication Number Publication Date
CN111586097A true CN111586097A (en) 2020-08-25

Family

ID=72119128

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010250602.8A Pending CN111586097A (en) 2020-04-01 2020-04-01 Network request processing method, computing device and storage medium

Country Status (1)

Country Link
CN (1) CN111586097A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112866379A (en) * 2021-01-15 2021-05-28 浪潮云信息技术股份公司 Access method and device of microservice
CN114584451A (en) * 2022-01-18 2022-06-03 北京智象信息技术有限公司 Method and device for debugging internal service interface based on micro-service environment
CN114817821A (en) * 2022-06-30 2022-07-29 数字广东网络建设有限公司 Display method and device of government affair information, electronic equipment and storage medium
CN115118787A (en) * 2022-06-21 2022-09-27 京东科技信息技术有限公司 Service control method, system, storage medium and electronic equipment

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170364434A1 (en) * 2016-06-15 2017-12-21 International Business Machines Corporation Splitting and merging microservices
CN108234566A (en) * 2016-12-21 2018-06-29 阿里巴巴集团控股有限公司 The data processing method and device of a kind of cluster
CN108847989A (en) * 2018-06-29 2018-11-20 杭州安恒信息技术股份有限公司 Log processing method, business service system and electronic equipment based on micro services framework
CN108900329A (en) * 2018-06-21 2018-11-27 珠海宏桥高科技有限公司 Real-time dynamic forwarding method based on gateway infrastructure service
CN109086409A (en) * 2018-08-02 2018-12-25 泰康保险集团股份有限公司 Micro services data processing method, device, electronic equipment and computer-readable medium
CN109474685A (en) * 2018-11-16 2019-03-15 中国银行股份有限公司 Service monitoring method and system under a kind of framework based on micro services
CN109639572A (en) * 2018-12-06 2019-04-16 网易(杭州)网络有限公司 Route management method, device and micro services system
CN110008045A (en) * 2019-04-12 2019-07-12 深圳乐信软件技术有限公司 Polymerization, device, equipment and the storage medium of micro services
CN110557284A (en) * 2019-08-30 2019-12-10 贝壳技术有限公司 data aggregation method and device based on client gateway
CN110837424A (en) * 2019-10-15 2020-02-25 东软集团股份有限公司 Service instance determining method and device, storage medium and electronic equipment

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170364434A1 (en) * 2016-06-15 2017-12-21 International Business Machines Corporation Splitting and merging microservices
CN108234566A (en) * 2016-12-21 2018-06-29 阿里巴巴集团控股有限公司 The data processing method and device of a kind of cluster
CN108900329A (en) * 2018-06-21 2018-11-27 珠海宏桥高科技有限公司 Real-time dynamic forwarding method based on gateway infrastructure service
CN108847989A (en) * 2018-06-29 2018-11-20 杭州安恒信息技术股份有限公司 Log processing method, business service system and electronic equipment based on micro services framework
CN109086409A (en) * 2018-08-02 2018-12-25 泰康保险集团股份有限公司 Micro services data processing method, device, electronic equipment and computer-readable medium
CN109474685A (en) * 2018-11-16 2019-03-15 中国银行股份有限公司 Service monitoring method and system under a kind of framework based on micro services
CN109639572A (en) * 2018-12-06 2019-04-16 网易(杭州)网络有限公司 Route management method, device and micro services system
CN110008045A (en) * 2019-04-12 2019-07-12 深圳乐信软件技术有限公司 Polymerization, device, equipment and the storage medium of micro services
CN110557284A (en) * 2019-08-30 2019-12-10 贝壳技术有限公司 data aggregation method and device based on client gateway
CN110837424A (en) * 2019-10-15 2020-02-25 东软集团股份有限公司 Service instance determining method and device, storage medium and electronic equipment

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112866379A (en) * 2021-01-15 2021-05-28 浪潮云信息技术股份公司 Access method and device of microservice
CN114584451A (en) * 2022-01-18 2022-06-03 北京智象信息技术有限公司 Method and device for debugging internal service interface based on micro-service environment
CN114584451B (en) * 2022-01-18 2023-10-17 北京智象信息技术有限公司 Method and device for debugging internal service interface based on micro-service environment
CN115118787A (en) * 2022-06-21 2022-09-27 京东科技信息技术有限公司 Service control method, system, storage medium and electronic equipment
CN114817821A (en) * 2022-06-30 2022-07-29 数字广东网络建设有限公司 Display method and device of government affair information, electronic equipment and storage medium
CN114817821B (en) * 2022-06-30 2022-09-16 数字广东网络建设有限公司 Display method and device of government affair information, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111586097A (en) Network request processing method, computing device and storage medium
CN111427766B (en) Request processing method and device and proxy server
CN111221521B (en) Method, device, computer system and readable storage medium for generating log code
CN108696381B (en) Protocol configuration method and device
CN111290806B (en) Calling method and device of application program interface, computer equipment and storage medium
CN107688538B (en) Script execution method and device and computing equipment
CN110351325B (en) Data processing method and related equipment
CN109831466B (en) Micro-service business processing method and nginx server
US20220231926A1 (en) Standardized format for containerized applications
CN109617647B (en) Message conversion method and device, computer equipment and computer readable storage medium
WO2023185166A1 (en) Service call method and apparatus, device and storage medium
CN113448756B (en) Inter-process communication system and method and computing device
CN110365724A (en) Task processing method, device and electronic equipment
CN109885347B (en) Method, device, terminal, system and storage medium for acquiring configuration data
WO2021179156A1 (en) Message processing method, device and system, and server
CN112417014A (en) Dynamic modification execution plan method, system, and computer-readable storage medium
US20160179450A1 (en) Information processing apparatus and method for information processing apparatus
CN112732468B (en) Data processing method, data interaction system and computing equipment
CN114489622A (en) Js application, electronic device, and storage medium
CN113220366A (en) Sub-application starting method and device, terminal and server
JP2014146276A (en) Client, server, management system and method thereof
US10437919B2 (en) Information processing system, information processing method, document processing system, and storage medium, for deleting a conversion process when a request to generate document data in a first format has been canceled
CN114186958A (en) Method, computing device and storage medium for exporting list data as spreadsheet
CN114301970A (en) Service calling method and device, electronic equipment and storage medium
CN113761588A (en) Data verification method and device, terminal equipment and 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