CN109104480B - Network request processing method and device - Google Patents

Network request processing method and device Download PDF

Info

Publication number
CN109104480B
CN109104480B CN201810886272.4A CN201810886272A CN109104480B CN 109104480 B CN109104480 B CN 109104480B CN 201810886272 A CN201810886272 A CN 201810886272A CN 109104480 B CN109104480 B CN 109104480B
Authority
CN
China
Prior art keywords
network request
resource consumption
response
network
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810886272.4A
Other languages
Chinese (zh)
Other versions
CN109104480A (en
Inventor
宋凡非
赵天兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Neusoft Corp
Original Assignee
Neusoft Corp
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 Neusoft Corp filed Critical Neusoft Corp
Priority to CN201810886272.4A priority Critical patent/CN109104480B/en
Publication of CN109104480A publication Critical patent/CN109104480A/en
Application granted granted Critical
Publication of CN109104480B publication Critical patent/CN109104480B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • H04L67/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 embodiment of the application discloses a method and a device for processing a network request, wherein the processing method comprises the following steps: the method comprises the steps of firstly obtaining a preset response priority parameter in a network request and the resource amount which can be consumed by the network request, determining the response level of the network request according to the response priority parameter of the network request and the predicted resource consumption of the network request, and when the response level of the network request reaches a preset threshold value, carrying out delay processing on the network request, namely selectively delaying processing the network request with low priority level and large resource consumption, so that a server can be ensured to preferentially process the network request with high priority level and small resource consumption, the network service quality and the user experience are improved to the maximum extent, and the network request is reasonably and effectively processed.

Description

Network request processing method and device
Technical Field
The present application relates to the field of internet technologies, and in particular, to a method and an apparatus for processing a network request.
Background
With the rapid development and the increasing popularization of the internet technology, the resources which can be provided by network products are more and more abundant, and the user access volume is also more and more large. This makes the performance of the application server more and more difficult to guarantee under the conditions of storage and processing capacity and bandwidth resources of the existing website application server. A series of problems such as large data volume, high concurrent access, frequent downtime and the like seriously affect the response efficiency of the application service. Particularly, with the emergence of new technologies such as containerization and servitization, the processing capacity of the existing application server is difficult to adapt to large-scale high-concurrency user access requirements. The method of improving physical hardware configuration or adding cluster nodes is only relied on, so that the investment cost is high, and the performance of service response cannot be improved fundamentally.
In the prior art, when the server pressure is increased dramatically, and when the server cannot process a received network request sent by a client, the received network request can be degraded based on a random rejection mode, and the mode has a simple implementation process and a certain relieving effect on the server pressure. However, the method cannot guarantee the network service quality and the user experience, and therefore, how to more reasonably and effectively complete the processing of the network request is an urgent technical problem to be solved.
Disclosure of Invention
In view of this, embodiments of the present application provide a method and an apparatus for processing a network request, so as to achieve more reasonable and effective processing of the network request.
In order to solve the above problem, the technical solution provided by the embodiment of the present application is as follows:
a method of processing a network request, the method comprising:
acquiring a network request;
reading a preset response priority parameter included in the network request;
calculating an expected resource consumption of the network request;
determining the response level of the network request according to the response priority parameter of the network request and the estimated resource consumption of the network request;
and if the response level of the network request reaches a preset threshold value, carrying out delay processing on the network request.
In one possible implementation, the calculating the expected resource consumption of the network request includes:
acquiring the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request;
and adding the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request to obtain the estimated resource consumption of the network request.
In a possible implementation manner, the obtaining the predicted processor resource consumption amount of the network request and the predicted memory resource consumption amount of the network request includes:
acquiring the actual processor resource consumption of the network request in the historical response process, and calculating to obtain the average value of the actual processor resource consumption as the predicted processor resource consumption of the network request;
and acquiring the actual memory resource consumption of the network request in the historical response process, and calculating to obtain the average value of the actual memory resource consumption as the predicted memory resource consumption of the network request.
In a possible implementation manner, the determining a response level of the network request according to the response priority parameter of the network request and the expected resource consumption amount of the network request includes:
and carrying out weighted summation on the response priority parameter of the network request and the estimated resource consumption of the network request to obtain the response level of the network request.
In a possible implementation manner, the weighted summation of the response priority parameter of the network request and the expected resource consumption of the network request to obtain the response level of the network request includes:
taking the reciprocal of the response priority parameter of the network request, and multiplying the reciprocal by a first weight value to obtain a first parameter value;
dividing the predicted resource consumption of the network request by a normalization parameter, and multiplying the result by a second weight value to obtain a second parameter value, wherein the normalization parameter is the maximum value in the predicted resource consumption of each network request;
and adding the first parameter value and the second parameter value to obtain the response level of the network request.
In one possible implementation, the method further includes:
and if the response level of the network request does not reach a preset threshold value, sending the network request to a corresponding request execution server for execution.
In one possible implementation, after the obtaining the network request, the method further includes:
judging whether to carry out delay processing of the network request according to the current server load;
if the delay processing of the network request needs to be carried out, executing the reading of the preset response priority parameter included in the network request and the subsequent steps;
and if the network request does not need to be delayed, sending the network request to a corresponding request execution server for execution.
An apparatus for processing network requests, the apparatus comprising:
an acquisition unit configured to acquire a network request;
a reading unit, configured to read a preset response priority parameter included in the network request;
a calculating unit, configured to calculate an expected resource consumption amount of the network request;
the determining unit is used for determining the response level of the network request according to the response priority parameter of the network request and the predicted resource consumption of the network request;
and the processing unit is used for carrying out delay processing on the network request if the response level of the network request reaches a preset threshold value.
In a possible implementation manner, the computing unit specifically includes:
an obtaining subunit, configured to obtain a predicted processor resource consumption amount of the network request and a predicted memory resource consumption amount of the network request;
and the calculating subunit is used for adding the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request to obtain the estimated resource consumption of the network request.
In a possible implementation manner, the obtaining subunit specifically includes:
the first obtaining subunit is configured to obtain actual processor resource consumption of the network request in a historical response process, and calculate an average value of the actual processor resource consumption to obtain an expected processor resource consumption of the network request;
and the second obtaining subunit is configured to obtain actual memory resource consumption of the network request in a historical response process, and calculate an average value of the actual memory resource consumption to be used as an expected memory resource consumption of the network request.
In a possible implementation manner, the determining unit is specifically configured to perform weighted summation on a response priority parameter of the network request and an expected resource consumption amount of the network request to obtain a response level of the network request.
In a possible implementation manner, the determining unit specifically includes:
the first calculating subunit is configured to multiply the reciprocal of the response priority parameter of the network request by a first weight value to obtain a first parameter value;
the second calculating subunit is configured to divide the predicted resource consumption of the network request by a normalization parameter, and then multiply the result by a second weight value to obtain a second parameter value, where the normalization parameter is a maximum value among the predicted resource consumption of each network request;
and the third calculation subunit is used for adding the first parameter value and the second parameter value to obtain the response level of the network request.
In one possible implementation, the apparatus further includes:
and the first sending unit is used for sending the network request to a corresponding request execution server for execution if the response level of the network request does not reach a preset threshold value.
In one possible implementation, the apparatus further includes:
the judging unit is used for judging whether the delay processing of the network request is needed or not according to the current server load after the network request is obtained;
the triggering unit is used for triggering and executing the reading unit to read the preset response priority parameter included in the network request and subsequent steps if the judgment result of the judging unit is that the delay processing of the network request is required;
and the second sending unit is used for sending the network request to a corresponding request execution server for execution if the judgment result of the judging unit is that the delay processing of the network request is not required.
A computer-readable storage medium having stored therein instructions which, when run on a terminal device, cause the terminal device to execute the above-mentioned method for processing a network request.
A computer program product, which, when run on a terminal device, causes the terminal device to perform the above-mentioned method of processing a network request.
Therefore, the embodiment of the application has the following beneficial effects:
according to the embodiment of the application, the preset response priority parameter in the network request and the resource amount which can be consumed by the network request are firstly obtained, the response level of the network request is determined according to the response priority parameter of the network request and the predicted resource consumption amount of the network request, when the response level of the network request reaches the preset threshold value, the network request is subjected to delay processing, namely, the network request with low priority level and large resource consumption amount is selectively delayed, so that the server can be ensured to preferentially process the network request with high priority level and small resource consumption amount, the network service quality and the user experience are maximally improved, and the network request is reasonably and effectively processed.
Drawings
Fig. 1 is a schematic diagram of a framework of an exemplary application scenario provided in an embodiment of the present application;
fig. 2 is a flowchart of a network request processing method according to an embodiment of the present application;
fig. 3 is an exemplary flowchart of a network request processing method according to an embodiment of the present application;
FIG. 4 is a flowchart of a method for calculating a projected resource consumption of a network request according to an embodiment of the present application;
FIG. 5 is a flow chart of a method for obtaining a response level according to an embodiment of the present disclosure;
fig. 6 is an exemplary flowchart of another network request processing method provided in an embodiment of the present application;
fig. 7 is a block diagram of a device for processing a network request according to an embodiment of the present application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, embodiments accompanying the drawings are described in detail below.
In order to facilitate understanding of the technical solutions provided by the present application, the following will briefly explain the research background of the technical solutions of the present application.
The inventor finds, in a research on a conventional method for relieving server pressure, that when a server is in a state of sharp increase in pressure and cannot process a network request sent by a terminal in time, the received network request is degraded, that is, the network request is delayed to be processed, so that the server pressure is relieved. However, the random rejection based method does not consider the priority and the service importance of different network requests and the resource consumption of the server in response to the network requests, which may cause the network requests with high priority and low resource consumption to be rejected, and some network requests with low priority and high resource consumption are processed by the server response, so that the service quality and the user experience of the core service provided by the server cannot be guaranteed.
Based on this, the application provides a method and a device for processing a network request, first obtaining a response priority parameter preset in the network request and a resource amount which can be consumed by the network request, determining a response level of the network request according to the response priority parameter of the network request and an expected resource consumption amount of the network request, and when the response level of the network request reaches a preset threshold, performing delay processing on the network request, namely selectively delaying processing a network request with a low priority level and a large resource consumption amount, so as to ensure that a server can preferentially process a network request with a high priority level and a small resource consumption amount, thereby maximizing network service quality and user experience, and reasonably and effectively completing processing of the network request.
Referring to fig. 1, the figure is a schematic diagram of a framework of an exemplary application scenario provided in an embodiment of the present application. The network request processing method provided by the embodiment of the present application may be applied to the server 20, where the server 20 may receive a network request sent by the terminal 10, read a preset response priority parameter from the received network request, calculate an expected resource consumption of the network request to the server 20 at the same time, and determine a response level of the network request according to the response priority parameter of the network request and the expected resource consumption, so as to determine that, when the response level is greater than a preset threshold, the network request is delayed, thereby alleviating a load of the server and improving service quality of a core service of the server.
The network request refers to a service request sent by the user to the server through the terminal 10, for example, when the user wants to log on a certain platform through the terminal 10, the terminal 10 sends a login request to the server 20 according to a trigger operation of the user on a terminal 10 page, or the terminal 10 sends a purchase request to the server 20 according to a trigger operation of the user on a terminal page. Of course, the method may also include a file transfer request, an email sending request, and the like, and the present embodiment does not limit the type of the network request.
Those skilled in the art will appreciate that the frame diagram shown in fig. 1 is only one example in which embodiments of the present application may be implemented, and the scope of applicability of embodiments of the present application is not limited in any way by this frame.
It should be noted that the terminal 10 in the embodiments of the present application may be any user equipment now known, developing or later developed that is capable of interacting with the server 20 via any form of wired and/or wireless connection (e.g., Wi-Fi, LAN, cellular, coaxial cable, etc.), including but not limited to: existing, developing, or future developing smartphones, non-smartphones, tablets, laptop personal computers, desktop personal computers, minicomputers, midrange computers, mainframe computers, and the like. It should also be noted that the server 20 in the embodiment of the present application may be an example of an existing, developing or future developing device capable of providing an application service of information recommendation to a user. The embodiments of the present application are not limited in any way in this respect.
In order to facilitate understanding of the technical solutions provided by the present application, a method for processing a network request provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Referring to fig. 2, which is a flowchart of a network request processing method provided in an embodiment of the present application, as shown in fig. 2, the method may include:
s201: a network request is obtained.
Generally, when a user clicks a control, presses a page for a long time, or the like on a client mounted on a terminal, the client generates a corresponding network request based on the user's operation, and sends the network request to a server to request the server to execute corresponding processing according to the network request. In this embodiment, when the server responds to the network request sent by the terminal, the server may obtain the network request so as to determine whether to respond to the network request according to the relevant information of the network request. The network request can comprise contents such as a transmission protocol, a request password, a request time stamp and encrypted request data, wherein the request password and the time stamp are used for preventing the network request from being tampered by an attack, and the encrypted request data can be used for characterizing services required to be provided by the server.
S202: and reading a preset response priority parameter included in the network request.
In this embodiment, the network request may include a preset response priority parameter, and in order to process the network request based on the response priority of the network request, the response priority parameter in the network request needs to be read.
In practical application, various network requests in a server can be preset with response priority, the response priority of the network requests is preset in the form of tag labels set in the network requests, and the response priority can be set according to the importance degree and/or sensitive factors of the network requests during specific implementation, for example, the response priority corresponding to network requests needing real-time transmission, such as voice and video, is high, and the response priority corresponding to network requests with lower time sensitivity of e-mails is lower, so that when the server receives the video network requests and the e-mail network requests simultaneously, the network requests with higher priority can be processed preferentially, and the service quality and the user experience are ensured.
The response priority preset in the network request may be identified by using a response priority parameter, and in a specific implementation, the response priority of the server may be identified by using characters, for example, 1 identifies the highest priority, 0.5 identifies the medium priority, and 0.1 identifies the lowest priority. In practical application, the level of the response priority and different response priority parameters may be set according to different situations, and the embodiment of the present application does not limit the expression form of the level of the response priority and the response priority parameters.
S203: an estimated resource consumption amount for the network request is calculated.
In this embodiment, when the server obtains the network request sent by the client, it needs to predict the resource consumption of the server when responding to the network request. The resource consumption may include resource consumption of a Central Processing Unit (CPU) and resource consumption of a memory when the server processes the network request, and a specific implementation manner of calculating the expected resource consumption of the network request will be described in the following embodiments.
It should be noted that, in this embodiment, the execution sequence between S202 and S203 is not limited, and in practical applications, S202 may be executed first and then S203 may be executed, S203 may be executed first and then S202 may be executed, or S202 and S203 may be executed in parallel.
S204: and determining the response level of the network request according to the response priority parameter of the network request and the predicted resource consumption of the network request.
In this embodiment, before the server responds to the network request sent by the terminal, the response level of the network request needs to be determined, and the response level may be determined according to the response priority parameter of the network request and the expected resource consumption of the server in response to the network request. The response level of the network request is a comprehensive evaluation index of the importance degree of the network request and the estimated occupied resources, and the server can decide whether to immediately respond to the network request according to the response level.
A specific implementation manner for determining the response level of the network request according to the response priority parameter of the network request and the expected resource consumption amount will be described in the following embodiments.
S205: and if the response level of the network request reaches a preset threshold value, carrying out delay processing on the network request.
In this embodiment, when the response level of the network request is greater than or equal to the preset threshold, the response priority of the network request may be considered to be low and the resource consumption of the server is large, and to relieve the pressure of the server, the network request may be added into the delay queue to be queued and delayed, so that the server may preferentially process the network request with high response priority and low resource consumption of the server, and thus, the maximum improvement of the service response is ensured. The preset threshold may be an empirical constant, and is used to identify an upper threshold of the response level, and the preset threshold may be set according to an actual use condition, and the setting of the preset threshold is not limited in this embodiment.
In addition, when the response level of the network request does not reach the preset threshold, the embodiment may also send the network request to the corresponding request execution server for execution.
It can be understood that when the response level of the network request does not reach the preset threshold, it indicates that the response priority of the network request is higher and the resource consumption of the server is lower, so that the server can process the network request in time, the response efficiency of the server is improved, and the user experience is improved. In the actual processing of the network request, the network request may be sent to a corresponding request execution server for execution, for example, a login request is sent to the login server for execution, a request for obtaining a video is sent to the video server for execution, and the like.
It can be seen from the foregoing embodiments that, in the embodiments of the present application, a response priority parameter preset in a network request and a resource amount that may be consumed by the network request are first obtained, a response level of the network request is determined according to the response priority parameter of the network request and an expected resource consumption amount of the network request, and when the response level of the network request reaches a preset threshold, a delay processing is performed on the network request, that is, a network request with a low priority level and a large resource consumption amount is selectively delayed, so that it is ensured that a server can preferentially process a network request with a high priority level and a small resource consumption amount, so as to maximize network service quality and user experience, and implement reasonable and effective completion of processing of the network request.
In addition, the priority of the network request and the resource consumption of the server are comprehensively considered, so that the server can determine whether the network request is delayed to be processed according to the comprehensive evaluation value, namely the response level, under the condition that the pressure of the server is increased sharply, so that the server can preferentially respond to the network request with high priority and low resource consumption, therefore, the embodiment of the application can also be applied to a large-scale concurrent service access scene, especially for the condition that a service gateway in a micro-service architecture faces a large number of service requests, the pressure of the server is reduced through delay processing, and the user experience is improved.
Referring to fig. 3, which is an exemplary flowchart of a network request processing method provided in an embodiment of the present application, as shown in fig. 3, first obtaining a network request sent by a terminal, reading a response priority parameter included in the network request, and calculating an expected resource consumption amount of the network request for a server, then determining a response level of the network request according to the response priority parameter and the expected resource consumption amount, and when the response level reaches a preset threshold, performing a delay process on the network request, and adding the network request into a delay queue for queuing, so that the server can respond to a response network request with a high priority and a relatively low resource consumption, so as to ensure a maximized service response.
As can be seen from the foregoing embodiments, when a network request sent by a terminal is obtained, a predicted resource consumption amount of the network request needs to be calculated.
Referring to fig. 4, which is a flowchart of a method for calculating an estimated resource consumption amount of a network request according to an embodiment of the present application, as shown in fig. 4, the method may include:
s401: and acquiring the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request.
In this embodiment, to calculate the expected resource consumption of a network request to a server, the expected processor resource consumption of the network request and the expected memory resource consumption of the network request, that is, the resource consumption of the network request to a processor and the resource consumption of a memory may be expected.
The embodiment of the present application provides a possible implementation manner for obtaining the predicted processor resource consumption of the network request, specifically, obtaining the actual processor resource consumption of the network request in the historical response process, and calculating to obtain an average value of the actual processor resource consumption as the predicted processor resource consumption of the network request.
In practical applications, when the server obtains the network request sent by the terminal, the resource consumption of the processor actually consumed when the server processes the network request of the same type in the historical response process may be obtained according to the request type included in the network request, and then the actual processor resource consumption corresponding to the network request of the same type may be used to add and average the actual processor resource consumption, and the calculated average is used as the predicted processor resource consumption of the network request. Wherein, the processor resource consumption refers to the consumption of CPU by the server in response to the network request.
For example, the server receives a network request A sent by the terminal, obtains the actual CPU resource consumption of the server processing the network request A in the historical response process according to the type of the network request, and supposing that n actual CPU resource consumption are obtained in total, namely S1, S2, S3, … and Sn respectively, the predicted CPU resource consumption S of the current network request isreq=(S1+S2+S3+… +Sn)/n。
It should be noted that, in this embodiment, the predicted processor resource consumption of the network request may be obtained by using all the actual processor resource consumption in the network request of the same type in the historical response process, or may be obtained by using a part of the actual processor resource consumption in the network request of the same type in the historical response process.
The embodiment of the present application provides a possible implementation manner for obtaining the estimated memory resource consumption of the network request, specifically, obtaining the actual memory resource consumption of the network request in the historical response process, and calculating to obtain an average value of the actual memory resource consumption as the estimated memory resource consumption of the network request.
In practical application, when the server obtains a network request sent by the terminal, the memory resource consumption actually consumed by the server when processing the same type of network request in the historical response process can be obtained according to the request type included in the network request, then the actual memory resource consumption corresponding to the same type of network request can be added to calculate the average value, and the calculated average value is used as the expected memory resource consumption of the network request.
For example, the server receives a network request a sent by the terminal, obtains the actual memory resource consumption of the server processing the network request a in the historical response process according to the type of the network request, and supposes that n actual memory resource consumptions are obtained in total, namely M1, M2, M3, … and Mn, respectively, then the predicted memory resource consumption M of the current network request is obtainedreq=(M1+M2+M3+…+Mn)/n。
It should be noted that, in this embodiment, the predicted memory consumption of the network request may be obtained by using all the actual memory consumption in the network request of the same type in the historical response process, or may be obtained by using a part of the actual memory consumption in the network request of the same type in the historical response process.
S402: and adding the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request to obtain the estimated resource consumption of the network request.
In this embodiment, the obtained estimated processor resource consumption and the estimated memory resource consumption of the network request are added to obtain the estimated resource consumption of the network request, so as to determine the response level of the network request according to the estimated resource consumption and the response priority parameter. For example, the estimated resource consumption Q ═ Sreq+Mreq
Through the embodiment, the estimated resource consumption of the network request can be obtained by obtaining the estimated processor resource consumption and the estimated memory consumption of the network request, so that the server determines the response level of the network request according to the estimated resource consumption of the network request and the response priority parameter preset in the network request, and further determines whether the network request needs to be subjected to delay processing according to the corresponding level, and the maximized service response is guaranteed.
In a possible implementation manner of the embodiment of the present application, the response level of the network request is determined according to the response priority parameter of the network request and the expected resource consumption of the network request, and specifically, the response priority parameter of the network request and the expected resource consumption of the network request may be weighted and summed to obtain the response level of the network request.
In practical applications, the predicted resource consumption of the network request obtained by the above embodiment and the response priority parameter included in the network request are subjected to weighted summation to obtain the response level of the network request, so that the server determines whether the network request needs to be subjected to delay processing according to the response level.
In the embodiment of the present application, a possible implementation method is provided for obtaining the response level of the network request by weighting and summing the response priority parameter of the network request and the expected resource consumption amount, and the method will be described below with reference to the accompanying drawings.
Referring to fig. 5, which is a flowchart of a method for obtaining a response level according to an embodiment of the present application, as shown in fig. 5, the method may include:
s501: and multiplying the response priority parameter of the network request by the first weight value after taking the reciprocal to obtain a first parameter value.
In this example, according to S202, a preset response priority parameter included in the network request may be obtained, and then the response priority parameter is inverted and multiplied by the first weight value to obtain the first parameter value. Wherein, the first weighted value can be set according to actual situation and experience, and is set at [0, 1 ]]I.e. a positive number smaller than 1. For example, if the response priority parameter of a network request is p and the first weight value is α, then
Figure BDA0001755740630000141
S502: and dividing the predicted resource consumption of the network request by the normalization parameter, and multiplying the result by the second weight value to obtain a second parameter value.
In this embodiment, the predicted resource consumption amount calculated to obtain the network request is normalized, and then the normalized predicted resource consumption amount is multiplied by the second weight value to obtain the second parameter value.
Wherein the normalization parameter is the maximum value of the predicted resource consumption of each network request, that is, the normalization parameter is the maximum value of the predicted resource consumption of all network requests that the server can respond to, that is, the normalization parameter is max { Q ═ max {i},QiFor the estimated resource consumption of the ith network request, i is from 1 to w, and w is the total number of network requests obtained by the server, wherein the estimated resource consumption of each network request can be calculated according to the manner provided in the above embodiment, for example, the server obtains three network requests A, B and C in total, wherein the estimated resource consumption Q of the network request C isCMaximum, then QCAre normalized parameters. The second weight value is a positive number smaller than 1, and may be set according to actual conditions and experience, and in addition, the first weight value and the second weight value may be added to be 1. For example, if the level of response to a network request and the projected resource consumption of the network request are considered to be of equal importance,in this case, α ═ β ═ 0.5 may be set; if the current resources are tense and a network request with large resource consumption needs to be delayed, β 1 may be set to a large value, such as β 0 ═ 0.4, β ═ 0.6, α ═ 0.3, β ═ 0.7, and the like; if the current resources are not tight and the network request with lower priority needs to be delayed, a larger value of α, such as α ═ 0.6, β ═ 0.4, α ═ 0.7, β ═ 0.3, etc., may be set. In the embodiment of the present application, values of the first weight value and the second weight value are not limited.
In conjunction with the above description, the process of calculating the second parameter value is, for example, the server obtains three network requests A, B and C in total, and the preset resource consumption of network request A is QA,QCIs normalized parameter, the second weighted value is beta, then
Figure BDA0001755740630000151
S503: and adding the first parameter value and the second parameter value to obtain the response level of the network request.
In this embodiment, the first parameter and the second parameter obtained through the above steps are summed to obtain a response level of the network request. For example, if the response level of the network request is L, then
Figure BDA0001755740630000152
Wherein L istRequesting a response level of t for the network; p is a radical oftResponse priority parameter, Q, for network requests ttPredicted resource consumption, Q, for network requests tiThe estimated resource consumption of the ith network request is 1 to w, w is the total number of the network requests acquired by the server, and max { Q { (Q) }iThe maximum of the predicted resource consumption of all network requests acquired by the server.
Through the embodiment, the first parameter value is obtained by correspondingly processing the response priority parameter of the network request, the second parameter value is obtained by correspondingly processing the predicted resource consumption of the network request, and then the response level of the network request is obtained by adding the first parameter value and the second parameter value, so that the server can judge whether the network request needs to be subjected to delay processing according to the response level, and the maximized service response is guaranteed.
In the embodiment of the application, after the server obtains the network request, whether the network request needs to be delayed or not can be judged according to the workload of the current server, and the network request does not need to be delayed under the condition that the workload of the server is small, so that the service response efficiency is improved.
Based on this, the method provided in the embodiment of the present application may further include: judging whether to carry out delay processing of the network request according to the current server load; if the network request needs to be delayed, executing the preset response priority parameter included in the read network request and the subsequent steps; and if the network request does not need to be delayed, sending the network request to a corresponding request execution server for execution.
In this embodiment, after the network request is obtained, it is first determined whether the load of the current server is greater than a threshold, where the load of the server may be determined according to the concurrency number of the network request, or according to the current resource occupation condition of the server. If the load of the current server is larger than the threshold value, the working state of the current server is saturated, and the network request cannot be continuously responded, the network request is subjected to delay processing; if the network request is not greater than the threshold value, the server has the capability to respond to the network request, and the network request is sent to the corresponding request execution server to be executed, so that the server response efficiency is improved, and the user experience is improved.
To facilitate understanding of the foregoing embodiments, reference is made to fig. 6, which is an exemplary flowchart of another network request processing method provided in this application embodiment.
As shown in fig. 6, first, a network request is obtained, whether to start the delay processing is determined according to the load of the current server, if the server is not busy, the delay processing is not required to be started, and the network request is directly sent to the corresponding request execution server to be executed, so as to respond to the network request. If the server is busy and needs to start delay processing, reading a response priority parameter of the network request, calculating the predicted resource consumption of the network request, then determining the response level of the network request according to the response priority parameter and the predicted resource consumption, judging whether the response level is greater than a preset threshold value, if so, adding the network request into a delay queue, and performing delay processing; and if the response level is not greater than the preset threshold value, sending the network request to a corresponding request execution server to respond to the network request. Therefore, the network request can be reasonably and effectively processed, and the network service quality and the user experience can be maximally improved.
Based on the above method embodiment, the present application further provides a device for processing a network request, which will be described below with reference to the accompanying drawings.
Referring to fig. 7, which shows a block diagram of a device for processing a network request according to an embodiment of the present application, the device may include:
an obtaining unit 701, configured to obtain a network request;
a reading unit 702, configured to read a preset response priority parameter included in the network request;
a calculating unit 703, configured to calculate an expected resource consumption amount of the network request;
a determining unit 704, configured to determine a response level of the network request according to the response priority parameter of the network request and the expected resource consumption of the network request;
the processing unit 705 is configured to perform delay processing on the network request if the response level of the network request reaches a preset threshold.
In some possible implementation manners, the computing unit specifically includes:
an obtaining subunit, configured to obtain a predicted processor resource consumption amount of the network request and a predicted memory resource consumption amount of the network request;
and the calculating subunit is used for adding the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request to obtain the estimated resource consumption of the network request.
In some possible implementation manners, the obtaining subunit specifically includes:
the first obtaining subunit is configured to obtain actual processor resource consumption of the network request in a historical response process, and calculate an average value of the actual processor resource consumption to obtain an expected processor resource consumption of the network request;
and the second obtaining subunit is configured to obtain actual memory resource consumption of the network request in a historical response process, and calculate an average value of the actual memory resource consumption to be used as an expected memory resource consumption of the network request.
In some possible implementations, the determining unit is specifically configured to perform weighted summation on the response priority parameter of the network request and the expected resource consumption amount of the network request to obtain the response level of the network request.
In some possible implementations, the determining unit specifically includes:
the first calculating subunit is configured to multiply the reciprocal of the response priority parameter of the network request by a first weight value to obtain a first parameter value;
the second calculating subunit is configured to divide the predicted resource consumption of the network request by a normalization parameter, and then multiply the result by a second weight value to obtain a second parameter value, where the normalization parameter is a maximum value among the predicted resource consumption of each network request;
and the third calculation subunit is used for adding the first parameter value and the second parameter value to obtain the response level of the network request.
In some possible implementations, the apparatus further includes:
and the first sending unit is used for sending the network request to a corresponding request execution server for execution if the response level of the network request does not reach a preset threshold value.
In some possible implementations, the apparatus further includes:
the judging unit is used for judging whether the delay processing of the network request is needed or not according to the current server load after the network request is obtained;
the triggering unit is used for triggering and executing the reading unit to read the preset response priority parameter included in the network request and subsequent steps if the judgment result of the judging unit is that the delay processing of the network request is required;
and the second sending unit is used for sending the network request to a corresponding request execution server for execution if the judgment result of the judging unit is that the delay processing of the network request is not required.
It should be noted that, for specific implementation of each unit in this embodiment, reference may be made to the above method embodiment, and this embodiment is not described herein again.
In addition, an embodiment of the present application further provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are run on a terminal device, the terminal device is caused to execute the above-mentioned network request processing method.
The embodiment of the present application further provides a computer program product, which when running on a terminal device, enables the terminal device to execute the method for processing the network request.
It can be seen from the foregoing embodiments that, in the embodiments of the present application, a response priority parameter preset in a network request and a resource amount that may be consumed by the network request are first obtained, a response level of the network request is determined according to the response priority parameter of the network request and an expected resource consumption amount of the network request, and when the response level of the network request reaches a preset threshold, a delay processing is performed on the network request, that is, a network request with a low priority level and a large resource consumption amount is selectively delayed, so that it is ensured that a server can preferentially process a network request with a high priority level and a small resource consumption amount, so as to maximize network service quality and user experience, and implement reasonable and effective completion of processing of the network request.
It should be noted that, in the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the system or the device disclosed by the embodiment, the description is simple because the system or the device corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (8)

1. A method for processing a network request, the method comprising:
acquiring a network request;
reading a preset response priority parameter included in the network request;
calculating an expected resource consumption of the network request;
carrying out weighted summation on the response priority parameter of the network request and the estimated resource consumption of the network request to obtain the response level of the network request;
and if the response level of the network request reaches a preset threshold value, carrying out delay processing on the network request.
2. The method of claim 1, wherein calculating the projected resource consumption of the network request comprises:
acquiring the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request;
and adding the estimated processor resource consumption of the network request and the estimated memory resource consumption of the network request to obtain the estimated resource consumption of the network request.
3. The method of claim 2, wherein obtaining the predicted processor resource consumption and the predicted memory resource consumption of the network request comprises:
acquiring the actual processor resource consumption of the network request in the historical response process, and calculating to obtain the average value of the actual processor resource consumption as the predicted processor resource consumption of the network request;
and acquiring the actual memory resource consumption of the network request in the historical response process, and calculating to obtain the average value of the actual memory resource consumption as the predicted memory resource consumption of the network request.
4. The method of claim 1, wherein the weighted summation of the response priority parameter of the network request and the expected resource consumption of the network request to obtain the response level of the network request comprises:
taking the reciprocal of the response priority parameter of the network request, and multiplying the reciprocal by a first weight value to obtain a first parameter value;
dividing the predicted resource consumption of the network request by a normalization parameter, and multiplying the result by a second weight value to obtain a second parameter value, wherein the normalization parameter is the maximum value in the predicted resource consumption of each network request;
and adding the first parameter value and the second parameter value to obtain the response level of the network request.
5. The method of claim 1, further comprising:
and if the response level of the network request does not reach a preset threshold value, sending the network request to a corresponding request execution server for execution.
6. The method of claim 1, wherein after the obtaining the network request, the method further comprises:
judging whether to carry out delay processing of the network request according to the current server load;
if the delay processing of the network request needs to be carried out, executing the reading of the preset response priority parameter included in the network request and the subsequent steps;
and if the network request does not need to be delayed, sending the network request to a corresponding request execution server for execution.
7. An apparatus for processing network requests, the apparatus comprising:
an acquisition unit configured to acquire a network request;
a reading unit, configured to read a preset response priority parameter included in the network request;
a calculating unit, configured to calculate an expected resource consumption amount of the network request;
the determining unit is used for carrying out weighted summation on the response priority parameter of the network request and the estimated resource consumption of the network request to obtain the response level of the network request;
and the processing unit is used for carrying out delay processing on the network request if the response level of the network request reaches a preset threshold value.
8. A computer-readable storage medium having stored therein instructions that, when run on a terminal device, cause the terminal device to perform the method of processing a network request of any one of claims 1-6.
CN201810886272.4A 2018-08-06 2018-08-06 Network request processing method and device Active CN109104480B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810886272.4A CN109104480B (en) 2018-08-06 2018-08-06 Network request processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810886272.4A CN109104480B (en) 2018-08-06 2018-08-06 Network request processing method and device

Publications (2)

Publication Number Publication Date
CN109104480A CN109104480A (en) 2018-12-28
CN109104480B true CN109104480B (en) 2021-08-13

Family

ID=64848904

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810886272.4A Active CN109104480B (en) 2018-08-06 2018-08-06 Network request processing method and device

Country Status (1)

Country Link
CN (1) CN109104480B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111182172A (en) * 2020-01-03 2020-05-19 北京中电飞华通信有限公司 Fax service processing method and system and electronic equipment
CN112689007B (en) * 2020-12-23 2023-05-05 江苏苏宁云计算有限公司 Resource allocation method, device, computer equipment and storage medium
CN113590030B (en) * 2021-06-30 2023-12-26 济南浪潮数据技术有限公司 Queue scheduling method, system, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102136096A (en) * 2010-12-15 2011-07-27 华为软件技术有限公司 Dynamic traffic control method and device for service and concurrency control system
CN103699445A (en) * 2013-12-19 2014-04-02 北京奇艺世纪科技有限公司 Task scheduling method, device and system
CN105897601A (en) * 2016-06-20 2016-08-24 乐视控股(北京)有限公司 Business request processing method and device
CN106650501A (en) * 2016-12-30 2017-05-10 迈普通信技术股份有限公司 Database access control method and apparatus

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101132545B (en) * 2006-08-24 2011-08-03 电信科学技术研究院 Method and system for implementing multimedia broadcast multicast in mobile communication system
CN100534067C (en) * 2007-01-19 2009-08-26 北京邮电大学 Scheduling method for ensuring time delay stability of non-real-time business data packet for OFDMA system
US20100162251A1 (en) * 2008-12-19 2010-06-24 Anita Richards System, method, and computer-readable medium for classifying problem queries to reduce exception processing
CN103841052B (en) * 2012-11-27 2017-03-08 中国科学院声学研究所 A kind of bandwidth resource allocation System and method for

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102136096A (en) * 2010-12-15 2011-07-27 华为软件技术有限公司 Dynamic traffic control method and device for service and concurrency control system
CN103699445A (en) * 2013-12-19 2014-04-02 北京奇艺世纪科技有限公司 Task scheduling method, device and system
CN105897601A (en) * 2016-06-20 2016-08-24 乐视控股(北京)有限公司 Business request processing method and device
CN106650501A (en) * 2016-12-30 2017-05-10 迈普通信技术股份有限公司 Database access control method and apparatus

Also Published As

Publication number Publication date
CN109104480A (en) 2018-12-28

Similar Documents

Publication Publication Date Title
CN110049130B (en) Service deployment and task scheduling method and device based on edge computing
US9894021B2 (en) Cloud messaging services optimization through adaptive message compression
CN109104480B (en) Network request processing method and device
WO2020019519A1 (en) Task allocation method and apparatus
CN109218369B (en) Remote procedure call request control method and device
CN112612618B (en) Interface current limiting method and device, computer equipment and storage medium
CN112689007B (en) Resource allocation method, device, computer equipment and storage medium
KR102641971B1 (en) Hybrid client-server data provision
CN110933136A (en) Service node selection method, device, equipment and readable storage medium
US9665409B2 (en) Methods and apparatus facilitating access to storage among multiple computers
CN109120548B (en) Flow control method and device
Chen et al. Overload control in QoS-aware web servers
CN112559173A (en) Resource adjusting method and device, electronic equipment and readable storage medium
CN111858040A (en) Resource scheduling method and device
CN115633039A (en) Communication establishing method, load balancing device, equipment and storage medium
CN115454602A (en) Task scheduling method, device and equipment
CN116708450A (en) Load balancing method, load balancing device, electronic equipment and computer readable storage medium
JP4411296B2 (en) Request restriction device, server device, request restriction method, request restriction program
CN106933673B (en) Method and device for adjusting number of logical threads of component
CN113742009B (en) Desktop cloud environment resource scheduling method, device, equipment and storage medium
CN113992586B (en) Flow control method, flow control device, computer equipment and storage medium
US10616081B2 (en) Application aware cluster monitoring
CN115665173B (en) MQ-based Websocket communication method, system and storage medium
CN116541167A (en) System flow control method, device, electronic equipment and computer readable medium
CN114598656B (en) Load balancing method and system applied to delivery service platform

Legal Events

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