CN113852663A - Network request processing method and device and network request processing system - Google Patents

Network request processing method and device and network request processing system Download PDF

Info

Publication number
CN113852663A
CN113852663A CN202110951052.7A CN202110951052A CN113852663A CN 113852663 A CN113852663 A CN 113852663A CN 202110951052 A CN202110951052 A CN 202110951052A CN 113852663 A CN113852663 A CN 113852663A
Authority
CN
China
Prior art keywords
request
network request
network
concurrent
pool
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
CN202110951052.7A
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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information 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 Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202110951052.7A priority Critical patent/CN113852663A/en
Publication of CN113852663A publication Critical patent/CN113852663A/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
    • 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/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • 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/61Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources taking into account QoS or priority requirements

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The disclosure relates to a network request processing method, a network request processing device and a network request processing system, wherein the method comprises the following steps: intercepting a first network request; acquiring a global maximum allowable concurrent network request number corresponding to the request pool according to the service vertical type; acquiring the current concurrent network request number corresponding to the request pool, and pushing the first network request into the request pool when the maximum allowed concurrent network request number is identified to be larger than the current concurrent network request number; initiating a network request; and when the current concurrent network request number in the request pool changes, updating and synchronizing the maximum allowed concurrent network request number and the current concurrent network request number. Therefore, the network request is controlled in a finer granularity mode based on the maximum allowed concurrent network request number and the identification result of the current concurrent network request number, and the limitation of the browser on the concurrent network request number is broken through, so that the processing efficiency of the network request is improved, and the page performance is improved.

Description

