CN113037644B - Distributed current limiting method and device - Google Patents

Distributed current limiting method and device Download PDF

Info

Publication number
CN113037644B
CN113037644B CN202110320702.8A CN202110320702A CN113037644B CN 113037644 B CN113037644 B CN 113037644B CN 202110320702 A CN202110320702 A CN 202110320702A CN 113037644 B CN113037644 B CN 113037644B
Authority
CN
China
Prior art keywords
micro service
quota
calling
quota object
micro
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110320702.8A
Other languages
Chinese (zh)
Other versions
CN113037644A (en
Inventor
黄欣欣
周文江
罗彧成
冯煦亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Music Entertainment Technology Shenzhen Co Ltd
Original Assignee
Tencent Music Entertainment Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Music Entertainment Technology Shenzhen Co Ltd filed Critical Tencent Music Entertainment Technology Shenzhen Co Ltd
Priority to CN202110320702.8A priority Critical patent/CN113037644B/en
Publication of CN113037644A publication Critical patent/CN113037644A/en
Application granted granted Critical
Publication of CN113037644B publication Critical patent/CN113037644B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/215Flow control; Congestion control using token-bucket
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The disclosure provides a distributed current limiting method and device, and belongs to the technical field of micro-services. The method comprises the following steps: determining the calling condition of the first micro service to the second micro service at the current time point; if the calling condition meets the obtaining condition of the quota object, predicting the number of times that the first micro service calls the second micro service in the latest historical time period from the current time point based on the number of times that the first micro service calls the second micro service, obtaining a quota object of a target quantity to a quota object distribution node based on the number of times that the quota object needs, wherein the quota object of the target quantity is the quota object needed by the first micro service for calling the second micro service, and processing the calling request of the first micro service to the second micro service by using the quota object of the target quantity. By adopting the method and the device, the delay of executing the processing request can be reduced during distributed current limiting.

Description

Distributed current limiting method and device
Technical Field
The present disclosure relates to the field of micro service technologies, and in particular, to a distributed current limiting method and apparatus.
Background
With the development of the micro-services, the calling stability between the micro-services becomes more and more important, and the restriction of the calling flow between the micro-services can ensure the calling stability between the micro-services, so that the micro-service system is an important means for ensuring the operation of the micro-service system.
In the related art, a quota object needs to be used for calling between micro services, for example, when a micro service a receives a processing request, the micro service a needs to call a micro service B when executing the processing request, and the micro service a requests a remote end to call the quota object of the micro service B. And the remote end judges whether a quota object for calling the micro-service B exists at present, and if so, provides a quota object for calling the micro-service B for the micro-service A. After receiving the quota object for calling the micro service B provided by the remote end, the micro service A calls the micro service B. If the remote end judges that the quota object calling the micro service B does not exist, a notification message that the quota object does not exist is provided for the micro service A, and the micro service A discards the processing request. The existing way of microservice execution to process requests is relatively high in latency.
Disclosure of Invention
In order to solve the problem that the delay for executing the processing request is high, the embodiments of the present disclosure provide a method and an apparatus for distributed current limiting. The technical scheme is as follows:
in one aspect, the present disclosure provides a method of distributed current limiting, the method comprising:
determining the calling condition of the first micro service to the second micro service at the current time point;
if the calling condition meets the acquisition condition of the quota object, predicting the number of quota object demands based on the number of times of calling the second micro service by the first micro service in the latest historical time period away from the current time point;
based on the quota object demand number, acquiring a quota object of a target number from a quota object distribution node, wherein the quota object of the target number is a quota object required by the first micro service for calling the second micro service;
and processing a call request of the first micro service to the second micro service by using the quota object of the target quantity.
In one possible implementation, the method further includes:
when the calling condition is that the target residual number is smaller than a preset value, determining that the calling condition meets an acquisition condition of a quota object, wherein the target residual number is the residual number of the quota object required by the first micro service for calling the second micro service; alternatively, the first and second electrodes may be,
and when the calling condition is that the acquisition period of the quota object required by the first micro service for calling the second micro service is reached, determining that the calling condition meets the acquisition condition of the quota object.
In this way, the quota object required by the first micro service to call the second micro service can be obtained more reasonably.
In a possible implementation manner, the predicting the number of quota object demands based on the number of times that the first micro service calls the second micro service in the historical time period closest to the current time point includes:
determining the times of calling the second micro service by the first micro service in each time interval of the historical time period closest to the current time point;
and predicting the number of quota object demands based on the times of calling the second micro service by the first micro service in each time interval.
Thus, the required number of quota objects can be accurately determined.
In a possible implementation manner, the predicting the number of quota object demands based on the number of times that the first micro service calls the second micro service in each time interval includes:
weighting the times of calling the second micro service by the first micro service in each time interval to obtain the quota object prediction number required by calling the second micro service by the first micro service;
acquiring a target residual number of the current time point, wherein the target residual number is the residual number of quota objects required by the first micro service for calling the second micro service;
and determining the difference value between the quota object prediction number and the target residual number as a quota object demand number.
Thus, the required number of quota objects can be accurately determined.
In a possible implementation manner, when the required number of quota objects is greater than or equal to the number of second micro service quota objects that the quota object allocating node has at the current time point, the target number is equal to the number of second micro service quota objects;
when the quota object demand number is less than the number of second micro-service quota objects which the quota object allocation node has at the current time point, the target number is equal to the quota object demand number;
the second micro service quota object is a quota object required when other micro services except the second micro service call the second micro service.
In another aspect, the present disclosure provides a distributed current limiting apparatus, including:
the determining module is used for determining the calling condition of the first micro service to the second micro service at the current time point;
the prediction module is used for predicting the number of quota object demands based on the number of times that the first micro service calls the second micro service in the latest historical time period away from the current time point if the calling condition meets the acquisition condition of the quota object;
an obtaining module, configured to obtain a target number of quota objects from a quota object allocation node based on the number of quota object demands, where the target number of quota objects is a quota object required by the first micro service to invoke the second micro service;
and the processing module is used for processing the call request of the first micro service to the second micro service by using the quota object of the target quantity.
In a possible implementation manner, the determining module is further configured to:
when the calling condition is that the target residual number is smaller than a preset value, determining that the calling condition meets an acquisition condition of a quota object, wherein the target residual number is the residual number of the quota object required by the first micro service for calling the second micro service; alternatively, the first and second electrodes may be,
and when the calling condition reaches the acquisition period of the quota object required by the first micro service for calling the second micro service, determining that the calling condition meets the acquisition condition of the quota object.
In one possible implementation, the prediction module is configured to:
determining the times of calling the second micro service by the first micro service in each time interval of the historical time period closest to the current time point;
and predicting the demand number of quota objects based on the times of calling the second micro service by the first micro service in each time interval.
In one possible implementation, the prediction module is configured to:
weighting the times of calling the second micro service by the first micro service in each time interval to obtain a quota object prediction number required by calling the second micro service by the first micro service;
acquiring a target residual number of the current time point, wherein the target residual number is the residual number of quota objects required by the first micro service for calling the second micro service;
and determining the difference value between the quota object prediction number and the target residual number as a quota object demand number.
In a possible implementation manner, when the required number of quota objects is greater than or equal to the number of second micro service quota objects that the quota object allocating node has at the current time point, the target number is equal to the number of second micro service quota objects;
when the quota object demand number is less than the number of second micro service quota objects possessed by the quota object allocation node at the current time point, the target quantity is equal to the quota object demand number;
the second micro service quota object is a quota object required when other micro services except the second micro service call the second micro service.
In yet another aspect, the present disclosure provides a computer device for distributed current limiting, the computer device comprising a memory and a processor, wherein: the memory is to store computer instructions; the processor executes computer instructions stored by the memory to cause the computer device to perform the method of the first aspect described above.
In yet another aspect, the present disclosure provides a computer readable storage medium having computer program code stored thereon, which, when executed by a computer device, performs the method of the first aspect.
The beneficial effects brought by the technical scheme provided by the embodiment of the disclosure at least comprise:
in the embodiment of the disclosure, by predicting the number of quota object demands in advance, the number of quota object demands is the number of quota objects required by the first micro service for calling the second micro service, and the quota object required by the first micro service for calling the second micro service is obtained in advance based on the number of quota object demands, so that the second micro service can be called after a call request for the first micro service for calling the second micro service is received, and the quota object is not required to be obtained to a quota object distribution node after the call request is received, so that the delay of executing a processing request can be reduced in distributed current limiting.
Drawings
Fig. 1 is a schematic flowchart of a distributed current limiting method according to an embodiment of the present disclosure;
fig. 2 is a schematic diagram of a framework of a distributed current limiting method according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a distributed current limiting apparatus according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a computer device provided in an embodiment of the present disclosure.
Detailed Description
To make the objects, technical solutions and advantages of the present disclosure more apparent, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.
In order to facilitate understanding of the technical solutions and embodiments provided by the present disclosure, the following explains the involved concepts:
the micro-service is a plurality of small services which are formed by splitting an independent system, the small services are deployed independently, and data can be transmitted between the services.
A services grid, refers to a layer of infrastructure for microservices, making communication between each microservice more fluid, reliable and rapid.
A network agent of a service grid is an agent for communication between micro-services, one network agent for each micro-service. For example, when the microservice a sends a call request to the microservice B, the microservice a sends the call request to the network proxy of the microservice a, and the network proxy of the microservice a sends the call request to the network proxy of the microservice B. The network proxy of microservice B sends the invocation request to microservice B.
In the related art, in the distributed throttling scheme, when a micro-service receives a processing request, a remote request is made to call a quota object of the micro-service required for executing the processing request, which results in a relatively high delay in executing the processing request. Moreover, when a network proxy exists in the service grid, communication is required between the microservice and the network proxy, further increasing the latency of executing the processing request. Based on the requirement, a distributed current limiting method with low time delay is provided.
The embodiment of the disclosure provides a distributed current limiting method, and an execution main body of the method can be a server on which one or more micro-services are installed. The server may be provided with a processor, a memory, and a transceiver. The processor may be configured to perform a process of distributed current limiting. The memory may be used to store data needed in performing the method of distributed throttling, such as the number of stored quota objects. The transceiver may be configured to receive and send data, such as an acquisition request for sending a quota object to a quota object allocating node, and receive a quota object sent by the quota object allocating node.
Before introducing the flow of the distributed current limiting method, firstly, introducing a process of generating a quota object by a quota object allocation node:
a quota object allocation node is a node that manages quota objects that invoke micro-services. The quota object used by the quota object allocation node is a token bucket, the quota object used by the first micro service for calling the second micro service is a token, and the first micro service calls the second micro service each time to use one token. And the quota object distribution node generates a token according to a constant rate, and correspondingly stores the generated token and the identifier of the second micro service. For example, the generated tokens may be stored in a token bucket corresponding to the identifier of the second micro service, where the token bucket has a maximum token number, and after the number of tokens in the token bucket reaches the maximum token number, the quota object allocating node discards the regenerated tokens, or does not generate tokens until the number of tokens in the token bucket does not reach the maximum token number. In this way, when the server requests the quota object allocation node to call the quota object of the second micro service, the quota object allocation node acquires the token from the token and sends the token to the server.
In another possible implementation manner, the current limiting algorithm used by the quota object allocation node may also be a sliding window, a fixed window, a leaky bucket, or the like.
The following describes a flow of a distributed current limiting method, as shown in fig. 1:
step 101, determining the calling condition of the first micro service to the second micro service at the current time point.
The first microservice and the second microservice are installed on a server, and the second microservice and the first microservice may be installed on the same server or different servers.
In this embodiment, each time a server where the first micro service is located reaches a preset period, a calling condition of the first micro service to the second micro service at a current time point is determined, and whether the first micro service is requested to call a quota object required by the second micro service can be determined according to the calling condition. The quota object is used when the first micro service calls the second micro service, and one quota object is used when the first micro service calls the second micro service once, namely the first micro service calls the second micro service once and consumes one quota object.
And step 102, if the calling condition meets the acquisition condition of the quota object, predicting the required number of the quota object based on the number of times that the first micro service calls the second micro service in the latest historical time period away from the current time point.
In this embodiment, the server may determine whether the call condition satisfies the acquisition condition of the quota object, and if the call condition does not satisfy the acquisition condition of the quota object, perform no subsequent processing. If the acquisition condition of the quota object is met, the server determines a history time period closest to the current time point, and the duration of the history time period may be preset, for example, if the current time point is 14 points 2020-12-10, and the length of the history time period is 8 hours, the history time period closest to the current time point is 6 points to 14 points 2020-12-10.
The server records the time point of calling the second micro service by the first micro service every time, and the server acquires the times of calling the second micro service by the first micro service in the historical time period. And then the server predicts the quota object demand number by using the times, wherein the quota object demand number is the number of quota objects required by the first micro service for calling the second micro service.
Step 103, based on the number of quota object demands, obtaining a quota object of a target quantity from a quota object allocation node, where the quota object calls a quota object required by a second micro service for the first micro service.
The quota object allocation node is a node for managing a quota object for calling the micro-services, any micro-service calls the second micro-service, and any micro-service can acquire the quota object for calling the second micro-service from the quota object allocation node.
In this embodiment, after determining the quota object demand number, the server may send an acquisition request of the quota object to the quota object allocation node, where the acquisition request of the quota object includes an identifier of the second micro service and the quota object demand number. The identification of the second micro-service is used to indicate that it is a quota object that invokes the second micro-service.
After receiving the quota object acquisition request sent by the server, the quota object allocation node can analyze the quota object acquisition request to obtain the identifier of the second micro service and the required number of the quota objects. The quota object allocation node determines a quota object corresponding to an identifier of a second micro service at the current time point, namely the second micro service quota object, and the second micro service quota object refers to a quota object usable by other micro services except the second micro service for calling the second micro service. And judging the size relationship between the number of the second micro service quota objects and the number of quota object demands. And if the number of the second micro service quota objects is greater than or equal to the number of the quota object demands, determining the target number as the number of the quota object demands, and if the number of the second micro service quota objects is less than the number of the quota object demands, determining the target number as the number of the second micro service quota objects at the current time point. The quota object allocation node sends a target number of quota objects to the server.
In addition, when other micro services occupy all the second micro service quota objects, the number of quota objects corresponding to the identifier of the second micro service on the quota object allocation node is 0. The quota object allocation node returns a notification message of no quota object to the server, and of course, may also return an acquisition time point of the quota object to the server, and the server may request the quota object from the quota object allocation node again at the acquisition time point of the quota object.
In addition, when the target number is smaller than the required number of the quota object, and the quota object allocation node sends the quota object of the target number to the server, the acquisition time point of the quota object may also be returned to the server, and the server may request the quota object from the quota object allocation node again at the acquisition time point of the quota object.
And 104, processing the call request of the first micro service to the second micro service by using the quota object of the target quantity.
In this embodiment, after the server obtains the quota objects of the target number, when the server receives the processing request, if it is determined that the processing request includes a call request for the first micro service to call the second micro service, the second micro service may be called by using the quota objects of the target number. After each invocation of the second microservice, the target number is subtracted by one.
In addition, when the target number is 0, the server may discard the call request for the first micro service to call the second micro service.
In the embodiment of the disclosure, the quota object required by the first micro service to call the second micro service is asynchronously obtained in advance, so that the second micro service can be called after the call request is received, and the quota object does not need to be obtained by the quota object distribution node after the call request is received, so that the delay of executing the processing request can be reduced during distributed current limiting.
The following is further described with respect to the flow of fig. 1:
there are various processes for determining that the calling condition of the first micro service to the second micro service meets the acquisition condition of the quota object, and two possible implementation manners are given as follows:
in a first mode, when the calling condition is that the target remaining number is smaller than a preset value, it is determined that the calling condition meets the acquisition condition of the quota object, where the target remaining number is the remaining number of the quota object required by the first micro service for calling the second micro service.
The preset value can be preset and stored in the server, and the preset value is smaller, such as 2, 3 and the like.
In this embodiment, at the current time point, the remaining number of quota objects required by the first micro service to invoke the second micro service, that is, the target remaining number, is determined. The server judges the size relation between the target residual number and a preset numerical value. And if the target residual number is smaller than the preset value, determining that the calling condition meets the acquisition condition of the quota object. And if the target residual number is not less than the preset value, determining that the calling condition does not meet the acquisition condition of the quota object.
In a second mode, when the calling condition reaches the acquisition period of the quota object required by the first micro service for calling the second micro service, the calling condition is determined to meet the acquisition condition of the quota object.
The acquisition period of the quota object may be preset and stored in the server, and may be 1 second or the like. The acquisition period of the quota object for each micro service to call other micro services may be the same or different.
In this embodiment, at a current time point, it is determined whether the current time point reaches a first acquisition period, where the acquisition period is a period in which the first micro service calls a quota object required by the second micro service, and it is determined that a calling condition satisfies an acquisition condition of the quota object.
Optionally, after detecting that the acquisition period of the quota object is reached, the server may determine the number of remaining quota objects of the acquired quota object, and determine that the calling condition satisfies the acquisition condition of the quota object only when the number of remaining quota objects is smaller than a preset value. Therefore, when the number of the remaining quota objects is small, the quota object is acquired by the quota object allocation node, and the problem that other micro-services cannot call the second micro-service due to the fact that too many quota objects are acquired is avoided.
In one possible implementation manner, in step 102, the process of determining the number of quota object demands may be:
determining the times of calling the second micro service by the first micro service in each time interval of the historical time period closest to the current time point; and predicting the demand number of the quota object based on the times of calling the second micro service by the first micro service in each time interval.
The quota object demand number is the number of quota objects required by the first micro service for calling the second micro service
In the embodiment, the server determines the latest historical time period from the current time point, and the server divides the historical time period into a plurality of identical time intervals, wherein the length of each time interval is identical. And the server acquires the times of calling the second micro service by the first micro service in each time interval of the historical time period. And then the server carries out weighting processing on the times of calling the second micro service by the first micro service in each time interval to obtain a weighted value. And the server determines the demand number of the quota object according to the weighted value. For example, the weighted value may be determined as the quota object demand number.
Here, in the weighting process, the sum of the weights of the time intervals is 1, and the weight of the time interval closer to the current time point is larger, and the weight of the time interval farther from the current time point is smaller.
Optionally, an Auto-Regressive Moving Average Model (ARMA) may also be used to predict the number of quota objects, and the process is as follows:
Y t =β 1 Y t-12 Y t-23 Y t-3 +…+β p Y t-p +Z t (1)
in the formula (1), Y t Invoking a second microservice for a first microserviceThe predicted number of quota objects needed may be simply referred to as the predicted number of quota objects. Beta is a 1 The weight parameter being the first time interval closest to the current point in time, Y t-1 Number of times of calling the second micro-service for the first micro-service in the first time interval closest to the current time point, and so on, beta p Weight parameter, Y, for the p-th time interval closest to the current time point t-p The number of times of calling the second micro service for the first micro service in the p-th time interval closest to the current time point. Z is a linear or branched member t And obtaining the accuracy rate parameter of the quota object demand number at the current time. Here beta is 1 >β 2 ,β 2 >β 3 And so on, beta p-1 >β p In this way, the referential of the number of times that the first micro service calls the second micro service in the time interval close to the current time point is higher, and the determined quota object demand number is closer to the number of times that the first micro service calls the second micro service. Then using Y t Determining quota object demand number, e.g. Y t The number of quota object requirements, etc.
In addition, when the ARMA is used for determining the required quota number, the server can also determine the Z of the t-th time interval based on the accuracy of the required quota number acquired in the t-1 th time interval t The adjustment mode is as follows:
first, it is determined
Figure BDA0002992711100000101
In formula (2), r represents the accuracy of the required number of quota objects acquired at t-1 th time interval, and Y represents s Indicates the number of actual quota objects used in the t-1 th time interval, Y t-1 And the demand number of the quota object obtained in the t-1 th time interval is represented.
Then using the accuracy range to which r belongs and the corresponding relation between the accuracy range and Z to determine Z corresponding to the accuracy range to which r belongs, and determining Z as Z of the t-th time interval t
In a possible implementation manner, when determining the number of quota object demands, taking the current time point into consideration, the processing of the remaining number of quota objects (i.e., the target remaining number) that the first micro service calls the second micro service is as follows:
weighting the times of calling the second micro service by the first micro service in each time interval to obtain the quota object prediction number required by calling the second micro service by the first micro service; acquiring a target residual number of a current time point, wherein the target residual number is the residual number of quota objects required by calling a second micro service by a first micro service; and determining the difference value between the forecast number of the quota objects and the target residual number as the demand number of the quota objects.
In this embodiment, the server determines the weighted value described above, i.e. the predicted number of quota objects, or Y, based on the number of times the first microservice invokes the second microservice in each time interval t . And the server determines the target residual number at the current time point, uses the quota object prediction number to subtract the target residual number to obtain the quota object demand number, or uses Y by the server t And subtracting the target residual number to obtain the quota object demand number. In this way, the remaining number of the target at the current time point is considered, so that the determined quota object demand number can be more accurate.
In addition, in order to better understand the method flow of distributed current limiting, when a token bucket is used, the processing flow of the embodiment of the disclosure is also provided: as shown in fig. 2, the quota object allocating node generates tokens at a constant rate. In fig. 2, the server determines the required number of quota objects, asynchronously obtains a target quota object from the token bucket, and executes a call request for the first micro service to call the second micro service. And when the target quota object is not obtained, the server discards the calling request of the first micro service for calling the second micro service.
In the embodiment of the disclosure, by predicting the number of quota object demands in advance, the number of quota object demands is the number of quota objects required by the first micro service for calling the second micro service, and the quota object required by the first micro service for calling the second micro service is obtained in advance based on the number of quota object demands, so that after a call request for the first micro service for calling the second micro service is received, the second micro service can be called without obtaining the quota object from a quota object distribution node after the call request is received, and therefore, when the distributed current limiting is performed, the delay of executing the processing request can be reduced.
Based on the same technical concept, an embodiment of the present disclosure further provides a distributed current limiting apparatus, as shown in fig. 3, the apparatus includes:
a determining module 310, configured to determine a calling condition of the first microservice to the second microservice at a current time point;
the prediction module 320 is configured to predict a required number of quota objects based on the number of times that the first micro service calls the second micro service in a historical time period closest to the current time point if the calling condition meets an acquisition condition of a quota object;
an obtaining module 330, configured to obtain a target number of quota objects from a quota object allocation node based on the number of quota object demands, where the target number of quota objects is a quota object required by the first micro service to invoke the second micro service;
the processing module 340 is configured to process, using the quota object of the target number, a call request of the first micro service to the second micro service.
In a possible implementation manner, the determining module 310 is further configured to:
when the calling condition is that the target residual number is smaller than a preset value, determining that the calling condition meets an acquisition condition of a quota object, wherein the target residual number is the residual number of the quota object required by the first micro service for calling the second micro service; alternatively, the first and second electrodes may be,
and when the calling condition reaches the acquisition period of the quota object required by the first micro service for calling the second micro service, determining that the calling condition meets the acquisition condition of the quota object.
In a possible implementation manner, the prediction module 320 is configured to:
determining the times of calling the second micro service by the first micro service in each time interval of a history time period closest to the current time point;
and predicting the demand number of quota objects based on the times of calling the second micro service by the first micro service in each time interval.
In a possible implementation manner, the prediction module 320 is configured to:
weighting the times of calling the second micro service by the first micro service in each time interval to obtain the quota object prediction number required by calling the second micro service by the first micro service;
acquiring a target residual number of the current time point, wherein the target residual number is the residual number of quota objects required by the first micro service for calling the second micro service;
and determining the difference value between the quota object prediction number and the target residual number as a quota object demand number.
In a possible implementation manner, when the required number of quota objects is greater than or equal to the number of second micro service quota objects that the quota object allocating node has at the current time point, the target number is equal to the number of second micro service quota objects;
when the quota object demand number is less than the number of second micro-service quota objects which the quota object allocation node has at the current time point, the target number is equal to the quota object demand number;
the second micro service quota object is a quota object required when other micro services except the second micro service call the second micro service.
In the embodiment of the disclosure, by predicting the required number of quota objects in advance, the required number of quota objects is the number of quota objects required by the first micro service for calling the second micro service, and obtaining the quota objects required by the first micro service for calling the second micro service in advance based on the required number of quota objects, the second micro service can be called after receiving a call request for calling the second micro service by the first micro service, and the quota objects do not need to be obtained to a quota object distribution node after receiving the call request, so that the delay of executing the processing request can be reduced during distributed current limiting.
It should be noted that: in the distributed current limiting device provided in the above embodiment, only the division of the functional modules is illustrated in the distributed current limiting process, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the distributed current limiting apparatus provided in the foregoing embodiment and the distributed current limiting method embodiment belong to the same concept, and specific implementation processes thereof are described in the method embodiment and are not described herein again.
Fig. 4 is a schematic structural diagram of a computer device 400 according to an embodiment of the present disclosure, where the computer device 400 may generate a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 401 and one or more memories 402, where at least one instruction is stored in the memory 402, and the at least one instruction is loaded and executed by the processor 401 to implement the method for distributed current limiting.
Optionally, if the quota object allocating node and the computer device are not integrated into a whole, the computer device further needs to have a communication interface, where the communication interface is used to execute obtaining of the quota object from the quota object allocating node.
In an exemplary embodiment, a computer readable storage medium, such as a memory including program code, which is executable by a processor in a computer device to perform the method of distributed current limiting in the above embodiments, is also provided. For example, the computer-readable storage medium is a non-transitory computer-readable storage medium, such as a read-only memory (ROM), a Random Access Memory (RAM), a compact disc-read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the storage medium may be a read-only memory, a magnetic disk or an optical disk.
The above description is intended to be illustrative of only one alternative embodiment of the disclosure, and not to be construed as limiting the disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principles of the disclosure are intended to be included within the scope of the disclosure.

Claims (7)

1. A method of distributed current limiting, the method comprising:
determining the calling condition of the first micro service to the second micro service at the current time point;
if the calling condition meets the acquisition condition of the quota object, predicting the number of quota object demands based on the number of times of calling the second micro service by the first micro service in the latest historical time period away from the current time point;
based on the quota object demand number, acquiring a quota object of a target quantity from a quota object distribution node, wherein the quota object is a quota object required by the first micro service for calling the second micro service;
processing a call request of the first micro service to the second micro service by using the quota object of the target quantity;
predicting the quota object demand number based on the number of times that the first micro service calls the second micro service in the historical time period closest to the current time point, including:
determining the times of calling the second micro service by the first micro service in each time interval of the historical time period closest to the current time point;
weighting the times of calling the second micro service by the first micro service in each time interval to obtain the quota object prediction number required by calling the second micro service by the first micro service;
acquiring a target residual number of the current time point, wherein the target residual number is the residual number of quota objects required by the first micro service for calling the second micro service;
and determining the difference value between the quota object prediction number and the target residual number as a quota object demand number.
2. The method of claim 1, further comprising:
when the calling condition is that the target residual number is smaller than a preset value, determining that the calling condition meets an acquisition condition of a quota object, wherein the target residual number is the residual number of the quota object required by the first micro service for calling the second micro service; alternatively, the first and second liquid crystal display panels may be,
and when the calling condition is that the acquisition period of the quota object required by the first micro service for calling the second micro service is reached, determining that the calling condition meets the acquisition condition of the quota object.
3. The method of any of claims 1 or 2, wherein the target number is equal to a number of second micro service quota objects that the quota object allocating node has at the current point in time when the quota object demand number is greater than or equal to the number of second micro service quota objects;
when the quota object demand number is less than the number of second micro-service quota objects which the quota object allocation node has at the current time point, the target number is equal to the quota object demand number;
the second micro service quota object is a quota object required when other micro services except the second micro service call the second micro service.
4. A distributed current limiting apparatus, comprising:
the determining module is used for determining the calling condition of the first micro service to the second micro service at the current time point;
the prediction module is used for predicting the number of quota object demands based on the number of times that the first micro service calls the second micro service in the latest historical time period away from the current time point if the calling condition meets the acquisition condition of the quota object;
an obtaining module, configured to obtain a target number of quota objects from a quota object allocation node based on the number of quota object demands, where the target number of quota objects is a quota object required by the first micro service to invoke the second micro service;
the processing module is used for processing the calling request of the first micro service to the second micro service by using the quota object of the target quantity;
the prediction module is configured to:
determining the times of calling the second micro service by the first micro service in each time interval of the historical time period closest to the current time point;
weighting the times of calling the second micro service by the first micro service in each time interval to obtain the quota object prediction number required by calling the second micro service by the first micro service;
acquiring a target residual number of the current time point, wherein the target residual number is the residual number of quota objects required by the first micro service for calling the second micro service;
and determining the difference value between the quota object prediction number and the target residual number as a quota object demand number.
5. The apparatus of claim 4, wherein the determining module is further configured to:
when the calling condition is that the target residual number is smaller than a preset value, determining that the calling condition meets an acquisition condition of a quota object, wherein the target residual number is the residual number of the quota object required by the first micro service for calling the second micro service; alternatively, the first and second electrodes may be,
and when the calling condition reaches the acquisition period of the quota object required by the first micro service for calling the second micro service, determining that the calling condition meets the acquisition condition of the quota object.
6. A distributed current-limited computer device, the computer device comprising a memory and a processor, wherein:
the memory is to store computer instructions;
the processor executes the computer instructions stored by the memory to cause the computer device to perform the method of any of claims 1 to 3.
7. A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program code which, when executed by a computer device, performs the method of any of claims 1 to 3.
CN202110320702.8A 2021-03-25 2021-03-25 Distributed current limiting method and device Active CN113037644B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110320702.8A CN113037644B (en) 2021-03-25 2021-03-25 Distributed current limiting method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110320702.8A CN113037644B (en) 2021-03-25 2021-03-25 Distributed current limiting method and device

Publications (2)

Publication Number Publication Date
CN113037644A CN113037644A (en) 2021-06-25
CN113037644B true CN113037644B (en) 2023-03-24

Family

ID=76473868

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110320702.8A Active CN113037644B (en) 2021-03-25 2021-03-25 Distributed current limiting method and device

Country Status (1)

Country Link
CN (1) CN113037644B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111130908A (en) * 2019-12-31 2020-05-08 中信百信银行股份有限公司 Micro-service dynamic aggregation and splitting system based on calling flow analysis and prediction

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110032447B (en) * 2019-04-11 2022-02-22 北京百度网讯科技有限公司 Method and apparatus for allocating resources
CN111447577B (en) * 2020-02-18 2021-07-27 中国联合网络通信集团有限公司 Quota management method and device
CN111475373A (en) * 2020-03-10 2020-07-31 中国平安人寿保险股份有限公司 Service control method and device under micro service, computer equipment and storage medium
CN112416594A (en) * 2020-11-30 2021-02-26 四川长虹智能制造技术有限公司 Micro-service distribution method, electronic equipment and computer storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111130908A (en) * 2019-12-31 2020-05-08 中信百信银行股份有限公司 Micro-service dynamic aggregation and splitting system based on calling flow analysis and prediction

Also Published As

Publication number Publication date
CN113037644A (en) 2021-06-25

Similar Documents

Publication Publication Date Title
US11146502B2 (en) Method and apparatus for allocating resource
US11216310B2 (en) Capacity expansion method and apparatus
EP2894827B1 (en) Method, apparatus, and system for managing migration of virtual machine
CN106959894B (en) Resource allocation method and device
EP3758325B1 (en) Traffic limiting method, node and system
JP2009026316A (en) Apparatus for predicting wait time in queue
US20190324805A1 (en) Method, apparatus and computer program product for resource scheduling
CN112311628B (en) Network speed measuring method, system, network equipment and storage medium
CN112367268A (en) Current limiting method and device for micro-service
CN110636388A (en) Service request distribution method, system, electronic equipment and storage medium
CN112181664A (en) Load balancing method and device, computer readable storage medium and electronic equipment
EP4068092A1 (en) Managing computer workloads across distributed computing clusters
CN113037644B (en) Distributed current limiting method and device
CN115086940B (en) QoS adjustment method, system, device and storage medium based on 5G
CN112286622A (en) Virtual machine migration processing and strategy generating method, device, equipment and storage medium
CN114257521A (en) Flow prediction method, device, electronic equipment and storage medium
US8549537B2 (en) Middleware bridge system and method
CN108257077B (en) GPU-based clustering data processing method and system and computing device
CN111782364A (en) Service calling method and device, electronic equipment and storage medium
CN111371675A (en) Intelligent addressing method, device, equipment and storage medium thereof
CN111130933A (en) Page flow estimation method and device and computer readable storage medium
CN113196238B (en) Service-aware server-less cloud computing system
US11418417B2 (en) Managing stateful workloads executing on temporarily available resources of a cloud computing system
CN117311999B (en) Resource scheduling method, storage medium and electronic equipment of service cluster
CN110430264B (en) Data reading method in cloud computing

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant