CN115022174A - Request processing method and device, readable storage medium and electronic equipment - Google Patents

Request processing method and device, readable storage medium and electronic equipment Download PDF

Info

Publication number
CN115022174A
CN115022174A CN202210697590.2A CN202210697590A CN115022174A CN 115022174 A CN115022174 A CN 115022174A CN 202210697590 A CN202210697590 A CN 202210697590A CN 115022174 A CN115022174 A CN 115022174A
Authority
CN
China
Prior art keywords
service request
resource pool
request
preset
forwarding rule
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210697590.2A
Other languages
Chinese (zh)
Other versions
CN115022174B (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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202210697590.2A priority Critical patent/CN115022174B/en
Publication of CN115022174A publication Critical patent/CN115022174A/en
Application granted granted Critical
Publication of CN115022174B publication Critical patent/CN115022174B/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
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0823Configuration setting characterised by the purposes of a change of settings, e.g. optimising configuration for enhancing reliability
    • H04L41/0836Configuration setting characterised by the purposes of a change of settings, e.g. optimising configuration for enhancing reliability to enhance reliability, e.g. reduce downtime
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1012Server selection for load balancing based on compliance of requirements or conditions with available server resources

Landscapes

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

Abstract

The invention provides a request processing method, a request processing device, a computer readable storage medium and electronic equipment, wherein the method comprises the following steps: receiving a service request sent by a client; responding to the service request according with a preset forwarding rule, forwarding the service request to a first resource pool, wherein the first resource pool is used for deploying unverified online version data; determining first response data corresponding to the service request based on the first resource pool; and in response to the fact that the service request does not accord with the preset forwarding rule, forwarding the service request to a second resource pool, wherein the second resource pool is used for deploying the on-line existing version data, and determining second response data corresponding to the service request based on the second resource pool. According to the technical scheme provided by the invention, the version data which is not verified and is directly on-line is deployed in the resource pool which is different from the existing on-line version data, so that the requirement of quickly on-line of the new version data is met, and meanwhile, the influence range of the new version data is effectively reduced.

Description

Request processing method and device, readable storage medium and electronic equipment
Technical Field
The present invention relates to the field of data processing, and in particular, to a request processing method and apparatus, a readable storage medium, and an electronic device.
Background
With the continuous development of internet technology, audience groups of internet services are continuously expanded, and the service updating speed is faster and faster. At present, in order to ensure the stability of a system, gray scale release is often adopted when releasing new version data, namely, at least one week of gray scale period is needed when updating iterative version data online each time, and when a problem occurs in online logic, the problem can be found in time during the gray scale period and rolled back as soon as possible, so that the influence on a user is reduced. However, when an emergency demand is met, iteration of online version data needs to be performed as soon as possible, online is performed at a minute level, and the online version data is not subjected to gray level verification in time, so that the online version data has a large potential safety hazard, and the online logic has a large influence when a problem occurs.
Disclosure of Invention
The invention provides a request processing method and device, a computer readable storage medium and electronic equipment, which aim to solve the technical problem that in the prior art, version data after being quickly online have greater potential safety hazards.
According to a first aspect of the present invention, there is provided a request processing method, including:
receiving a service request sent by a client;
responding to that the service request accords with a preset forwarding rule, forwarding the service request to a first resource pool, wherein the first resource pool is used for deploying unverified online version data; determining first response data corresponding to the service request based on the first resource pool;
and in response to that the service request does not conform to the preset forwarding rule, forwarding the service request to a second resource pool, wherein the second resource pool is used for deploying online version data, and determining second response data corresponding to the service request based on the second resource pool.
Optionally, the method further comprises:
determining a default parameter value of a system variable corresponding to the service request, wherein the system variable is a parameter which is added in advance and used for indicating a resource pool object, and the default parameter value is used for indicating and forwarding to a second resource pool;
the forwarding the service request to a first resource pool in response to the service request meeting a preset forwarding rule includes:
and in response to the fact that the service request conforms to a preset forwarding rule, rewriting default parameter values of the system variables into dynamic parameter values, and forwarding the service request to a first resource pool based on the dynamic parameter values.
Optionally, the rewriting the default parameter value of the system variable to a dynamic parameter value in response to the service request meeting a preset forwarding rule includes:
reading a preset forwarding rule in the Lua script, and acquiring a protocol method corresponding to the service request;
based on the protocol method, acquiring request parameters carried by the service request;
and if the request parameter accords with a preset parameter, the service request accords with a preset forwarding rule, and a default parameter value of the system variable is rewritten into a dynamic parameter value.
Optionally, the obtaining request parameters carried by the service request based on the protocol method includes:
determining a URL parameter carried by the service request as a request parameter in response to the protocol method being a GET method;
and/or, responding to the protocol method being a POST method, reading the request content of the service request, and acquiring the request parameters.
Optionally, the responding to the protocol method being a POST method, reading request content of the service request, and acquiring a request parameter includes:
and responding to the fact that the protocol method is a POST method, reading request content of the service request, and determining URL parameters carried by the service request as request parameters if a target field in the request content is empty.
Optionally, the method further comprises:
determining a resource usage rate of the second resource pool;
and in response to the resource utilization rate being greater than the preset utilization rate, forwarding the service request to be forwarded to the second resource pool to a third resource pool, wherein the third resource pool is used for deploying the online existing version data.
Optionally, before receiving the service request sent by the client, the method further includes:
when the Nginx interface is pre-configured, determining a target interface, adding a system variable, and assigning the system variable as a default parameter value;
the receiving of the service request sent by the client includes:
and receiving a service request which is sent by the client and corresponds to the target interface.
According to a second aspect of the present invention, there is provided a request processing apparatus comprising:
the request receiving module is used for receiving a service request sent by a client;
the first processing module is used for responding to the fact that the service request accords with a preset forwarding rule, forwarding the service request to a first resource pool, and the first resource pool is used for deploying unverified online version data; determining first response data corresponding to the service request based on the first resource pool;
and the second processing module is used for responding to the fact that the service request does not accord with the preset forwarding rule, forwarding the service request to a second resource pool, wherein the second resource pool is used for deploying on-line existing version data, and determining second response data corresponding to the service request based on the second resource pool.
According to a third aspect of the present invention, there is provided a computer-readable storage medium storing a computer program for executing the above-described request processing method.
According to a fourth aspect of the present invention, there is provided an electronic apparatus comprising:
a processor;
a memory for storing the processor-executable instructions;
the processor is used for reading the executable instruction from the memory and executing the instruction to realize the request processing method.
Compared with the prior art, the request processing method, the request processing device, the computer readable storage medium and the electronic equipment provided by the invention at least have the following beneficial effects:
according to the technical scheme, when unverified version data is online, the unverified online version data is deployed in a first resource pool, the stable online existing version data is deployed in a second resource pool, preset forwarding rules are preset, and resource pool objects corresponding to different service requests are determined by the aid of the preset forwarding rules. When request processing is carried out, whether a service request sent by a client side accords with a preset forwarding rule or not is judged, the service request is forwarded to a first resource pool in response to the fact that the service request accords with the preset forwarding rule, and first response data corresponding to the service request is determined based on the first resource pool; and in response to the fact that the service request does not accord with the preset forwarding rule, forwarding the service request to the second resource pool, and determining second response data corresponding to the service request based on the second resource pool. According to the technical scheme, the first resource pool is newly added, the version data which is not verified to be online is deployed in the first resource pool, the version data which is not verified to be online and the existing version data on the line are separately deployed, the requirement of the new version data for being online quickly can be met, when the logic of the subsequent version data which is not verified to be online is in a problem, the whole business operation cannot be stopped under the condition that the existing version data on the line effectively operates, and the influence range of the new version data is effectively reduced.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the description of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a first flowchart illustrating a request processing method according to an exemplary embodiment of the present invention;
fig. 2 is a flowchart illustrating a request processing method according to an exemplary embodiment of the present invention;
fig. 3 is a flowchart illustrating steps 2011 to 2013 in a request processing method according to an exemplary embodiment of the present invention;
FIG. 4 is a third flowchart illustrating a request processing method according to an exemplary embodiment of the present invention;
FIG. 5 is a block diagram of a request processing device according to an exemplary embodiment of the present invention;
fig. 6 is a block diagram of an electronic device provided in an exemplary embodiment of the invention.
Detailed Description
The technical solutions in the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, belong to the protection scope of the present embodiments.
Exemplary method
Fig. 1 is a flowchart illustrating a request processing method according to an exemplary embodiment of the present invention, which includes at least the following steps:
step 10, receiving a service request sent by a client.
In an embodiment, after performing corresponding operations at a client, a user sends a service request to a server, and the server receives the service request. The client includes, but is not limited to, a mobile phone, a computer, a smart phone, and a smart speaker. The server includes, but is not limited to, a server and a cloud server.
In a possible application scenario, a user clicks to play the video a at a mobile phone end, at this time, a mobile phone client sends a video access request (service request) to a server, and the server receives the video access request and performs subsequent processing.
Step 20, responding to that the service request conforms to a preset forwarding rule, forwarding the service request to a first resource pool, where the first resource pool is used for deploying unverified online version data; and determining first response data corresponding to the service request based on the first resource pool.
In an embodiment, the preset forwarding rule is a preset rule for determining a resource pool object corresponding to the service request, the service request conforms to the preset forwarding rule, the resource pool object corresponding to the service request is a first resource pool, the service request does not conform to the preset forwarding rule, and the resource pool object corresponding to the service request is a second resource pool. The first resource pool is used for deploying unverified online version data, specifically unverified online version data can be unverified in a gray scale period, the unverified online version data is unstable code data, and safety hazards often exist in the unstable code data. After the service request is forwarded to the first resource pool, the service request is responded by using the resources in the first resource pool, first response data corresponding to the service request is determined, and the first response data is returned to the client. Wherein the first response data includes, but is not limited to, an access address and a password for a resource in the first resource pool.
Specifically, resources deployed in the first resource pool do not need to be too many, 3-5 instances are possible, and only a few minutes are needed for one-time full deployment, so that for new version data on line in emergency needs, only the resources of the first resource pool need to be redeployed, the requirement of the new version data on line quickly is met, and the influence range of the new version data is effectively reduced.
In a possible implementation manner, the content of the preset forwarding rule may be that an interface corresponding to the service request is a preset interface. When the service request received by the server side corresponds to a preset interface, namely the service request conforms to a preset forwarding rule, the service request is forwarded to a first resource pool; when the service request received by the server corresponds to a non-preset interface, that is, the service request does not conform to the preset forwarding rule, step 30 is further executed to forward the service request to the second resource pool, so as to implement interface-based request traffic forwarding.
For example, the preset forwarding rule is that the preset interface corresponding to the service request is interface a. When a service terminal is connected to a service request 1, determining an interface corresponding to the service request 1, and if the interface corresponding to the service request 1 is A, the service request conforms to a preset forwarding rule; and if the interface corresponding to the service request 1 is B, the service request does not conform to the preset forwarding rule. In the implementation mode, the service request is corresponding to the preset interface according with the preset forwarding rule and is forwarded to the first resource pool; if the service request does not conform to the preset forwarding rule, the service request corresponds to a non-preset interface and is further forwarded to the second resource pool.
In another possible implementation manner, the content of the preset forwarding rule may carry a target parameter for the service request. When a service request received by a server carries target parameters, namely the service request conforms to a preset forwarding rule, forwarding the service request to a first resource pool; when the service request received by the server does not carry the target parameter, that is, the service request does not conform to the preset forwarding rule, step 30 is further executed to forward the service request to the second resource pool, so as to implement parameter-based request traffic forwarding. Of course, a plurality of target parameters may be set, and the requested traffic may be forwarded after the plurality of target parameters are conditionally aggregated.
For example, the preset forwarding rule is that the target parameter carried by the service request is [ "agenttype" ] ═ 32 ". When a service end receives a service request 2, determining parameter information carried by the service request 2, and if the parameter information carried by the service request 2 is [ "agenttype" ] ═ 32 [, the service request conforms to a preset forwarding rule; if the parameter information carried by the service request 2 is [ "agenttype" ] ═ 16", the service request does not conform to the preset forwarding rule. In the implementation mode, the service request is expressed to carry the target parameter according with the preset forwarding rule, and then the service request is forwarded to the first resource pool; if the service request does not meet the preset forwarding rule, the service request does not carry the target parameter, and then the service request is forwarded to the second resource pool.
In another possible implementation manner, the content of the preset forwarding rule may also be a target method for a protocol method corresponding to the service request. When the protocol method corresponding to the service request received by the server side is a target method, namely the service request conforms to a preset forwarding rule, the service request is forwarded to the first resource pool; and when the protocol method corresponding to the service request received by the server side is a non-target method, the service request does not conform to the preset forwarding rule, and then step 30 is executed to forward the service request to the second resource pool, so that request flow forwarding based on the method is realized.
For example, the protocol method corresponding to the service request is a GET method according to the preset forwarding rule. When the service end is connected to the service request 3, determining a protocol method corresponding to the service request 3, and if the protocol method corresponding to the service request 3 is a GET method, the service request conforms to a preset forwarding rule; if the protocol method corresponding to the service request 3 is the POST method, the service request does not conform to the preset forwarding rule. In the implementation mode, the protocol method corresponding to the service request is expressed as a target method according with the preset forwarding rule and then forwarded to the first resource pool; if the protocol method corresponding to the service request is not the non-target method, the protocol method is forwarded to the second resource pool.
It should be noted that the content of the preset forwarding rule may also be a combination of the foregoing implementation manners, for example, the preset forwarding rule is that an interface corresponding to the service request is a preset interface, and a corresponding protocol method is a target method. The request flow forwarding of different service requests is realized by setting different preset forwarding rules. In this embodiment, specific contents of the preset forwarding rule are not limited, and a user may set the forwarding rule according to actual requirements, and may determine resource pool objects corresponding to different service requests according to the preset forwarding rule.
Step 30, in response to that the service request does not conform to the preset forwarding rule, forwarding the service request to a second resource pool, where the second resource pool is used for deploying online version data, and determining second response data corresponding to the service request based on the second resource pool.
In an embodiment, the second resource pool deploys the on-line version data, and the on-line version data may be a code version verified through a gray scale period, is stable version data, is often used for long-term operation, and is generally safe. If the on-line version data is directly replaced by the on-line version data which is not verified in an iterative mode, the operation of the whole service is influenced when the on-line logic of the subsequent on-line version data which is not verified in an iterative mode, and the influence range is large. In this embodiment, a service request is forwarded through a preset forwarding rule, and for the service request forwarded to the second resource pool, the service request is responded by using a resource in the second resource pool, second response data corresponding to the service request is determined, and the second response data is returned to the client. Wherein the second response data includes, but is not limited to, an access address and a password for the resource in the second resource pool.
In the above embodiment, when unverified online version data is online, the unverified online version data is deployed in the first resource pool, while existing stable online version data is deployed in the second resource pool, a preset forwarding rule is preset, and resource pool objects corresponding to different service requests are determined by using the preset forwarding rule. When request processing is carried out, whether a service request sent by a client side accords with a preset forwarding rule or not is judged, the service request is forwarded to a first resource pool in response to the fact that the service request accords with the preset forwarding rule, and first response data corresponding to the service request is determined based on the first resource pool; and in response to the fact that the service request does not accord with the preset forwarding rule, forwarding the service request to the second resource pool, and determining second response data corresponding to the service request based on the second resource pool. In the embodiment, a first resource pool is newly added, the version data which is not verified to be online is deployed in the first resource pool, the version data which is not verified to be online and the existing version data on the line are separately deployed, the requirement of the new version data on the line can be met, when the on-line logic of the subsequent version data which is not verified to be online has a problem, the whole business operation can not be stopped under the condition that the existing version data on the line effectively operates, and the influence range of the new version data is effectively reduced.
As shown in fig. 2, in an exemplary embodiment of the invention, the method further includes:
and step 40, determining a default parameter value of a system variable corresponding to the service request, wherein the system variable is a parameter which is added in advance and used for indicating a resource pool object, and the default parameter value is used for indicating and forwarding to a second resource pool.
In this embodiment, the step 20 includes:
step 201, in response to that the service request conforms to a preset forwarding rule, rewriting a default parameter value of the system variable into a dynamic parameter value, and forwarding the service request to a first resource pool based on the dynamic parameter value.
Step 202, determining first response data corresponding to the service request based on the first resource pool.
In a possible implementation manner, the forwarding the service request to the second resource pool in response to that the service request does not conform to the preset forwarding rule includes: and responding to the service request not conforming to the preset forwarding rule, and forwarding the service request to a second resource pool based on a default parameter value of a system variable.
In the above embodiment, the system variable is preset, and the system variable is used to indicate the resource pool object and assign the system variable as the default parameter value, for each received service request, the system variable corresponding to the service request is the default parameter value, and the default parameter value is used to indicate that the resource pool object is the second resource pool, that is, if the default parameter value of the system variable is not rewritten, the service request is forwarded to the second resource pool for processing. After receiving the service request, judging whether the service request accords with a preset forwarding rule, if so, rewriting a default parameter value of a system variable into a dynamic parameter value, wherein the dynamic parameter value is used for indicating a resource pool object as a first resource pool, and then forwarding the service request to the first resource pool according to the rewritten dynamic parameter value. And controlling the resource pool object corresponding to the service request through the parameter value of the system variable, and rewriting the default parameter value of the system variable when the service request conforms to the preset forwarding rule, so that the resource pool object corresponding to different service requests can be quickly and accurately determined.
As shown in fig. 3, in an exemplary embodiment of the present invention, the step 201, in response to that the service request conforms to a preset forwarding rule, rewrites a default parameter value of the system variable to a dynamic parameter value, including:
and step 2011, reading a preset forwarding rule in the Lua script, and acquiring a protocol method corresponding to the service request.
In one embodiment, the preset forwarding rule is set through the Lua script, the Lua is a lightweight script language and has high performance, and due to the compactness, the rapidness and the built-in protocol of the Lua, the Lua script is adopted to realize business logic, so that the business logic realization cost is greatly reduced while the high concurrent service capability is ensured. And reading a preset forwarding rule set in the Lua script, and acquiring a protocol method corresponding to the service request according to the content of the preset forwarding rule. The specific protocol method is an HTTP protocol method.
Step 2012, based on the protocol method, obtaining the request parameters carried by the service request.
In an embodiment, the service request carries request parameters, where the request parameters include, but are not limited to, an Agenttype, a Source, and a user id, and the request parameters carried by the service request are obtained in different ways, so that after the protocol method corresponding to the service request is determined, the request parameters carried by the service request are further obtained according to the protocol method corresponding to the service request.
Specifically, the presetting of the target method, the obtaining of the request parameter carried by the service request based on the protocol method, includes: and judging whether the protocol method is a target method or not, and if the protocol request is the target method, acquiring request parameters carried by the service request based on the protocol request. The target method can be set as a GET method, a POST method, a GET method and a POST method, and preliminary request traffic screening based on the target method is achieved.
In a possible implementation manner, the obtaining, based on the protocol method, the request parameter carried by the service request includes: and determining the URL parameter carried by the service request as a request parameter in response to the protocol method being a GET method. At this time, the target method may be set as a GET method, so that when it is determined that the protocol method corresponding to the service request is the GET method, the URL parameter in the GET method is obtained, and the URL parameter is determined as a request parameter, at this time, preliminary request traffic screening based on the GET method is implemented.
In another possible implementation manner, the obtaining, based on the protocol method, the request parameter carried by the service request includes: and responding to the protocol method being a POST method, reading the request content of the service request, and acquiring the request parameters. At this time, the target method may be set as a POST method, so that when it is determined that the protocol method corresponding to the service request is the POST method, the request content of the service request is read, the request parameter is obtained, and at this time, the primary request traffic screening based on the POST method is realized.
Further, the responding to the protocol method being a POST method, reading request content of the service request, and acquiring request parameters includes: and responding to the fact that the protocol method is a POST method, reading request content of the service request, and determining URL parameters carried by the service request as request parameters if a target field in the request content is empty. In a possible application scenario, the protocol method is an nonstandard POST method, and at this time, a target field in the request content may be empty, where the target field is a preselected field, such as a "from" field, and in order to further obtain the request parameter, a URL parameter carried by the service request is obtained, and the URL parameter is determined as the request parameter.
In another possible implementation manner, the obtaining request parameters carried by the service request based on the protocol method includes: determining a URL parameter carried by the service request as a request parameter in response to the protocol method being a GET method; and responding to the protocol method being a POST method, reading the request content of the service request, and acquiring the request parameters. At this time, preliminary request traffic screening based on the GET method and the POST method is realized.
Step 2013, if the request parameter accords with a preset parameter, the service request accords with a preset forwarding rule, a default parameter value of the system variable is rewritten into a dynamic parameter value, and the service request is forwarded to the first resource pool based on the dynamic parameter value.
In an embodiment, a preset parameter is pre-designated, a judgment logic in the content of the preset forwarding rule is set to determine whether the request parameter conforms to the preset parameter, if the request parameter conforms to the preset parameter, the service request conforms to the preset forwarding rule, so that a default parameter value of a system variable is rewritten into a dynamic parameter value, and request traffic forwarding based on the preset parameter is realized.
Further, if the request parameter conforms to a preset parameter, the service request conforms to a preset forwarding rule, and the rewriting of the default parameter value of the system variable into a dynamic parameter value includes: and if the request parameter value corresponding to the request parameter accords with the preset parameter value corresponding to the preset parameter, the service request accords with the preset forwarding rule, and the default parameter value of the system variable is rewritten into the dynamic parameter value. That is, a preset parameter is pre-designated, a preset parameter value is designated, the judgment logic in the content of the preset forwarding rule is set to determine whether the request parameter value meets the preset parameter value, if the request parameter value meets the preset parameter value, the service request meets the preset forwarding rule, so that the default parameter value of the system variable is rewritten into a dynamic parameter value, and the forwarding of the request flow based on the preset parameter and the preset parameter value is realized.
In this embodiment, the method further includes: when the Nginx interface is configured in advance, determining a target interface, adding a system variable, and assigning the system variable as a default parameter value;
correspondingly, the receiving the service request sent by the client includes: and receiving a service request which is sent by the client and corresponds to the target interface.
And carrying out rule configuration on the Nginx interface in advance, defining a target interface during configuration, additionally arranging a system variable, assigning the system variable as a default parameter value, after defining the target interface and receiving a service request corresponding to the target interface, further executing the step 20 and the step 30, further realizing preliminary request flow screening based on the target interface, and carrying out further request flow forwarding on the service request subjected to preliminary screening through a preset forwarding rule.
For example, the Nginx interface is configured in advance, and an example of the interface configuration rule is as follows:
Figure BDA0003703307870000111
namely, determining two target interfaces, namely/apis/third/position and/apis/third/callback, by utilizing location/(logic | callback); and adding a system variable passapi _ new _ feature _ upstream by using set $ passapi _ new _ feature _ upstream 'third _ port', assigning a default parameter value of the system variable to be third _ port, and assigning the default parameter value of the system variable to be a second resource pool, namely, existing version data on a deployment line in the third _ port. And loading a script of passapi _ new _ feature _ rewrite. Lua script passpi _ new _ feature _ rewrite.lua is exemplified as follows:
Figure BDA0003703307870000112
Figure BDA0003703307870000121
that is, a protocol Method for acquiring a service request, i.e., an HTTP Method, acquires a URL parameter using ngx.req.get _ uri _ args () and assigns the URL parameter to args when the service request corresponds to a GET Method. When the service request corresponds to a POST method, reading request content through ngx.req.read _ body (), and assigning parameter values in the request content to args; presetting a target field 'from', when the target field 'from' is judged to be empty, acquiring a URL parameter of a service request through ngx. Further, whether the args has an "agenttype" parameter (preset parameter) and whether the value of the agenttype parameter is equal to 32 (preset parameter value) is judged, and if the args has the "agenttype" parameter and the value is 32, the variable pasapi _ new _ feature _ upstream is assigned to pasport _ new _ feature _ upstream. Rewriting system parameters through a preset forwarding rule set by the Lua script, and if the system parameters accord with the preset forwarding rule, forwarding the request flow to a first resource pool, namely, passport _ new _ feature _ upstream by nginx; if the request traffic does not meet the preset forwarding rule, the request traffic is forwarded to a default second resource pool, i.e., thirdparty _ pool. And configuring the variable name of the upstream through proxy _ pass of the Nginx, dynamically changing system variables, and forwarding different request flows to different resource pool objects.
In the above embodiment, by using a method of combining the Nginx and the Lua script, a specific preset forwarding rule is formulated according to the actual situation of the service, and the related request traffic is forwarded to the first resource pool, so that the requirement of the new version data on-line quickly can be met, and the influence range of the new version data can be reduced.
As shown in fig. 4, in an embodiment of the present invention, the method further includes:
and step 50, determining the resource utilization rate of the second resource pool.
And step 60, in response to that the resource utilization rate is greater than the preset utilization rate, forwarding the service request to be forwarded to the second resource pool to a third resource pool, where the third resource pool is used for deploying the online existing version data.
In the above embodiment, a third resource pool is added, where the third resource pool is used to deploy existing version data on the line, and the third resource pool may be regarded as a branch of the second resource pool. And when the resource utilization rate of the second resource pool is greater than the preset utilization rate, forwarding the service request which should be originally forwarded to the second resource pool to a third resource pool, so that the third resource pool processes the temporarily increased service request. The temporary proliferated service request is a service request which suddenly increases in a specific time period, for example, when a certain tv drama is hot-mapped, or a certain famous anchor is broadcast directly, or a certain evening is broadcast, the temporary proliferated service request may exist, and if the temporary proliferated service request updates the second resource pool, the resource in the second resource pool may be left unused. Therefore, by additionally arranging the third resource pool, the temporarily proliferated service request is forwarded to the third resource pool, so that the temporarily proliferated service request can be quickly and flexibly responded, the resources in the third resource pool can be timely recovered when the temporarily proliferated service request disappears, the flexibility of resource pool configuration is ensured, and the second resource pool is protected.
Exemplary devices
Based on the same concept as the method embodiment of the invention, the embodiment of the invention also provides a request processing device.
Fig. 5 is a schematic structural diagram of a request processing apparatus according to an exemplary embodiment of the present invention, including:
a request receiving module 51, configured to receive a service request sent by a client;
a first processing module 52, configured to forward the service request to a first resource pool in response to that the service request meets a preset forwarding rule, where the first resource pool is used to deploy unverified online version data; determining first response data corresponding to the service request based on the first resource pool;
and a second processing module 53, configured to forward the service request to a second resource pool in response to that the service request does not meet the preset forwarding rule, where the second resource pool is configured to deploy online version data, and determine second response data corresponding to the service request based on the second resource pool.
In an exemplary embodiment of the invention, the apparatus further comprises:
a parameter determining module, configured to determine a default parameter value of a system variable corresponding to the service request, where the system variable is a parameter that is added in advance and used for indicating a resource pool object, and the default parameter value is used for indicating and forwarding to a second resource pool;
the first processing module comprises:
a parameter rewriting unit, configured to rewrite a default parameter value of the system variable to a dynamic parameter value in response to that the service request conforms to a preset forwarding rule, and forward the service request to a first resource pool based on the dynamic parameter value;
and the request response unit is used for determining first response data corresponding to the service request based on the first resource pool.
In an exemplary embodiment of the present invention, the parameter rewriting unit includes:
the method acquisition subunit is used for reading a preset forwarding rule in the Lua script and acquiring a protocol method corresponding to the service request;
a parameter obtaining subunit, configured to obtain, based on the protocol method, a request parameter carried by the service request;
and the parameter rewriting subunit is configured to, if the request parameter conforms to a preset parameter, rewrite a default parameter value of the system variable to a dynamic parameter value, and forward the service request to the first resource pool based on the dynamic parameter value, where the service request conforms to a preset forwarding rule.
In an exemplary embodiment of the present invention, the parameter obtaining subunit is configured to, in response to that the protocol method is a GET method, determine a URL parameter carried by the service request as a request parameter; and/or, responding to the fact that the protocol method is a POST method, reading the request content of the service request, and obtaining the request parameters.
In an exemplary embodiment of the present invention, the parameter obtaining subunit is configured to, in response to that the protocol method is a GET method, determine a URL parameter carried by the service request as a request parameter; and/or responding to the fact that the protocol method is a POST method, reading request content of the service request, and determining URL parameters carried by the service request as request parameters if a target field in the request content is empty.
In an exemplary embodiment of the invention, the apparatus further comprises: a resource protection module; the resource protection module is used for determining the resource utilization rate of the second resource pool; and in response to the resource utilization rate being greater than the preset utilization rate, forwarding the service request to be forwarded to the second resource pool to a third resource pool, wherein the third resource pool is used for deploying the online existing version data.
In an exemplary embodiment of the invention, the apparatus further comprises:
the system comprises a parameter configuration module, a parameter setting module and a parameter setting module, wherein the parameter configuration module is used for determining a target interface when a Nginx interface is configured in advance, adding a system variable and assigning the system variable as a default parameter value;
and the request receiving module is used for receiving the service request which is sent by the client and corresponds to the target interface.
Exemplary electronic device
FIG. 6 illustrates a block diagram of an electronic device in accordance with an embodiment of the present invention.
As shown in fig. 6, the electronic device 100 includes one or more processors 101 and memory 102.
The processor 101 may be a Central Processing Unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in the electronic device 100 to perform desired functions.
Memory 102 may include one or more computer program products that may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, Random Access Memory (RAM), cache memory (cache), and/or the like. The non-volatile memory may include, for example, Read Only Memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium and executed by the processor 101 to implement the request processing methods of the various embodiments of the invention described above and/or other desired functions.
In one example, the electronic device 100 may further include: an input device 103 and an output device 104, which are interconnected by a bus system and/or other form of connection mechanism (not shown).
Of course, for simplicity, only some of the components of the electronic device 100 relevant to the present invention are shown in fig. 6, and components such as buses, input/output interfaces, and the like are omitted. In addition, electronic device 100 may include any other suitable components depending on the particular application.
Exemplary computer program product and computer-readable storage Medium
Sixth aspect, in addition to the above methods and apparatus, embodiments of the present invention may also be a computer program product comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the request processing method according to various embodiments of the present invention described in the "exemplary methods" section above of this specification.
The computer program product may write program code for carrying out operations for embodiments of the present invention in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server.
Furthermore, embodiments of the present invention may also be a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, cause the processor to perform steps in a request processing method according to various embodiments of the present invention described in the "exemplary methods" section above in this specification.
The computer-readable storage medium may take any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The basic principles of the present invention have been described above with reference to specific embodiments, but it should be noted that the advantages, effects, etc. mentioned in the present invention are only examples and are not limiting, and the advantages, effects, etc. must not be considered to be possessed by various embodiments of the present invention. Furthermore, the foregoing detailed description of the invention is provided for the purpose of illustration and understanding only, and is not intended to be limiting, since the invention will be described in any way as it would be understood by one skilled in the art.
The block diagrams of devices, apparatuses, systems involved in the present invention are only given as illustrative examples and are not intended to require or imply that the connections, arrangements, configurations, etc. must be made in the manner shown in the block diagrams. These devices, apparatuses, devices, systems may be connected, arranged, configured in any manner, as will be appreciated by those skilled in the art. Words such as "including," "comprising," "having," and the like are open-ended words that mean "including, but not limited to," and are used interchangeably herein. The words "or" and "as used herein mean, and are used interchangeably with, the word" and/or, "unless the context clearly dictates otherwise. The word "such as" is used herein to mean, and is used interchangeably with, the phrase "such as but not limited to".
It should also be noted that in the apparatus, devices and methods of the present invention, the components or steps may be broken down and/or re-combined. These decompositions and/or recombinations are to be regarded as equivalents of the present invention.
The previous description of the inventive aspects is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other aspects without departing from the scope of the invention. Thus, the present invention is not intended to be limited to the aspects shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing description has been presented for purposes of illustration and description. Furthermore, this description is not intended to limit embodiments of the invention to the form disclosed herein. While a number of example aspects and embodiments have been discussed above, those of skill in the art will recognize certain variations, modifications, alterations, additions and sub-combinations thereof.

Claims (10)

1. A method for processing a request, comprising:
receiving a service request sent by a client;
responding to that the service request accords with a preset forwarding rule, forwarding the service request to a first resource pool, wherein the first resource pool is used for deploying unverified online version data; determining first response data corresponding to the service request based on the first resource pool;
and in response to that the service request does not conform to the preset forwarding rule, forwarding the service request to a second resource pool, wherein the second resource pool is used for deploying online version data, and determining second response data corresponding to the service request based on the second resource pool.
2. The method of claim 1, further comprising:
determining a default parameter value of a system variable corresponding to the service request, wherein the system variable is a parameter which is added in advance and used for indicating a resource pool object, and the default parameter value is used for indicating and forwarding to a second resource pool;
the forwarding the service request to a first resource pool in response to the service request meeting a preset forwarding rule includes:
and in response to the fact that the service request conforms to a preset forwarding rule, rewriting default parameter values of the system variables into dynamic parameter values, and forwarding the service request to a first resource pool based on the dynamic parameter values.
3. The method of claim 2, wherein the adapting the default parameter values of the system variables to dynamic parameter values in response to the service request complying with a preset forwarding rule comprises:
reading a preset forwarding rule in the Lua script, and acquiring a protocol method corresponding to the service request;
based on the protocol method, acquiring request parameters carried by the service request;
and if the request parameter accords with a preset parameter, the service request accords with a preset forwarding rule, and a default parameter value of the system variable is rewritten into a dynamic parameter value.
4. The method according to claim 3, wherein the obtaining request parameters carried by the service request based on the protocol method includes:
determining a URL parameter carried by the service request as a request parameter in response to the protocol method being a GET method; and/or the presence of a gas in the gas,
and responding to the protocol method being a POST method, reading the request content of the service request, and acquiring the request parameters.
5. The method according to claim 4, wherein the reading the request content of the service request and obtaining the request parameters in response to the protocol method being a POST method comprises:
and responding to the fact that the protocol method is a POST method, reading request content of the service request, and determining URL parameters carried by the service request as request parameters if a target field in the request content is empty.
6. The method of claim 1, further comprising:
determining a resource usage rate of the second resource pool;
and in response to the resource utilization rate being greater than the preset utilization rate, forwarding the service request to be forwarded to the second resource pool to a third resource pool, wherein the third resource pool is used for deploying the online existing version data.
7. The method according to any of claims 1-6, wherein before receiving the service request sent by the client, the method further comprises:
when the Nginx interface is pre-configured, determining a target interface, adding a system variable, and assigning the system variable as a default parameter value;
the receiving of the service request sent by the client includes:
and receiving a service request which is sent by the client and corresponds to the target interface.
8. A request processing apparatus, comprising:
the request receiving module is used for receiving a service request sent by a client;
the first processing module is used for responding to the fact that the service request accords with a preset forwarding rule, forwarding the service request to a first resource pool, and the first resource pool is used for deploying unverified online version data; determining first response data corresponding to the service request based on the first resource pool;
and the second processing module is used for responding to the fact that the service request does not accord with the preset forwarding rule, forwarding the service request to a second resource pool, wherein the second resource pool is used for deploying on-line existing version data, and determining second response data corresponding to the service request based on the second resource pool.
9. A computer-readable storage medium storing a computer program for executing the request processing method of any one of claims 1 to 7.
10. An electronic device, the electronic device comprising:
a processor;
a memory for storing the processor-executable instructions;
the processor is configured to read the executable instructions from the memory and execute the instructions to implement the request processing method of any one of claims 1 to 7.
CN202210697590.2A 2022-06-20 2022-06-20 Request processing method and device, readable storage medium and electronic equipment Active CN115022174B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210697590.2A CN115022174B (en) 2022-06-20 2022-06-20 Request processing method and device, readable storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210697590.2A CN115022174B (en) 2022-06-20 2022-06-20 Request processing method and device, readable storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN115022174A true CN115022174A (en) 2022-09-06
CN115022174B CN115022174B (en) 2024-03-26

Family

ID=83074960

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210697590.2A Active CN115022174B (en) 2022-06-20 2022-06-20 Request processing method and device, readable storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115022174B (en)

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060236319A1 (en) * 2005-04-15 2006-10-19 Microsoft Corporation Version control system
CN103905225A (en) * 2012-12-25 2014-07-02 中国移动通信集团浙江有限公司 Service control method, service control device and service system
CN105955761A (en) * 2016-06-30 2016-09-21 乐视控股(北京)有限公司 Docker-based gray level issuing device and docker-based gray level issuing method
CN106998369A (en) * 2017-05-26 2017-08-01 努比亚技术有限公司 Gray scale dissemination method, gateway blocker and computer-readable recording medium
CN109857428A (en) * 2018-12-29 2019-06-07 大唐软件技术股份有限公司 Gray scale dissemination method for IOM system
CN110365502A (en) * 2018-03-26 2019-10-22 华为技术有限公司 A kind of method, apparatus and storage medium of service upgrade management
CN111857763A (en) * 2019-04-30 2020-10-30 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN111897542A (en) * 2020-08-31 2020-11-06 北京三快在线科技有限公司 Method and device for gray scale release
CN111988200A (en) * 2020-08-18 2020-11-24 湖南快乐阳光互动娱乐传媒有限公司 Automatic regression testing method and device based on real flow
WO2020252751A1 (en) * 2019-06-20 2020-12-24 深圳市欢太科技有限公司 Resource pushing method, device, server, and storage medium
US20200412644A1 (en) * 2019-06-28 2020-12-31 Beijing Baidu Netcom Science And Technology Co., Ltd. Content based routing method and apparatus
CN112162762A (en) * 2020-10-16 2021-01-01 中国工商银行股份有限公司 Gray scale distribution method, gray scale distribution device and electronic equipment
CN112988394A (en) * 2021-04-20 2021-06-18 北京世纪好未来教育科技有限公司 Business service publishing method, device, medium and equipment based on cloud native container
CN113676549A (en) * 2021-09-02 2021-11-19 京东科技信息技术有限公司 Application request distribution method, application gateway, electronic device and storage medium

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060236319A1 (en) * 2005-04-15 2006-10-19 Microsoft Corporation Version control system
CN103905225A (en) * 2012-12-25 2014-07-02 中国移动通信集团浙江有限公司 Service control method, service control device and service system
CN105955761A (en) * 2016-06-30 2016-09-21 乐视控股(北京)有限公司 Docker-based gray level issuing device and docker-based gray level issuing method
CN106998369A (en) * 2017-05-26 2017-08-01 努比亚技术有限公司 Gray scale dissemination method, gateway blocker and computer-readable recording medium
CN110365502A (en) * 2018-03-26 2019-10-22 华为技术有限公司 A kind of method, apparatus and storage medium of service upgrade management
CN109857428A (en) * 2018-12-29 2019-06-07 大唐软件技术股份有限公司 Gray scale dissemination method for IOM system
CN111857763A (en) * 2019-04-30 2020-10-30 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
WO2020252751A1 (en) * 2019-06-20 2020-12-24 深圳市欢太科技有限公司 Resource pushing method, device, server, and storage medium
US20200412644A1 (en) * 2019-06-28 2020-12-31 Beijing Baidu Netcom Science And Technology Co., Ltd. Content based routing method and apparatus
CN111988200A (en) * 2020-08-18 2020-11-24 湖南快乐阳光互动娱乐传媒有限公司 Automatic regression testing method and device based on real flow
CN111897542A (en) * 2020-08-31 2020-11-06 北京三快在线科技有限公司 Method and device for gray scale release
CN112162762A (en) * 2020-10-16 2021-01-01 中国工商银行股份有限公司 Gray scale distribution method, gray scale distribution device and electronic equipment
CN112988394A (en) * 2021-04-20 2021-06-18 北京世纪好未来教育科技有限公司 Business service publishing method, device, medium and equipment based on cloud native container
CN113676549A (en) * 2021-09-02 2021-11-19 京东科技信息技术有限公司 Application request distribution method, application gateway, electronic device and storage medium

Also Published As

Publication number Publication date
CN115022174B (en) 2024-03-26

Similar Documents

Publication Publication Date Title
US20160055034A1 (en) Stream processing using a client-server architecture
CN107547629B (en) Method and device for downloading client static resources, electronic equipment and readable medium
US20150120854A1 (en) Subscriber based priority of messages in a publisher-subscriber domain
CN107798064B (en) Page processing method, electronic device and computer readable storage medium
WO2021121407A1 (en) Capacity changing method and apparatus for virtual machine
US11463494B2 (en) Balance of initial frame and limitation of traffic
CN112528274B (en) Data processing method, device, electronic equipment and storage medium
CN111694639B (en) Updating method and device of process container address and electronic equipment
CN111586437B (en) Barrage message processing method, system, computing device and storage medium
CN111367518A (en) Page layout method and device, computing equipment and computer storage medium
CN114528517A (en) View processing method and device, electronic equipment and computer readable medium
CN115022174A (en) Request processing method and device, readable storage medium and electronic equipment
CN111078900B (en) Data risk identification method and system
CN113835789A (en) Rendering method, rendering device, electronic equipment and computer storage medium
CN115454576B (en) Virtual machine process management method and system and electronic equipment
US10616317B2 (en) Method and system for affinity load balancing
CN104407846B (en) Information processing method and device
CN113946376A (en) Load adjustment method and device, electronic equipment and storage medium
CN115129469B (en) Cross-process communication method, device, equipment and storage medium
CN115277694B (en) Data acquisition method, device, system, electronic equipment and storage medium
CN113094607B (en) Method and device for obtaining local resources
CN110858240A (en) Front-end module loading method and device
CN105991728B (en) File downloading method and terminal
CN111611259B (en) Interface request processing method, device, system and computer readable storage medium
CN112988391A (en) Data processing method, device, equipment and storage medium

Legal Events

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