Network request processing method and device and network request processing system
Technical Field
The present disclosure relates to the field of computer technology application technologies, and in particular, to a method and an apparatus for processing a network request, and a system for processing a network request.
Background
Since the SPA (Single Page Web Application) has the advantages of good interaction experience, separation of front-end and back-end development, capability of properly reducing server pressure, and the like, the SPA has been widely applied to various project architectures. In particular, for large Web (World Wide Web) projects, the framework usually adopts the SPA method, i.e., the content on the page is controlled by JavaScript for display.
However, in the related art, the upper limit of the browser on the number of concurrent requests under the same domain name is limited, so that when the number of network requests such as page requests is large, the processing efficiency of the network requests is low. In addition, when the route is switched, because the route of the SPA is not aware of the browser, the page request of the previous page is not processed, so that useless network requests are increased and concurrent resources are occupied, and the performance of the Web page is reduced.
Therefore, how to improve the processing efficiency of the network request and improve the page performance for the project adopting the SPA architecture becomes an urgent problem to be solved.
Disclosure of Invention
The present disclosure provides a network request processing method, a network request processing device, and a network request processing system, so as to solve at least the problems of low network request processing efficiency, low page performance, and the like in the related art. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, a method for processing a network request is provided, including: intercepting a first network request and constructing a request interceptor queue according to one or more unsent first network requests, wherein the first network request is in a request-in-state; acquiring a service vertical class corresponding to the first network request, and acquiring a global maximum allowable concurrent network request number corresponding to a request pool according to the service vertical class; acquiring the current number of concurrent network requests corresponding to the request pool, and pushing the first network request in the request interceptor queue to the request pool when the maximum allowed number of concurrent network requests is identified to be greater than the current number of concurrent network requests; initiating the network request after the first network request is pushed to the request pool; and updating the maximum allowed concurrent network request number and the current concurrent network request number when the current concurrent network request number in the request pool changes, and synchronizing the updated maximum allowed concurrent network request number and the current concurrent network request number.
According to an embodiment of the present disclosure, after the first network request is pushed to the request pool, and the network request is initiated, the method further includes: intercepting a network request result corresponding to the first network request; and re-acquiring the global maximum allowed number of concurrent network requests and the current number of concurrent network requests, and pushing the second network requests in the request interceptor queue to the request pool when the unsent second network requests exist in the request interceptor queue after the maximum allowed number of concurrent network requests is identified to be greater than the current number of concurrent network requests.
According to an embodiment of the present disclosure, before obtaining the global maximum allowed concurrent network request number corresponding to the request pool according to the service vertical class, the method further includes: and registering a network request method in a network request instance according to the first network request.
According to an embodiment of the present disclosure, the pushing the first network request in the request interceptor queue to a request pool includes: acquiring a queuing sequence and a corresponding priority level corresponding to each first network request in the request interceptor queue; pushing the high-priority first network request to the request pool according to the enqueue order when the high-priority first network request exists.
According to an embodiment of the present disclosure, said pushing the high priority first network request to the request pool according to the enqueue order includes: acquiring the number of the first network requests with high priority; pushing the high-priority first network request with the enqueue order first to the request pool when the number is greater than or equal to two; pushing the high priority first network request to the request pool when the number is less than two.
According to an embodiment of the present disclosure, further comprising: pushing the first network request that is enqueued first to the request pool when the high priority first network request is not present.
According to an embodiment of the present disclosure, after the obtaining a corresponding enqueue order and a corresponding priority level of each first network request in the request interceptor queue, the method includes: acquiring a corresponding field of each first network request in a database; determining a preconfigured request weight in the field.
According to an embodiment of the present disclosure, the first network request is a cancel request for the first network request, further comprising: receiving the cancel request instruction; according to the request canceling instruction, sending a first searching instruction to the request interceptor to obtain a corresponding request identity, and according to the request identity, obtaining a corresponding network request; and when the corresponding network request is acquired, acquiring the corresponding network request instance and registering a network request canceling method to cancel the network request.
According to an embodiment of the present disclosure, further comprising: and when the corresponding network request is not acquired, sending a second searching instruction to the request pool so that the request pool acquires the corresponding network request to cancel the network request.
According to a second aspect of the embodiments of the present disclosure, there is provided an apparatus for processing a network request, the apparatus including: a first interception unit configured to perform intercepting a first network request and construct a request interceptor queue according to one or more un-issued first network requests, wherein the first network request is in a request-in-state; the first obtaining unit is configured to execute obtaining of a service vertical class corresponding to the first network request, and obtain a global maximum allowed concurrent network request number corresponding to a request pool according to the service vertical class; a second obtaining unit, configured to perform obtaining of a current number of concurrent network requests corresponding to the request pool, and push the first network request in the request interceptor queue to the request pool when it is identified that the maximum allowed number of concurrent network requests is greater than the current number of concurrent network requests; an initiating unit configured to perform initiating the network request after the first network request is pushed into the request pool; and the synchronization unit is configured to update the maximum allowed concurrent network request number and the current concurrent network request number when the current concurrent network request number in the request pool changes, and synchronize the updated maximum allowed concurrent network request number and the current concurrent network request number.
According to an embodiment of the present disclosure, the method further includes a second intercepting unit configured to perform: intercepting a network request result corresponding to the first network request; and re-acquiring the global maximum number of allowed concurrent network requests and the current number of concurrent network requests, and pushing the second network requests in the request interceptor queue to the request pool when the unsent second network requests exist in the request interceptor queue after the maximum number of allowed concurrent network requests is identified to be greater than the current number of concurrent network requests.
According to an embodiment of the present disclosure, the first intercepting unit is further configured to perform: and registering a network request method in a network request instance according to the first network request.
According to an embodiment of the present disclosure, the second obtaining unit is further configured to perform: acquiring a queuing sequence and a corresponding priority level corresponding to each first network request in the request interceptor queue; pushing the high-priority first network request to the request pool according to the enqueue order when the high-priority first network request exists.
According to an embodiment of the present disclosure, the second obtaining unit is further configured to perform: acquiring the number of the first network requests with high priority; pushing the high priority first network request that is enqueued first to the request pool when the number is greater than or equal to two; pushing the high priority first network request to the request pool when the number is less than two.
According to an embodiment of the present disclosure, the second obtaining unit is further configured to perform: pushing the first network request that is enqueued sequentially first to the request pool when the high priority first network request is not present.
According to an embodiment of the present disclosure, the second obtaining unit is further configured to perform: acquiring a corresponding field of each first network request in a database; determining a preconfigured request weight in the field.
According to an embodiment of the present disclosure, the first network request is a cancel request for the first network request, further comprising: a receiving unit configured to perform receiving the cancel request instruction; a third obtaining unit, configured to execute sending a first search instruction to the request interceptor according to the cancel request instruction, so as to obtain a corresponding request identity, and obtain the corresponding network request according to the request identity; and the canceling unit is configured to execute, when the corresponding network request is acquired, acquiring the corresponding network request instance and registering a network request canceling method to cancel the network request.
According to an embodiment of the present disclosure, the cancelling unit is further configured to perform: and when the corresponding network request is not acquired, sending a second searching instruction to the request pool so that the request pool acquires the corresponding network request to cancel the network request.
According to a third aspect of the embodiments of the present disclosure, there is provided a network request processing system, the system including: a processing device for network requests, a request interceptor, a request pool and a response interceptor according to the embodiment of the second aspect of the disclosure; the request interceptor is used for intercepting the network request in a request state; the request pool is used for caching the network request; and the response interceptor is used for intercepting a network request result corresponding to the network request.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method for processing a network request as provided in the first aspect of the disclosure.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform a method of processing a network request as provided in the first aspect of the present disclosure.
According to a sixth aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method of processing a network request as provided in the first aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
according to the method, the first network request in the request state is intercepted, the global maximum allowed concurrent network request number and the current concurrent network request number corresponding to the request pool are obtained, when the maximum allowed concurrent network request number is larger than the current concurrent network request number, the first network request in the request interceptor queue is pushed into the request pool, and then the network request is initiated after the first network request is pushed into the request pool, so that the network request is controlled in a finer granularity mode based on the identification results of the maximum allowed concurrent network request number and the current concurrent network request number, the limitation of a browser on the concurrent network request number is broken through, the processing efficiency of the network request is improved, and the page performance is improved. Further, the public method can update the maximum allowed concurrent network request number and the current concurrent network request number after identifying that the current concurrent network request number in the request pool changes every time, and synchronize the updated maximum allowed concurrent network request number and the current concurrent network request number so as to process the network requests according to the updated maximum allowed concurrent network request number and the current concurrent network request number.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
Fig. 1 is a flow chart illustrating a method of processing a network request according to an example embodiment.
Fig. 2 is a flow chart illustrating another method of processing a network request in accordance with an example embodiment.
Fig. 3 is a flow chart illustrating another method of processing a network request in accordance with an example embodiment.
Fig. 4 is a flow chart illustrating another method of processing a network request in accordance with an example embodiment.
Fig. 5 is a flow chart illustrating another method of processing a network request in accordance with an example embodiment.
Fig. 6 is a flow chart illustrating another method of processing a network request in accordance with an example embodiment.
Fig. 7 is a flow chart illustrating another method of processing a network request in accordance with an example embodiment.
Fig. 8 is a flow diagram illustrating an overall processing procedure of a network request process in accordance with an exemplary embodiment.
Fig. 9 is a block diagram illustrating an apparatus for processing a network request in accordance with an example embodiment.
Fig. 10 is a block diagram illustrating another apparatus for processing a network request in accordance with an example embodiment.
Fig. 11 is a block diagram illustrating another apparatus for processing a network request in accordance with an example embodiment.
FIG. 12 is a block diagram illustrating a network request processing system in accordance with an exemplary embodiment.
FIG. 13 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a flow chart illustrating a method of processing a network request according to an example embodiment. It should be noted that the main execution body of the network request processing method disclosed by the present disclosure is a network request processing device. The network request processing method according to the embodiment of the present disclosure may be executed by a network request processing apparatus according to the embodiment of the present disclosure, and the network request processing apparatus may specifically be a hardware device, or software in the hardware device, or the like. The hardware devices include, for example, terminal devices, servers, and the like.
As shown in fig. 1, the method for processing a network request according to this embodiment includes the following steps:
in step 101, a first network request is intercepted and a request interceptor queue is constructed from one or more un-issued first network requests, wherein the first network request is in a request-in-progress state.
In the embodiment of the present disclosure, the request interceptor may intercept a network request sent by a user, where the intercepted network request sent by the user is a network request in a request state, and a request interceptor queue is formed according to an intercepted sequence.
For example, Vue-resources (interface request plug-in) And Axios (client) are taken as examples, And both depend on Ajax (asynchronous Javascript And xml) And encapsulate Ajax uniformly. In this case, the exposed interceptor writes the corresponding method and Ajax in that method.
When the method is executed, the request interceptor firstly executes data, such as Token (Token/mark) and encryption code required at the back end, which are required to be added to a request header during request once, assigns values to a variable, and then transmits the variable to Ajax in a conventional manner. Further, Ajax, the so-called request intercept, may be performed. That is, the data to be added is executed first, and then Ajax is executed, and the process of adding data is the execution process of the request interceptor.
Among them, Axios refers to a Hyper Text Transfer Protocol (HTTP) client based on the program (noun).
The Ajax refers to a Web interaction mode of asynchronous JavaScript and XML (eXtensible Markup Language).
In step 102, a service vertical class corresponding to the first network request is obtained, and a global maximum allowable concurrent network request number corresponding to the request pool is obtained according to the service vertical class.
It should be noted that, in the present disclosure, the global maximum allowed concurrent network request number corresponding to the request pool may be configured according to different scenarios of the service. Optionally, a service vertical class corresponding to the first network request may be obtained, and the global maximum allowable concurrent network request number corresponding to the request pool may be obtained according to the service vertical class.
The service vertical class corresponding to the first network request may be a vertical class corresponding to any service application scenario, and a specific division manner of the service vertical class is not limited in this disclosure. Optionally, the queue length of the request pool queue may be obtained, and the current concurrent network request number corresponding to the request pool may be determined according to the queue length.
It should be noted that, since the global maximum allowed number of concurrent network requests corresponding to the request pool provided in the present disclosure may be configured according to different scenarios of the service, when an application scenario of the service changes, the corresponding service vertical class may also change. In this case, the current service vertical class can be dynamically acquired and updated.
In step 103, the current number of concurrent network requests corresponding to the request pool is obtained, and when it is identified that the maximum allowed number of concurrent network requests is greater than the current number of concurrent network requests, the first network request in the request interceptor queue is pushed to the request pool.
In the embodiment of the present disclosure, after the global maximum allowed concurrent network request number and the current concurrent network request number corresponding to the request pool are obtained, the global maximum allowed concurrent network request number and the current concurrent network request number corresponding to the request pool may be compared, and if it is identified that the maximum allowed concurrent network request number is greater than the current concurrent network request number, the first network request in the request interceptor queue may be pushed to the request pool; if the maximum number of allowed concurrent network requests is identified to be less than or equal to the current number of concurrent network requests, no operation may be performed on the network requests in the request interceptor queue.
It should be noted that, in the present disclosure, before obtaining the global maximum allowed number of concurrent network requests corresponding to the request pool and the current number of concurrent network requests, a network request method may be registered in the network request instance according to the first network request, so as to be invoked when the request is cancelled.
In step 104, a network request is initiated after the first network request is pushed into the request pool.
In the embodiment of the present disclosure, after pushing the first network request in the request interceptor queue to the request pool, a method of the request instance may be called, and the HTTP request is initiated.
In step 105, when the current number of concurrent network requests in the request pool changes, the maximum number of allowed concurrent network requests and the current number of concurrent network requests are updated, and the updated maximum number of allowed concurrent network requests and the current number of concurrent network requests are synchronized.
In the embodiment of the present disclosure, for any one processing procedure of the request interceptor and the response interceptor, the maximum allowed concurrent network request number and the current concurrent network request number are determined, and the updated maximum allowed concurrent network request number and the current concurrent network request number are synchronized.
In this case, the dynamically modified current number of concurrent network requests will take effect in time.
According to the method, the first network request in the request state is intercepted, the global maximum allowed concurrent network request number and the current concurrent network request number corresponding to the request pool are obtained, when the maximum allowed concurrent network request number is larger than the current concurrent network request number, the first network request in the request interceptor queue is pushed into the request pool, and then the network request is initiated after the first network request is pushed into the request pool, so that the network request is controlled in a finer granularity mode based on the identification results of the maximum allowed concurrent network request number and the current concurrent network request number, the limitation of a browser on the concurrent network request number is broken through, the processing efficiency of the network request is improved, and the page performance is improved. Further, the public method can update the maximum allowed concurrent network request number and the current concurrent network request number after identifying that the current concurrent network request number in the request pool changes every time, and synchronize the updated maximum allowed concurrent network request number and the current concurrent network request number so as to process the network requests according to the updated maximum allowed concurrent network request number and the current concurrent network request number.
Further, after initiating the network request, the response interceptor may intercept a network request result corresponding to the first network request.
As a possible implementation manner, as shown in fig. 2, on the basis of the foregoing embodiment, a specific process after the foregoing step 103 includes the following steps:
in step 201, a network request result corresponding to the first network request is intercepted.
In the embodiment of the disclosure, the response interceptor may intercept a network request result corresponding to the first network request.
For example, the response interceptor may perform relevant operations after receiving the response, such as jumping to the login page when the server returns the network request result that the login status is invalid and needs to be logged in again. For the response interceptor, namely after the network request result is returned, the result is not directly exported, but the network request result information such as the response code and the like is processed, and the processed result is exported to the page. The process of processing the network request result information such as the response code is the execution process of the response interceptor.
In step 202, the global maximum allowed number of concurrent network requests and the current number of concurrent network requests are obtained again, and after the maximum allowed number of concurrent network requests is identified to be greater than the current number of concurrent network requests, when a second network request which is not sent exists in the request interceptor queue, the second network request in the request interceptor queue is pushed into the request pool.
In the embodiment of the disclosure, after a network request result corresponding to a first network request is intercepted, the global maximum allowed concurrent network request number and the current concurrent network request number may be obtained again, and the global maximum allowed concurrent network request number and the current concurrent network request number corresponding to a request pool are compared, if it is identified that the maximum allowed concurrent network request number is greater than the current concurrent network request number, it may be determined whether a second network request that is not sent exists in a request interceptor queue; if the maximum allowed number of concurrent network requests is identified to be less than or equal to the current number of concurrent network requests, no operation may be performed on the network requests in the request interceptor queue.
Further, after the second network request which is not sent exists in the request interceptor queue, the second network request in the request interceptor queue can be pushed into the request pool, and the method of the request instance can be called to initiate the HTTP request.
The method comprises intercepting a network request result corresponding to a first network request, re-acquiring a global maximum allowed concurrent network request number and a current concurrent network request number, pushing a second network request in a request interceptor queue to a request pool when judging that a second network request which is not sent exists in the request interceptor queue after the maximum allowed concurrent network request number is larger than the current concurrent network request number, so that the maximum allowed concurrent network request number and the current concurrent network request number corresponding to the request pool are re-acquired after a response interceptor intercepts the network request result, controlling the network request in the request interceptor queue based on the updated maximum allowed concurrent network request number and the identification result of the current concurrent network request number, and breaking through the limitation of a browser on the concurrent network request number, the processing efficiency of the network request is further improved, and the page performance is improved.
It should be noted that, when a plurality of network requests are queued in the request interceptor queue, the matching first network request may be determined based on a preset push policy, and the first network request is pushed into the request pool.
As a possible implementation manner, as shown in fig. 3, on the basis of the foregoing embodiment, a specific process after the foregoing step 102 includes the following steps:
in step 301, an enqueue order and a corresponding priority level of each first network request in the request interceptor queue are obtained.
Alternatively, the corresponding enqueue order may be obtained by obtaining the intercepted order corresponding to the first network request.
Alternatively, the corresponding priority level may be obtained by obtaining a field corresponding to the first network request.
It should be noted that, in the present disclosure, after obtaining the enqueue order and the corresponding priority level corresponding to each first network request in the request interceptor queue, it may be determined whether there is a high-priority first network request.
As a possible implementation manner, as shown in fig. 4, on the basis of the foregoing embodiment, a specific process of determining whether there is a high-priority first network request includes the following steps:
in step 401, a corresponding field in the database for each first network request is obtained.
And the reserved position in the field is pre-configured with related information for judging whether the network request is a high-priority request.
In step 402, the pre-configured request weight in the field is determined, and whether a high-priority first network request exists is judged according to the request weight.
In step 302, when there is a high priority first network request, the high priority first network request is pushed to the request pool according to the enqueue order.
Optionally, when there is a high-priority First network request, the First-queued high-priority First network request may be preferentially pushed into the request pool based on a FIFO (First Input First Output) principle; alternatively, when there is no high priority first network request, the first network request with the enqueue order first may be pushed into the request pool first based on the FIFO principle only.
As a possible implementation manner, as shown in fig. 5, on the basis of the foregoing embodiment, a specific process of pushing the high-priority first network request to the request pool according to the enqueue order in step 302 includes the following steps:
in step 501, the number of high priority first network requests is obtained.
It should be noted that, in the present disclosure, after obtaining the number of the high-priority first network requests, it may be determined whether the number is greater than or equal to two.
For example, the first network request a, the first network request b, and the first network request c are acquired as high-priority network requests, and in this case, the number of the high-priority first network requests is greater than two.
In step 502, when the number is greater than or equal to two, the first network request with the high priority in the enqueue order is pushed to the request pool.
For example, the first network request a, the first network request b, and the first network request c are obtained as high-priority network requests, and the enqueuing order of the first network request is the first network request a, the first network request b, and the first network request c, in this case, the first network request a may be pushed into the request pool.
In step 503, when the number is less than two, the high priority first network request is pushed to the request pool.
For example, when only the first network request a is a high-priority network request, the first network request a may be directly pushed into the request pool.
According to the method and the device, the enqueue sequence and the corresponding priority level of each first network request in the request interceptor queue are obtained, and when the first network request with high priority exists, the first network request with high priority is pushed into the request pool according to the enqueue sequence, so that the network requests in the request interceptor queue are more reasonably dynamically controlled based on the FIFO principle and the priority level corresponding to the first network request, the processing efficiency of the network requests is further improved, and the page performance is improved.
It should be noted that, based on the network request processing method provided by the present disclosure, any first network request cancellation can be implemented.
As a possible implementation manner, as shown in fig. 6, on the basis of the foregoing embodiment, the method specifically includes the following steps:
in step 601, a cancel request instruction is received.
In the disclosed embodiment, the cancellation of any request consists of two parts, namely the processing of the request interceptor and the processing of the request pool. In this case, the request interceptor may receive a cancel request instruction.
In step 602, according to the cancel request instruction, a first search instruction is sent to the request interceptor to obtain a corresponding request identity, and a corresponding network request is obtained according to the request identity.
In the embodiment of the present disclosure, after receiving the Request canceling instruction, the Request interceptor may obtain a corresponding Request identity (Request ID), and obtain a corresponding network Request according to the Request ID.
In step 603, when the corresponding network request is obtained, the corresponding network request instance is obtained and the network request cancellation method is registered, so as to cancel the network request.
In the embodiment of the present disclosure, when the corresponding Request ID is obtained, the Request may be found in the Request interceptor queue according to the Request ID and the Request ID. Optionally, when finding the corresponding request, obtaining a corresponding network request instance and registering a network request cancellation method, at this time, obtaining and judging the maximum allowed concurrent network request number and the current concurrent network request number of the request pool again, and performing request processing; optionally, when the corresponding network request is not obtained, the request pool may be notified to search, obtain the corresponding network request instance, and register a network request cancellation method to cancel the network request.
According to the method and the device, the cancel Request instruction is received, the first search instruction is sent to the Request interceptor according to the cancel Request instruction so as to obtain the corresponding Request ID, the corresponding network Request is obtained according to the Request ID, and the network Request is cancelled when the corresponding network Request is obtained, so that the Request occupation of a browser and the useless Request of a server are reduced by canceling any network Request, all requests can be interrupted when routing is switched by matching with SPA, and the performance of the Web page is further improved.
Further, in the present disclosure, for any one processing procedure of the request interceptor and the response interceptor, the maximum allowed concurrent network request number and the current concurrent network request number are determined, and the updated maximum allowed concurrent network request number and the current concurrent network request number are synchronized.
As a possible implementation manner, as shown in fig. 7, on the basis of the foregoing embodiment, the method specifically includes the following steps:
in step 701, when the current number of concurrent network requests in the request pool changes, the maximum number of allowed concurrent network requests and the current number of concurrent network requests are updated, and the updated maximum number of allowed concurrent network requests and the current number of concurrent network requests are synchronized.
It should be noted that, in the present disclosure, it may be determined whether the current number of concurrent network requests in the request pool changes or not. Further, when the current number of concurrent network requests in the request pool changes, the maximum number of allowed concurrent network requests and the current number of concurrent network requests may be updated, and the updated maximum number of allowed concurrent network requests and the current number of concurrent network requests may be synchronized.
In the embodiment of the present disclosure, after the current concurrent network request number in the request pool is identified to change each time, the maximum allowed concurrent network request number and the current concurrent network request number may be updated, and the updated maximum allowed concurrent network request number and the current concurrent network request number are synchronized, so as to process the network request according to the updated maximum allowed concurrent network request number and the current concurrent network request number.
In summary, as shown in fig. 8, the network request processing method provided by the present disclosure can dynamically control the concurrency number of the network requests, break through the limitation of the browser on the concurrency number of the network requests, and implement processing of network requests with finer granularity based on the FIFO principle and the priority level corresponding to the network requests, thereby improving the processing efficiency of the network requests. Furthermore, any network request is cancelled, so that the request occupation of the browser and the useless request of the server are reduced, all the requests can be interrupted when the routing is switched by matching with the SPA, and the page performance is improved.
Fig. 9 is a block diagram illustrating an apparatus for processing a network request in accordance with an example embodiment. As shown in fig. 9, the apparatus 100 for processing a network request includes: a first interception unit 11, a first acquisition unit 12, a second acquisition unit 13, an initiation unit 14 and a synchronization unit 15.
The first intercepting unit 11 is configured to perform intercepting a first network request, and construct a request interceptor queue according to one or more unsent first network requests, where the first network request is in a request state;
a first obtaining unit 12, configured to perform obtaining of a service vertical class corresponding to the first network request, and obtain a global maximum allowed concurrent network request number corresponding to a request pool according to the service vertical class;
a second obtaining unit 13, configured to perform obtaining of a current number of concurrent network requests corresponding to the request pool, and push the first network request in the request interceptor queue to the request pool when it is identified that the maximum allowed number of concurrent network requests is greater than the current number of concurrent network requests;
an initiating unit 14 configured to perform initiating the network request after the first network request is pushed into the request pool; and the number of the first and second groups,
a synchronization unit 15, configured to update the maximum allowed number of concurrent network requests and the current allowed number of concurrent network requests when the current allowed number of concurrent network requests in the request pool changes, and synchronize the updated maximum allowed number of concurrent network requests and the current concurrent network requests.
Optionally, as shown in fig. 10, the apparatus 100 for processing a network request further includes a second intercepting unit 16 configured to perform:
intercepting a network request result corresponding to the first network request;
and re-acquiring the global maximum allowed number of concurrent network requests and the current number of concurrent network requests, and pushing the second network requests in the request interceptor queue to the request pool when the unsent second network requests exist in the request interceptor queue after the maximum allowed number of concurrent network requests is identified to be greater than the current number of concurrent network requests.
Optionally, the first intercepting unit 11 is further configured to perform:
and registering a network request method in a network request instance according to the first network request.
Optionally, the second obtaining unit 13 is further configured to perform:
acquiring an enqueuing sequence and a corresponding priority level corresponding to each first network request in the request interceptor queue;
pushing the high-priority first network request to the request pool according to the enqueue order when the high-priority first network request exists.
Optionally, the second obtaining unit 13 is further configured to perform:
acquiring the number of the first network requests with high priority;
pushing the high-priority first network request with the enqueue order first to the request pool when the number is greater than or equal to two;
pushing the high priority first network request to the request pool when the number is less than two.
Optionally, the second obtaining unit 13 is further configured to perform:
pushing the first network request that is enqueued first to the request pool when the high priority first network request does not exist.
Optionally, the second obtaining unit 13 is further configured to perform:
acquiring a corresponding field of each first network request in a database;
determining a preconfigured request weight in the field.
Optionally, the first network request is a cancel request for the first network request, as shown in fig. 11, the apparatus 100 for processing a network request further includes:
a receiving unit 17 configured to perform receiving the cancel request instruction;
a third obtaining unit 18, configured to execute sending a first search instruction to the request interceptor according to the cancel request instruction, so as to obtain a corresponding request identity, and obtain the corresponding network request according to the request identity;
a canceling unit 19, configured to, when the corresponding network request is acquired, acquire the corresponding network request instance and register a network request canceling method to cancel the network request.
Optionally, the cancelling unit 19 is further configured to perform:
and when the corresponding network request is not acquired, sending a second searching instruction to the request pool so that the request pool acquires the corresponding network request to cancel the network request.
According to the method, the first network request in the request state is intercepted, the global maximum allowed concurrent network request number and the current concurrent network request number corresponding to the request pool are obtained, when the maximum allowed concurrent network request number is larger than the current concurrent network request number, the first network request in the request interceptor queue is pushed into the request pool, and then the network request is initiated after the first network request is pushed into the request pool, so that the network request is controlled in a finer granularity mode based on the identification results of the maximum allowed concurrent network request number and the current concurrent network request number, the limitation of a browser on the concurrent network request number is broken through, the processing efficiency of the network request is improved, and the page performance is improved. Further, the public method can update the maximum allowed concurrent network request number and the current concurrent network request number after identifying that the current concurrent network request number in the request pool changes every time, and synchronize the updated maximum allowed concurrent network request number and the current concurrent network request number so as to process the network requests according to the updated maximum allowed concurrent network request number and the current concurrent network request number.
FIG. 13 is a block diagram illustrating a network request processing system in accordance with an exemplary embodiment. As shown in fig. 13, the network request processing system 200 includes: a processing device 100 of network requests, a request interceptor 21, a request pool 22, and a response interceptor 23.
In the embodiment of the present disclosure, the processing procedure of the network request for the Web is mainly divided into the following three stages: a request phase (request interceptor), a process phase (request pool), and a response phase (response interceptor).
Wherein, the request interceptor 21 is configured to intercept the network request in the request state.
Optionally, the request interceptor 21 corresponds to a request interceptor queue, and is responsible for intercepting unsent network requests, and the data structure satisfies the FIFO principle. The queue is entered first when a network request is not issued, and the request interceptor 21 is called when registering the cancel method in the request instance for canceling the request. Further, the request interceptor 21 may obtain the current maximum number of allowed concurrent network requests and the current number of concurrent network requests.
Further, when it is recognized that the maximum allowed number of concurrent network requests is greater than the current number of concurrent network requests, the request interceptor 21 pushes out and adds the high-priority network request at the head of the queue to the request pool 22.
Wherein, the request pool 22 is used for caching the network requests.
Alternatively, the data structure of the request pool 22 is a map structure, and its key is the unique ID of the network request and value is an instance of the network request. The request pool 22 may provide a method to obtain the current maximum number of allowed concurrent network requests as well as the current number of concurrent network requests.
Further, when a network request is entered into the request pool, a method of the request instance is invoked to initiate an HTTP request.
Wherein, the response interceptor 23 is configured to intercept a network request result corresponding to the network request.
Optionally, the response interceptor 23 corresponds to a response interceptor queue, and is responsible for intercepting the return of the network request, and the data structure satisfies the FIFO principle. And when the network requests return, the network requests enter the queue and obtain the current maximum allowed number of concurrent network requests and the current number of concurrent network requests again, and when the maximum allowed number of concurrent network requests is greater than the current number of concurrent network requests, the second network request of the call request controller 21 is dequeued to the request pool 22.
The method and the device control the network requests based on the maximum allowed concurrent network request number and the recognition result of the current concurrent network request number, control the network requests in a finer granularity, and break through the limitation of the browser on the concurrent network request number, thereby improving the processing efficiency of the network requests and the page performance.
In order to implement the above embodiments, the present disclosure further provides an electronic device, as shown in fig. 13, where the electronic device 8000 includes: a processor 801; one or more memories 802 for storing instructions executable by the processor 801; wherein the processor 801 is configured to execute the network request processing method according to the above embodiment. The processor 801 and the memory 802 are connected by a communication bus.
In an exemplary embodiment, the present disclosure also provides a computer-readable storage medium comprising instructions, such as the memory 802 comprising instructions, executable by the processor 801 of the device 1000 to perform the above-described method. Alternatively, the computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product is also provided, which includes a computer program, and the computer program is executed by a processor to implement the network request processing method of the above-mentioned embodiment.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method for processing a network request, the method comprising:
intercepting a first network request and constructing a request interceptor queue according to one or more unsent first network requests, wherein the first network request is in a request-in-state;
acquiring a service vertical class corresponding to the first network request, and acquiring a global maximum allowable concurrent network request number corresponding to a request pool according to the service vertical class;
acquiring the current concurrent network request number corresponding to the request pool, and pushing the first network request in the request interceptor queue to the request pool when recognizing that the maximum allowed concurrent network request number is greater than the current concurrent network request number;
initiating the network request after the first network request is pushed into the request pool; and the number of the first and second groups,
when the current concurrent network request number in the request pool changes, updating the maximum allowed concurrent network request number and the current concurrent network request number, and synchronizing the updated maximum allowed concurrent network request number and the current concurrent network request number.
2. The method of claim 1, wherein after the network request is initiated after the first network request is pushed into the request pool, the method further comprises:
intercepting a network request result corresponding to the first network request;
and re-acquiring the global maximum number of allowed concurrent network requests and the current number of concurrent network requests, and pushing the second network requests in the request interceptor queue to the request pool when the unsent second network requests exist in the request interceptor queue after the maximum number of allowed concurrent network requests is identified to be greater than the current number of concurrent network requests.
3. The method for processing a network request according to claim 1, wherein before obtaining the global maximum allowed concurrent network request number corresponding to the request pool according to the service vertical class, the method further comprises:
and registering a network request method in a network request instance according to the first network request.
4. The method according to claim 3, wherein the pushing the first network request in the request interceptor queue to a request pool comprises:
acquiring a queuing sequence and a corresponding priority level corresponding to each first network request in the request interceptor queue;
pushing the high-priority first network request to the request pool according to the enqueue order when the high-priority first network request exists.
5. The method for processing the network request according to any one of claims 1 to 4, wherein the first network request is a cancel request for the first network request, further comprising:
receiving the cancel request instruction;
according to the request canceling instruction, sending a first searching instruction to the request interceptor to obtain a corresponding request identity, and according to the request identity, obtaining a corresponding network request;
and when the corresponding network request is acquired, acquiring the corresponding network request instance and registering a network request cancellation method to cancel the network request.
6. An apparatus for processing network requests, the apparatus comprising:
the first interception unit is configured to intercept a first network request and construct a request interceptor queue according to one or more unsent first network requests, wherein the first network request is in a request state;
a first obtaining unit, configured to perform obtaining of a service vertical class corresponding to the first network request, and obtain a global maximum allowed concurrent network request number corresponding to a request pool according to the service vertical class;
a second obtaining unit, configured to perform obtaining of a current number of concurrent network requests corresponding to the request pool, and push the first network request in the request interceptor queue to the request pool when it is identified that the maximum allowed number of concurrent network requests is greater than the current number of concurrent network requests;
an initiating unit configured to perform initiating the network request after the first network request is pushed into the request pool; and the number of the first and second groups,
a synchronization unit configured to update the maximum allowed concurrent network request number and the current concurrent network request number when the current concurrent network request number in the request pool changes, and synchronize the updated maximum allowed concurrent network request number and the current concurrent network request number.
7. A network request processing system, comprising: the network request processing device, request interceptor, request pool, and response interceptor of claim 6;
the request interceptor is used for intercepting the network request in a request state;
the request pool is used for caching the network request;
and the response interceptor is used for intercepting a network request result corresponding to the network request.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the method of processing a network request according to any one of claims 1 to 5.
9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method of processing a network request of any one of claims 1 to 5.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the method of processing a network request according to any one of claims 1 to 5.
CN202110951052.7A 2021-08-18 2021-08-18 Network request processing method and device and network request processing system Pending CN113852663A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110951052.7A CN113852663A (en) 2021-08-18 2021-08-18 Network request processing method and device and network request processing system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110951052.7A CN113852663A (en) 2021-08-18 2021-08-18 Network request processing method and device and network request processing system

Publications (1)

Publication Number Publication Date
CN113852663A true CN113852663A (en) 2021-12-28

Family

ID=78975911

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110951052.7A Pending CN113852663A (en) 2021-08-18 2021-08-18 Network request processing method and device and network request processing system

Country Status (1)

Country Link
CN (1) CN113852663A (en)

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002029596A1 (en) * 2000-10-06 2002-04-11 Cerberian Inc. A system and method for monitoring global network activity
US20100329269A1 (en) * 2009-06-24 2010-12-30 Oracle International Corporation System and method for processing communications using service interceptors
CN106101059A (en) * 2016-05-23 2016-11-09 微梦创科网络科技(中国)有限公司 A kind of web-page requests processing method and processing device
CN106257456A (en) * 2016-07-08 2016-12-28 北京京东尚科信息技术有限公司 The method of data base's stability, Apparatus and system is improved under high concurrent request
CN106850297A (en) * 2017-02-09 2017-06-13 合网络技术(北京)有限公司 The processing method and processing device of network request
CN107544849A (en) * 2017-09-30 2018-01-05 北京天元创新科技有限公司 A kind of WEB server concurrency management method and system
CN108073580A (en) * 2016-11-08 2018-05-25 北京国双科技有限公司 A kind of processing method and processing device based on page concurrent request
CN108415767A (en) * 2018-03-07 2018-08-17 中国平安人寿保险股份有限公司 Server thread control method, device, equipment and readable storage medium storing program for executing
CN108683604A (en) * 2018-04-03 2018-10-19 平安科技(深圳)有限公司 concurrent access control method, terminal device and medium
CN109561133A (en) * 2018-10-23 2019-04-02 深圳壹账通智能科技有限公司 Method for processing business, device, equipment and computer readable storage medium
CN110706069A (en) * 2019-09-25 2020-01-17 口碑(上海)信息技术有限公司 Exception handling method, device, server and system for order payment request
CN110769017A (en) * 2018-07-27 2020-02-07 北京国双科技有限公司 Data request processing method and device, storage medium and processor
CN111405024A (en) * 2020-03-11 2020-07-10 京东数字科技控股有限公司 Service processing method, gateway, electronic device and storage medium
CN113014455A (en) * 2021-03-15 2021-06-22 读书郎教育科技有限公司 Method for monitoring network request frequency

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002029596A1 (en) * 2000-10-06 2002-04-11 Cerberian Inc. A system and method for monitoring global network activity
US20100329269A1 (en) * 2009-06-24 2010-12-30 Oracle International Corporation System and method for processing communications using service interceptors
CN106101059A (en) * 2016-05-23 2016-11-09 微梦创科网络科技(中国)有限公司 A kind of web-page requests processing method and processing device
CN106257456A (en) * 2016-07-08 2016-12-28 北京京东尚科信息技术有限公司 The method of data base's stability, Apparatus and system is improved under high concurrent request
CN108073580A (en) * 2016-11-08 2018-05-25 北京国双科技有限公司 A kind of processing method and processing device based on page concurrent request
CN106850297A (en) * 2017-02-09 2017-06-13 合网络技术(北京)有限公司 The processing method and processing device of network request
CN107544849A (en) * 2017-09-30 2018-01-05 北京天元创新科技有限公司 A kind of WEB server concurrency management method and system
CN108415767A (en) * 2018-03-07 2018-08-17 中国平安人寿保险股份有限公司 Server thread control method, device, equipment and readable storage medium storing program for executing
CN108683604A (en) * 2018-04-03 2018-10-19 平安科技(深圳)有限公司 concurrent access control method, terminal device and medium
CN110769017A (en) * 2018-07-27 2020-02-07 北京国双科技有限公司 Data request processing method and device, storage medium and processor
CN109561133A (en) * 2018-10-23 2019-04-02 深圳壹账通智能科技有限公司 Method for processing business, device, equipment and computer readable storage medium
CN110706069A (en) * 2019-09-25 2020-01-17 口碑(上海)信息技术有限公司 Exception handling method, device, server and system for order payment request
CN111405024A (en) * 2020-03-11 2020-07-10 京东数字科技控股有限公司 Service processing method, gateway, electronic device and storage medium
CN113014455A (en) * 2021-03-15 2021-06-22 读书郎教育科技有限公司 Method for monitoring network request frequency

