CN116016675A - Service request processing method and device, gateway equipment and storage medium - Google Patents

Service request processing method and device, gateway equipment and storage medium Download PDF

Info

Publication number
CN116016675A
CN116016675A CN202211532697.8A CN202211532697A CN116016675A CN 116016675 A CN116016675 A CN 116016675A CN 202211532697 A CN202211532697 A CN 202211532697A CN 116016675 A CN116016675 A CN 116016675A
Authority
CN
China
Prior art keywords
service
request
working state
response
acquiring
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
CN202211532697.8A
Other languages
Chinese (zh)
Inventor
于宗潍
张骏杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
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 CN202211532697.8A priority Critical patent/CN116016675A/en
Publication of CN116016675A publication Critical patent/CN116016675A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the invention relates to a service request processing method, a device, gateway equipment and a storage medium, wherein the method comprises the following steps: when a target request of a first service is received, acquiring a working state of a second service, wherein the gateway is connected with an application program interface of the second service; when the working state is determined to be a first load state, generating a simulation data result in response to the target request; and returning the simulation data result to the first service. Therefore, cross-language and scene fusing can be realized, service overload is relieved, research and development cost is reduced, and service processing efficiency is improved.

Description

Service request processing method and device, gateway equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of Internet, in particular to a service request processing method, a device, gateway equipment and a storage medium.
Background
Service fusing generally refers to a protection measure adopted in a software system to prevent the whole system from being failed due to overload phenomenon of service caused by some reasons. Because the existing programming languages are of a plurality of types, the fusing schemes of the various languages are not the same, the various languages need to be defined by a calling party one by one, and meanwhile, some languages have no fusing scheme temporarily.
Therefore, in the prior art, there is no unified fusing scheme, and the development cost of the fusing component is high, the usability and the like need to be continuously optimized to be used in the production environment, so that overload phenomenon is easy to occur in service, and system faults are caused.
Disclosure of Invention
In view of this, in order to solve the technical problem that the overload phenomenon occurs in the service, the embodiments of the present invention provide a service request processing method, a device, a gateway device and a storage medium.
In a first aspect, an embodiment of the present invention provides a service request processing method, which is applied to a gateway, and includes:
when a target request of a first service is received, acquiring a working state of a second service, wherein the gateway is connected with an application program interface of the second service;
when the working state is determined to be a first load state, generating a simulation data result in response to the target request;
and returning the simulation data result to the first service.
In one possible implementation manner, the acquiring the working state of the second service includes:
acquiring the response success rate of the second service to the request within a preset time period;
acquiring average response time of the second service to the request within a preset time period;
When the response success rate is smaller than or equal to the first threshold value, determining that the working state is the first load state;
or alternatively, the first and second heat exchangers may be,
and when the average response time is greater than or equal to the second threshold value, determining that the working state is the first load state.
In one possible implementation manner, the acquiring the working state of the second service further includes:
and when the response success rate is greater than a first threshold value and the average response time is smaller than a second threshold value, determining that the working state is a second load state.
In one possible embodiment, the method further comprises: and when the working state is the second load state, sending the target request to the second service so that the second service executes the operation corresponding to the target request.
In one possible implementation manner, the acquiring the working state of the second service includes:
acquiring the average response success rate of the second service in the current period;
determining a difference value between the average response success rate of the previous period and the average response success rate of the current period;
and when the difference value is larger than a third threshold value, determining the working state as a first load state.
In one possible implementation manner, the acquiring the working state of the second service includes:
acquiring the average response time of the second service in the current period;
determining a difference value between the average response time of the current period and the average response time of the previous period;
and when the difference value is larger than a fourth threshold value, determining that the working state is the first load state.
In one possible embodiment, the method further comprises:
acquiring a response result corresponding to the second service when the second service returns a target state code for the first time within a preset time period, wherein the target state code is generated by the second service in response to a request;
and taking the response result as a simulation data result corresponding to the target request.
In a possible implementation manner, after the step of returning the simulation data result to the first service, the method further includes:
storing the target request;
acquiring the working state of the second service every preset time period;
when the working state is switched from the first load state to a second load state, the target request is sent to the second service;
And receiving and storing a response result returned by the second service.
In a second aspect, an embodiment of the present invention provides a service request processing apparatus, including:
the gateway comprises an application program interface of the second service;
the generation module is used for responding to the target request to generate a simulation data result when the working state is a first load state;
and the sending module is used for returning the simulation data result to the first service.
In a third aspect, an embodiment of the present invention provides a gateway device, including: a processor and a memory, where the processor is configured to execute a service request processing program stored in the memory, so as to implement the service request processing method according to any one of the foregoing first aspects.
In a fourth aspect, an embodiment of the present invention provides a storage medium storing one or more programs executable by one or more processors to implement the service request processing method according to any one of the first aspects.
According to the service request processing scheme provided by the embodiment of the invention, when a target request of a first service is received, the working state of a second service is acquired, and the gateway is connected with an application program interface of the second service; when the working state is determined to be a first load state, generating a simulation data result in response to the target request; and returning the simulation data result to the first service. The method and the device realize fusing of cross-language and scenes, relieve service overload, reduce research and development cost and improve service processing efficiency.
Drawings
Fig. 1 is a flow chart of a service request processing method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating another service request processing method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for processing a service request according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating another service request processing method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a service request processing device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a gateway device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
For the purpose of facilitating an understanding of the embodiments of the present invention, reference will now be made to the following description of specific embodiments, taken in conjunction with the accompanying drawings, which are not intended to limit the embodiments of the invention.
Fig. 1 is a flow chart of a service request processing method according to an embodiment of the present invention, as shown in fig. 1, where the method specifically includes:
and S11, when receiving a target request of the first service, acquiring the working state of the second service, wherein the gateway is connected with an application program interface of the second service.
The service request processing method provided by the embodiment of the invention is applied to the gateway, the gateway can be a fusing gateway, an access port for providing access for the second service can be provided, the second service can be fused through the gateway, and the first service can call the second service through the gateway. Specifically, when the gateway receives the request of the first service, the state of the second service is judged, and a response result is returned to the first service according to the state of the second service, so that the processing pressure of the second service is reduced.
In this embodiment, the first service is a calling end, the second service is a called end, and the first service calls the second service by sending a request, and receives a result returned in response to the request. The second service may have a unique application program interface (Application Programming Interface, API) which may be demo.
Further, the first service adjusts the calling mode of the second service to be sent to the gateway demo. Overload of the second service, failure of the second service, normal second service, etc.
Specifically, the method for acquiring the working state may include: and acquiring average response time, response success rate and the like of the gateway in the last period of time, and determining the current working state of the second service according to the threshold range of the average response time and/or the threshold range of the response success rate, wherein different threshold ranges correspond to different working states.
In one possible implementation, the configuration is performed in the gateway in advance, and the content of the configuration may include, but is not limited to: conditions for determining the current operating state of the second service (e.g., a threshold range for determining an average response time, a response success rate), and a simulation data result (mock result) corresponding to the current operating state of the second service. So that the configured gateway can quickly and accurately judge the working state after receiving the target request.
And S12, when the working state is determined to be the first load state, generating a simulation data result in response to the target request.
In this embodiment, the first load state characterizes that the second service is currently unable to process the target request, for example, the first load state may be: the second service is overloaded or the second service fails. The gateway does not send the target request to the second service at this time, but rather performs fuse protection.
Specifically, the gateway is preset with simulation data results, each type of request corresponds to at least one simulation data result, and when the second service is in the first load state, the simulation data result corresponding to the target request is determined.
S13, returning the simulation data result to the first service.
In this embodiment, the simulation data result is used as the data responding to the target request, and the simulation data result is returned to the first service, and at this time, the first service uses the received simulation data result as the response data, so that the response speed to the request of the first service is ensured.
In one possible implementation manner, when the working state is the second load state, the second service working state is represented as a normal load, and the target service can be processed normally, at this time, the gateway performs traffic release, that is, sends the target request to the second service, so that the second service performs an operation corresponding to the target request, and returns the response result to the first service after the second service generates the response result in response to the target request.
According to the service request processing method provided by the embodiment of the invention, when the target request of the first service is received, the working state of the second service is obtained, and the gateway is connected with the application program interface of the second service; when the working state is determined to be a first load state, generating a simulation data result in response to the target request; and returning the simulation data result to the first service. The cross-language and cross-scene fusing is realized through the fusing gateway, so that the phenomenon of service overload is relieved, the research and development cost is reduced, and the service request efficiency is improved.
Fig. 2 is a flow chart of another service request processing method according to an embodiment of the present invention, as shown in fig. 2, where the method specifically includes:
s21, configuring in the gateway in advance.
In this embodiment, after the second service interfaces its api to the fused gateway, the gateway is configured, where the configuration content may include, but is not limited to: (1) When the second service is in the first load state, the mock results returned to the first service may correspond to different mock results, e.g., the mock results may be 'result', 'mock', 'msg', 'error, return mock result', etc.
(2) A response time threshold for comparison with an average response time of the second service over a preset period of time, for example, the response time threshold may be: 800ms, and when the average response time exceeds the value, directly returning a mock interface to the first service so that the first service receives a preset mock result.
(3) And the response success rate threshold is used for comparing the response success rate of the second service in the preset time period. For example, 95%, and directly returns a mock interface to the first service when the response success rate is lower than the value, so that the first service receives a preset mock result.
S22, when a target request of the first service is received, acquiring a response success rate of the second service to the request within a preset time period; and acquiring the average response time of the second service to the request within a preset time period.
In this embodiment, when the gateway receives the target request sent by the first service, the gateway calculates the health status of the second service interface demo.
Specifically, a preset time period (for example, 5 minutes) is set, and the gateway obtains the duty ratio of the 2xx and 3xx status codes returned by the second service in the preset time period, so as to obtain the response success rate. And acquiring the response time of each time in a preset time period, and determining the average response time according to the response time and the response times of each time.
S23, when the response success rate is smaller than or equal to the first threshold value, determining that the working state is the first load state; or when the average response time is greater than or equal to the second threshold value, determining that the working state is the first load state.
In this embodiment, a first threshold is preset, where the first threshold is a response success rate threshold in step S21, and when the response success rate is less than or equal to the first threshold, it is indicated that the second service cannot process the target request, or the success rate of processing the target request is low, at this time, the second service is determined to be in a working state as a first load state, and the first load state characterizes that the second service is overloaded or failed at this time. Or, a second threshold is preset, the second threshold is an average response time threshold in step S21, and when the average response time is greater than or equal to the first threshold, it is indicated that the second service cannot process the target request, or the time for processing the target request is longer, and at this time, the second service is determined and the working state is the first load state.
In one possible implementation, when the response success rate is greater than the first threshold value and the average response time is less than the second threshold value, determining that the working state is a second load state, wherein the second load state represents that the second service is a health state, and the target request can be normally processed. When the working state is the second load state, the gateway can directly send the target request to the second service, so that the second service executes the operation corresponding to the target request, and returns a response result corresponding to the target request to the first service in response to the target request.
S24, returning the simulation data result to the first service.
In this embodiment, when the working state is determined to be the first load state, the gateway determines, from the preconfigured mock results, a target mock result corresponding to the target request as the analog data result, and returns the analog data result to the first service.
S25, storing the target request; acquiring the working state of the second service every preset time period; when the working state is switched from the first load state to a second load state, the target request is sent to the second service; and receiving and storing a response result returned by the second service.
In this embodiment, after the analog data result is returned, the gateway stores the target request in the storage area in the gateway, repeatedly acquires the working state of the second service in the preset time period every interval preset time period, when the working state is switched from the first load state to the second load state, the second service can normally process the target request at this time, the gateway can normally release the target request, after the target request is sent to the second service, the gateway receives the response result returned by the second service, and updates the analog data result stored in the gateway according to the response result, or stores the response result in the gateway as the analog data result corresponding to the target request, so as to realize that the same target request is received next time, and when the second service is in the first load state, the response result can be directly returned. In one possible implementation, the response result may be returned to the first service again.
The service request processing method provided by the embodiment of the invention is configured in the gateway in advance; when a target request of a first service is received, acquiring a response success rate of a second service to the request within a preset time period; acquiring average response time of the second service to the request within a preset time period; when the response success rate is smaller than or equal to a first threshold value, determining that the working state is a first load state; or when the average response time is greater than or equal to the second threshold value, determining that the working state is a first load state; returning the simulation data result to the first service; storing the target request; acquiring the working state of the second service every preset time period; when the working state is switched from the first load state to the second load state, sending a target request to the second service; and receiving and storing a response result returned by the second service. Therefore, the fusing scheme is irrelevant to programming language, the service is not invaded, the service code is not influenced, any language can be used, the problem of service overload is solved by controlling the fusing through the gateway, the development cost of the fusing scheme is reduced, the configuration is simple, the user experience is improved, and the service availability of the user side is ensured by timely fusing.
Fig. 3 is a flow chart of another service request processing method according to an embodiment of the present invention, as shown in fig. 3, where the method specifically includes:
s31, when a target request of a first service is received, acquiring an average response success rate of the second service in a current period; determining a difference value between the average response success rate of the previous period and the average response success rate of the current period; and when the difference value is larger than a third threshold value, determining the working state as a first load state.
In this embodiment, if the content in step S21 is not preconfigured, the gateway performs intelligent fusing, that is, determines the working state of the second service according to the change condition of the response success rate and the change condition of the average response time in different periods, and specifically calculates the moving average value of the response success rate and the moving average value of the average response time.
The moving average algorithm may include: the fusing gateway records 1 index value every preset time period, and a plurality of preset time periods exist in each period, so that in each period, we record response success rate indexes as rate1, rate2 and rate3 … response time indexes as time1, time2 and time3 …, and the moving average Mt of the t-th period is used as the predicted value of the t+1th period, wherein yt and yt-1 … respectively represent the observed values of the t, t-1 … th periods (namely rate1 or time 1); n is the average number of terms.
Figure BDA0003970819710000101
The average response success rate and the average response time can be calculated by the formula.
Specifically, the duration (for example, 10 minutes) of each period is preset, the gateway obtains the response success rate of the second service in each preset time period (for example, 1 minute) in the current period, a plurality of response success rates are obtained, the average response success rate of the current period is determined according to the number of the plurality of response success rates, and the average response success rate of the previous period is determined in the same manner.
In one possible implementation, an average response time of the second service in the current period is obtained; determining a difference value between the average response time of the current period and the average response time of the previous period; and when the difference value is larger than a fourth threshold value, determining the working state as the first load state.
Specifically, the gateway obtains the response time of the second service to each request in the current period, determines the average response time according to the response times and the response time of each request, and the average response time of the previous period is determined by the same, further, determines the difference value between the average response time of the previous period and the average response time of the current period, and when the difference value is larger than a fourth threshold value, indicates that the current response time is obviously increased compared with the previous period, and determines that the working state is the first load state.
In one possible implementation manner, a first average response success rate in a period corresponding to the current moment is obtained, a second average response success rate in a period corresponding to the same moment as the current moment in the previous 24 hours is obtained, a difference value between the second average response success rate and the first average response success rate is determined, and when the difference value is greater than a fifth threshold value, the working state is determined to be the first load state.
In one possible implementation manner, a first average response time in a period corresponding to the current moment is obtained, a second average response time in a period corresponding to the same moment as the current moment in the previous 24 hours is obtained, a difference value between the second average response time and the first average response time is determined, and when the difference value is greater than a sixth threshold value, the working state is determined to be the first load state.
S32, acquiring a response result corresponding to the second service when the second service returns to the target state code for the first time in a preset time period; and taking the response result as a simulation data result corresponding to the target request.
In this embodiment, each preset time period or preset period is acquired, whether the second service returns a target state code or not in the current time period or the current period, when the determination result is yes, a response result corresponding to the first time of returning the target state code is acquired, the response result is taken as a simulation data result corresponding to the target request and is stored in the gateway, wherein the target state code is generated by the second service in response to the request in the preset time period or the preset period, and may be a 200-state code.
Further, after the time enters the next time period or the next period, the response result is updated based on the target state code received in the next time period or the next period.
And S33, returning the simulation data result to the first service when the working state is a first load state.
In this embodiment, similar to step S13, please refer to step S13 for specific description, and detailed description is omitted in this embodiment.
According to the service request processing method provided by the embodiment of the invention, when the target request of the first service is received, the average response success rate of the second service in the current period is obtained; determining a difference value between the average response success rate of the previous period and the average response success rate of the current period; when the difference value is larger than a third threshold value, determining that the working state is a first load state; acquiring a response result corresponding to the second service when the target state code is returned for the first time in a preset time period; taking the response result as a simulation data result corresponding to the target request; and when the working state is a first load state, returning the simulation data result to the first service. Therefore, when the second service is overloaded, a response result can be timely returned to the first service, the user experience is improved, the processing burden of the second service is avoided, and the service processing efficiency is improved.
As an example, fig. 4 is a schematic diagram of another service request processing method according to an embodiment of the present invention. As shown in fig. 4, the method includes: the service A is a first service, the service B is a second service, the service A calls an interface of the service B, and the service B has a unique interface demo.
1. The B service interfaces its api to the fusing gateway and can selectively configure the following options (or not)
(1) The mock results returned upon failure, e.g., { ' result ': mock ', ' msg ': error, return mock result }
(2) The first threshold is 800ms, and when the average response time exceeds the value, the mock interface is directly returned to the service A;
(3) The second threshold is 95%, and when the response success rate is lower than the value, the mock interface is directly returned to the calling party.
2. The A service adjusts the calling mode of the B service to be sent to the fusing gateway demo.
3. When the request of A is sent to B, through the fusing gateway, the gateway calculates the duty ratio of 2xx and 3xx state codes in the B service interface demo.
If the B service is not configured, the gateway intelligently fuses, and the average response success rate and the average response time are determined according to the index value, including:
i. Recording and storing a response result when the service B returns the 200 state codes for the first time, keeping the latest response result of the interface updated every 5 minutes, and if the latest 200 state code result is not available, not updating the record;
after the flow is accessed, taking the response success rate and the moving average value within 10 minutes of the response time as the reference, and when the average response success rate index value at the current moment drops by 10 percent (the value is configurable) or the average response time index value rises by 100 percent (the value is configurable), considering that the service B is in a first load state, starting fusing, and returning the response result recorded in the i for the service A;
after 24 hours of access, increasing the comparison of the response success rate and the response time at the same time before 24 hours on the basis of ii, and when the response success rate index value at the current time is 10 percent (the value is configurable) or the response time index value is 100 percent (the value is configurable) in an up-to-date way, considering the service B as a second load state, starting fusing, and returning the return result recorded in i for the service A;
and IV, after the fusing is started, the gateway starts the detection of the service B, copies the call request of the service A to be sent to the service B, continuously checks the health state of the service B, and after the service B is recovered, closes the fusing, and normally releases the flow.
Fig. 5 is a schematic structural diagram of a service request processing device according to an embodiment of the present invention, where, as shown in fig. 5, the device specifically includes:
the acquiring module 51 is configured to acquire, when receiving a target request of a first service, a working state of a second service, where the gateway is connected to an application program interface of the second service;
a generating module 52, configured to generate a simulation data result in response to the target request when the working state is a first load state;
and a sending module 53, configured to return the simulation data result to the first service.
In a possible implementation manner, the acquiring module is specifically configured to acquire a response success rate of the second service to the request within a preset period of time;
acquiring average response time of the second service to the request within a preset time period;
a determining module 54, configured to determine that the working state is the first load state when the response success rate is less than or equal to the first threshold;
or alternatively, the first and second heat exchangers may be,
and when the average response time is greater than or equal to the second threshold value, determining that the working state is the first load state.
In a possible implementation manner, the determining module is specifically configured to determine that the working state is the second load state when the response success rate is greater than a first threshold and the average response time is less than a second threshold.
In a possible implementation manner, the sending module is further configured to send the target request to the second service when the working state is the second load state, so that the second service executes an operation corresponding to the target request.
In a possible implementation manner, the obtaining module is specifically configured to obtain an average response success rate of the second service in the current period;
the determining module is specifically configured to determine a difference value between an average response success rate of a previous period and an average response success rate of a current period;
and when the difference value is larger than a third threshold value, determining the working state as a first load state.
In a possible implementation manner, the acquiring module is specifically configured to acquire an average response time of the second service in a current period;
the determining module is specifically configured to determine a difference between an average response time of a current period and an average response time of a previous period;
and when the difference value is larger than a fourth threshold value, determining that the working state is the first load state.
In a possible implementation manner, the obtaining module is further configured to obtain, every a preset time period, a response result corresponding to the second service when the second service returns a target status code for the first time in the preset time period, where the target status code is generated by the second service in response to a request;
The determining module is further configured to use the response result as a simulation data result corresponding to the target request.
In one possible implementation, the storage module is configured to store the target request;
the acquisition module is further used for acquiring the working state of the second service every preset time period;
the sending module is further configured to send the target request to the second service when the working state is switched from the first load state to the second load state.
The service request processing device provided in this embodiment may be a device as shown in fig. 5, and may perform all steps of the service request processing method shown in fig. 1-4, thereby achieving the technical effects of the service request processing method shown in fig. 1-4, and the detailed description is omitted herein for brevity.
Fig. 6 is a schematic structural diagram of a gateway device according to an embodiment of the present invention, and a gateway device 600 shown in fig. 6 includes: at least one processor 601, memory 602, at least one network interface 604, and other user interfaces 603. The various components in gateway device 600 are coupled together by bus system 605. It is understood that the bus system 605 is used to enable connected communications between these components. The bus system 605 includes a power bus, a control bus, and a status signal bus in addition to a data bus. But for clarity of illustration the various buses are labeled as bus system 605 in fig. 6.
The user interface 603 may include, among other things, a display, a keyboard, or a pointing device (e.g., a mouse, a trackball, a touch pad, or a touch screen, etc.).
It is to be appreciated that the memory 602 in embodiments of the invention may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM) which acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (Double Data Rate SDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), and Direct memory bus RAM (DRRAM). The memory 602 described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
In some implementations, the memory 602 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 6021 and application programs 6022.
The operating system 6021 includes various system programs, such as a framework layer, a core library layer, a driver layer, and the like, for implementing various basic services and processing hardware-based tasks. The application 6022 includes various application programs such as a Media Player (Media Player), a Browser (Browser), and the like for realizing various application services. The program for implementing the method of the embodiment of the present invention may be included in the application 6022.
In the embodiment of the present invention, the processor 601 is configured to execute the method steps provided by the method embodiments by calling a program or an instruction stored in the memory 602, specifically, a program or an instruction stored in the application 6022, for example, including:
when a target request of a first service is received, acquiring a working state of a second service, wherein the gateway is connected with an application program interface of the second service;
when the working state is determined to be a first load state, generating a simulation data result in response to the target request;
And returning the simulation data result to the first service.
In one possible implementation manner, obtaining a response success rate of the second service to the request within a preset time period;
acquiring average response time of the second service to the request within a preset time period;
when the response success rate is smaller than or equal to the first threshold value, determining that the working state is the first load state;
or alternatively, the first and second heat exchangers may be,
and when the average response time is greater than or equal to the second threshold value, determining that the working state is the first load state.
In one possible implementation, when the response success rate is greater than a first threshold value and the average response time is less than a second threshold value, the operating state is determined to be a second load state.
In one possible implementation manner, when the working state is the second load state, the target request is sent to the second service, so that the second service executes an operation corresponding to the target request.
In one possible implementation manner, obtaining an average response success rate of the second service in the current period;
determining a difference value between the average response success rate of the previous period and the average response success rate of the current period;
And when the difference value is larger than a third threshold value, determining the working state as a first load state.
In one possible implementation, an average response time of the second service in the current period is obtained;
determining a difference value between the average response time of the current period and the average response time of the previous period;
and when the difference value is larger than a fourth threshold value, determining that the working state is the first load state.
In a possible implementation manner, every preset time period, a response result corresponding to the second service when the second service returns a target state code for the first time within the preset time period is obtained, wherein the target state code is generated by the second service in response to a request;
and taking the response result as a simulation data result corresponding to the target request.
In one possible implementation, the target request is stored;
acquiring the working state of the second service every preset time period;
and when the working state is switched from the first load state to the second load state, sending the target request to the second service.
The method disclosed in the above embodiment of the present invention may be applied to the processor 601 or implemented by the processor 601. The processor 601 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 601 or instructions in the form of software. The processor 601 may be a general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software elements in a decoding processor. The software elements may be located in a random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory 602, and the processor 601 reads information in the memory 602 and performs the steps of the above method in combination with its hardware.
It is to be understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For a hardware implementation, the processing units may be implemented within one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processors (Digital Signal Processing, DSP), digital signal processing devices (dspev, DSPD), programmable logic devices (Programmable Logic Device, PLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA), general purpose processors, controllers, micro-controllers, microprocessors, other electronic units designed to perform the functions described herein, or a combination thereof.
For a software implementation, the techniques described herein may be implemented by means of units that perform the functions described herein. The software codes may be stored in a memory and executed by a processor. The memory may be implemented within the processor or external to the processor.
The gateway device provided in this embodiment may be a gateway device as shown in fig. 6, and may perform all steps of the service request processing method shown in fig. 1 to 4, so as to achieve the technical effects of the service request processing method shown in fig. 1 to 4, and the detailed description will be omitted herein for brevity.
The embodiment of the invention also provides a storage medium (computer readable storage medium). The storage medium here stores one or more programs. Wherein the storage medium may comprise volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid state disk; the memory may also comprise a combination of the above types of memories.
When one or more programs in the storage medium are executable by one or more processors, the service request processing method executed on the device side is implemented.
The processor is configured to execute a service request processing program stored in the memory, so as to implement the following steps of a service request processing method executed on the device side:
when a target request of a first service is received, acquiring a working state of a second service, wherein the gateway is connected with an application program interface of the second service;
when the working state is determined to be a first load state, generating a simulation data result in response to the target request;
and returning the simulation data result to the first service.
In one possible implementation manner, obtaining a response success rate of the second service to the request within a preset time period;
Acquiring average response time of the second service to the request within a preset time period;
when the response success rate is smaller than or equal to the first threshold value, determining that the working state is the first load state;
or alternatively, the first and second heat exchangers may be,
and when the average response time is greater than or equal to the second threshold value, determining that the working state is the first load state.
In one possible implementation, when the response success rate is greater than a first threshold value and the average response time is less than a second threshold value, the operating state is determined to be a second load state.
In one possible implementation manner, when the working state is the second load state, the target request is sent to the second service, so that the second service executes an operation corresponding to the target request.
In one possible implementation manner, obtaining an average response success rate of the second service in the current period;
determining a difference value between the average response success rate of the previous period and the average response success rate of the current period;
and when the difference value is larger than a third threshold value, determining the working state as a first load state.
In one possible implementation, an average response time of the second service in the current period is obtained;
Determining a difference value between the average response time of the current period and the average response time of the previous period;
and when the difference value is larger than a fourth threshold value, determining that the working state is the first load state.
In a possible implementation manner, every preset time period, a response result corresponding to the second service when the second service returns a target state code for the first time within the preset time period is obtained, wherein the target state code is generated by the second service in response to a request;
and taking the response result as a simulation data result corresponding to the target request.
In one possible implementation, the target request is stored;
acquiring the working state of the second service every preset time period;
and when the working state is switched from the first load state to the second load state, sending the target request to the second service.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of function in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.

