Request processing method, device, electronic device, storage medium and product
By detecting request types and responding to preheating requests with priority, the problem of discarding preheating requests caused by reliance on service current limiting is solved, ensuring service startup speed and fault recovery efficiency.
Patent Information
- Application Number
- CN202111276977.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-10-29
AI Technical Summary
When the service starts, the service-dependent request current limit causes the warm-up request to not be processed normally, thus slowing down the startup speed.
By detecting the request type, if it is a preheating request, it will respond directly. If it is a non-preheating request and it conforms to the current limiting policy, it will be discarded. This ensures that the preheating request is not discarded to avoid slowing down the startup speed.
Ensure that preheating requests are processed normally to avoid slowing down the startup speed and improve fault recovery speed.
Smart Images

Figure CN114138357B
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the field of network technology, and in particular, relates to a request processing method, device, electronic device, storage medium and product. Background Art
[0002] At present, when a service is started, in order to improve the startup speed of the service instances contained in the service, a preheating step is performed during the startup process. Specifically, a preheating request can be sent to the dependent service, and the dependent service responds to the preheating request to complete the preheating. The dependent service is the service indicated by the call information defined in the service.
[0003] However, in the related art, when the dependent service performs request flow limiting, the received preheating request may not be processed normally, which may cause the service to fail to start normally, thereby slowing down the startup speed. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a request processing method, device, electronic device, storage medium and product.
[0005] According to a first aspect of the present disclosure, a request processing method is provided, which is applied to a first service that enables request flow limiting, and the method includes:
[0006] For the received first request, detecting a request type of the first request; the first request is used to instruct the first service to perform a preset operation;
[0007] If the request type of the first request is a preheating request, respond to the first request; the preheating request is a request sent by a second service, and the second service defines call information for the first service;
[0008] If the request type of the first request is a non-preheating request and the first request meets the discarding condition of the current limiting strategy, the first request is discarded.
[0009] Optionally, before detecting the request type of the first request, the method further includes:
[0010] Determine whether the received second request meets the discard condition based on the current limiting strategy; the second request includes the first request;
[0011] If the second request meets the discarding condition, the second request meeting the discarding condition is used as the first request, and the step of detecting the request type of the first request is performed.
[0012] Optionally, detecting the request type of the first request includes:
[0013] Detecting whether the first request includes a specified preheating request marking parameter;
[0014] If the first request includes the preheating request marking parameter, determining that the request type is a preheating request;
[0015] If the first request does not include the preheat request marking parameter, the request type is determined to be a non-preheat request.
[0016] Optionally, the first service and the second service belong to the same service cluster; and the detecting the request type of the first request includes:
[0017] Based on a designated interface provided by the service cluster, read the IP address of a service instance currently being started in the service cluster;
[0018] If the IP address carried in the first request belongs to the IP address of the service instance currently being started, determining that the request type is a warm-up request;
[0019] If the IP address carried in the first request does not belong to the IP address of the service instance currently being started, it is determined that the request type is a non-preheating request.
[0020] Optionally, if the request type is a preheating request, the method further includes: setting the processing priority of the first request to a specified priority; the specified priority is used to instruct the first service to prioritize processing of the request.
[0021] Optionally, detecting the request type of the first request includes:
[0022] Detecting whether the service instance receiving the first request is a preset preheating request processing instance, or detecting whether the access interface receiving the first request is a preset preheating request processing interface; the service instance and the access interface belong to the first service;
[0023] If yes, determining that the request type of the first request is a preheating request;
[0024] If not, it is determined that the request type of the first request is a non-preheating request.
[0025] Optionally, the preheating request is a request sent during the process of restarting and / or starting up a service instance in the second service after capacity expansion.
[0026] Optionally, the current limiting strategy includes discarding subsequent requests received within a predetermined time period when the number of requests received within the predetermined time period is greater than a preset number threshold.
[0027] According to a second aspect of the present disclosure, a request processing device is provided, which is applied to enable a first service of request current limiting, and the device includes:
[0028] A detection module is configured to detect a request type of a received first request, wherein the first request is used to instruct the first service to perform a preset operation;
[0029] a response module, configured to respond to the first request if the request type of the first request is a preheating request; the preheating request is a request sent by a second service, and the second service defines call information for the first service;
[0030] The discarding module is configured to discard the first request if the request type of the first request is a non-preheating request and the first request meets the discarding condition of the current limiting policy.
[0031] Optionally, the device further comprises:
[0032] A judgment module is configured to judge whether a received second request meets the discard condition based on the current limiting strategy before detecting the request type of the first request; the second request includes the first request;
[0033] The execution module is configured to use the second request that meets the discarding condition as the first request if the second request meets the discarding condition, and execute the step of detecting the request type of the first request.
[0034] Optionally, the detection module is specifically configured as follows:
[0035] Detecting whether the first request includes a specified preheating request marking parameter;
[0036] If the first request includes the preheating request marking parameter, determining that the request type is a preheating request;
[0037] If the first request does not include the preheat request marking parameter, the request type is determined to be a non-preheat request.
[0038] Optionally, the first service and the second service belong to the same service cluster; and the detection module is specifically configured to:
[0039] Based on a designated interface provided by the service cluster, read the IP address of a service instance currently being started in the service cluster;
[0040] If the IP address carried in the first request belongs to the IP address of the service instance currently being started, determining that the request type is a warm-up request;
[0041] If the IP address carried in the first request does not belong to the IP address of the service instance currently being started, it is determined that the request type is a non-preheating request.
[0042] Optionally, the device further includes: a setting module configured to set the processing priority of the first request to a specified priority if the request type is a preheating request; the specified priority is used to indicate that the first service prioritizes processing the request.
[0043] Optionally, the detection module is specifically configured as follows:
[0044] Detecting whether the service instance receiving the first request is a preset preheating request processing instance, or detecting whether the access interface receiving the first request is a preset preheating request processing interface; the service instance and the access interface belong to the first service;
[0045] If yes, determining that the request type of the first request is a preheating request;
[0046] If not, it is determined that the request type of the first request is a non-preheating request.
[0047] Optionally, the preheating request is a request sent during the process of restarting and / or starting up a service instance in the second service after capacity expansion.
[0048] Optionally, the current limiting strategy includes discarding subsequent requests received within a predetermined time period when the number of requests received within the predetermined time period is greater than a preset number threshold.
[0049] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0050] processor;
[0051] a memory for storing instructions executable by the processor;
[0052] The processor is configured to execute the instructions to implement the request processing method as described in any one of the first aspects.
[0053] According to a fourth aspect of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device executes the request processing method as described in any one of the first aspects.
[0054] According to a fifth aspect of the present disclosure, a computer program product is provided, the computer program product comprising readable program instructions, and when the readable program instructions are executed by a processor of an electronic device, the electronic device executes the request processing method as described in any one of the first aspects.
[0055] Compared with the related art, the present invention has the following advantages and positive effects:
[0056] The request processing method provided by the embodiment of the present disclosure, when the first service turns on request current limiting, will first detect the request type of the first request for the received first request, and when the request type of the first request is a preheating request, that is, when the first request is a preheating request sent by the second service that depends on the first service, the first request will be directly responded to. If the request type of the first request is not a preheating request, the first request will be discarded only when the first request meets the discarding condition of the current limiting strategy. In this way, it can be ensured that the preheating request is not discarded, thereby avoiding the problem that the preheating request cannot be processed normally, thereby slowing down the startup speed.
[0057] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the specific implementation methods of the present disclosure are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present disclosure. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0059] Figure 1 is a flowchart of a request processing method provided by an embodiment of the present disclosure;
[0060] Figure 2 It is a processing flow diagram provided by an embodiment of the present disclosure;
[0061] Figure 3 is a block diagram of a request processing device provided by an embodiment of the present disclosure;
[0062] Figure 4 is a block diagram of a device for request processing according to an exemplary embodiment;
[0063] Figure 5 The invention is a block diagram showing a device for request processing according to an exemplary embodiment. DETAILED DESCRIPTION
[0064] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0065] An exemplary application scenario involved in the embodiments of the present disclosure is described below. At present, every large website or application is supported by a large-scale service cluster. The front-end services, back-end services, RPC services, etc. in the service cluster will be deployed on physical servers or container cloud hosts to run. In order to ensure availability, these services usually deploy multiple identical service instances in one or more computer rooms, and support scaling to cope with traffic changes with obvious peak and valley characteristics over time and sudden failures of service hosts. Under normal circumstances, occasional abnormalities in a small number of service instances will not affect the availability of the service, and only these service instances need to be restarted to troubleshoot.
[0066] However, services may also face sudden surges in traffic, such as overall failures in some data centers, problems with competitor services leading to a large influx of users, and traffic diversion activities that exceed expectations. In the case of sudden surges in traffic, some host machines may go down on a large scale, and it is necessary to enable a flow limiting strategy to protect surviving service instances and prevent cluster avalanche. At this time, in order to ensure the normal operation of the service, development and maintenance personnel not only need to restart the downed service, but also need to expand capacity in time to cope with traffic that exceeds the current service capacity, and then achieve fault recovery.
[0067] Furthermore, the service startup process usually has a warmup step. For example, since there are many modules in the business code that use implementation dependencies, lazy init is used in many places to avoid wasting resources by pulling up unnecessary implementations. Lazy loading causes the first few requests to be processed very slowly or even time out when the service is just started. Therefore, it is necessary to initialize the things that the service is about to use when the process starts, that is, to perform a warmup step. A warmup step is required when restarting or starting an expanded service instance. At this time, if the service on which the service depends has request current limiting turned on, the warmup request sent by the service may not be responded to normally, thereby slowing down the restart and expansion of the service cluster, resulting in slower fault recovery.
[0068] For example, suppose there are two services, service A depends on service B. Both services A and B have multiple service instances. When the traffic suddenly increases, these two services face traffic that exceeds their processing capacity, and some service instances crash. In order to avoid a complete crash, the remaining services have enabled the current limiting strategy. At this time, it is necessary to restart the service instances of A and B that have crashed and expand the capacity. However, if the capacity expansion service A is restarted first, the dependent service B needs to be called in the warm-up step when restarting and expanding the capacity, and service B has enabled the current limiting strategy, so it cannot guarantee a normal response. Therefore, the service instance may fail to start because it cannot complete the warm-up step. In this case, the warm-up request can only be sent again if it is not responded to, or the restart and expansion of service B must be completed first, and then the current limiting strategy must be turned off, and then service A can complete the restart and expansion normally. That is, it is necessary to strictly restart / expand in the order of the call topology relationship corresponding to the dependency relationship. In this way, the startup speed will be reduced and the fault recovery speed will be slow.
[0069] To this end, an embodiment of the present disclosure provides a request processing method, which is described in detail below.
[0070] Figure 1 is a flowchart of a request processing method provided by an embodiment of the present disclosure. The method can be applied to a first service that enables request flow limiting, such as Figure 1 As shown, the method may include:
[0071] Step 101: Detect a request type of a received first request; the first request is used to instruct the first service to perform a preset operation.
[0072] In the embodiment of the present disclosure, a service may be composed of multiple service instances, and the service instances may be deployed on a physical machine, for example, a server deployed in a computer room. Different services may implement different business functions, for example, services may be used to implement login functions, identity authentication functions, payment functions, and the like. The first request may be part of the request / all of the requests received by the first service, and the preset operation indicated by the first request may be pre-set according to actual needs, and different first requests may be used to instruct the first service to perform different preset operations. For example, the first request may be used to instruct the first service to return survival information, return preset preloaded data, perform login information verification, perform payment information verification, or close specific functions, and the like. Further, the first request may include a preheating request sent by a second service that depends on the first service. Specifically, the first service and the second service may be services that have a dependency relationship, and the second service may depend on the first service. Among them, the second service may define the call information of the first service to the first service, that is, the second service may implement certain functions by calling the first service, and therefore, the second service may be referred to as depending on the first service. In a specific implementation scenario, from the perspective of program development, the first service may be regarded as an upstream service, and the second service may be regarded as a downstream service. From the perspective of the calling relationship, the second service can be regarded as an upstream service, and the first service can be regarded as a downstream service. Furthermore, the first service can enable request flow limiting to limit the flow when the current flow is too large and there are too many requests to be processed. Among them, one request can be regarded as a flow.
[0073] Furthermore, since the first service currently has request flow limiting turned on, the first request can be regarded as a request to be flow-limited entering the first service, and the first request sent by the second service may be discarded due to flow limiting. Therefore, the request type of each first request can be further identified. The request type can be predefined in the embodiment of the present disclosure. For example, the request type can be divided into preheating traffic and ordinary business traffic, that is, it can be divided into preheating requests and non-preheating requests.
[0074] Step 102: If the request type of the first request is a preheating request, respond to the first request; the preheating request is a request sent by a second service, and the second service defines call information for the first service.
[0075] In an embodiment of the present disclosure, if the request type of the first request is a preheating request, it can be determined that the first request is a request sent by the service instance in the second service during the startup process in order to implement the preheating step. Accordingly, the first request can be responded to directly to ensure that the preheating request will not be discarded due to current limiting, thereby ensuring to a certain extent that all received preheating requests can be processed normally, thereby avoiding the problem of failure to complete the startup normally, thereby slowing down the fault recovery speed. Among them, the way to respond to the preheating request can be set according to actual needs. For example, it can be to return survival information to the second service, return preset preloaded data to establish a data connection, etc., and the embodiment of the present disclosure does not limit this.
[0076] Step 103: If the request type of the first request is a non-preheating request and the first request meets the discarding condition of the current limiting policy, the first request is discarded.
[0077] In the embodiment of the present disclosure, the current limiting strategy may be pre-set for the request current limiting function. Optionally, the current limiting strategy may include discarding the requests subsequently received within the predetermined time period if the number of requests received within the predetermined time period is greater than the preset number threshold. Among them, the predetermined time period may include setting according to actual needs. For example, the predetermined time period may be 5 minutes, or it may also be 10 minutes. For example, a current limiting algorithm may correspond to a current limiting strategy. For example, the current limiting algorithm corresponding to the current limiting strategy may include a counter (fixed window) algorithm, a sliding window algorithm, a leaky bucket algorithm, a token bucket algorithm, and the like. These algorithms can judge the status of the service by the number of requests currently or within a period of time. If there are too many requests, exceeding the currently configured amount, it is considered that the service will be overloaded, and accordingly, the requests exceeding the amount will be considered to meet the discarding condition; if the number of requests does not exceed the currently configured amount, it is considered that it does not meet the discarding condition. That is, the discarding condition is that the receiving time is in the current time window and it is the Xth request received in the current time window, where X is greater than the currently configured amount. The length of the current time window may be a predetermined duration. In the embodiment of the present disclosure, by adopting a strategy of discarding subsequent requests received within a predetermined time period if the number of requests received within the predetermined time period is greater than a preset number threshold, the problem of excessive concurrent requests causing the first service to crash can be avoided to a certain extent.
[0078] Furthermore, if the request type is a non-preheating request, the first request may be current limited. Specifically, it may be determined whether the first request meets the discarding condition of the current limiting strategy. If so, the first request may be discarded for current limiting.
[0079] In summary, the request processing method provided by the embodiment of the present disclosure, when the first service turns on request current limiting, will first detect the request type of the first request for the received first request, and the first request is used to instruct the first service to perform a preset operation. In the case where the request type of the first request is a preheating request, that is, in the case where the first request is a preheating request sent by the second service that depends on the first service, the first request will be responded to directly. Only when the request type of the first request is a non-preheating request, the first request will be discarded when it meets the discarding condition of the current limiting strategy. In this way, it can be ensured that the preheating request is not discarded, thereby avoiding the problem that the preheating request cannot be processed normally, thereby slowing down the startup speed.
[0080] Optionally, in an application scenario, that is, the preheating request in the embodiment of the present disclosure may be a request sent in the link of starting after the service instance in the second service is restarted and / or expanded. Since the problem of slowing down the startup speed is avoided, when the second service recovers from the fault by restarting / expanding the capacity, and the preheating request is sent in the restart / expanding the capacity link, it can ensure that the restart / expanding the capacity starts normally, and ensure the speed of the restart / expanding the capacity, thereby avoiding the problem of slowing down the fault recovery. At the same time, since it can be ensured that the preheating request is responded to and processed normally, and that the preheating step can be completed normally, there is no need to call the order of topological relationships to restart / expand, and multiple services can be restarted / expanded at the same time, thereby speeding up the fault recovery.
[0081] Optionally, before detecting the request type of the first request, the embodiment of the present disclosure may further include:
[0082] Step S21: determine whether the received second request meets the discarding condition based on the current limiting strategy; the second request includes the first request.
[0083] In the embodiment of the present disclosure, the request participating in the request type detection may be a request that is determined to be discarded, the second request may be a request sent by any service to the first service, the second request may include the request sent by the second service, and the second request may include the first request. Specifically, after receiving the second request, the first service may directly determine whether the second request meets the discarding condition based on the current limiting strategy. Specifically, the judgment method can refer to the aforementioned related description, which will not be repeated here.
[0084] Step S22: If the second request meets the discarding condition, the second request that meets the discarding condition is used as the first request, and the step of detecting the request type of the first request is performed.
[0085] If the second request meets the discard condition, it means that the second request will not be responded to but will be discarded. However, the second request that meets the discard condition may include the preheating request sent by the second service. Therefore, these second requests can be used as first requests, and the preheating traffic can be further retrieved from these first requests, that is, the request types of these first requests are identified, and the first requests that are preheating traffic are retained and responded to. The first requests that are not preheating requests are discarded.
[0086] In the disclosed embodiment, a judgment is first made based on a preset current limiting strategy, and the second request that is judged to meet the discarding condition and will be discarded is used as the first request to participate in the retrieval, so as to identify the preheating request therefrom, thereby avoiding the preheating request from being discarded and reducing the detection processing amount of the request type, thereby improving the processing efficiency.
[0087] At the same time, since in the disclosed embodiment, the preheating request is retrieved for the request that hits the flow limiting strategy, that is, the request that meets the discarding condition. In this way, when the first service performs request flow limiting, there is no need to modify the original business code implementation logic and the original flow limiting algorithm, and it will not affect the business code implementation logic and the logic of the original flow limiting algorithm, and the invasiveness is weak.
[0088] Optionally, the operation of detecting the request type of the first request may specifically include, in implementation mode 1:
[0089] Step S31: Detect whether the first request includes a specified preheating request marking parameter.
[0090] In an embodiment of the present disclosure, a preheating request marking parameter may be pre-agreed, and the specific content of the preheating request marking parameter may be set according to actual needs. For example, the preheating request marking parameter may be a number, a letter, a special mark, etc., which is not limited in the present disclosure. When the service sends a request, the preheating request marking parameter may be added to the designated flag position of the preheating request to characterize the request as a preheating request. Conversely, if the request sent is not a preheating request, the preheating request marking parameter may not be added to the designated flag position to characterize the request as not a preheating request. Among them, the designated flag position may be specified according to actual needs, which is not limited in the present disclosure. Accordingly, when the first service receives the request, it may parse the first request and then detect whether the preheating request marking parameter is added to the designated flag position.
[0091] Step S32: If the first request includes the preheating request marking parameter, determine that the request type is a preheating request.
[0092] Step S33: If the first request does not include the preheating request marking parameter, determine that the request type is a non-preheating request.
[0093] In the disclosed embodiment, by pre-agreing on a preheating request marking parameter, it is possible to conveniently identify whether the request type is a preheating request by identifying whether the request carries the preheating request marking parameter, thereby ensuring processing efficiency to a certain extent.
[0094] Optionally, the first service and the second service may belong to the same service cluster. The operation of detecting the request type of the first request may specifically include, in implementation mode 2:
[0095] Step S41: Based on the designated interface provided by the service cluster, read the IP address of the service instance currently being started in the service cluster.
[0096] In the embodiments of the present disclosure, an IP address (Internet Protocol Address) refers to an Internet Protocol address, which can also be called an Internet Protocol address. An IP address is a unified address format provided by the IP protocol, which assigns a logical address to each network and each host on the Internet to shield the difference in physical addresses. The designated interface provided by the service cluster can be pre-set. For example, the designated interface can be used to provide a dynamically configured IP address of a service instance that is currently being started. The service cluster can be configured with a device specifically used to collect the IP addresses of the service instances that are currently being started and provide a designated interface. For example, the service instance can actively report the IP address to the device when it is started. The IP addresses of service instances of different services deployed in the same host machine have different corresponding ports, and accordingly, the IP addresses are different. The service instance that is being started can be a service instance that is restarted when a failure occurs or a service instance that is increased by expansion.
[0097] Furthermore, when the first service needs to detect the request type, it can call the specified interface in real time to obtain the IP address of the service instance currently being started.
[0098] Step S42: If the IP address carried in the first request belongs to the IP address of the service instance currently being started, determine that the request type is a preheating request.
[0099] Specifically, the first request can be parsed to obtain the IP address carried by the first request. The IP address carried by the first request is the IP address of the service instance that sent the first request. Then, the IP address carried by the first request can be compared with the IP address of the service instance currently being started. If there is an IP address that is the same as the IP address carried by the first request, it can be determined that the request type of the first request is a preheating request. Otherwise, it can be determined that it is not a preheating request.
[0100] Step S43: If the IP address carried in the request does not belong to the IP address of the service instance currently being started, determine that the request type is a non-preheating request.
[0101] In the disclosed embodiment, the IP address of the service instance currently being started in the service cluster is first read based on the designated interface provided by the service cluster. In the case where the IP address carried by the first request belongs to the IP address of the service instance currently being started, the request type can be determined to be a preheating request. In the case where the IP address carried by the first request does not belong to the IP address of the service instance currently being started, the request type can be determined to be a non-preheating request. In this way, it is only necessary to compare the IP addresses to conveniently identify whether the request type is a preheating request, thereby ensuring processing efficiency to a certain extent.
[0102] Furthermore, the implementation method 1 and the implementation method 2 described above have low implementation costs and will not cause a significant degree of intrusion into the original code, thereby avoiding code redundancy.
[0103] Optionally, in the case where the request type of the first request is a preheating request, the following operation may be further performed: setting the processing priority of the first request to a specified priority; the specified priority is used to indicate that the first service prioritizes the request. The specified priority may be the highest priority. In an actual application scenario, if a request meets the discard condition of the current limiting policy, the request will be discarded and will not have a processing priority. In the disclosed embodiment, for a preheating request retrieved from a request that meets the discard condition of the current limiting policy, a specified priority is further set for the preheating request to indicate priority processing, that is, the priority is increased, so that the preheating request can be responded to as soon as possible, thereby speeding up the preheating step to a certain extent, thereby increasing the startup speed and improving the fault recovery efficiency.
[0104] Optionally, in yet another implementation, the operation of detecting the request type of the first request may specifically include:
[0105] Step S51, checking whether the instance receiving the first request is a preset preheating request processing instance, or checking whether the access interface receiving the first request is a preset preheating request processing interface; the service instance and the access interface belong to the first service.
[0106] In the disclosed embodiment, the preset preheating request processing instance may be a service instance specially allocated for the first service to receive preheating requests. The service instance is only responsible for processing all preheating requests and does not participate in the processing of normal online user access traffic. Accordingly, the second service can use the IP address of the preheating request processing instance as the target address to directly send the preheating request to the preheating request processing instance when the request sent is a preset request. Conversely, if the request sent is not a preset request, the request can be sent to a non-preheating request processing instance to determine whether the request meets the discarding condition of the current limiting strategy based on the non-preheating request processing instance.
[0107] Alternatively, in the embodiment of the present disclosure, a preheating request processing interface may be provided in advance, and the second service may send a request by calling the preheating request processing interface when the request sent is a preset request. On the contrary, if the request sent is not a preset request, the normal interface may be called to send the request. Among them, the interface may be referred to as a method, and the first service may split the provided external interface / method into two types in the service instance: a normal interface / method and a preheating interface (i.e., a preheating request processing interface) / method, and the preheating interface / method does not open the current limiting strategy to ensure that the preheating request can be directly responded to and avoid the preheating request being discarded. It should be noted that this implementation method requires a special preheating request processing instance, and in the case of a problem with the preheating request processing instance, it will interfere with the conventional service startup. Alternatively, since two interfaces need to be split, redundant code will be introduced accordingly, so the above implementation method one or implementation method two may be preferentially adopted in actual application. Of course, the required recognition logic may also be selected according to the requirements, that is, the implementation method is selected, and the adaptability is strong.
[0108] Furthermore, the first service can determine whether the request type of the first request is a preheating request by detecting whether the service instance that receives the first request is a preset preheating request processing instance and detecting the access interface that receives the first request, that is, whether the interface called when the first request is sent is a preset preheating request processing interface.
[0109] Step S52: If yes, determine that the request type of the first request is a preheating request.
[0110] Step S53: If not, determine that the request type of the first request is a non-preheating request.
[0111] In the disclosed embodiment, it is detected whether the service instance receiving the first request is a preset preheating request processing instance. Alternatively, it is detected whether the access interface receiving the first request is a preset preheating request processing interface. If so, it is determined that the request type of the first request is a preheating request. If not, it is determined that the request type of the first request is a non-preheating request. In this way, it is possible to easily identify whether the service instance is a preset preheating request processing instance / whether the access interface is a preset preheating request processing interface, and it is possible to determine whether the request type is a preheating request, thereby providing more implementation methods and improving selectivity.
[0112] Figure 2 is a processing flow diagram provided by an embodiment of the present disclosure, such as Figure 2 As shown, the entire processing link can be divided into a conventional flow limiting part and a preheating flow recovery part. The logic of the conventional flow limiting part does not need to be changed. The conventional flow limiting algorithm is still used to determine whether the service status of the current first service can respond to the access request (i.e., the second request mentioned above). If the calculation result of the flow limiting algorithm is to let go of the current flow, the request is responded to normally, that is, the request is processed. If the current first service load is large and the access request hits the flow limiting strategy, that is, it meets the original discarding conditions, then the preheating flow recovery part can be entered.
[0113] Furthermore, the preheating traffic recovery part can directly reclassify the traffic that was originally determined to meet the discarding conditions, that is, perform preheating traffic identification to determine whether the request type of the first request is preheating traffic (that is, preheating request). Among them, non-preheating requests can be regarded as regular traffic and can be directly discarded, and preheating traffic can come from upstream service instances that are being restarted or expanded and started, which can be regarded as special traffic and processed to ensure that the preheating request can be responded to normally.
[0114] Under normal circumstances, the use of conventional current limiting strategies can protect service instances. However, when faced with a large-scale traffic surge and the service cluster needs to be restarted / expanded, conventional current limiting strategies will cause preheating requests to be unable to be processed normally, which in turn has a negative impact on the restart / expansion speed. In the disclosed embodiment, on the basis of adopting conventional current limiting strategies, while ensuring that the service instance can be protected, the preheating traffic is retrieved to identify the preheating requests generated by other services that depend on the service when restarting / expanding, and their execution priority is increased to avoid the preheating requests being discarded, ensuring that the preheating requests can be responded to normally. In this way, it is possible to avoid the problem of large-scale downtime of the service cluster in the face of a sudden increase in traffic, because the current limiting strategy downstream of the call chain intercepts the preheating request when the upstream service instance that needs to be restarted / expanded is started, resulting in startup failure and slowing down the fault recovery speed.
[0115] At the same time, since it can ensure that the preset request is not discarded by the current limiting strategy, as long as there is a surviving instance of the service in the dependency chain, it can ensure that the startup is normal. Accordingly, there is no need to restart / expand in the order of the call topology relationship corresponding to the dependency relationship. Multiple services can be restarted / expanded at the same time, which can speed up the service recovery.
[0116] Figure 3 is a block diagram of a request processing device provided by an embodiment of the present disclosure, the device is applied to a first service that enables request current limiting, such as Figure 3 As shown, the device 20 may include:
[0117] The detection module 201 is configured to detect a request type of a received first request, wherein the first request is used to instruct the first service to perform a preset operation;
[0118] The response module 202 is configured to respond to the first request if the request type of the first request is a preheating request; the preheating request is a request sent by a second service, and the second service defines call information for the first service;
[0119] The discarding module 203 is configured to discard the first request if the request type of the first request is a non-preheating request and the first request meets the discarding condition of the current limiting policy.
[0120] The request processing device provided by the embodiment of the present disclosure, when the first service turns on request current limiting, will first detect the request type of the first request for the first request received, and when the request type of the first request is a preheating request, that is, when the first request is a preheating request sent by the second service that depends on the first service, the first request will be directly responded to. If the request type of the first request is not a preheating request, the first request will be discarded only when the first request meets the discarding condition of the current limiting strategy. In this way, it can be ensured that the preheating request is not discarded, thereby avoiding the problem that the preheating request cannot be processed normally, thereby slowing down the startup speed.
[0121] Optionally, the device 20 further includes:
[0122] A judgment module is configured to judge whether a received second request meets the discard condition based on the current limiting strategy before detecting the request type of the first request; the second request includes the first request;
[0123] The execution module is configured to use the second request that meets the discarding condition as the first request if the second request meets the discarding condition, and execute the step of detecting the request type of the first request.
[0124] Optionally, the detection module 201 is specifically configured as follows:
[0125] Detecting whether the first request includes a specified preheating request marking parameter;
[0126] If the first request includes the preheating request marking parameter, determining that the request type is a preheating request;
[0127] If the first request does not include the preheat request marking parameter, the request type is determined to be a non-preheat request.
[0128] Optionally, the first service and the second service belong to the same service cluster; the detection module 201 is specifically configured to:
[0129] Based on a designated interface provided by the service cluster, read the IP address of a service instance currently being started in the service cluster;
[0130] If the IP address carried in the first request belongs to the IP address of the service instance currently being started, determining that the request type is a warm-up request;
[0131] If the IP address carried in the first request does not belong to the IP address of the service instance currently being started, it is determined that the request type is a non-preheating request.
[0132] Optionally, the device 20 further includes: a setting module configured to set the processing priority of the first request to a specified priority if the request type is a preheating request; the specified priority is used to indicate that the first service prioritizes processing the request.
[0133] Optionally, the detection module 201 is specifically configured as follows:
[0134] Detecting whether the service instance receiving the first request is a preset preheating request processing instance, or detecting whether the access interface receiving the first request is a preset preheating request processing interface; the service instance and the access interface belong to the first service;
[0135] If yes, determining that the request type of the first request is a preheating request;
[0136] If not, it is determined that the request type of the first request is a non-preheating request.
[0137] Optionally, the preheating request is a request sent during the process of restarting and / or starting up a service instance in the second service after capacity expansion.
[0138] Optionally, the current limiting strategy includes discarding subsequent requests received within a predetermined time period when the number of requests received within the predetermined time period is greater than a preset number threshold.
[0139] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0140] According to an embodiment of the present disclosure, an electronic device is provided, comprising: a processor and a memory for storing processor executable instructions, wherein the processor is configured to implement the steps in the request processing method in any of the above embodiments when executing.
[0141] According to an embodiment of the present disclosure, a storage medium is further provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the steps in the request processing method in any of the above embodiments.
[0142] According to one embodiment of the present disclosure, a computer program product is also provided. The computer program product includes readable program instructions. When the readable program instructions are executed by a processor of an electronic device, the electronic device can execute the steps in the request processing method in any of the above embodiments.
[0143] Figure 4 700 is a block diagram of an apparatus for request processing according to an exemplary embodiment. For example, the apparatus 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0144] Reference Figure 4 , the device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .
[0145] The processing component 702 generally controls the overall operation of the device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the request processing method described above. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0146] The memory 704 is configured to store various types of data to support operations on the device 700. Examples of such data include instructions for any application or method operating on the device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0147] The power supply component 706 provides power to the various components of the device 700. The power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 700.
[0148] The multimedia component 708 includes a screen that provides an output interface between the device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0149] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the device 700 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.
[0150] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0151] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the device 700. For example, the sensor assembly 714 can detect the open / closed state of the device 700, the relative positioning of components, such as the display and keypad of the device 700, the sensor assembly 714 can also detect the position change of the device 700 or a component of the device 700, the presence or absence of user contact with the device 700, the orientation or acceleration / deceleration of the device 700, and the temperature change of the device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0152] The communication component 716 is configured to facilitate wired or wireless communication between the device 700 and other devices. The device 700 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0153] In an exemplary embodiment, the apparatus 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned request processing method.
[0154] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by the processor 720 of the device 700 to complete the request processing method described above. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0155] Figure 5 800 is a block diagram of a device for request processing according to an exemplary embodiment. For example, the device 800 may be provided as a server. Figure 5 The apparatus 800 includes a processing component 822, which further includes one or more processors, and a memory resource represented by a memory 832 for storing instructions, such as an application, that can be executed by the processing component 822. The application stored in the memory 832 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 822 is configured to execute instructions to perform the above-mentioned request processing method.
[0156] The device 800 may also include a power supply component 826 configured to perform power management of the device 800, a wired or wireless network interface 850 configured to connect the device 800 to a network, and an input / output (I / O) interface 858. The device 800 may operate based on an operating system stored in the memory 832, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or the like.
[0157] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0158] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A request processing method, characterized in that: Applied to a first service that enables request current limiting, the method includes: For the received first request, detecting a request type of the first request; the first request is used to instruct the first service to perform a preset operation; If the request type of the first request is a preheating request, respond to the first request; the preheating request is a request sent by a second service, and the second service defines call information for the first service; If the request type of the first request is a non-preheating request and the first request meets the discarding condition of the current limiting policy, discard the first request; Before detecting the request type of the first request, the method further includes: Determine whether the received second request meets the discard condition based on the current limiting strategy; the second request includes the first request; If the second request meets the discarding condition, the second request meeting the discarding condition is used as the first request, and the step of detecting the request type of the first request is performed.
2. The method according to claim 1, characterized in that The detecting the request type of the first request includes: Detecting whether the first request includes a specified preheating request marking parameter; If the first request includes the preheating request marking parameter, determining that the request type is a preheating request; If the first request does not include the preheat request marking parameter, the request type is determined to be a non-preheat request.
3. The method according to claim 1, characterized in that The first service and the second service belong to the same service cluster; and the detecting the request type of the first request includes: Based on a designated interface provided by the service cluster, read the IP address of a service instance currently being started in the service cluster; If the IP address carried in the first request belongs to the IP address of the service instance currently being started, determining that the request type is a warm-up request; If the IP address carried in the first request does not belong to the IP address of the service instance currently being started, it is determined that the request type is a non-preheating request.
4. The method according to claim 1, characterized in that: If the request type is a preheating request, the method further includes: setting the processing priority of the first request to a specified priority; the specified priority is used to instruct the first service to give priority to processing the request.
5. The method according to claim 1, characterized in that The detecting the request type of the first request includes: Detecting whether the service instance receiving the first request is a preset preheating request processing instance, or detecting whether the access interface receiving the first request is a preset preheating request processing interface; the service instance and the access interface belong to the first service; If yes, determining that the request type of the first request is a preheating request; If not, it is determined that the request type of the first request is a non-preheating request.
6. The method according to claim 1, characterized in that The warm-up request is a request sent during the process of restarting and / or starting up the service instance in the second service after capacity expansion.
7. The method according to any one of claims 1 and 4-6, characterized in that: The current limiting strategy includes discarding subsequent requests received within a predetermined time period when the number of requests received within the predetermined time period is greater than a preset number threshold.
8. A request processing device, characterized in that: Applied to a first service for enabling request current limiting, the device comprises: A detection module is configured to detect a request type of a received first request, wherein the first request is used to instruct the first service to perform a preset operation; a response module, configured to respond to the first request if the request type of the first request is a preheating request; the preheating request is a request sent by a second service, and the second service defines call information for the first service; a discarding module, configured to discard the first request if the request type of the first request is a non-preheating request and the first request meets the discarding condition of the current limiting policy; The device further includes: a judgment module configured to judge whether a received second request meets the discard condition based on the current limiting strategy before detecting the request type of the first request; the second request includes the first request; The execution module is configured to use the second request that meets the discarding condition as the first request if the second request meets the discarding condition, and execute the step of detecting the request type of the first request.
9. The device according to claim 8, characterized in that The detection module is specifically configured as follows: Detecting whether the first request includes a specified preheating request marking parameter; If the first request includes the preheating request marking parameter, determining that the request type is a preheating request; If the first request does not include the preheat request marking parameter, the request type is determined to be a non-preheat request.
10. The device according to claim 8, characterized in that The first service and the second service belong to the same service cluster; the detection module is specifically configured to: Based on a designated interface provided by the service cluster, read the IP address of a service instance currently being started in the service cluster; If the IP address carried in the first request belongs to the IP address of the service instance currently being started, determining that the request type is a warm-up request; If the IP address carried in the first request does not belong to the IP address of the service instance currently being started, it is determined that the request type is a non-preheating request.
11. The device according to claim 8, characterized in that The device also includes: a setting module, configured to set the processing priority of the first request to a specified priority if the request type is a preheating request; the specified priority is used to instruct the first service to give priority to processing the request.
12. The device according to claim 8, characterized in that The detection module is specifically configured as follows: Detecting whether the service instance receiving the first request is a preset preheating request processing instance, or detecting whether the access interface receiving the first request is a preset preheating request processing interface; The service instance and the access interface belong to the first service; If yes, determining that the request type of the first request is a preheating request; If not, it is determined that the request type of the first request is a non-preheating request.
13. The device according to claim 8, characterized in that The warm-up request is a request sent during the process of restarting and / or starting up the service instance in the second service after capacity expansion.
14. The device according to any one of claims 8 and 11-13, characterized in that The current limiting strategy includes discarding subsequent requests received within a predetermined time period when the number of requests received within the predetermined time period is greater than a preset number threshold.
15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the request processing method according to any one of claims 1 to 7.
16. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device executes the request processing method as claimed in any one of claims 1 to 7.
17. A computer program product, characterized in that The computer program product comprises readable program instructions, and when the readable program instructions are executed by a processor of an electronic device, the electronic device executes the request processing method according to any one of claims 1 to 7.