Similar Documents

Publication Publication Date Title
US11025724B2 (en) Transport of control data in proxy-based network communications
US11010219B2 (en) Object-oriented remote procedure calls for browser applications
CN113037862B (en) Service request processing method, device, equipment and storage medium
US9680719B2 (en) Communication system, client terminal, and server
US10778795B2 (en) Synchronization of property values between a client and a server
WO2022183802A1 (en) Load balancing method, apparatus, and device, storage medium, and computer program product
CN109873863A (en) The asynchronous invoking method and device of service
JP7071379B2 (en) Deferring a call request from a remote object
CN111858083A (en) Remote service calling method and device, electronic equipment and storage medium
CN110727507B (en) Message processing method and device, computer equipment and storage medium
CN109144992A (en) A kind of method and apparatus of data storage
CN113452770B (en) Data synchronization method, device, computer equipment and storage medium
CN113852663A (en) Network request processing method and device and network request processing system
US11777852B1 (en) System and method for web service atomic transaction (WS-AT) affinity routing
CN116483570A (en) Dynamic capacity expansion and contraction method, device and equipment for stateful service and storage medium
CN114666411A (en) Request processing method, device, server, storage medium and product
US20110282926A1 (en) Relay apparatus, recording medium storing a relay program, and a relay method
CN112837156A (en) Transaction method and device with fixed execution sequence
CN112000313A (en) Request response method, device, equipment and storage medium
CN114595457A (en) Task processing method and device, computer equipment and storage medium
CN112328598A (en) ID generation method, device, electronic equipment and storage medium
CN113901377B (en) Service calling method, device, storage medium and equipment of legacy system
CN111049779A (en) Information processing method, electronic device, and computer program product
EP3435629B1 (en) Transport of control data in proxy-based network communications
CN114168560A (en) Data management method and device

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