CN-122027162-A - Adaptive token request method, electronic device and computer program product
Abstract
The application discloses an adaptive token request method, electronic equipment and a computer program product. The method comprises the steps of obtaining a request result of a current service department for requesting tokens continuously N times, wherein the request result comprises successful requests or unsuccessful requests, N is a positive integer, adjusting the request quantity of the current tokens based on the times of successfully requesting the tokens in the N request results, generating token requests based on the request quantity of the current tokens, and sending the token requests to a token distribution terminal. The method and the device can reduce the frequency of frequently initiating small-batch token application to the token distribution terminal, reduce the processing pressure of the token distribution terminal, and enable the token distribution terminal to intensively schedule global resources in a more stable application mode.
Inventors
- WANG YOUCHENG
Assignees
- 前锦网络信息技术(上海)有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251230
Claims (10)
- 1. An adaptive token request method, the method comprising: obtaining a request result of a current service department for continuously requesting a token for N times, wherein the request result comprises a successful request or an unsuccessful request, and N is a positive integer; Based on the times of successfully requesting tokens in the N continuous request results, adjusting the request quantity of the current tokens; Based on the number of the current tokens, generating token requests and sending the token requests to a token distribution terminal.
- 2. The method of claim 1, wherein the obtaining the request result of the current service department for N consecutive requests for tokens comprises: The method comprises the steps of obtaining the number of token requests of each request token and the number of tokens actually obtained by each request; Corresponding to each request token, and under the condition that the number of the token requests is equal to the number of the actually obtained tokens, the request result is a successful request; In the case that the number of token requests is smaller than the number of tokens actually obtained, the request result is an unsuccessful request.
- 3. The method of claim 1, wherein adjusting the number of requests for the current token based on the number of successful requests for tokens in the N number of request results in succession comprises: and under the condition that the continuous N times of request results are all successful requests, determining the request quantity of the current tokens based on the token quantity obtained by the last request, wherein the request quantity of the current tokens is larger than the token quantity obtained by the last request.
- 4. The method of claim 1, wherein the determining the number of current tokens based on the number of tokens obtained from the last request comprises: obtaining a token base number and an influence factor of the number of the obtained tokens; determining an increased number of tokens based on a product of the token cardinality and the impact factor; and adding the number of tokens to the sum of the number of tokens obtained by the last request as the number of the current tokens.
- 5. The method of claim 4, wherein obtaining a token influencing factor comprises: Determining the number X of times that the number of tokens obtained by continuous requests is greater than or equal to the token base when the number of tokens obtained by the last request is greater than or equal to the token base; And determining the value of the token influence factor according to the preset frequency range corresponding to the frequency X, wherein the larger the value of the preset frequency range corresponding to the frequency X is, the smaller the value of the token influence factor is.
- 6. The method of claim 1, wherein adjusting the number of requests for the current token based on the number of successful requests for tokens in the N number of request results in succession comprises: In the request results of the N continuous requests of tokens, under the condition that the latest M request results are unsuccessful requests, obtaining the number of tokens obtained by each request in the M requests, wherein M is smaller than N and is a positive integer; and calculating the average value of the number of tokens obtained by M requests to obtain the current number of token requests.
- 7. The method of claim 1, wherein generating a token request based on the number of requests for the current token further comprises: Acquiring a scene identifier of a service scene corresponding to a service activity to be processed and a department identifier of a current service department; Based on the number of requests for the current token, the scene identification and the department identification, a token request is generated.
- 8. An electronic device comprising a processor and a memory storing computer program instructions, the electronic device implementing the method of any one of claims 1-7 when executing the computer program instructions.
- 9. A computer readable storage medium, wherein computer program instructions are stored on the computer readable storage medium, which when executed by a processor, implement the method of any one of claims 1-7.
- 10. A computer program product comprising computer program instructions which, when executed by a processor, implement the method of any one of claims 1 to 7.
Description
Adaptive token request method, electronic device and computer program product Technical Field The present application relates to the field of computer communications, and in particular, to an adaptive token request method, an electronic device, and a computer program product. Background With the continuous expansion of business scale of enterprises, a plurality of business nodes are often set to respectively cope with different business scenes to provide diversified business services, for example, in a recruitment platform, various business scenes such as touch push, similar position recommendation, multiple delivery recommendation, market hot recruitment recommendation and the like are provided. Providing business services by each business node requires obtaining resources provided by the enterprise operation platform, for example, the enterprise operation platform may provide tokens to each business node, so as to control the traffic of the business node, API call quota, message consumption, computing resources and other resources. Because the resources consumed by different service nodes are different, in order to ensure the stability and the availability of enterprise services, the resource consumption of each service scene needs to be balanced, so that the resource consumption of each service node needs to be limited, and the excessive consumption of the resources by part of service nodes is avoided. However, if the service requirement of a certain service scenario increases, the service scenario needs to frequently request tokens from the platform as a request end, so that frequent access requests can cause operation pressure on the platform, increase platform delay and cause performance bottlenecks. In addition, if the consumption of the service request is more, under the limitation of the platform, the request token from the platform may be rejected by the platform, thereby affecting the service quality of the service scene and further affecting the user experience. In order to solve the above-mentioned problems, it is necessary to provide a token request method with adaptive capability, so as to reduce the operation pressure of the platform and improve the success rate of the token request. Disclosure of Invention In view of the above, embodiments of the present application provide an adaptive token request method, an electronic device, and a computer program product, which are used for solving at least one technical problem. The embodiment of the application provides a self-adaptive token request method which comprises the steps of obtaining a request result of a current service department for requesting a token continuously N times, wherein the request result comprises a successful request or an unsuccessful request, N is a positive integer, adjusting the request quantity of the current token based on the times of successfully requesting the token in the N request results, generating a token request based on the request quantity of the current token, and sending the token request to a token distribution terminal. Optionally, in some embodiments of the present application, obtaining the request result of the current service department continuously requesting N times of tokens includes obtaining a token request number of each request token and an actually obtained token number of each request, obtaining a successful request corresponding to each request token if the token request number is equal to the actually obtained token number, and obtaining an unsuccessful request if the token request number is smaller than the actually obtained token number. Optionally, in some embodiments of the present application, adjusting the number of requests of the current token based on the number of successful requests of the N request results in succession includes determining the number of requests of the current token based on the number of tokens obtained from the previous request, where the number of requests of the current token is greater than the number of tokens obtained from the previous request, if the N successive request results are all successful requests. Optionally, in some embodiments of the present application, determining the number of requests for the current token based on the number of tokens obtained from the last request includes obtaining a token base and obtaining an impact factor for the number of tokens, determining the number of tokens to be increased based on a product of the token base and the impact factor, and taking the sum of the number of tokens to be increased and the number of tokens obtained from the last request as the number of requests for the current token. Optionally, in some embodiments of the present application, obtaining the token influencing factor includes determining a number X of times the number of tokens obtained by consecutive requests is greater than or equal to the token radix when the number of tokens obtained by the previous request is greater than or equa