Claims (11)

1. A service request processing method, applied to a gateway, comprising:
when a target request of a first service is received, acquiring a working state of a second service, wherein the gateway is connected with an application program interface of the second service;
when the working state is determined to be a first load state, generating a simulation data result in response to the target request;
And returning the simulation data result to the first service.
2. The method of claim 1, wherein the acquiring the operational status of the second service comprises:
acquiring the response success rate of the second service to the request within a preset time period;
acquiring average response time of the second service to the request within a preset time period;
when the response success rate is smaller than or equal to the first threshold value, determining that the working state is the first load state;
or alternatively, the first and second heat exchangers may be,
and when the average response time is greater than or equal to the second threshold value, determining that the working state is the first load state.
3. The method of claim 2, wherein the acquiring the operational status of the second service further comprises:
and when the response success rate is greater than a first threshold value and the average response time is smaller than a second threshold value, determining that the working state is a second load state.
4. A method according to claim 3, characterized in that the method further comprises:
and when the working state is the second load state, sending the target request to the second service so that the second service executes the operation corresponding to the target request.
5. The method of claim 1, wherein the acquiring the operational status of the second service comprises:
acquiring the average response success rate of the second service in the current period;
determining a difference value between the average response success rate of the previous period and the average response success rate of the current period;
and when the difference value is larger than a third threshold value, determining the working state as a first load state.
6. The method of claim 1, wherein the acquiring the operational status of the second service comprises:
acquiring the average response time of the second service in the current period;
determining a difference value between the average response time of the current period and the average response time of the previous period;
and when the difference value is larger than a fourth threshold value, determining that the working state is the first load state.
7. The method according to claim 1, wherein the method further comprises:
acquiring a response result corresponding to the second service when the second service returns a target state code for the first time within a preset time period, wherein the target state code is generated by the second service in response to a request;
and taking the response result as a simulation data result corresponding to the target request.
8. The method of claim 1, wherein after the returning the simulated data results to the first service, the method further comprises:
storing the target request;
acquiring the working state of the second service every preset time period;
when the working state is switched from the first load state to a second load state, the target request is sent to the second service;
and receiving and storing a response result returned by the second service.
9. A service request processing apparatus, comprising:
the gateway is connected with an application program interface of the second service;
the generation module is used for responding to the target request to generate a simulation data result when the working state is a first load state;
and the sending module is used for returning the simulation data result to the first service.
10. A gateway device, comprising: a processor and a memory, the processor being configured to execute a service request processing program stored in the memory to implement the service request processing method according to any one of claims 1 to 7.
11. A storage medium storing one or more programs executable by one or more processors to implement the service request processing method of any one of claims 1 to 7.
CN202211532697.8A 2022-11-29 2022-11-29 Service request processing method and device, gateway equipment and storage medium Pending CN116016675A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211532697.8A CN116016675A (en) 2022-11-29 2022-11-29 Service request processing method and device, gateway equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211532697.8A CN116016675A (en) 2022-11-29 2022-11-29 Service request processing method and device, gateway equipment and storage medium

