CN116016677A - Service request processing method and device and computer equipment - Google Patents

Service request processing method and device and computer equipment Download PDF

Info

Publication number
CN116016677A
CN116016677A CN202211593334.5A CN202211593334A CN116016677A CN 116016677 A CN116016677 A CN 116016677A CN 202211593334 A CN202211593334 A CN 202211593334A CN 116016677 A CN116016677 A CN 116016677A
Authority
CN
China
Prior art keywords
service
server
service type
type
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211593334.5A
Other languages
Chinese (zh)
Inventor
史明明
江魁栋
李尚真
李晶
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
CCB Finetech Co Ltd
Original Assignee
China Construction Bank Corp
CCB Finetech 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 China Construction Bank Corp, CCB Finetech Co Ltd filed Critical China Construction Bank Corp
Priority to CN202211593334.5A priority Critical patent/CN116016677A/en
Publication of CN116016677A publication Critical patent/CN116016677A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The application relates to a service request processing method, a service request processing device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: receiving service request information of a client; the analysis script is called to analyze the request body in the service request information to obtain a requested service code and a service type corresponding to the service code; determining a target server for processing the service code according to the service flow state of the service type, the service type and a mapping relation table between the service type and the server; and forwarding the service code to the target server. According to the service flow state of the service type, the service type and the mapping relation table between the service type and the server, the target server of the service code can be directly obtained.

Description

