A request processing method, device and readable medium
By obtaining the first flow control remaining amount in the concurrency time period, the number of access requests is controlled, which solves the problem that the flow control threshold of the service interface is exceeded under high concurrency, avoids the sending of invalid requests, reduces the burden on the service interface, and increases the Processing efficiency.
Patent Information
- Application Number
- CN202210493178.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-07
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2042-05-07
AI Technical Summary
During high concurrent access, the flow control threshold of the service interface is exceeded, causing the access request to be unable to respond successfully, resulting in a large number of invalid requests sent during the retry process, resulting in wasting processing resources and burden on the service interface.
By obtaining the first flow control remaining amount in the concurrency time period, the number of access requests sent to the service interface shall not exceed the remaining amount to avoid exceeding the flow control threshold and update and clear the flow control remaining amount information when appropriate.
It effectively avoids flow control errors caused by excessive access requests, reduces the sending of invalid requests, reduces the burden on the service interface, and improves processing efficiency.
Smart Images

Figure CN115002225B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network technology, and in particular to a request processing method, device and readable medium. Background Art
[0002] At present, the application of service interfaces is becoming more and more widespread. In order to ensure its own stability, the service provider will set corresponding flow control thresholds for the service interface to perform flow control. In a concurrent time period, access requests within the flow control threshold can be successfully responded to, the service interface can be accessed normally, and the API can be successfully called. However, access requests that exceed the flow control threshold cannot be successfully responded to, the service interface cannot be accessed normally, and the call fails.
[0003] When a high-concurrency access is initiated to a service interface, since multiple access requests are sent at a time, the flow control threshold of the service interface may be exceeded, resulting in the access request being unable to be successfully responded to. In the prior art, when a successful response fails, retries are often performed continuously according to a preset backoff strategy. However, in this method, since a large number of invalid requests that will not be successfully responded to may be sent to the service interface during the retry process, it will cause a waste of processing resources and burden the service interface. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application provide a request processing method, device and readable medium to solve the problem that a large number of invalid requests that will not be successfully responded to may be sent to the service interface during the retry process, thereby causing waste of processing resources and placing a burden on the service interface.
[0005] In order to solve the above problem, the embodiment of the present application discloses a request processing method, including:
[0006] In the case where there are unsent access requests, obtaining a first flow control remaining amount of the service interface required to be accessed by the access request within a concurrent time period; the first flow control remaining amount is used to represent the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period;
[0007] According to the first flow control remaining amount of the service interface, an access request for accessing the service interface is sent to the service interface; wherein the number of the access requests sent is not greater than the first flow control remaining amount.
[0008] Optionally, in another embodiment of the present application, the method further includes:
[0009] Writing the second flow control remainder into a target buffer allocated for the service interface;
[0010] The updating of the second flow control remainder includes:
[0011] Updating the second flow control remaining amount in the target cache; the effective duration of the target cache is not less than the duration of the concurrent time period;
[0012] The method further comprises:
[0013] After the effective time has passed, the target cache is cleared.
[0014] Optionally, in another embodiment of the present application, the method further includes:
[0015] Generate a keyword for representing the interface identity according to the accessed service interface information in the request;
[0016] Writing the second flow control remainder into a target buffer allocated for the service interface comprises:
[0017] The second flow control remainder is written into a target cache corresponding to the keyword.
[0018] Optionally, in another embodiment of the present application, the obtaining of a first flow control remaining amount of a service interface required to be accessed by the access request within a concurrent time period includes:
[0019] Receiving response information returned by the service interface in response to the access request; the response information includes a first flow control remaining amount of the service interface in the concurrent time period;
[0020] The first flow control remainder is extracted from the response information.
[0021] Optionally, in another embodiment of the present application, the method further includes:
[0022] In a case where the first flow control remaining amount is not greater than a second preset threshold value and / or the response information returned by the received service interface is used to characterize a response failure of the service interface, reacquiring the first flow control remaining amount within the next concurrent time period, and sending the access request for accessing the service interface to the service interface based on the reacquired first flow control remaining amount;
[0023] When the first flow control remaining amount is greater than the second preset threshold, the step of sending an access request for accessing the service interface to the service interface according to the first flow control remaining amount of the service interface is performed.
[0024] Optionally, in another embodiment of the present application, when there are at least two service interfaces, at least some of the service interfaces have different flow control thresholds.
[0025] The embodiment of the present application also discloses another request processing method, which is applied to a client and includes:
[0026] Receive cloud resource processing tasks;
[0027] Generate at least one group of access requests according to the cloud resource processing task; wherein the same group of access requests is used to access the same service interface of the server, and the server has at least one service interface;
[0028] For a group of access requests, in the case where there are unsent access requests, obtaining a first flow control remaining amount of the corresponding service interface within a concurrent time period from the server; the first flow control remaining amount is used to represent the remaining number of requests that the service interface can successfully respond to the access requests within the concurrent time period;
[0029] According to the first flow control remaining amount of the service interface, the access request is sent to the server to access the service interface; wherein the number of the access requests sent is not greater than the first flow control remaining amount.
[0030] Accordingly, the embodiment of the present application further discloses a request processing device, including:
[0031] A first acquisition module is used to acquire, in the case where there are unsent access requests, a first flow control remaining amount of a service interface that the access request needs to access within a concurrent time period; the first flow control remaining amount is used to represent the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period;
[0032] A sending module is used to send access requests for accessing the service interface to the service interface according to the first flow control remaining amount of the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount.
[0033] The embodiment of the present application also discloses another request processing device, which is applied to a client and includes:
[0034] A receiving module, used for receiving cloud resource processing tasks;
[0035] A generating module, configured to generate at least one set of access requests according to the cloud resource processing task; wherein the same set of access requests is used to access the same service interface of the server, and the server has at least one service interface;
[0036] An acquisition module, used for acquiring, for a group of access requests, a first flow control remaining amount of a corresponding service interface in a concurrent time period from a server in the case where there are unsent access requests; the first flow control remaining amount is used to represent the remaining number of requests that the service interface can successfully respond to access requests in the concurrent time period;
[0037] A sending module is used to send the access request to the server to access the service interface according to the first flow control remaining amount of the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount.
[0038] Accordingly, the embodiment of the present application further discloses a device, including:
[0039] one or more processors; and
[0040] One or more machine-readable media having instructions stored thereon, when executed by the one or more processors, cause the apparatus to perform the above-described method.
[0041] Accordingly, the embodiments of the present application also disclose one or more machine-readable media on which instructions are stored, which, when executed by one or more processors, enable the device to perform the above method.
[0042] The embodiments of the present application include the following advantages:
[0043] The embodiment of the present application includes: in the case of unsent access requests, obtaining the first flow control remaining amount of the service interface that the access request needs to access within the concurrent time period; the first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to the access request within the concurrent time period; according to the first flow control remaining amount of the service interface, sending the access request that needs to access the service interface to the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount. In this way, to a certain extent, it can avoid the problem that too many access requests are sent, resulting in the number of requests for the service interface that needs to be accessed exceeding the flow control threshold, the service interface cannot be accessed normally, and the access request cannot be successfully responded to, thereby avoiding the problem of sending invalid requests for retrying, resulting in wasting processing resources and burdening the service interface. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is an implementation architecture diagram provided by an embodiment of the present application;
[0045] Figure 2 This is a schematic diagram of an application scenario provided by an embodiment of the present application;
[0046] Figure 3 This is another application scenario schematic diagram provided by an embodiment of the present application;
[0047] Figure 4 This is another application scenario schematic diagram provided by an embodiment of the present application;
[0048] Figure 5 This is another application scenario schematic diagram provided by an embodiment of the present application;
[0049] Figure 6 is a flowchart of a request processing method provided by an embodiment of the present application;
[0050] Figure 7 This is a flow chart provided by an embodiment of the present application;
[0051] Figure 8 is a flowchart of another request processing method provided by an embodiment of the present application;
[0052] Fig. 9 is a structural diagram of a request processing device provided by an embodiment of the present application;
[0053] Fig.10 is a structural diagram of another request processing device provided by an embodiment of the present application;
[0054] Fig.11 It is a structural schematic diagram of a device provided in another embodiment of the present application. DETAILED DESCRIPTION
[0055] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0056] In order to enable those skilled in the art to better understand the present application, the concepts involved in the present application are explained below:
[0057] Service interface: may refer to an application programming interface (API) provided by a server. Specifically, API may refer to an open API provided by a server, and sending an access request to a service interface may refer to sending an access request to the server providing the service interface.
[0058] Flow control: also known as flow control, is used to control the number of visits to the same service interface within the same concurrent time period.
[0059] Flow control threshold: The flow control thresholds of different service interfaces can be different or the same. The flow control threshold of a service interface is used to characterize the maximum number of access requests for accessing the service interface that can be successfully responded to within a concurrent time period. For example, if the flow control threshold of API1 is 1000, then a maximum of 1000 call requests for accessing API1 can be successfully responded to within a concurrent time period.
[0060] Concurrency time period: It can also be called a time slice. The length of the time slice can be set according to actual needs. For example, a time slice can be 1 second. Accordingly, the flow control threshold can represent the maximum number of requests that can be successfully responded to per second.
[0061] Access request: a request for accessing a service interface. An access request can be sent from a client to a server. Accessing a service interface can be understood as calling a service interface. If the service interface can be accessed normally, the service interface can successfully respond to the access request, and the access request can successfully call the service interface. If the service interface cannot be accessed normally, the service interface cannot successfully respond to the access request, and the access request cannot successfully call the service interface, and a call failure will occur. If the number of times the service interface to be accessed is accessed within a concurrent time period does not exceed the flow control threshold, the access request can be successfully responded to, and the service interface can be accessed normally. If the number of times the service interface to be accessed is accessed within a concurrent time period exceeds the flow control threshold, the access request cannot be successfully responded to, and the service interface cannot be accessed normally, and a call failure will occur. The number of times the service interface is accessed can refer to the number of access requests that the service interface has successfully responded to. Generally, if the flow control threshold is not exceeded, the number of access requests received by the service interface is the number of access requests that have been successfully responded to.
[0062] First flow control remainder: used to characterize the remaining number of requests that the service interface can successfully respond to access requests within a concurrent time period. The first flow control remainder within a concurrent time period can change dynamically. If the server has not received an access request for accessing the service interface within the concurrent time period, the first flow control remainder of the service interface within the concurrent time period can be equal to the flow control threshold. As the client sends an access request for accessing the service interface, the first flow control remainder will decrease accordingly. Exemplarily, assuming that the flow control threshold is 1000, 500 access requests for accessing the service interface have been received within the concurrent time period, and the service interface has successfully responded to 500 access requests, then the first flow control remainder of the service interface within the concurrent time period is 500. Further, if 300 access requests for accessing the service interface are received again, the first flow control remainder of the service interface within the concurrent time period becomes 200.
[0063] High concurrency: refers to sending a large number of access requests to the service interface within the same time slice.
[0064] Backoff strategy: refers to the retry strategy adopted after a call to an interface fails. For example, resending the access request according to the preset retry interval.
[0065] The application scenarios involved in this application are described below.
[0066] Reference Figure 1 , shows an implementation architecture diagram of the present application, and the implementation architecture includes: client 00 and server 01. Server 01 can be a cloud platform composed of servers, or it can be a single server. Multiple service interfaces can be provided in server 01. Each service interface can be used to perform a specified operation, and the specified operation can be set based on actual needs, for example, it can be operations such as creation, deletion, update, query, and reading. Client 00 can perform specified operations by accessing the service interface. Assuming that service interface 1 can be used to create an instance, client 01 can access service interface 1 to create an instance.
[0067] In a high-concurrency scenario, the client will access the service interface in the server with a large number of concurrent requests, and will send multiple access requests each time. However, due to the flow control threshold of the service interface, access failure may occur, affecting the stability of the client. In an embodiment of the present application, when the client 00 requests access to the service interface, for the unsent access request, it first obtains the first flow control remaining amount of the service interface that the access request needs to access within the concurrent time period. According to the first flow control remaining amount, the access request that needs to access the service interface in the unsent access request is sent. According to the first flow control remaining amount that can actually be successfully responded to, the number of access requests sent to the server 01 is controlled to avoid exceeding the flow control threshold of the service interface. In this way, to a certain extent, the problem that the access request is not successfully responded to, the service interface cannot be accessed normally, resulting in access failure and flow control errors can be avoided, thereby reducing the probability of flow control errors, avoiding the loss caused by sending a large number of invalid requests for retries, thereby avoiding wasting processing resources and burdening the server 01.
[0068] Reference Figure 2 , shows a schematic diagram of an application scenario of the present application, in which the client currently has M unsent access requests and the server provides N APIs for explanation. Assume that access request 1-access request 100 is used to access API1, and access request 101-access request M is used to access API2. For one group of access requests: access request 1-access request 100, the first flow control remaining amount of API1 within the concurrent time period can be determined. For another group of access requests: access request 101-access request M, the first flow control remaining amount of API2 within the concurrent time period can be determined.
[0069] Further, for a group of access requests: access request 1-access request 100, access requests in access request 1-access request 100 can be sent to the server according to the first flow control remaining amount of API1, wherein the number of access requests sent is not greater than the first flow control remaining amount of API1. Assuming that the first flow control remaining amount of API1 is 500, then access request 1-access request 100 can all be sent to API1. For access requests newly generated for accessing API1 within the concurrent time period, since there is still a surplus in the first flow control remaining amount of API1, these access requests can continue to be sent to the server later. For another group of access requests: access request 101-access request M, access requests in access request 101-access request M can be sent to the server according to the first flow control remaining amount of API2, wherein the number of access requests sent is not greater than the first flow control remaining amount of API2. In this way, the problem of API1 or API2 access failure within the concurrent time period can be avoided, thereby avoiding the problem of wasting processing resources and burdening the service interface in the server due to retries. It should be noted that the server can return a response message (Response) to the client for the received access request, wherein the response message can be used to indicate whether the access request is successfully responded to, that is, whether the requested API is accessed normally.
[0070] Furthermore, the access request in the embodiment of the present application may be generated based on a task initiated on the client. The task may be initiated manually by the user or automatically by the client. Figure 3 , showing another application scenario diagram of the present application, the user can initiate a pending task on the client, and the client can generate multiple access requests based on the pending task. Exemplarily, the client can parse the pending task to generate multiple access requests. When sending an access request, for an access request that has not been sent, the client can obtain the first flow control remaining amount of the API required to be accessed by the access request within the concurrent time period. For any API that needs to be accessed, according to the first flow control remaining amount of the API, an access request for accessing the API is sent to the server to avoid the problem of too large a number of access requests sent, resulting in access failures, thereby avoiding the problem of wasting processing resources and burdening the service interface in the server due to retries. Since the number of access requests sent this time is not greater than the first flow control remaining amount, the server can successfully respond to the access request and access the API that needs to be accessed. Accordingly, the server can return response information to indicate that the service interface responds successfully and the API required to be accessed by the access request is successfully called.
[0071] Among them, the specific type of the above-mentioned pending tasks can be set based on actual needs. For example, the pending tasks can be cloud resource processing tasks, such as resource orchestration tasks. Resource orchestration tasks can be used to orchestrate resources. Exemplarily, resources, as objects to be orchestrated, can be created, deleted, updated, read, used in combination, and the like. Resources can include instances, services, and the like. Among them, instances can include virtual switches (Vswitch), elastic computing service instances (ECS), database instances (RDS), and the like, and services can include elastic scaling services, load balancing services, and the like. In the resource orchestration scenario, the client can be a resource orchestration tool, and the server can be a cloud platform. Resources can be cloud resources provided by the cloud platform, or they can be resources provided by other platforms. The client can be integrated with the server. When the client and the server are integrated, it is usually implemented by calling the OpenAPI provided by the server. During the development process, the integration of the client and the server can realize a client for managing resources. The integration process can refer to encapsulating and calling the OpenAPI of the cloud platform, and making different processing according to the response results of the OpenAPI. After the integration is completed, the integrated client can be downloaded and installed in the form of a client. When using it, users can specify the number of concurrent resources to be created and managed concurrently. The client can convert this number of concurrent resources into the number of concurrent calls to OpenAPI to achieve concurrent management of cloud resources. However, as the types and number of resources used in tasks continue to increase, the number of concurrent calls will continue to increase in order to improve management efficiency. However, due to the flow control threshold of OpenAPI, the continuous increase in the number of concurrent calls may cause the failure of resource orchestration tasks.
[0072] In the embodiment of the present application, the user can initiate a resource orchestration task on the client, and the access request can be generated by the client based on the resource orchestration task. Assuming that the resource orchestration task corresponds to D resources, and each resource needs to call E APIs in sequence for orchestration, then D*E access requests can be generated based on the resource orchestration task, and E groups of access requests can be obtained. Figure 4, shows another application scenario diagram of the present application, assuming that three groups of access requests are generated based on the resource orchestration task: access request 1-access request 100, access request 101-access request 200, access request 201-access request X. For a group of access requests, for the unsent access requests, the client can send access requests to the server according to the first flow control remaining amount of the API required to be accessed by the group of access requests within the concurrent time period, so as to avoid the problem that the number of access requests sent is greater than the first flow control remaining amount, resulting in call failure. Since the number of access requests sent this time is not greater than the first flow control remaining amount, the API required to be accessed by the access request can be successfully called. By successfully calling the API, resource orchestration can be performed, and orchestration operations that can be implemented by the called API can be executed, such as creating resources, updating resources, reading resources, etc. Exemplarily, assuming that Q access requests are sent, and the API required to be accessed by these Q access requests is used to create resources, then Q resources can be created.
[0073] Reference Figure 5 , shows another application scenario schematic diagram of the present application, in which the access request can be generated by the client based on the order processing task. For the unsent access request, the client can send an access request to the server according to the first flow control remaining amount of the API required to be accessed by the access request within the concurrent time period to call the API required to be accessed by the access request. Since the access request sent is not greater than the first flow control remaining amount, the API can be successfully called to process the order. Assuming that the API called this time is used to update the order status, there are R access requests sent this time, and these access requests are used to indicate the update status of order 1, order 2, ..., order R, respectively. Then, through the called API, the status of order 1, order 2..., order R can be updated. Among them, the order can be a logistics order, a payment order, and so on. The server can also provide APIs for performing other operations, such as APIs for creating orders, APIs for deleting orders, and APIs for modifying orders. Orders can be created, deleted, and modified by accessing these APIs.
[0074] The request processing method involved in this application is described in detail below.
[0075] Reference Figure 6 , shows a flowchart of the steps of a request processing method of the present application, which may include:
[0076] Step 101: In the event that there are unsent access requests, obtain the first flow control remaining amount of the service interface that the access request needs to access within a concurrent time period; the first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period.
[0077] In an embodiment of the present application, the unsent access requests may be all access requests generated based on the tasks to be processed, or may be the remaining unsent access requests among all access requests generated based on the tasks to be processed. The unsent access requests existing in a concurrent time period may be those generated in the concurrent time period and / or in the previous concurrent time period. The first flow control remainder of the service interface in the concurrent time period may be determined based on the flow control threshold of the service interface and the number of access requests that have been successfully responded to by the service interface in the concurrent time period. For example, the first flow control remainder may be the difference between the flow control threshold of the service interface and the number of access requests that have been successfully responded to in the concurrent time period. Under the same access volume, the larger the flow control threshold, the larger the first flow control remainder of the service interface can be.
[0078] The access requests generated in a concurrent time period may be generated based on one or more pending tasks. The number of unsent access requests may vary, so the unsent access requests may be sent in one concurrent time period or may be sent over multiple concurrent time periods.
[0079] Step 102: Send access requests for accessing the service interface to the service interface according to the first flow control remaining amount of the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount.
[0080] In the embodiment of the present application, sending an access request to a service interface may be sending an access request to a server that provides the service interface. The server may call the service interface according to the access request to implement interface access if the flow control threshold of the service interface is not exceeded. For any service interface that needs to be accessed, the number of access requests specifically sent this time may be determined according to the number of access requests that need to access the service interface. Exemplarily, when the number of access requests that need to access the service interface is not greater than the first flow control remaining amount, all access requests that need to access the service interface may be sent, thereby increasing the number of access requests sent and improving the sending efficiency. Alternatively, when there is a large difference between the first flow control remaining amount and the number of access requests that need to access the service interface, for example, when the difference is greater than the first difference threshold, all access requests that need to access the service interface may be sent to the service interface. When the difference between the first flow control remaining amount and the number of access requests that need to access the service interface is small, for example, when the difference is not greater than the first difference threshold, some access requests that need to access the service interface may be sent to the service interface. The larger the difference, the more access requests that may be sent this time. In this way, it is possible to avoid to a greater extent the problem that the number of requests for accessing the service interface during the concurrent time period exceeds the flow control threshold due to the current sending operation, and thus the problem that the service interface cannot be accessed normally can be avoided to a greater extent. It should be noted that the client in the embodiment of the present application can be one or more. In the case of multiple clients, since the number of access requests sent is less than the first flow control remaining amount, it is possible to avoid to a certain extent the problem that the number of requests for accessing the service interface exceeds the flow control threshold due to other clients requesting to access the service interface at the same time.
[0081] In the embodiment of the present application, access requests for accessing the same service interface may be regarded as a group of access requests. For a group of access requests, if there are unsent access requests in the group of access requests, the first flow control remaining amount of the service interface to be accessed by the group of access requests within the concurrent time period is obtained, and according to the first flow control remaining amount of the service interface to be accessed by the group of access requests, the access request to access the service interface is sent to the service interface.
[0082] In summary, the request processing method provided in the embodiment of the present application obtains the first flow control remaining amount of the service interface that the access request needs to access within the concurrent time period in the presence of unsent access requests. The first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to the access request within the concurrent time period. According to the first flow control remaining amount of the service interface, an access request that needs to access the service interface is sent to the service interface. Among them, the number of access requests sent is not greater than the first flow control remaining amount. In this way, to a certain extent, it can be avoided that too many access requests are sent, resulting in the number of requests for the service interface that needs to be accessed exceeding the flow control threshold, the service interface cannot be accessed normally, and the access request cannot be successfully responded to, thereby avoiding the problem of sending invalid requests for retries, resulting in a waste of processing resources and a burden on the service interface.
[0083] Optionally, in an embodiment of the present application, if the first flow control remaining amount is not greater than the second preset threshold and / or the response information returned by the received service interface is used to characterize the failure of the service interface to respond, the first flow control remaining amount can be re-acquired in the next concurrent time period, and the access request for accessing the service interface can be sent to the service interface based on the re-acquired first flow control remaining amount. Among them, the second preset threshold can be set according to actual needs, for example, the second preset threshold can be 0. If the first flow control remaining amount is not greater than the second preset threshold and / or the response information returned by the service interface is used to characterize the failure of the service interface to respond, it can be determined that the service interface to be accessed cannot successfully respond to the access request within the concurrent time period. Therefore, it is possible to wait until the next concurrent time period, re-acquire the first flow control remaining amount in the next concurrent time period, and send it based on the re-acquired first flow control remaining amount. In this way, the problem of repeated failure caused by immediate retry can be avoided, and the probability of failure of the sent access request response can be reduced as much as possible. If the first flow control remaining amount is greater than the second preset threshold, the step of sending an access request for accessing the service interface to the service interface according to the first flow control remaining amount of the service interface can be executed, thereby sending the access request to the service interface as early as possible and shortening the request processing time.
[0084] In one implementation scenario, there may be at least two service interfaces, and in the case where there are at least two service interfaces, at least some of the service interfaces have different flow control thresholds. Exemplarily, the flow control thresholds of at least two service interfaces may be different, or the flow control thresholds of some of the service interfaces may be the same. Since the number of access requests sent is limited based on the flow control remaining amount of the service interface actually required to be accessed by the unsent access request in the embodiment of the present application, even in the scenario where there are differences in the flow control thresholds of the service interfaces, the problem of too many access requests being sent, resulting in the access request being unable to be successfully responded to, can be avoided.
[0085] Optionally, the step of obtaining the first flow control remaining amount of the service interface to be accessed by the access request within the concurrent time period may specifically include:
[0086] Sub-step S21, receiving response information returned by the service interface in response to the access request; the response information includes the first flow control remaining amount of the service interface in the concurrent time period.
[0087] In an embodiment of the present application, the response information may be specifically returned by the server that provides the service interface. The response information returned by the service interface for the access request may be returned for the most recently received access request for accessing the required service interface within the concurrent time period. The service interface may return a response message for any access request received. Since the time when multiple access requests sent in parallel arrive at the service interface may be different, the first flow control remaining amount carried in different response messages is different. For example, the flow control threshold of the service interface is 1000, and the service interface has received 500 access requests so far. For the 501st access request received, the first flow control remaining amount included in the returned response information may be 499, and for the 502nd access request received, the first flow control remaining amount included in the returned response information may be 498.
[0088] Furthermore, when the access request accesses the service interface normally or fails to access the service interface normally, response information will be returned. Accordingly, when the service interface is accessed normally, the returned response information can be used to indicate that the service interface responds successfully and the service interface is successfully accessed. When the service interface is not accessed normally, the returned response information can be used to indicate that the service interface responds unsuccessfully and the service interface is not accessed normally.
[0089] It should be noted that if there is only one client and no access request has been sent to the service interface within the concurrent time period, the flow control threshold of the service interface can be directly determined as the first flow control remaining amount. If there are multiple clients, the specified information returned by the service interface can be received, and the specified information can be used to indicate that no access request has been received within the concurrent time period. When the specified information is received, the flow control threshold of the service interface is determined as the first flow control remaining amount. Correspondingly, in the case of multiple clients, the service interface can also periodically synchronize the current first flow control remaining amount, and determine the first flow control remaining amount synchronized the most recently as the first flow control remaining amount of the service interface within the concurrent time period. In this way, even in the case of multiple clients, it can be ensured to a certain extent that the client obtains a more accurate first flow control remaining amount.
[0090] Sub-step S22: extracting the first flow control remainder from the response information.
[0091] In the embodiment of the present application, the response information can be parsed to extract the first flow control remainder from a specified position of the response information, wherein the specified position can be set according to actual needs, for example, the specified position can be a response header of the response information.
[0092] In the embodiment of the present application, the first flow control remaining amount can be obtained by extracting the response information returned by the received service interface for the access request, so that the acquisition efficiency of the first flow control remaining amount can be ensured to a certain extent. And extracting the first flow control remaining amount from the response information returned by the service interface can ensure to a certain extent that the obtained first flow control remaining amount conforms to the actual situation of the service interface, thereby ensuring the accuracy of the first flow control remaining amount to a certain extent.
[0093] Optionally, the step of sending an access request for accessing the service interface to the service interface according to the first flow control remaining amount of the service interface may specifically include:
[0094] Sub-step S31, adjusting the first flow control residual amount to obtain a second flow control residual amount; the second flow control residual amount is smaller than the first flow control residual amount.
[0095] After the first flow control remaining amount is obtained, the first flow control remaining amount of the service interface may still be consumed. For example, the service interface may receive access requests sent by other clients, or receive access requests that arrive later than multiple access requests sent in parallel. In this way, the actual first flow control remaining amount of the service interface will be reduced. In other words, the first flow control remaining amount obtained by the client may be larger than the current actual flow control remaining amount. Assume that the flow control threshold of the service interface is 1000, and the service interface has received 500 access requests so far. Last time, 50 access requests were sent to the service interface, so the actual first flow control remaining amount of the service interface should be 450. However, there are differences in the order in which the access requests arrive at the service interface, and there are also differences in the order in which the response information returned for the access requests is received. Assume that the response information returned by the service interface for the 530th access request received is received first, and the first flow control remaining amount is obtained: 470. The actual first flow control remaining amount of the service interface after receiving all access requests should be 450. If the first flow control remaining amount obtained is directly used for sending, the number of access requests sent this time may be too large. Therefore, in the embodiment of the present application, the first flow control surplus amount obtained can be adjusted to reduce the first flow control surplus amount. In this way, the reduced value is subsequently sent, which can avoid the problem of too many access requests sent this time to a certain extent.
[0096] It should be noted that in the embodiment of the present application, after completing a parallel transmission, the number of response messages received can be counted. When the number of response messages received is equal to the number of access requests sent in parallel, the maximum first flow control remaining amount can be extracted from multiple response messages, thereby improving the accuracy of the obtained first flow control remaining amount.
[0097] Sub-step S32: Based on the second flow control remaining amount, sending an access request for accessing the service interface to the service interface.
[0098] Since the first flow control remaining amount obtained may be too large, in the embodiment of the present application, the second flow control remaining amount is obtained by reducing the first flow control remaining amount, so that the second flow control remaining amount is more consistent with the actual remaining situation of the service interface. Based on the second flow control remaining amount, an access request is sent to the service interface. Since the sending basis adopted is more consistent with the actual remaining situation of the service interface, it can avoid to a greater extent the problem that the number of requests of the service interface exceeds the flow control threshold after sending, thereby causing a retry.
[0099] Optionally, in one implementation, the above-mentioned step of adjusting the first flow control residual to obtain the second flow control residual may specifically include: adjusting the first flow control residual according to a preset first adjustment weight to obtain the second flow control residual. Among them, the first adjustment weight can be set according to actual needs, and the embodiment of the present application is not limited to this. For example, the first adjustment weight can be 0.6. When adjusting according to the first adjustment weight, a method that can reduce the first flow control residual can be adopted. For example, the product of the first adjustment weight and the first flow control residual can be calculated, and the product can be used as the second flow control residual. In this implementation, the second flow control residual can be obtained by directly adjusting according to the pre-set first adjustment weight, thereby ensuring the adjustment efficiency to a certain extent.
[0100] In another implementation, the step of adjusting the first flow control remainder to obtain the second flow control remainder may specifically include:
[0101] Sub-step S41: determine the second adjustment weight of the first flow control remaining amount according to the first flow control remaining amount of the service interface in the concurrent time period and the flow control threshold of the service interface in the concurrent time period; wherein the second adjustment weight is positively correlated with the first flow control remaining amount.
[0102] In an embodiment of the present application, the ratio of the first flow control remainder to the flow control threshold can be determined, and the second adjustment weight of the first flow control remainder can be determined according to the ratio. Among them, the ratio is positively correlated with the first flow control remainder, and the second adjustment weight can be positively correlated with the ratio. The flow control threshold of the service interface can be pre-synchronized to the client. When determining the second adjustment weight, the interval to which the ratio belongs can be determined, and then the weight corresponding to the interval to which it belongs is determined as the second adjustment weight of the first flow control remainder. Among them, the maximum value of the second adjustment weight can be 1. Exemplarily, when the ratio is greater than 70%, the second adjustment weight can be 1.
[0103] Sub-step S42: reducing the first flow control residual amount based on the second adjustment weight to obtain the second flow control residual amount.
[0104] Exemplarily, the product of the second adjustment weight and the first flow control remainder can be calculated, and the product can be used as the second flow control remainder. In this implementation, the second adjustment weight of the first flow control remainder is determined based on the first flow control remainder of the service interface in the concurrent time period and the flow control threshold of the service interface in the concurrent time period, and the first flow control remainder is lowered based on the second adjustment weight as the second flow control remainder. Among them, the second adjustment weight is positively correlated with the first flow control remainder. In this way, based on the first flow control remainder of the service interface to be accessed, the adjustment weight used during the adjustment is adaptively determined, so that to a certain extent, it can be ensured that the adjusted second flow control remainder is more in line with the actual situation of the service interface to be accessed, and the rationality of the adjusted second flow control remainder is ensured.
[0105] Optionally, the step of sending an access request for accessing the service interface to the service interface based on the second flow control remaining amount may specifically include:
[0106] Sub-step S51: setting a waiting time for access requests that need to access the service interface; wherein the waiting times for at least some of the access requests are different.
[0107] Specifically, different waiting times may be set for different access requests that need to access the service interface. Assuming that there are 100 access requests that need to access the service interface, the 100 waiting times set may all be different. Alternatively, the waiting times for some access requests may be set to be the same, for example, there may be 10 identical waiting times among the 100 waiting times set, and the embodiments of the present application do not limit this.
[0108] Sub-step S52: sending the access request to the service interface according to the waiting time of the access request; wherein the number of access requests sent within the concurrent time period is not greater than the second flow control remainder.
[0109] In the embodiment of the present application, a waiting time is set for the access request that needs to access the service interface, and when the number of requests sent is controlled not to be greater than the second flow control remaining amount, the access request is sent to the service interface according to the waiting time of the access request, which can avoid to a greater extent the problem that the number of requests for the service interface to be accessed exceeds the flow control threshold due to the sent access request, and the service interface cannot be accessed normally, thereby avoiding retries to a greater extent. And because the waiting time of the access request is different, it can avoid to a certain extent the problem of sending the access requests that need to access the same service interface to the service interface at the same time, causing an impact on the service interface.
[0110] Optionally, in one implementation, the step of setting a waiting time for an access request that needs to access the service interface may specifically include:
[0111] Sub-step S61: for access requests that need to access the same service interface, after the previous access request is sent, setting a waiting time for the next access request.
[0112] Accordingly, the step of sending the access request to the service interface according to the waiting time of the access request may specifically include:
[0113] Sub-step S71: After the last access request is sent, select another access request to send after the waiting time, until the number of access requests sent reaches the target number or until the concurrent time period ends; wherein the target number is not greater than the second flow control remainder.
[0114] In this implementation, a waiting time can be set for access requests that need to access the same service interface one by one, and after the waiting time is reached, the access requests are sent one by one. Specifically, a waiting time can be randomly set for one of the access requests that need to access the same service interface, and after the waiting time of the access request has passed, the access request is selected for sending. After sending, a waiting time can be randomly set for one of the remaining access requests, and after the waiting time of the access request has passed, the access request is selected for sending. Among them, an access request selected after the last access request is sent can be an access request for which a waiting time is set after the last access request is sent. By analogy, when the number of access requests sent reaches the target number, or when the concurrent time period ends, the sending is stopped. Among them, the target number can be set according to actual needs, for example, the target number can be equal to the second flow control remaining amount, so that more access requests can be sent to improve access efficiency. The target number can also be less than the second flow control remaining amount, so that the problem of the total number of access requests sent being too large can be further avoided.
[0115] In this implementation, for access requests that need to access the same service interface, after the last access request is sent, a waiting time is set for the next access request to wait, and after the last access request is sent, another access request is selected based on the waiting time to be sent, until the number of access requests sent reaches the target number or until the concurrent time period ends. In this way, multiple access requests sent can be sent one by one, thereby greatly alleviating the receiving pressure of the service interface.
[0116] Optionally, in another implementation, the access requests that need to access the same service interface may be sent after the waiting time is set for all the access requests that need to access the same service interface, so as to ensure the overall operation efficiency. Specifically, when sending, the timing may be started after the waiting time is set for all the access requests that need to access the same service interface. If the waiting time of a certain access request is reached, the access request may be sent to the service interface until the number of access requests sent reaches the target number or until the concurrent time period ends, the sending is terminated and the timing is stopped. Alternatively, the timing may be restarted after the last access request is sent, until the number of access requests sent reaches the target number or until the concurrent time period ends, the sending is terminated.
[0117] Optionally, in the embodiment of the present application, a target ratio may be obtained first, and when the target ratio is greater than or equal to a preset ratio threshold, a step of setting a waiting time for an access request that needs to access the service interface is entered. When the target ratio is less than the preset ratio threshold, the access request that needs to access the service interface is directly sent to the service interface; the target ratio is the ratio between the number of access requests that need to access the service interface and the second flow control remaining amount, or the target ratio is the ratio between the second flow control remaining amount and the flow control threshold of the service interface.
[0118] Among them, the preset ratio threshold can be set according to actual needs. For example, the preset ratio threshold can be 1, or a value less than 1. In the case where the target ratio is the ratio between the number of access requests that need to access the service interface and the second flow control remaining amount, if the target ratio is less than the preset ratio threshold, it can be considered that the second flow control remaining amount is relatively sufficient. Therefore, the access request that needs to access the service interface can be directly sent to the service interface. In this way, the sending efficiency can be ensured. For example, multiple sending threads can be created, and the access requests that need to access the service interface can be sent to the service interface in parallel using multiple sending threads. If the target ratio is greater than or equal to the preset ratio threshold, it can be considered that the second flow control remaining amount may not be sufficient. Therefore, a waiting time can be set for the access request that needs to access the service interface, so that the access request can be selected and sent in sequence according to the waiting time, thereby avoiding sending too many access requests at one time.
[0119] In the case where the target ratio is the ratio between the second flow control remaining amount and the flow control threshold of the service interface, if the target ratio is less than the preset ratio threshold, then the flow control threshold of the service interface to be accessed may be larger, and the number of access requests that the service interface to be accessed can withstand in a single concurrent time period is larger. Therefore, the access request that needs to access the service interface can be directly sent to the service interface. And if the target ratio is less than the preset ratio threshold, the number of access requests that the service interface to be accessed can currently successfully respond to may be small. Therefore, directly sending the access request that needs to access the service interface to the service interface can avoid the problem that the remaining flow control amount of the service interface is consumed by the access requests of other clients during the waiting process, resulting in the failure of the response to the sent access request. On the contrary, if the target ratio is greater than or equal to the preset ratio threshold, it can be determined that the number of access requests that can be withstand in a single concurrent time period of the service interface to be accessed is small. Therefore, a waiting time can be set for the access request that needs to access the service interface, so that the access request is selected according to the waiting time and sent in sequence, thereby avoiding sending too many access requests at one time.
[0120] In the embodiment of the present application, when the second flow control remaining amount is greater than the number of access requests that need to access the service interface, all access requests that need to access the service interface can be directly sent. When it is not greater than the number, the target number of access requests are randomly sent by setting the waiting time. According to the number of access requests that need to access the service interface that are not actually sent and the second flow control remaining amount of the service interface, the number of access requests sent is controlled to avoid flow control errors as much as possible.
[0121] Optionally, the operation of setting a waiting time for an access request that needs to access the service interface may specifically include:
[0122] Sub-step S81: randomly selecting a value from a preset duration range, and setting the selected value as the waiting duration of the access request; wherein the maximum end value of the duration range is less than the duration of the concurrent time period.
[0123] Exemplarily, a value can be randomly selected from the duration range as the waiting time for any access request that needs to access the service interface. In the embodiment of the present application, by randomly selecting a numerical value as the waiting time for the access request, the waiting time for the accessible request is dynamically set to avoid the same waiting time for the access request as much as possible, thereby increasing the randomness of the waiting time. And the maximum end value of the duration range is less than the duration of the concurrent time period, which can shorten the sending interval between access requests to a certain extent, avoiding the problem that the access request needs to wait until the next concurrent time period due to the set waiting time being too long, and the number of access requests that can be sent in the concurrent time period is small, thereby reducing the efficiency of request sending.
[0124] It should be noted that the waiting time for access requests can also be set to a fixed value, and the access requests are sent at a fixed waiting interval when they are sent. Furthermore, due to the concurrent requests, the time when the requests are sent within the concurrent time period is often randomly distributed. Compared with the method of setting a fixed waiting interval, the random setting method is also adopted when setting the waiting time for the access request, so that the distribution of the waiting time for the access request can follow the rules of issuing concurrent requests as much as possible, thereby reducing the waiting time of the request as a whole and improving the request processing efficiency.
[0125] Among them, the duration value range can be determined in the following way: obtain the concurrent time period, the lower limit weight value and the upper limit weight value of the service interface; determine the duration value range according to the lower limit weight value, the upper limit weight value and the concurrent time period. Among them, the lower limit weight value and the upper limit weight value can be set according to actual needs. For example, the lower limit weight value can be 0.1, and the upper limit weight value can be 0.8. The product between the lower limit weight value and the duration of the concurrent time period can be calculated to obtain the minimum end value, and the product between the upper limit weight value and the duration of the concurrent time period can be calculated to obtain the maximum end value. The duration value range is composed based on the minimum end value and the maximum end value. Assuming that N represents the time period, the duration value range can be 0.1N~0.8N. In the embodiment of the present application, by obtaining the lower limit weight value and the upper limit weight value, the duration value range is determined based on the lower limit weight value, the upper limit weight value and the concurrent time period. In this way, the duration value range can be made more reasonable to a certain extent, avoiding the problem of selecting a waiting time that is too short or too long, making the waiting time more reasonable and accurate.
[0126] Since the concurrent time period in the flow control strategy of the service interface is usually a division of continuous time, the duration of each concurrent time period is relatively short. When the flow control threshold of the service interface itself is not high, if the same number of requests as the flow control threshold is released, the probability of flow control errors is high. In the embodiment of the present application, based on the range of time values determined by the concurrent time period, a value is randomly selected as the waiting time, so as to control the interval between the access requests sent, thereby avoiding the occurrence of flow control errors as much as possible.
[0127] Optionally, in the embodiment of the present application, the second flow control remaining amount can also be updated after the access request is sent; when the second flow control remaining amount reaches the first preset threshold and the time is still within the concurrent time period, the access request is stopped from being sent. In the embodiment of the present application, by updating the second flow control remaining amount, it can be determined whether it is necessary to stop sending based on the specific value of the second flow control remaining amount, thereby improving the processing efficiency to a certain extent. At the same time, by timely updating the second flow control remaining amount, it is possible to prevent subsequent sending requests from being blocked.
[0128] Among them, updating the second flow control remainder may be to update the second flow control remainder according to the number of access requests sent after the access request is sent. Specifically, the number of access requests sent may be subtracted from the second flow control remainder to obtain the updated second flow control remainder. Assuming that one access request was sent last time, the second flow control remainder may be reduced by one to achieve the update. The first preset threshold may be set according to actual needs, and the first preset threshold may be the difference between the second flow control remainder and the target number. For example, the first preset threshold may be 0, that is, the aforementioned target value may be equal to the second flow control remainder. If the second flow control remainder reaches the first preset threshold, it may be determined that the number of access requests sent has reached the target number. Of course, the target value may be less than the second flow control remainder, and the first preset threshold may be greater than 0, so that the total number of access requests sent this time may be less than the second flow control remainder.
[0129] After each update, it can be detected whether the updated second flow control remaining amount is equal to the first preset threshold. If the time is still within the concurrent time period, and the updated second flow control remaining amount is not equal to the first preset threshold, it means that after determining the first flow control threshold of the concurrent time period, the number of access requests that have been sent has not reached the target number. Therefore, after the last access request is sent, an access request can be selected from the remaining access requests after a waiting period, and then sent until the second flow control remaining amount in the concurrent time period reaches the first preset threshold. Of course, if the concurrent time period ends and the next concurrent time period has begun, the remaining unsent access requests can continue to be sent in the next concurrent time period.
[0130] Optionally, in an embodiment of the present application, after obtaining the second flow control remaining amount, the second flow control remaining amount may be written into the target cache allocated to the service interface. The above-mentioned operation of updating the second flow control remaining amount may specifically include: updating the second flow control remaining amount in the target cache; the effective duration of the target cache is not greater than the duration of the concurrent time period. Among them, the target cache may be a cache area in the client for storing the flow control remaining amount. It should be noted that, in one implementation method, the first flow control remaining amount may not be adjusted, and the first flow control remaining amount may be written into the target cache and sent directly according to the first flow control remaining amount.
[0131] When the second flow control remaining amount is updated, the second flow control remaining amount may be read from the target cache, the updated second flow control remaining amount may be rewritten into the target cache, and the previous second flow control remaining amount may be overwritten in the target cache.
[0132] Furthermore, in the embodiment of the present application, the target cache can be emptied after the effective duration of the target cache has passed. Since the effective duration of the target cache is not less than the duration of the concurrent time period, the target cache is emptied after the effective duration of the target cache has passed, which can avoid the situation where the target cache is emptied before the concurrent time period ends, thereby causing the loss of the second flow control remaining amount, and the inability to limit the number of requests sent based on the second flow control remaining amount, thereby causing the problem of access errors.
[0133] Optionally, in the embodiment of the present application, a keyword for characterizing the interface identity may be generated based on the accessed service interface information in the request. The service interface information may include the name and number of the service interface, etc., and the keywords of different service interfaces may be different. When generating the keyword, the service interface information may be directly determined as the keyword of the service interface, or the keyword may be obtained after further processing the service interface information, for example, adding preset characters.
[0134] Accordingly, the operation of writing the second flow control remainder into the target buffer allocated for the service interface may specifically include:
[0135] Sub-step S91: writing the second flow control remainder into the target cache corresponding to the keyword.
[0136] The target cache corresponding to the keyword may be a target cache allocated to the service interface represented by the keyword.
[0137] In an embodiment of the present application, by generating a keyword representing the interface identity for the service interface, and writing the second flow control remaining amount into the target cache corresponding to the keyword based on the keyword, it is convenient to subsequently search for the second flow control remaining amount of the service interface based on the keyword.
[0138] Specifically, the keyword of the service interface can be used as the key name (key), and the second flow control remaining amount of the service interface can be used as the key value (value), and written into the target cache in the form of a key-value pair. In this way, even if multiple service interfaces share the target cache, different service interfaces can be conveniently distinguished based on the key name in the key-value pair. Of course, independent target caches can also be allocated to different service interfaces, and this embodiment of the present application does not limit this.
[0139] In the prior art, there is often no limit on the number of requests sent, and retries are only performed when flow control errors or access failures occur. For example, retries are performed with the maximum number of retries and a fixed interval or an interval selected based on an exponential algorithm, or retries are performed with retry parameters or strategies set by the user, or retries are performed based on several fixed retry strategies corresponding to the error code. In the process of continuous retries, the degree of delay will increase, which will in turn cause the execution time of the client task to continue to increase, affecting the efficiency of task execution. Moreover, the increasing number of retries will cause a large number of invalid requests to be sent to the server, causing an impact on the server.
[0140] The same group of access requests is used to access the same service interface of the server for illustration. Figure 7 This is a flow chart of an embodiment of the present application. Figure 7 As shown, for a group of access requests, the client can first determine whether there are unsent access requests. If so, determine whether the second flow control remaining amount in the target cache is greater than the number of unsent access requests. If greater, set the waiting time and send them one by one according to the waiting time. If not, directly send.
[0141] After sending the access request, the server will return a response message. If the first flow control remaining amount carried in the response message is sufficient, and the response message is used to indicate a successful response. The second flow control remaining amount can be calculated, and the second flow control remaining amount calculated this time can be written into the target cache. Otherwise, you can wait for the next concurrent time period to retry. Among them, the first flow control remaining amount is sufficient, which means that the first flow control remaining amount is greater than 0.
[0142] The first flow control remainder may be obtained multiple times within a concurrent time period, so the new second flow control remainder can be calculated multiple times and written into the target cache. After being sent one by one according to the waiting time, the updated second flow control remainder may be the second flow control remainder written most recently, and the second flow control remainder may be overwritten by the newly written second flow control remainder in the subsequent process. Furthermore, the second flow control remainder obtained multiple times within a concurrent time period tends to change dynamically with the number of access requests that the service interface has responded to. Therefore, in an embodiment of the present application, the number of access requests sent can be dynamically adjusted accordingly based on the second flow control remainder, thereby avoiding the occurrence of flow control errors to a large extent, reducing the number of flow control errors, and enabling the client to ensure the successful execution of tasks in high-concurrency scenarios while shortening the task running time as much as possible, thereby improving the execution efficiency of tasks.
[0143] Furthermore, compared to the prior art in which the retry time is adjusted to shorten the retry time as much as possible and multiple retries are performed to improve the retry success rate, in the embodiment of the present application, since the number of flow control errors is small, it is possible to wait until the next concurrent time period to retry after each flow control error occurs, thereby ensuring the retry success rate while avoiding multiple retries.
[0144] It should be noted that in an embodiment of the present application, a controller for processing access requests for accessing the same service interface can be established, and the controller is used to control the access request sending process according to the flow control remaining amount and the number of access requests, so as to avoid the occurrence of a large number of flow control errors as much as possible. Among them, the above-mentioned flow control remaining amount may refer to the first flow control remaining amount or the second flow control remaining amount. In an embodiment of the present application, it is also possible to send in a default manner when sending for the first time, and after triggering a flow control error, perform concurrency reduction. Among them, concurrency degradation may refer to obtaining the first flow control remaining amount of the service interface, and determining the access request to be sent according to the first flow control remaining amount.
[0145] Reference Figure 8 , shows a flowchart of another request processing method of the present application, which can be applied to a client, and includes:
[0146] Step 201: Receive a cloud resource processing task.
[0147] The cloud resource processing task may be a resource orchestration task initiated by a user on the client.
[0148] Step 202: Generate at least one group of access requests according to the cloud resource processing task; wherein the same group of access requests is used to access the same service interface of the server, and the server has at least one service interface.
[0149] The request parameters of the access request may include interface information for characterizing the service interface to be accessed, and access requests with consistent interface information may be regarded as a group of access requests.
[0150] Step 203. For a group of access requests, if there are unsent access requests, obtain the first flow control remaining amount of the corresponding service interface within the concurrent time period from the server; the first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period.
[0151] Specifically, for any group of access requests, the first flow control remaining amount of the service interface that the group of access requests needs to access within the concurrent time period can be obtained. Or, for some groups of access requests, the first flow control remaining amount of the service interface that the group of access requests needs to access within the concurrent time period can be obtained.
[0152] Step 204: according to the first flow control remaining amount of the service interface, send the access request to the server to access the service interface; wherein the number of the access requests sent is not greater than the first flow control remaining amount.
[0153] Specifically, the implementation method of each step can refer to the above-mentioned related description, which will not be repeated here.
[0154] It should be noted that the data involved in the embodiments of the present application and the processes of other information, signals or data used are all carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0155] In summary, the request processing method provided in the embodiment of the present application receives a cloud resource processing task. According to the cloud resource processing task, at least one group of access requests is generated. Among them, the same group of access requests is used to access the same service interface of the server, and there is at least one service interface on the server. For a group of access requests, in the presence of unsent access requests, the first flow control remaining amount of the corresponding service interface in the concurrent time period is obtained from the server. The first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to the access request within the concurrent time period. According to the first flow control remaining amount of the service interface, an access request is sent to the server to access the service interface. Among them, the number of access requests sent is not greater than the first flow control remaining amount. In this way, to a certain extent, it can avoid the problem that too many access requests are sent, resulting in the number of requests for the service interface to be accessed exceeding the flow control threshold, the service interface cannot be accessed normally, and the access request cannot be successfully responded to, thereby avoiding the problem of sending invalid requests for retrying, resulting in a waste of processing resources and burdening the server.
[0156] Reference Fig. 9 , shows a structural diagram of a request processing device of the present application, the device 30 may include:
[0157] The first acquisition module 301 is used to acquire, in the case where there are unsent access requests, a first flow control remaining amount of a service interface that the access request needs to access within a concurrent time period; the first flow control remaining amount is used to represent the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period;
[0158] The sending module 302 is used to send access requests for accessing the service interface to the service interface according to the first flow control remaining amount of the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount.
[0159] In summary, the request processing device provided in the embodiment of the present application obtains the first flow control remaining amount of the service interface that needs to be accessed by the access request within the concurrent time period in the presence of unsent access requests. The first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to the access request within the concurrent time period. According to the first flow control remaining amount of the service interface, an access request that needs to access the service interface is sent to the service interface. Among them, the number of access requests sent is not greater than the first flow control remaining amount. In this way, to a certain extent, it can be avoided that too many access requests are sent, resulting in the number of requests for the service interface that needs to be accessed exceeding the flow control threshold, the service interface cannot be accessed normally, and the access request cannot be successfully responded to, thereby avoiding the problem of sending invalid requests for retries, resulting in a waste of processing resources and a burden on the service interface.
[0160] Optionally, the sending module 302 is specifically configured to:
[0161] Adjusting the first flow control residual amount to obtain a second flow control residual amount; the second flow control residual amount is less than the first flow control residual amount;
[0162] Based on the second flow control remainder, an access request for accessing the service interface is sent to the service interface.
[0163] Optionally, the sending module 302 is further specifically configured to:
[0164] According to a preset first adjustment weight, the first flow control remaining amount is adjusted to obtain the second flow control remaining amount;
[0165] Alternatively, based on the first flow control remaining amount of the service interface in the concurrent time period and the flow control threshold of the service interface in the concurrent time period, a second adjustment weight of the first flow control remaining amount is determined; and based on the second adjustment weight, the first flow control remaining amount is lowered to obtain the second flow control remaining amount; wherein the second adjustment weight is positively correlated with the first flow control remaining amount.
[0166] Optionally, the sending module 302 is further specifically configured to:
[0167] Setting a waiting time for access requests that need to access the service interface; wherein the waiting times for at least some of the access requests differ;
[0168] The access request is sent to the service interface according to the waiting time of the access request; wherein the number of the access requests sent is not greater than the second flow control remainder.
[0169] Optionally, the sending module 302 is further specifically configured to:
[0170] For access requests that need to access the same service interface, after the previous access request is sent, set the waiting time for the next access request to wait;
[0171] After the last access request is sent, another access request is selected to be sent after the waiting time, until the number of access requests sent reaches a target number or until the concurrent time period ends; wherein the target number is not greater than the second flow control remainder.
[0172] Optionally, the sending module 302 is further specifically configured to:
[0173] A value is randomly selected from a preset duration value range, and the selected value is set as the waiting duration of the access request; wherein the maximum end value of the duration value range is less than the duration of the concurrent time period.
[0174] Optionally, the device 30 further includes:
[0175] A second acquisition module is used to acquire a concurrent time period, a lower weight value and an upper weight value of the service interface;
[0176] A determination module is used to determine the duration value range according to the lower limit weight value, the upper limit weight value and the concurrent time period.
[0177] Optionally, the device 30 further includes:
[0178] An updating module, configured to update the second flow control remaining amount after the access request is sent;
[0179] The stopping module is used to stop sending the access request when the second flow control remaining amount reaches a first preset threshold and the time is still within the concurrent time period.
[0180] Optionally, the device 30 further includes:
[0181] A third acquisition module is used to acquire a target ratio; the target ratio is the ratio between the number of access requests that need to access the service interface and the second flow control remaining amount, or the target ratio is the ratio between the second flow control remaining amount and the flow control threshold of the service interface;
[0182] When the target ratio is greater than or equal to a preset ratio threshold, entering a step of setting a waiting time for an access request that needs to access the service interface;
[0183] When the target ratio is less than the preset ratio threshold, the access request for accessing the service interface is directly sent to the service interface.
[0184] Optionally, the device 30 further includes:
[0185] A writing module, used for writing the second flow control remaining amount into a target buffer allocated for the service interface;
[0186] The update module is specifically used for:
[0187] Updating the second flow control remaining amount in the target cache; the effective duration of the target cache is not less than the duration of the concurrent time period;
[0188] The device 30 further includes: a clearing module, configured to clear the target cache after the valid time has elapsed.
[0189] Optionally, the device 30 further includes:
[0190] A generating module, used to generate a keyword for representing an interface identity according to the accessed service interface information in the request;
[0191] The writing module is specifically used for:
[0192] The second flow control remainder is written into a target cache corresponding to the keyword.
[0193] Optionally, the first acquisition module 301 is specifically configured to:
[0194] Receiving response information returned by the service interface in response to the access request; the response information includes a first flow control remaining amount of the service interface in the concurrent time period;
[0195] The first flow control remainder is extracted from the response information.
[0196] Optionally, the device 30 further includes:
[0197] a fourth acquisition module, configured to reacquire the first flow control remaining amount within a next concurrent time period when the first flow control remaining amount is not greater than a second preset threshold value and / or the response information received and returned by the service interface is used to characterize a response failure of the service interface, and send the access request for accessing the service interface to the service interface based on the reacquired first flow control remaining amount;
[0198] An execution module is used to execute the step of sending an access request for accessing the service interface to the service interface based on the first flow control remaining amount of the service interface when the first flow control remaining amount is greater than the second preset threshold.
[0199] Optionally, when there are at least two service interfaces, at least some of the service interfaces have different flow control thresholds.
[0200] Reference Fig.10 , shows a structural diagram of another request processing device of the present application, which is applied to a client. The device 40 may include:
[0201] Receiving module 401, used to receive cloud resource processing tasks;
[0202] A generating module 402 is used to generate at least one group of access requests according to the cloud resource processing task; wherein the same group of access requests is used to access the same service interface of the server, and the server has at least one service interface;
[0203] The acquisition module 403 is used to acquire, for a group of access requests, a first flow control remaining amount of the corresponding service interface in a concurrent time period from the server in the case where there are unsent access requests; the first flow control remaining amount is used to represent the remaining number of requests that the service interface can successfully respond to the access requests in the concurrent time period;
[0204] The sending module 404 is used to send the access request to the server to access the service interface according to the first flow control remaining amount of the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount.
[0205] In summary, the request processing device provided in the embodiment of the present application receives a cloud resource processing task. According to the cloud resource processing task, at least one group of access requests is generated. Among them, the same group of access requests is used to access the same service interface of the server, and there is at least one service interface on the server. For a group of access requests, in the case of an unsent access request, the first flow control remaining amount of the corresponding service interface in the concurrent time period is obtained from the server. The first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to the access request within the concurrent time period. According to the first flow control remaining amount of the service interface, an access request is sent to the server to access the service interface. Among them, the number of access requests sent is not greater than the first flow control remaining amount. In this way, to a certain extent, it can avoid the problem that too many access requests are sent, resulting in the number of requests for the service interface to be accessed exceeding the flow control threshold, the service interface cannot be accessed normally, and the access request cannot be successfully responded to, thereby avoiding the problem of sending invalid requests for retrying, resulting in a waste of processing resources and burdening the server.
[0206] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0207] Fig.11 is a schematic diagram of the structure of a device provided in an embodiment of the present application. Fig.11 , the server 800 can be used to implement the request processing method provided in the above embodiment. The server 800 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 822 (for example, one or more processors) and memory 832, one or more storage media 830 (for example, one or more mass storage devices) storing application programs 842 or data 844. Among them, the memory 832 and the storage medium 830 can be short-term storage or permanent storage. The program stored in the storage medium 830 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the processor 822 can be configured to communicate with the storage medium 830 and execute a series of instruction operations in the storage medium 830 on the server 800.
[0208] The server 800 may also include one or more power supplies 826, one or more wired or wireless network interfaces 850, one or more input / output interfaces 858, one or more keyboards 856, and / or one or more operating systems 841, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc. The processor 822 may execute instructions for performing the following operations on the server 800:
[0209] In the case where there are unsent access requests, obtaining a first flow control remaining amount of the service interface required to be accessed by the access request within a concurrent time period; the first flow control remaining amount is used to represent the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period;
[0210] According to the first flow control remaining amount of the service interface, an access request for accessing the service interface is sent to the service interface; wherein the number of the access requests sent is not greater than the first flow control remaining amount.
[0211] The present application also provides one or more machine-readable media having instructions stored thereon, which, when executed by one or more processors, enable the device to perform the above method.
[0212] The present application provides a device having one or more machine-readable media storing instructions thereon, which, when executed by the one or more processors, enable the device to perform the above method.
[0213] The present application also provides one or more machine-readable media having instructions stored thereon, which, when executed by one or more processors, enable the device to perform the above method.
[0214] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0215] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0216] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0217] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0218] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0219] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0220] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0221] The method and device provided by the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. For general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A request processing method, characterized in that: The method comprises: In the case where there are unsent access requests, obtaining a first flow control remaining amount of a service interface that needs to be accessed by the access request within a concurrent time period; the first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period; the first flow control remaining amount is determined based on a flow control threshold of the service interface and the number of access requests that the service interface has successfully responded to within the concurrent time period; According to the first flow control remaining amount of the service interface, an access request for accessing the service interface is sent to the service interface; wherein the number of the access requests sent is not greater than the first flow control remaining amount.
2. The method according to claim 1, characterized in that The sending, to the service interface, an access request for accessing the service interface according to the first flow control remaining amount of the service interface, comprises: Adjusting the first flow control residual amount to obtain a second flow control residual amount; the second flow control residual amount is less than the first flow control residual amount; Based on the second flow control remainder, an access request for accessing the service interface is sent to the service interface.
3. The method according to claim 2, characterized in that The adjusting the first flow control remainder to obtain a second flow control remainder includes: According to a preset first adjustment weight, the first flow control remaining amount is adjusted to obtain the second flow control remaining amount; Alternatively, based on the first flow control remaining amount of the service interface in the concurrent time period and the flow control threshold of the service interface in the concurrent time period, a second adjustment weight of the first flow control remaining amount is determined; and based on the second adjustment weight, the first flow control remaining amount is lowered to obtain the second flow control remaining amount; wherein the second adjustment weight is positively correlated with the first flow control remaining amount.
4. The method according to claim 2 or 3, characterized in that: The sending, to the service interface, an access request for accessing the service interface based on the second flow control remaining amount, comprises: Setting a waiting time for access requests that need to access the service interface; wherein the waiting times for at least some of the access requests differ; The access request is sent to the service interface according to the waiting time of the access request; wherein the number of the access requests sent is not greater than the second flow control remainder.
5. The method according to claim 4, characterized in that The step of setting a waiting time for an access request requiring access to the service interface includes: For access requests that need to access the same service interface, after the previous access request is sent, set the waiting time for the next access request to wait; The sending the access request to the service interface according to the waiting time of the access request includes: After the last access request is sent, another access request is selected to be sent after the waiting time, until the number of access requests sent reaches a target number or until the concurrent time period ends; wherein the target number is not greater than the second flow control remainder.
6. The method according to claim 4, characterized in that The step of setting a waiting time for an access request requiring access to the service interface includes: A value is randomly selected from a preset duration value range, and the selected value is set as the waiting duration of the access request; wherein the maximum end value of the duration value range is less than the duration of the concurrent time period.
7. The method according to claim 6, characterized in that The method further comprises: Obtain the concurrent time period, lower weight value and upper weight value of the service interface; The duration value range is determined according to the lower limit weight value, the upper limit weight value and the concurrent time period.
8. The method according to claim 5, characterized in that The method further comprises: After the access request is sent, updating the second flow control remaining amount; When the second flow control remainder reaches the first preset threshold and the time is still within the concurrent time period, stop sending the access request.
9. The method according to claim 4, characterized in that The method further comprises: Obtaining a target ratio; the target ratio is a ratio between the number of access requests that need to access the service interface and the second flow control remaining amount, or the target ratio is a ratio between the second flow control remaining amount and the flow control threshold of the service interface; When the target ratio is greater than or equal to a preset ratio threshold, entering a step of setting a waiting time for an access request that needs to access the service interface; When the target ratio is less than the preset ratio threshold, the access request for accessing the service interface is directly sent to the service interface.
10. A request processing method, applied to a client, characterized in that: The method comprises: Receive cloud resource processing tasks; Generate at least one group of access requests according to the cloud resource processing task; wherein the same group of access requests is used to access the same service interface of the server, and the server has at least one service interface; For a group of access requests, in the case where there are unsent access requests, a first flow control remaining amount of the corresponding service interface within a concurrent time period is obtained from the server; the first flow control remaining amount is used to characterize the remaining number of requests to which the service interface can successfully respond to the access requests within the concurrent time period; the first flow control remaining amount is determined based on a flow control threshold of the service interface and the number of access requests to which the service interface has successfully responded within the concurrent time period; According to the first flow control remaining amount of the service interface, the access request is sent to the server to access the service interface; wherein the number of the access requests sent is not greater than the first flow control remaining amount.
11. A request processing device, characterized in that: The device comprises: A first acquisition module is used to acquire, in the case where there are unsent access requests, a first flow control remaining amount of a service interface that the access request needs to access within a concurrent time period; the first flow control remaining amount is used to characterize the remaining number of requests that the service interface can successfully respond to access requests within the concurrent time period; the first flow control remaining amount is determined based on a flow control threshold of the service interface and the number of access requests that the service interface has successfully responded to within the concurrent time period; A sending module is used to send access requests for accessing the service interface to the service interface according to the first flow control remaining amount of the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount.
12. A request processing device, applied to a client, characterized in that: The device comprises: A receiving module, used for receiving cloud resource processing tasks; A generating module, configured to generate at least one group of access requests according to the cloud resource processing task; wherein the same group of access requests is used to access the same service interface of the server, and the server has at least one service interface; An acquisition module, used for acquiring, for a group of access requests, a first flow control remaining amount of a corresponding service interface within a concurrent time period from a server in the case where there are unsent access requests; the first flow control remaining amount is used to characterize the remaining number of requests to which the service interface can successfully respond within the concurrent time period; the first flow control remaining amount is determined based on a flow control threshold of the service interface and the number of access requests to which the service interface has successfully responded within the concurrent time period; A sending module is used to send the access request to the server to access the service interface according to the first flow control remaining amount of the service interface; wherein the number of access requests sent is not greater than the first flow control remaining amount.
13. A device, characterized in that: include: one or more processors; and One or more machine-readable media having instructions stored thereon, which, when executed by the one or more processors, cause the apparatus to perform the method of any one of claims 1 to 10.
14. One or more machine-readable media having stored thereon instructions which, when executed by one or more processors, perform the method of any one of claims 1 to 10.