Publications (1)

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

Family

ID=86030967

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211532697.8A Pending CN116016675A (en) 2022-11-29 2022-11-29 Service request processing method and device, gateway equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116016675A (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA1201227A (en) * 1980-10-24 1986-02-25 Edward B. Miller Method and apparatus for controlling distributed electrical loads
US20150264412A1 (en) * 2012-10-18 2015-09-17 Zte Corporation Fusion device, system and method for implementing internet protocol television service
CN108600005A (en) * 2018-04-23 2018-09-28 国云科技股份有限公司 A method of defence micro services avalanche effect
CN109240765A (en) * 2018-08-28 2019-01-18 中国联合网络通信集团有限公司 Blowout method, device, equipment and the computer readable storage medium of Service Source
CN110120973A (en) * 2019-04-28 2019-08-13 华为技术有限公司 A kind of request control method, relevant device and computer storage medium
CN111447272A (en) * 2020-03-26 2020-07-24 支付宝(杭州)信息技术有限公司 Load balancing method and device
CN111787073A (en) * 2020-06-18 2020-10-16 多加网络科技(北京)有限公司 Current-limiting fusing platform and method for unified service
CN112835707A (en) * 2019-11-25 2021-05-25 高新兴科技集团股份有限公司 Load scheduling method and device for distributed system, computer storage medium and equipment
CN113014673A (en) * 2021-04-08 2021-06-22 广州趣丸网络科技有限公司 Service call optimization method and device
CN114157666A (en) * 2021-10-25 2022-03-08 北京千方科技股份有限公司 Load balancing system, method, medium and device based on intelligent cloud platform
CN115357779A (en) * 2022-08-17 2022-11-18 珠海格力电器股份有限公司 Data processing method, device and system, electronic equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA1201227A (en) * 1980-10-24 1986-02-25 Edward B. Miller Method and apparatus for controlling distributed electrical loads
US20150264412A1 (en) * 2012-10-18 2015-09-17 Zte Corporation Fusion device, system and method for implementing internet protocol television service
CN108600005A (en) * 2018-04-23 2018-09-28 国云科技股份有限公司 A method of defence micro services avalanche effect
CN109240765A (en) * 2018-08-28 2019-01-18 中国联合网络通信集团有限公司 Blowout method, device, equipment and the computer readable storage medium of Service Source
CN110120973A (en) * 2019-04-28 2019-08-13 华为技术有限公司 A kind of request control method, relevant device and computer storage medium
CN112835707A (en) * 2019-11-25 2021-05-25 高新兴科技集团股份有限公司 Load scheduling method and device for distributed system, computer storage medium and equipment
CN111447272A (en) * 2020-03-26 2020-07-24 支付宝(杭州)信息技术有限公司 Load balancing method and device
CN111787073A (en) * 2020-06-18 2020-10-16 多加网络科技(北京)有限公司 Current-limiting fusing platform and method for unified service
CN113014673A (en) * 2021-04-08 2021-06-22 广州趣丸网络科技有限公司 Service call optimization method and device
CN114157666A (en) * 2021-10-25 2022-03-08 北京千方科技股份有限公司 Load balancing system, method, medium and device based on intelligent cloud platform
CN115357779A (en) * 2022-08-17 2022-11-18 珠海格力电器股份有限公司 Data processing method, device and system, electronic equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
RUBI RANA: ""Day-Ahead Scheduling of Electric Vehicles for Overloading Management in Active Distribution System via Web-Based Application"", 《 IEEE SYSTEMS JOURNAL》, 13 July 2018 (2018-07-13) *
张开琦: ""微服务架构负载均衡及服务容错研究"", 《中国优秀硕士学位论文全文数据库 信息科技辑》, 15 January 2022 (2022-01-15) *

Similar Documents

Publication Publication Date Title
CN104239156A (en) External service call method and system
KR20160142311A (en) Page cache write logging at block-based storage
CN111294845A (en) Node switching method and device, computer equipment and storage medium
US20080059746A1 (en) Distributed storage network
WO2020173136A1 (en) Method and apparatus for monitoring application system, device, and storage medium
CN112130758B (en) Data reading request processing method and system, electronic equipment and storage medium
CN111736765A (en) Method, device and medium for supervising data block state
CN111147583A (en) HTTP redirection rewriting method and device
CN108563774B (en) GPS data processing method and device
CN116016675A (en) Service request processing method and device, gateway equipment and storage medium
CN113590027B (en) Data storage method, data acquisition method, system, device and medium
CN111324520A (en) Service interface monitoring method and device, electronic equipment and storage medium
CN112558872A (en) Data processing method and device, storage medium and electronic equipment
CN113722364A (en) Redis use control method and device
CN111694703A (en) Cache region management method and device and computer equipment
CN106776131B (en) Data backup method and server
CN105634794B (en) Processing method, modem and the mobile terminal of network communicating function exception
CN104461655A (en) Method for automatically selecting application installation position and mobile terminal
CN112367384B (en) Kafka cluster-based dynamic speed limiting method and device and computer equipment
CN110855484A (en) Method, system, electronic device and storage medium for automatically detecting traffic change
CN113190481B (en) Data transmission method and device, electronic equipment and computer readable storage medium
CN112182454A (en) Webpage optimization method and device, storage medium and electronic equipment
CN112486517A (en) Application program installation method and system, electronic equipment and storage medium
CN112527363A (en) Software package version updating method, device, system, equipment and medium
CN105376774B (en) Processing method, modem and the mobile terminal of network communicating function exception

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