Service request processing method and device and computer equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a service request processing method, an apparatus, a computer device, a storage medium, and a computer program product.
Background
With the popularization of the internet, the number of netizens in China is increasing, and various application programs related to daily life are developed to provide services for people. Such as shopping applications, video applications, and the like. When the user clicks a button or a menu while using the application program, a request is initiated to the server at least once, and the server processes the request information of the user. In the case of priority of server resources, in order to increase the processing rate of the server to the request information of the user, a load balancing manner is presented.
The prior art load balancing mode can only simply and evenly distribute requests to different servers for processing. Because the load balancing mode is single, the load balancing capability in a complex service scene is affected.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a service request processing method, apparatus, computer device, computer readable storage medium, and computer program product that can improve the load balancing effect capability.
In a first aspect, the present application provides a service request processing method, where the method includes:
receiving service request information of a client;
The analysis script is called to analyze the request body in the service request information to obtain a requested service code and a service type corresponding to the service code;
determining a target server for processing the service code according to the service flow state of the service type and a mapping relation table between the service type and the server;
and forwarding the service code to the target server.
In one embodiment, determining the target server for processing the service code according to the service traffic state of the service type and a mapping relation table between the service type and the server includes:
if the service type is in a normal service flow state, a mapping relation table between the service type and a server is obtained;
and searching in a mapping relation table between the service type and the server according to the service type, and determining a target server for processing the service code.
In one embodiment, determining the target server for processing the service code according to the service traffic state of the service type and a mapping relation table between the service type and the server includes:
if the service type is in a service flow surge state, acquiring a designated forwarding server corresponding to the service type according to a mapping relation table between the service type and the server;
And determining a target server for processing the service code according to the load state of the designated forwarding server.
In one embodiment, determining the target server for processing the service code according to the load state of the designated forwarding server includes: if the load of the designated forwarding server is not saturated, using the designated forwarding server with the unsaturated load as a target server for processing the service code;
and if the load of the appointed forwarding server is saturated, expanding the standby appointed server into the standby appointed server of the service type, and taking the standby appointed server as a target server for processing the service code.
In one embodiment, the method further comprises: if the absolute value of the difference value between the service request quantity of the service type in the current period and the preset service request quantity is larger than a first threshold value, and the absolute value of the difference value between the service request quantity of the service type in two adjacent periods is larger than a second threshold value, determining that the service type is in a service flow surge state.
In one embodiment, the method further comprises:
if the service type is in a service flow surge state, acquiring the associated service type of the service type;
And expanding a designated forwarding server for the associated service type.
In one embodiment, the method further comprises:
and updating a mapping relation table between the service type and the server according to the expanded designated forwarding server of the service type.
In a second aspect, the present application provides a service request processing apparatus, including:
the receiving module is used for receiving the service request information of the client;
the analysis module is used for calling an analysis script to analyze a request body in the service request information to obtain a requested service code and a service type corresponding to the service code;
the processing module is used for determining a target server for processing the service code according to the service flow state of the service type and a mapping relation table between the service type and the server;
and the forwarding module is used for forwarding the service code to the target server.
In one embodiment, the processing module is further configured to obtain a mapping relationship table between the service type and the server if the service type is in a normal service traffic state; and searching in a mapping relation table between the service type and the server according to the service type, and determining a target server for processing the service code.
In one embodiment, the processing module is further configured to obtain, if the service type is in a service traffic surge state, a designated forwarding server corresponding to the service type according to a mapping relationship table between the service type and a server; and determining a target server for processing the service code according to the load state of the designated forwarding server.
In one embodiment, the processing module is further configured to, if the load of the designated forwarding server is not saturated, use the designated forwarding server with the unsaturated load as a target server for processing the service code; if the load of the appointed forwarding server is saturated, expanding a standby appointed server into the appointed forwarding server of the service type; and taking the standby appointed server as a target server of the service type.
In one embodiment, the processing module is further configured to determine that the service type is in a service flow surge state if an absolute value of a difference between the number of service requests of the service type in the current period and a preset number of service requests is greater than a first threshold, and an absolute value of a difference between the number of service requests of the service type in two adjacent periods is greater than a second threshold.
In one embodiment, the processing module is further configured to obtain an associated service type of the service type if the service type is in a service traffic surge state; and expanding a designated forwarding server for the associated service type.
In one embodiment, the processing module is further configured to update a mapping relationship table between the service type and a server according to the extended designated forwarding server of the service type.
In a third aspect, the present application provides a computer device comprising a memory storing a computer program and a processor implementing the following method steps when executing the computer program:
receiving service request information of a client;
the analysis script is called to analyze the request body in the business request information to obtain a requested business code and a business type corresponding to the business code;
determining a target server for processing the service code according to the service flow state of the service type and a mapping relation table between the service type and the server;
and forwarding the service code to the target server.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the following method steps:
Receiving service request information of a client;
the analysis script is called to analyze the request body in the business request information to obtain a requested business code and a business type corresponding to the business code;
determining a target server for processing the service code according to the service flow state of the service type and a mapping relation table between the service type and the server;
and forwarding the service code to the target server.
In a fifth aspect, the present application provides a computer program product comprising a computer program which, when executed by a processor, performs the following method steps:
receiving service request information of a client;
the analysis script is called to analyze the request body in the business request information to obtain a requested business code and a business type corresponding to the business code;
determining a target server for processing the service code according to the service flow state of the service type and a mapping relation table between the service type and the server;
and forwarding the service code to the target server.
According to the service request processing method, the device, the computer equipment, the storage medium and the computer program product, the service code of the request of the code layer and the service type of the service layer are obtained by calling the analysis script to analyze the request body of the service request information, and the target server of the service code can be directly obtained according to the service flow state of the service type, the service type and the mapping relation table between the service type and the server. The method is different from the traditional uniform load balancing mode, sets corresponding servers for different service types, considers the service flow states of the service types, does not need to additionally increase forwarding configuration for service requests of each user, completes forwarding of service codes through a mapping relation table of the service types and the servers, is simple and efficient in forwarding process, and also considers the service flow states of the different service types when in distribution, so that multiple emergency situations can be applied, and the load balancing capability is improved.
Drawings
FIG. 1 is an application environment diagram of a service request processing method in one embodiment;
FIG. 2 is a flow diagram of a method for processing a service request in one embodiment;
FIG. 3 is a flowchart of a method for determining a server corresponding to a service code according to an embodiment;
FIG. 4 is a method of determining a transaction code in one embodiment;
FIG. 5 is a flow diagram of a method of specifying a target server in one embodiment;
FIG. 6 is a schematic diagram of a service request information period in one embodiment;
FIG. 7 is a diagram of a mapping relationship table between traffic types and servers in one embodiment;
FIG. 8 is a flow diagram of a method of load balancing according to transaction dynamics based on Nginx in one embodiment;
FIG. 9 is a block diagram of a service request processing apparatus in one embodiment;
fig. 10 is an internal structural view of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
It should be noted that, user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
According to the 49 th statistical report of the development status of the Internet of China, the scale of the netizens of China reaches 10.32 hundred million by 2021 in 12 months, and the popularization rate of the Internet reaches 73.0% compared with 4296 ten thousand in 12 months of 2020, which is a huge pressure on various websites and APP. Generally, when a user clicks a button or menu, a request is initiated to a server at least once, and the time of each request is approximately between 50 ms and 200ms, for a server deploying an 8-core 32G memory of a java application, 100 threads can be started at the same time to process a transaction, and in theory, the peak value of processing the transaction by a single server is 2000 transactions/second. In the face of huge network citizens, a single server cannot bear the load, and at this time, a virtual service address (VIP) is generally set by a web server to virtualize a plurality of cloud server resources into a high-performance and high-availability application service pool, so that throughput is increased and transaction processing capacity is improved. Typical web servers include nmginx, apache and Lighttpd, where weight-based rotation load balancing of nmginx is the current mainstream solution, and can distribute all requests sent by clients according to weight rotation set by each server, so as to reduce pressure of each server and improve availability of the system.
Wherein Nginx (engine x) is a high-performance HTTP and reverse proxy WEB server, the nmginx layer comprises: the processor module (handers), the filter module (filters) and the proxy module (proteins) are used for interacting with some services such as fastCGI at the back end, so as to realize functions of service proxy, load balancing and the like.
The Nginx is used as a mainstream Web server at present, is very widely used, and can improve the bandwidth of the server, increase the throughput, improve the processing capacity of transactions, improve the flexibility and the usability of a network and the like through a load balancing scheme of the Nginx, wherein the load balancing scheme defaults to support the following five types: polling, polling by weight, IP Hash, minimum number of connections, and URL Hash.
For the traditional load balancing mode, the request information can be simply and uniformly distributed to different servers, the request is indistinguishable, and after the request information is analyzed, forwarding of the request information is completed by adding forwarding configuration to the request information. With the increase of service types, the forwarding configuration of the service becomes complicated and inconvenient to maintain due to the rapid increase of the service volume.
In view of this, the service request processing method provided in the embodiment of the present application may be applied to the application environment shown in fig. 1. Wherein the client 102 communicates with the proxy server 104 via a network. The proxy server 104 communicates with the target server 106 and the data storage system may store data that the proxy server 104 needs to process. The data storage system may be integrated on the proxy server 104 or may be located on the cloud or other network server. The proxy server 104 receives the service request information of the client 102; the proxy server 104 calls an analysis script to analyze a request body in the service request information to obtain a requested service code and a service type corresponding to the service code; the proxy server 104 determines a target server for processing the service code according to the service flow state of the service type, the service type and a mapping relation table between the service type and the server; the proxy server 104 forwards the traffic code to the target server 106.
The client 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. Proxy server 104 may be implemented as a stand-alone server or a cluster of servers, and target server 106 may be implemented as a stand-alone server or a cluster of servers that may handle different traffic types of servers.
In one embodiment, as shown in fig. 2, a service request processing method is provided, and an example of application of the method to the proxy server in fig. 1 is described, including the following steps:
s202, receiving service request information of a client.
The service request information may be a request message generated by a user performing a certain operation on the client, and the service request information may include a service code and a service type.
The service code is the identification of the service request information of the user at the code level, and the service type is the type of the service request information of the user at the service level. It can be understood that the service code of the code layer is a code that can be directly processed by the proxy server, and can be analyzed, identified or forwarded, etc., and the service type of the service layer is a type of specific operation of the proxy server for extracting the service request information, for example, ordering, requesting to obtain user rights and interests, requesting to obtain user member information, etc.
Specifically, the service request information may be a specific request message generated when the user performs a transaction operation at the client. Taking a business request as an example of a transaction request, the transaction request message includes a transaction code and a transaction type.
The transaction code included in the transaction request message may be a code-level transaction code such as registration code, login code, search code, order code, payment code, etc. The transaction type contained in the transaction request message may be a transaction type of a business layer such as registration, login, search, ordering, payment, and the like.
The service request information may be an HTTP request based on an HTTP protocol, which is an abbreviation of a hypertext transfer protocol (Hyper Text Transfer Protocol), which is a request-response protocol. It specifies what messages the client might send to the server and what responses it gets.
Based on the HTTP protocol, the client can initiate an HTTP request to the server, and the server returns response information to the client by processing the HTTP request. Specifically, the browser is used as an HTTP client to send HTTP request information to an HTTP server (WEB server) through a URL, and the WEB server returns response information to the client according to the received HTTP request information.
The client and server communication process involves two types of messaging, including: client-side initiated HTTP request message and server-side initiated HTTP response message. The HTTP request message initiated by the client specifically comprises: request lines, request headers, empty lines, and request data (request body); the HTTP response information initiated by the server side specifically comprises: status line, message header (response header) empty line, and response body.
Specifically, the service request information of the client may be received through the proxy server.
The proxy server is a server with a transfer function, and is used for receiving and analyzing the service request information of the client and forwarding the service request information to the target server according to the analysis result. The target server processes the service request information to obtain service response information, and the service response information is returned to the client through the proxy server.
Specifically, a WEB server is built by taking a proxy server as an nmginx module as a core, and service request information is an HTTP request, which is described as an example:
as shown in fig. 3, the nginnx module receives HTTP request information of a client, where the HTTP request includes a request line, a request header, and request data, and data such as a service code, a service type, and the like may be stored in the request header or the request data, and the proxy server forwards the HTTP request message to the target server according to a certain rule. The target server processes the service request information of the client side to generate service response information, wherein the service response information comprises a state row, a message header and a response text. Wherein, the status line corresponds to the request line, the message header corresponds to the request header, and the message body corresponds to the request data one by one.
S204, the analysis script is called to analyze the request body in the service request information, and the service code of the request and the service type corresponding to the service code are obtained.
The parsing script may be an embedded script type compatible with a processing module (such as an nmginx module) in the proxy server, and the parsing script is used for parsing a request body of service request information of the client, and specifically, the parsing script may be a Lua script or other scripts having a parsing function and compatible with the nmginx module in the proxy server.
The service request information is typically an HTTP request, which typically includes a request line, a request header (request header), and a request body (request data).
Specifically, the request line of the HTTP request includes a protocol type required for parsing, and the request header or the request body of the HTTP request includes an object that needs to be parsed by the proxy server. Specifically, the parsing mode may be that the nmginx module of the proxy server invokes the Lua script, and parses the code in the request header or the request body based on the protocol type of the request line, to obtain the requested service code and the service type corresponding to the service code.
In addition, the location where the analysis object is stored in the service request information is also different for different service request information, and in general, the analysis object is stored in the request body of the service request information, in a specific case, the analysis object may be stored in the request header of the service request information, in which case, it is necessary to store the analysis object in the request header of the service request information in a manner of "attribute and attribute value" by a certain storage rule, which is more complicated than another manner.
The service code of the request is a code which can be directly processed by the proxy server, and specifically, the service code of the transaction request can be a transaction code. The service type is the type of service request information of the user in the service layer, and specifically may be the transaction type of the transaction request message, for example, the transaction type of registration, login, search, ordering, payment and the like.
Specifically, the Nginx module analyzes a request body of service request information based on a protocol type of a request line, and in the analysis process, the Nginx module controls the Lua script to extract service codes and service types contained in the request body to obtain the service codes of the request and the service types corresponding to the service codes.
S206, determining the target server for processing the service code according to the service flow state of the service type and the mapping relation table between the service type and the server.
Wherein, the service flow state of the service type represents the amount of the service volume of the target service type in a period of time, and the service flow state comprises: normal traffic state, traffic surge state, etc.
The normal flow state may be that a difference between an increase amount of service request information of the client and a service request information processing amount of the target server is smaller than a preset threshold value within a period of time, and in the flow state, the target server may be guaranteed to process the service request information of the client and return service response information on the premise that the target server does not exceed a design load.
The service flow surge state may be that a difference between an increase amount of service request information of the client and a service request information processing amount of the target server is greater than a preset threshold value within a period of time, in the flow state, processing of the service request information of the client is ensured and service response information is returned within a short period of time, but as time goes on, computing resources of the target server are gradually saturated until the load capacity of the target server reaches a design load value, and at this time, processing of the service request information of the client cannot be ensured and service response information is returned.
The mapping relation table between the service types and the servers can be preconfigured in the proxy server, the number of the target servers can be multiple, and the service types processed by the target servers are generally different.
Specifically, different mapping tables are selected according to the traffic state of the traffic type, for example, when the traffic state of a certain traffic type is a normal traffic state, a mapping table of the normal traffic state is selected, and when the traffic state of a certain traffic type is a traffic surge state, a mapping table of the traffic surge state is selected, that is, the number of servers corresponding to the traffic type is more than that of the normal traffic state, or the performance of the servers corresponding to the traffic type is better than that of the normal traffic state.
The mapping table under different traffic flow states can be selected through the traffic flow states of the traffic types, and the target server for processing the traffic codes is determined according to the mapping table, the traffic types and the traffic types under the different traffic flow states.
The target server may be a server with a strong load capacity or a large load residual space, and specifically, when the service type corresponds to a plurality of specified servers, the server with the highest load capacity or the largest load residual space may be used as the target server. S208, the service code is forwarded to the target server.
And after the target server of the determined service code of the service type is obtained, forwarding the service code to the target server.
Specifically, for a plurality of service request information, the service request information is analyzed and forwarded according to different service types, and the service code is forwarded to a target server for processing a single service type. It should be noted that the target server may be configured to process servers of multiple service types, but in a certain period, the target server only processes service codes of a single service type, thereby improving processing efficiency. The processing service type of the target server may also be changed, for example, in the first period, the service type processed by the target server is a login service processing type, and in the second period, the service type processed by the target server is changed to a payment service processing type.
In the service request processing method, the service code of the request of the code layer and the service type of the service layer are obtained by analyzing the request body of the service request information by calling the analysis script, and the target server of the service code can be directly obtained according to the service flow state of the service type, the service type and the mapping relation table between the service type and the server. The method is different from the traditional uniform load balancing mode, sets corresponding servers for different service types, considers the service flow states of the service types, does not need to additionally increase forwarding configuration for service requests of each user, completes forwarding of service codes through a mapping relation table of the service types and the servers, is simple and efficient in forwarding process, and also considers the service flow states of the different service types when in distribution, so that multiple emergency situations can be applied, and the load balancing capability is improved.
In one embodiment, according to the service traffic state of the service type and the mapping relation table between the service type and the server, the target server for processing the service code is determined, as shown in fig. 4, and the method for determining the service code includes:
S402, if the service type is in a normal service flow state, a mapping relation table between the service type and a server is obtained;
the normal service flow state may be that a difference between an increase amount of service request information of the client and a service request information processing amount of the target server is smaller than a preset threshold value within a period of time, and in the flow state, the target server can be guaranteed to process the service request information of the client and return service response information on the premise that the target server does not exceed a design load.
Specifically, a mapping relationship table between a plurality of service types and servers may be determined in advance. The mapping relation table can be a mapping relation table of a normal service flow state or a mapping relation table of a service flow surge state.
Taking a service type as a registration service type as an example, describing that if the difference between the increment of the registration service request information and the processing amount of the service request information of the target server is smaller than a preset threshold value within a period of time, at this time, the registration service type is in a normal service flow state, a mapping relation table between the service type and the server, that is, a mapping relation table of the normal service flow state is obtained.
And if the difference between the increment of the registered service request information and the service request information processing amount of the target server in a period of time is larger than a preset threshold value, acquiring a mapping relation table between the service type and the server, namely, a mapping relation table of the service flow surge state.
S404, searching in a mapping relation table between the service type and the server according to the service type, and determining a target server for processing the service code.
Wherein, according to the mapping relation table between a plurality of service types and the server which is determined in advance, the target server for processing the service codes is determined according to the service types.
In this embodiment, according to the service type, the mapping relationship table between the service type and the server is searched, so that the server for processing the transaction code under the transaction type can be quickly obtained according to the mapping relationship table between the service type and the server, and a basis is provided for forwarding the transaction code to the target server.
In one embodiment, determining a target server for processing a service code according to a service traffic state of a service type and a mapping relation table between the service type and the server includes: if the service type is in a service flow surge state, acquiring a designated forwarding server corresponding to the service type according to a mapping relation table between the service type and the server; and determining a target server for processing the service codes according to the load state of the designated forwarding server.
The service flow surge state may be that a difference between an increase amount of service request information of the client and a service request information processing amount of the target server is greater than a preset threshold value in a period of time, in the flow state, processing of the service request information of the client is guaranteed and service response information is returned in a short time, but as time goes on, computing resources of the target server are gradually saturated until load capacity of the target server reaches a design load value, and at this time, processing of the service request information of the client cannot be guaranteed and service response information is returned.
If the service type of the service request information is in a service flow surge state, acquiring a designated forwarding server corresponding to the service type.
The designated server comprises all servers under a certain service type, and the designated server comprises one or more servers, so that when the designated server is one, the designated server is a target server, and when the designated server is a plurality of servers, one server can be selected from the designated servers to serve as the target server.
The designated forwarding server may include a target server and other servers, where the other servers may process the same traffic type as the target server and the computing resources of the other servers may be different from the computing resources of the target server, e.g., the other servers may perform better than the target server or the target servers may perform better than the other servers. It should be noted that performance and computing resources represent specific data throughput capacity of a server, which are all indexes for measuring the capacity of service to process data.
Wherein specifying the load state of the forwarding server includes: load saturation of the designated forwarding server, load non-saturation of the designated forwarding server.
If the load of the designated forwarding server is saturated, a standby designated server should be selected as the target server of the service type in the service traffic surge state. If the load of the designated forwarding server is not saturated, the designated forwarding server can be used as the target server of the service type in the service flow surge state.
In this embodiment, by determining the load state of the designated forwarding server, the problem of load imbalance possibly caused when the service type is in the service flow surge state can be solved, and a server with sufficient computing resources is provided in advance for the service code of the subsequent target server to process the service request information, so that the data throughput of the server is improved, and further the processing efficiency of the server is improved.
In one embodiment, determining a target server for processing a traffic code based on a load status of a designated forwarding server includes: if the load of the designated forwarding server is not saturated, using the designated forwarding server with the unsaturated load as a target server for processing the service code; if the load of the appointed forwarding server is saturated, expanding the standby appointed server into a standby appointed server of a service type; and taking the standby designated server as a target server of the service type.
Specifically, a flow chart of a method for specifying a target server shown in fig. 5 includes:
s502, judging whether the load state of the designated forwarding server is saturated, if so, executing S504, and if not, executing S508.
The load state of the designated forwarding service can be judged through the interface data flow of the proxy server and the designated forwarding server, and a load state judgment result of the designated forwarding server is obtained according to the accumulated value of the data throughput in a period of time and the design load of the designated forwarding server.
S504, expanding the standby appointed server into a standby appointed server of a service type.
Wherein, one or more designated forwarding servers can be additionally configured for the target servers corresponding to the service types in advance. And when the server load is in a saturated state, using the additionally configured one or more designated forwarding servers as standby designated servers.
The backup assigned service may be temporarily configured, and the backup assigned server may be expanded to be an assigned server of the service type.
S506, taking the standby appointed server as a target server of the service type.
S508, the designated forwarding server with unsaturated load is used as a target server for processing the service code.
In this embodiment, by judging whether the load states of the designated forwarding servers are saturated, the most suitable target server for processing the service codes is found in the load states of different designated forwarding servers, and the performance and the load states of each server are considered, so that the computing resources of the target server are matched with the traffic of the service request information, thereby saving the computing resources of the target server and improving the processing efficiency of the target server.
In one embodiment, the service request processing method further includes: if the absolute value of the difference between the service request quantity of the service type in the current period and the preset service request quantity is larger than a first threshold value, and the absolute value of the difference between the service request quantity of the service type in the adjacent two periods is larger than a second threshold value, determining that the service type is in a service flow surge state.
Wherein the first threshold is determined by taking into account an average of the number of service requests of a service type over a period of time.
The second threshold is used for measuring the speed increase of the service request quantity of the service type in the current period, the size of the second threshold is determined according to the performance of the target server and the load state of the server, and it can be understood that the better the performance of the target server is, the larger the load state of the server is unsaturated.
The duration of one period may be determined according to the initiation frequency of the service request information, and if the initiation frequency of the service request information is higher, the time of one period is shorter, specifically, the duration of one period may be 5min.
Specifically, as shown in the schematic diagram of the service request information period in fig. 6, the state that the service type is in the service flow at the current moment is judged: if the absolute value of the difference between the service request quantity of the service type in the second period and the preset service request quantity is larger than a first threshold value, and the absolute value of the difference between the service request quantity of the service type in the first period and the service request quantity in the second period is larger than a second threshold value, determining that the service type is in a service surge state.
In this embodiment, by setting two thresholds, the absolute increment of the service request number and the increment speed of the service request number are determined, so that whether the service type is in the service flow surge state can be accurately determined, and a basis is provided for how to forward the service request information in the service flow surge state subsequently.
In one embodiment, if the service type is in a service flow surge state, acquiring an associated service type of the service type; specifying forwarding servers for associated traffic type extensions
The related service types refer to service types related to the original service types on a service level, and the original service types are registration, login, search, ordering and payment.
Specifically, the original service type is a registration service type, and the associated service type may be a login service type. The original service type is a login service type, and the associated service type can be a registration service type.
If the original service type is one of the search, order and payment service types, the associated service type can be the other two types.
When the service type is in a service flow surge state, expanding the designated forwarding server for the associated service type comprises: and expanding the designated forwarding servers according to the sequence of the associated service types.
The sequence of the associated service types indicates that the original service types and the associated service types have a logic sequence on the service level, for example, there is no sequence for registering and logging in the two service types and the associated service types, that is, the user can send out the registration service request first or the logging in service request first.
For example, for three service types of searching, ordering and paying, there is a sequence, the sequence is generally searching first, ordering and paying later, or ordering first and paying later, or directly paying.
Specifically, for the original service types and the associated service types without sequence, when the original service types are in a service flow surge state, the assigned forwarding servers are extended and designated simultaneously according to the original service types and the associated service types, namely, the assigned forwarding servers are extended and designated for the associated service types.
For ordered original service types and associated service types, when the original service types are in a service flow surge state, expanding and designating a forwarding server according to the associated service types after the original service types in order.
In this embodiment, by considering the degree and sequence of association between the original service type and the associated service type, the service associated with the surge service can be prejudged in advance, the server is expanded in advance, preparation is made for surge of the related service, and the processing efficiency is improved.
As shown in fig. 7, the mapping relationship table between the updated service type and the server is obtained according to the mapping relationship table before the update of the original service type and the target server and the mapping relationship table which needs to be added for the update of the extended designated forwarding server of the service type.
Specifically, the mapping relation table before updating includes service types (registration service type, search service type, and order service type), and target servers (server 1, server 2, and server 3) corresponding to the service types. If the conditions of the surge of the service flow and the saturation of the load of the designated forwarding server occur, the corresponding relation between the original service type (registration service type, search service type and order service type) and the designated forwarding server corresponding to the associated service type (login service type and payment service type) is recorded, and a mapping relation table which needs to be increased is obtained. And obtaining the mapping relation table between the updated service type and the server according to the mapping relation table before updating of the original service type and the target server and the mapping relation table between the service type of the extended service and the appointed forwarding service.
In this embodiment, the mapping relation table between the service type and the server is updated, so that the service type and the extended service type can be directly forwarded according to the updated mapping table, and the forwarding convenience of the service request information can be improved.
In one embodiment, as shown in fig. 8, there is provided a load balancing method according to transaction dynamics based on nginix, including:
S802, the client initiates service request information.
S804, the proxy server receives the service request information of the client.
Wherein, the proxy server accepts the HTTP request through the Nginx application.
S806, the analysis script is called to analyze the request body in the service request information, and the service code of the request and the service type corresponding to the service code are obtained.
And analyzing the HTTP request through the Nginx application, and calling the Lua script to dynamically acquire the service type of the client request in the analysis process.
S808, judging whether the service type is in the normal flow state of the service, if so, executing S810, and if not, executing S814.
S810, if the service type is in a normal service flow state, a mapping relation table between the service type and the server is obtained.
If the absolute value of the difference between the service request quantity of the service type in the current period and the preset service request quantity is larger than a first threshold value, and the absolute value of the difference between the service request quantity of the service type in the adjacent two periods is larger than a second threshold value, determining that the service type is in a service flow surge state.
If the service type is in a service flow surge state, acquiring the associated service type of the service type; extending a designated forwarding server for the associated service type; and designating a forwarding server according to the expansion of the associated service type.
And updating the mapping relation table between the service type and the server according to the appointed forwarding server of the extended service type.
S812, searching in a mapping relation table between the service type and the server according to the service type, determining a target server for processing the service code, and executing S818.
S814, if the service type is in the service flow surge state, acquiring the designated forwarding server corresponding to the service type according to the mapping relation table between the service type and the server.
If the load of the designated forwarding server is not saturated, the designated forwarding server with the unsaturated load is used as a target server for processing the service code; if the load of the appointed forwarding server is saturated, expanding the standby appointed server into a standby appointed server of a service type; and using the standby designated server as a target server for processing the service codes.
And updating the mapping relation table between the service type and the server according to the appointed forwarding server of the extended service type.
S816, determining a target server for processing the service code according to the load state of the designated forwarding server.
S818, forwarding the service code to the target server.
S820, the target server returns a service response message.
In one embodiment, directly rewriting the load balancing module of the nginnx, adding a configuration for forwarding according to transactions is a high-coupling application mode, and the mode is high in stability and not prone to error.
Specifically, what is done on the nginx level is to add a location to match the transaction without using lua script processing, and the specific added configuration is simply exemplified as follows:
# for search transactions
# denotes the destination server address for transaction specific forwarding;
setting some header information (request header addition configuration 1);
some header information is additionally set (request header addition configuration 2);
some header information is set again (request header increment configuration 3).
In this embodiment, the service code of the request of the code layer and the service type of the service layer are obtained by analyzing the request body of the service request information by calling an analysis script, and the target server of the service code can be directly obtained according to the service flow state of the service type, the service type and the mapping relation table between the service type and the server. The method is different from the traditional uniform load balancing mode, sets corresponding servers for different service types, considers the service flow states of the service types, does not need to additionally increase forwarding configuration for service requests of each user, completes forwarding of service codes through a mapping relation table of the service types and the servers, is simple and efficient in forwarding process, and also considers the service flow states of the different service types when in distribution, so that multiple emergency situations can be applied, and the load balancing capability is improved. The method is a non-invasive method for expanding the load balancing mode of the Nginx, and an Nginx load balancing strategy is added, so that the method can be distributed to different servers for processing aiming at the transaction type initiated by the client, and the aim of processing specific transactions by specific servers is fulfilled. The Nginx load balancing mode is enhanced, the dynamic allocation of transactions according to transaction types is supported, the service requirements of the scene are well met, the setting of Nginx configuration is greatly reduced, the use is convenient, and the expansibility is good.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a service request processing device for implementing the service request processing method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of one or more service request processing devices provided below may refer to the limitation of the service request processing method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 9, there is provided a service request processing apparatus, including: a receiving module 902, a parsing module 904, a processing module 906, and a forwarding module 908, wherein:
a receiving module 902, configured to receive service request information of a client;
the parsing module 904 is configured to invoke a parsing script to parse a request body in the service request information, so as to obtain a requested service code and a service type corresponding to the service code;
a processing module 906, configured to determine a target server for processing the service code according to the service traffic state of the service type and a mapping relationship table between the service type and the server;
and a forwarding module 908, configured to forward the service code to the target server.
In one embodiment, the processing module 906 is further configured to obtain a mapping relationship table between the service type and the server if the service type is in a normal service traffic state; and searching in a mapping relation table between the service type and the server according to the service type, and determining a target server for processing the service code.
In one embodiment, the processing module 906 is further configured to obtain, if the service type is in a service traffic surge state, a designated forwarding server corresponding to the service type according to a mapping relationship table between the service type and the server; and determining a target server for processing the service codes according to the load state of the designated forwarding server.
In one embodiment, the processing module 906 is further configured to, if the load of the designated forwarding server is not saturated, use the designated forwarding server with the unsaturated load as a target server for processing the service code; if the load of the appointed forwarding server is saturated, the standby appointed server is expanded into a standby appointed server of a service type, and the standby appointed server is used as a target server for processing the transaction code.
In one embodiment, the processing module 906 is further configured to determine that the service type is in the traffic surge state if an absolute value of a difference between the number of service requests of the service type in the current period and the preset number of service requests is greater than a first threshold and an absolute value of a difference between the number of service requests of the service type in two adjacent periods is greater than a second threshold.
In one embodiment, the processing module 906 is further configured to obtain an associated service type of the service type if the service type is in a service traffic surge state; a forwarding server is specified for the associated service type extension.
In one embodiment, the processing module 906 is further configured to update the mapping relationship table between the service type and the server according to the specified forwarding server of the extended service type.
The above-described respective modules in the service request processing apparatus may be implemented in whole or in part by software, hardware, and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 10. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing service request information data. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a service request handling method.
It will be appreciated by those skilled in the art that the structure shown in fig. 10 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase ChangeMemory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as Static Random access memory (Static Random access memory AccessMemory, SRAM) or dynamic Random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (17)

1. A method for processing a service request, the method comprising:
receiving service request information of a client;
the analysis script is called to analyze the request body in the service request information to obtain a requested service code and a service type corresponding to the service code;
determining a target server for processing the service code according to the service flow state of the service type and a mapping relation table between the service type and the server;
And forwarding the service code to the target server.
2. The method of claim 1, wherein determining the target server that handles the service code based on the service traffic status of the service type and a mapping table between service types and servers, comprises:
if the service type is in a normal service flow state, a mapping relation table between the service type and a server is obtained;
and searching in a mapping relation table between the service type and the server according to the service type, and determining a target server for processing the service code.
3. The method of claim 1, wherein determining the target server that handles the service code based on the service traffic status of the service type and a mapping table between service types and servers, comprises:
if the service type is in a service flow surge state, acquiring a designated forwarding server corresponding to the service type according to a mapping relation table between the service type and the server;
and determining a target server for processing the service code according to the load state of the designated forwarding server.
4. A method according to claim 3, wherein determining the destination server that handles the traffic code based on the load status of the designated forwarding server comprises:
If the load of the designated forwarding server is not saturated, using the designated forwarding server with the unsaturated load as a target server for processing the service code;
and if the load of the appointed forwarding server is saturated, expanding the standby appointed server into the standby appointed server of the service type, and taking the standby appointed server as a target server for processing the service code.
5. The method according to claim 2, wherein the method further comprises: if the absolute value of the difference value between the service request quantity of the service type in the current period and the preset service request quantity is larger than a first threshold value, and the absolute value of the difference value between the service request quantity of the service type in two adjacent periods is larger than a second threshold value, determining that the service type is in a service flow surge state.
6. A method according to claim 3, characterized in that the method further comprises:
if the service type is in a service flow surge state, acquiring the associated service type of the service type;
and expanding a designated forwarding server for the associated service type.
7. The method according to claim 4 or 6, characterized in that the method further comprises:
And updating a mapping relation table between the service type and the server according to the expanded designated forwarding server of the service type.
8. A service request processing apparatus, the apparatus comprising:
the receiving module is used for receiving the service request information of the client;
the analysis module is used for calling an analysis script to analyze a request body in the service request information to obtain a requested service code and a service type corresponding to the service code;
the processing module is used for determining a target server for processing the service code according to the service flow state of the service type and a mapping relation table between the service type and the server;
and the forwarding module is used for forwarding the service code to the target server.
9. The apparatus of claim 8, wherein the processing module is further configured to obtain a mapping table between a service type and a server if the service type is in a normal traffic state; and searching in a mapping relation table between the service type and the server according to the service type, and determining a target server for processing the service code.
10. The apparatus of claim 8, wherein the processing module is further configured to obtain a designated forwarding server corresponding to the service type according to a mapping relationship table between the service type and a server if the service type is in a service traffic surge state; and determining a target server for processing the service code according to the load state of the designated forwarding server.
11. The apparatus of claim 10, wherein the processing module is further configured to, if a load of the designated forwarding server is not saturated, use the designated forwarding server with the unsaturated load as a target server for processing the service code; and if the load of the appointed forwarding server is saturated, expanding the standby appointed server into the standby appointed server of the service type, and taking the standby appointed server as a target server for processing the service code.
12. The apparatus of claim 9, wherein the processing module is further configured to determine that the traffic type is in a traffic surge state if an absolute value of a difference between a number of traffic requests of the traffic type in a current period and a preset number of traffic requests is greater than a first threshold and an absolute value of a difference between a number of traffic requests of the traffic type in two adjacent periods is greater than a second threshold.
13. The apparatus of claim 10, wherein the processing module is further configured to obtain an associated service type for the service type if the service type is in a service traffic surge state; and expanding a designated forwarding server for the associated service type.
14. The apparatus according to claim 11 or 13, wherein the processing module is further configured to update a mapping relationship table between the service type and a server according to the extended designated forwarding server of the service type.
15. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when the computer program is executed.
16. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
17. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
CN202211593334.5A 2022-12-13 2022-12-13 Service request processing method and device and computer equipment Pending CN116016677A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211593334.5A CN116016677A (en) 2022-12-13 2022-12-13 Service request processing method and device and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211593334.5A CN116016677A (en) 2022-12-13 2022-12-13 Service request processing method and device and computer equipment

Publications (1)

Publication Number Publication Date
CN116016677A true CN116016677A (en) 2023-04-25

Family

ID=86023925

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211593334.5A Pending CN116016677A (en) 2022-12-13 2022-12-13 Service request processing method and device and computer equipment

Country Status (1)

Country Link
CN (1) CN116016677A (en)

Similar Documents

Publication Publication Date Title
US10331504B2 (en) Method and system for extending application programming interfaces
JP6676080B2 (en) Method and system for installing an application version via near field communication
CN110557284B (en) Data aggregation method and device based on client gateway
JP2018055241A (en) Device, method and program for providing document file creation service in cloud system
WO2020232698A1 (en) Secure web application delivery platform
US20170155712A1 (en) Method and device for updating cache data
Srirama et al. Croudstag: social group formation with facial recognition and mobile cloud services
US9742835B2 (en) System and method for backend control of frontend user interfaces
US9350738B2 (en) Template representation of security resources
CN110650209A (en) Method and device for realizing load balance
WO2017143747A1 (en) Network request method and system for network terminal
US20160301625A1 (en) Intelligent High-Volume Cloud Application Programming Interface Request Caching
CN115811481B (en) Interactive service testing method and device, computer equipment and storage medium
CN116776030A (en) Gray release method, device, computer equipment and storage medium
US10069938B1 (en) Returning identifiers in default query responses
US9602594B2 (en) Processing requests
CN114666418B (en) Service system connection method, device and storage medium
CN116016677A (en) Service request processing method and device and computer equipment
US11023440B1 (en) Scalable distributed data processing and indexing
CN112929453B (en) Method and device for sharing session data
US10878187B1 (en) Network-based content rendering
US11095748B1 (en) Network-based content rendering
CN108733805B (en) File interaction method, system, computer equipment and storage medium
CN115250276A (en) Distributed system and data processing method and device
CN111782428A (en) Data calling system and method

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