CN109150746B - Global flow control method and device - Google Patents

Global flow control method and device Download PDF

Info

Publication number
CN109150746B
CN109150746B CN201810735932.9A CN201810735932A CN109150746B CN 109150746 B CN109150746 B CN 109150746B CN 201810735932 A CN201810735932 A CN 201810735932A CN 109150746 B CN109150746 B CN 109150746B
Authority
CN
China
Prior art keywords
time
flow control
tokens
central controller
token
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
CN201810735932.9A
Other languages
Chinese (zh)
Other versions
CN109150746A (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.)
Nanjing Xingyun Digital Technology Co Ltd
Original Assignee
Nanjing Xingyun Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Xingyun Digital Technology Co Ltd filed Critical Nanjing Xingyun Digital Technology Co Ltd
Priority to CN201810735932.9A priority Critical patent/CN109150746B/en
Publication of CN109150746A publication Critical patent/CN109150746A/en
Application granted granted Critical
Publication of CN109150746B publication Critical patent/CN109150746B/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
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention discloses a global flow control method and a global flow control device, relates to the technical field of internet, and can provide a global flow control scheme which can be flexibly deployed in a distributed system, so that the cost problem caused by the fact that the system resource amount is increased by increasing hardware equipment is reduced. The invention comprises the following steps: after receiving a request message sent by an application server, determining a flow control item corresponding to the request message, wherein the flow control item comprises at least one sub-item; requesting a central controller to acquire a token according to the flow control item; and obtaining the token distributed by the central controller and feeding the token back to the application server sending the request. The invention is suitable for global flow control in a distributed system.

Description

Global flow control method and device
Technical Field
The invention relates to the technical field of internet, in particular to a global flow control method and a global flow control device.
Background
With the rise of the e-commerce and internet financial industry, the requirements of high concurrency, high reliability, low delay, low cost and other comprehensive capabilities are put forward for an IT system supporting various online services.
In order to guarantee the overall health of the entire IT ecological chain, IT is a common control means to perform flow control and degradation on the accessed subsystems. With the rapid growth of business scale, often an IT ecological chain involves hundreds of subsystems, thousands to tens of thousands of hardware devices, the risk point of the whole system rises sharply, and in order to ensure that the whole or part of the system is always on-line, the system architecture in a large-scale global system generally performs distributed multi-activity deployment. In actual engineering application, the validity period of the token needs to be determined at the issuing side of the token, the tokens with the same validity period are packaged in one or more subsets, and when the application server requests the token, the subsets are allocated as token resources. Under the condition of traditional single application/data node and single machine room, the problem of occupying system resources in the distribution process of the sub-sets is not obvious.
However, for a distributed multi-activity system, the demands of different nodes for tokens are different, so that in order to ensure the uniformity in the token allocation process and alleviate the problem that the tokens are idle and occupied, designers can think of reducing the granularity of subsets in a best way and improving the uniformity of token allocation. However, the smaller the granularity of the subsets is, the larger the number of subsets to be managed at the same time is, the more system resources are occupied, and as a result, the consumption of the system resources is increased by one order of magnitude.
For systems of important departments such as banks, railway ticketing and the like, the problem can be solved by increasing the amount of system resources in a way of adding hardware equipment, but the cost of the way is too high for most Internet enterprises.
Disclosure of Invention
Embodiments of the present invention provide a global flow control method and apparatus, which can provide a global flow control scheme that can be flexibly deployed in a distributed system, and alleviate a cost problem caused by increasing system resource amount by increasing hardware devices.
In order to achieve the above purpose, the embodiment of the invention adopts the following technical scheme:
after receiving a request message sent by an application server, determining a flow control item corresponding to the request message, wherein the flow control item comprises at least one sub-item;
requesting a central controller to acquire a token according to the flow control item;
obtaining tokens distributed by the central controller and feeding back the tokens to a requesting application server, wherein the quantity of the tokens distributed for one subentry is obtained by the central controller according to the total time and the flow control value per second; the flow control value per second is: the number of tokens allocated per unit time by the central controller.
The embodiment provides a flow control system combining local control and central control, which comprises the following steps: and loading a corresponding rule engine on the local component so as to judge the scene needing flow control, wherein the rule engine can adopt the existing technology and algorithm. The central controller calculates the number of tokens to be allocated at the flow control value per second and the summed time, thereby achieving a token generation quantity that is completely measured in time. And, since direct communication of the application server and the central controller is isolated by the local component, the communication pressure of the central controller is reduced. The embodiment is particularly suitable for a large-scale and distributed real-time processing system, and can realize a flow control mechanism which is quickly configured, changed and validated for the large-scale and distributed real-time processing system by changing the time threshold value and the flow control value per second, and can adapt to almost all flow control scenes in practical application.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic diagram of a possible system architecture according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a method according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of another method provided by the embodiment of the present invention;
fig. 4 is a schematic diagram of an embodiment provided in the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the present invention will be described in further detail with reference to the accompanying drawings and specific embodiments. Reference will now be made in detail to the embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention. As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or coupled. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items. It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The method flow in this embodiment may be specifically executed on a system as shown in fig. 1, where the system includes: an application server, a central controller and local components. The application server is specifically configured to run various online service systems, such as: the system comprises an online shopping provider, a logistics system, an order system, an online financial system and the like, wherein during the operation process of the application servers, due to preset operation rules and operation mechanisms, tokens are required to be requested from a background server. It should be noted that, in this embodiment, the reason why the application server needs to request the token and the specific business rule are not limited, and the scheme of this embodiment is mainly used in the processing process after receiving the token request.
The central controller may be specifically configured to: one side of a distributed system such as a backend server, data center, etc. for managing clusters of application servers is often referred to as the "backend". The application server and the central controller disclosed in this embodiment may be specifically a server, a workstation, a super computer, or a server cluster system for data processing, which is composed of a plurality of servers.
It should be noted that, in practical applications, the local component may be implemented on a separate server device; alternatively, the application server and the local component are integrated in the same server cluster, that is, the functions of the application server and the local component are assumed by the same server cluster, for example: in a server cluster system of application servers, virtual machines are established and used to run program code for implementing specific functions of local components.
At the program code level, the local component functional requirements may include: by adopting an efficient rule engine, related flow control items can be rapidly judged according to requests; efficiently interacting with a central controller, obtaining the token value of each subentry, and informing a local application system in a proper mode when no token exists; appropriate mechanisms are taken to ensure that the entire process of obtaining tokens ends within a certain time threshold (e.g., within 10 ms). That is, in the present embodiment, a dedicated local component is used to send a token request to the central controller, instead of a huge number of application servers directly sending token requests to the central controller, thereby reducing the communication pressure of the central controller.
From the program code level, the central controller may be implemented as: the method comprises the following steps of deploying a large number of java application service clusters and redis high-availability clusters; the algorithm requirements involved in the present embodiment are mainly fulfilled by the incr instruction in reds. The local component is provided for the application server in a jar packet mode, so that the flow control function is provided in a transparent mode, namely the local component is invisible for the application server, and no additional transformation is needed on one side of the application server, so that the implementation cost of the scheme of the embodiment is reduced. The central controller may exist as an exclusive service, i.e. there is only one global to the system. The central controller can be deployed in a cluster mode on a hardware level, and all components do not have a single point.
An embodiment of the present invention provides a global flow control method, which can be implemented on a local component shown in fig. 1, as shown in fig. 2, and includes:
and S11, after receiving the request message sent by the application server, determining the flow control item corresponding to the request message.
Wherein the flow control term comprises at least one sub-term. The request message is used for the application server to request the background side to acquire the token. The central controller may be specifically configured to: one side of a distributed system such as a backend server, data center, etc. for managing clusters of application servers is often referred to as the "backend". In the prior art, an application server directly communicates with a background side to request for obtaining a token, in this embodiment, a local component receives a request message, counts the request messages sent by one or more application servers within a period of time, generates a flow control item, and then requests a central controller to obtain the token through the flow control item, so that the number of access times of the central controller is reduced, and communication pressure is reduced.
And S12, requesting to acquire a token from the central controller according to the flow control item.
In this embodiment, the local component may determine and determine which are used as flow control items, where one item corresponds to one scene primary key. The scene primary key may specifically be a character such as a number or a letter, and is used to identify a certain service scene, such as an order service, a sales promotion service, and the like. In a preferred embodiment of this embodiment, the scene primary key is used to identify each service link in the service scene, for example: in the business of receiving orders made by users, the business links are as follows: order establishment, order information proofreading, commodity stock proofreading and feedback acknowledgement messages can respectively identify the 4 business links through 4 scene main keys, and each business link is usually processed through at least one application server cluster due to large business volume in practical application. In technical terms, each application server is generally divided into one thread in the global system, such as: if there are 100 application servers that undertake order creation, then there are 100 threads that simultaneously request tokens from the central controller. And S13, obtaining the token distributed by the central controller and feeding back the token to the application server sending the request.
Wherein the number of tokens allocated for a subentry is obtained by the central controller from the summed time and flow control value per second.
The central controller allocates time slices for each received token request and moves the time points forward on a second time axis until the value of the time points on the second time axis reaches the current time value of a first time axis, the amount of forward movement of the time points is equal to the amount of allocated time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one sub-item.
The flow control value per second is: the number of tokens allocated per unit time by the central controller.
The current flow control mechanism has roughly 2 ideas:
1. under the condition that the number of connections is limited within a certain time, the concurrency is controlled, and the method is mainly suitable for relieving load pressure in various large-scale promotion activities (such as twenty-one and twenty-two).
2. And controlling the token release amount in unit time. Such as: 2000 orders are processed by 100 servers, load balancing is needed, but actual performances of different servers are different, some servers can process 200, and some servers can process only 50, so that token subsets with different sizes are packaged and distributed to application servers sending requests according to different servers, namely, subsets identified by timestamps are used for packaging tokens, and subsets are distributed.
The embodiment provides a flow control system combining local control and central control, which comprises the following steps: and loading a corresponding rule engine on the local component so as to judge the scene needing flow control, wherein the rule engine can adopt the existing technology and algorithm. The central controller calculates the number of tokens to be allocated at the flow control value per second and the summed time, thereby achieving a token generation quantity that is completely measured in time. And, since direct communication of the application server and the central controller is isolated by the local component, the communication pressure of the central controller is reduced. For example: the local component decision flow is shown in fig. 4.
The embodiment is particularly suitable for a large-scale and distributed real-time processing system, and can realize a flow control mechanism which is quickly configured, changed and validated for the large-scale and distributed real-time processing system by changing the time threshold value and the flow control value per second, and can adapt to almost all flow control scenes in practical application. For example: it can be configured according to the scene, like a typical mutual-fund system, and can control the account payment processing flow of user A to be 5 times per second at 10 to 12 points per week. And through the flow control value per second which can be adjusted in real time, the token generation and acquisition mechanism is improved, the in-out tokens can be smoothly and continuously, and the problem of inaccurate counting before and after the token bucket switching point is solved.
In this embodiment, a time slice is allocated to each received token request, and a time point is moved forward on a second time axis until a value of the time point on the second time axis reaches a current time value of a first time axis, the amount of forward movement of the time point is equal to the amount of allocated time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one sub-item. Thus, a token generation and distribution manner which is completely measured in time is realized. At a time point on the second time axis, the current time is approached in small steps according to the allocated time slices, and each token request requests one small slice from the central controller until the time point on the second time axis catches up with the time point on the first time axis (namely, natural time), and the total time refers to: the time slices allocated during this "step by step approach" are summed up after the natural time has been traced back to the time point on the second time axis. In this embodiment, the specific step of requesting the central controller to acquire the token includes: and judging whether tokens corresponding to all the sub-items in the flow control item are cached locally or not, and screening out the sub-items which do not cache the tokens locally. And requesting to acquire the token from the central controller according to the screened items. The server device where the local component is located caches the token returned by the central controller, and the local component does not request the central controller before consuming the token, so that the load of the central controller is further reduced. For example: the interaction between systems is usually in a certain protocol format as the communication standard between systems. The local component disassembles the protocol and inputs each request entry into the rule engine, which must efficiently resolve all "flow control scenarios" involved in the set of requests.
The rule engine outputs key values of all flow control scenarios. The local component traverses the key-value list of the requested item. And judging whether the local component buffers a token of a certain key value, and if so, consuming the local cache. And forming a new list of key values of all the local unbuffered tokens which are traversed and judged, and sending the new list to the central controller. The central controller returns token values for all key values required. The local component caches and consumes the returned token list. In this process, the absence of tokens indicates that flow control is triggered.
Further, the method also comprises the following steps: when a request to the central controller for a token fails, the downgrade operation can continue, meaning that the local component generates a little token and gives it to the application server, which is mostly requested back, but still gets a portion of the locally generated token to operate normally, such as: the local component generates a token; and screening application servers from the application servers sending the requests, and feeding back tokens to the screened application servers, wherein the number of the tokens generated by the local component is less than that of the tokens requested by all the application servers. Thereby ensuring that the application system can still operate in a proper degradation mechanism even under the condition that the central controller cannot be communicated with the central controller and the like, and the application system is not influenced.
The embodiment provides a global flow control method, which may be implemented on a central controller shown in fig. 1, as shown in fig. 3, and the method includes:
and S21, receiving the token request sent by the local component.
And recording a flow control item in the token request, wherein the flow control item comprises at least one sub-item. Specifically, one sub-item corresponds to one scene main key. And after distributing the token to the local component, overwriting the scene primary key corresponding to each sub-item.
The token issuing method in this embodiment may be understood as a token algorithm measured in full time. And marking a certain flow control scene (such as scenes needing data interaction between an application server and a background side, such as order placing, pre-purchase, online financial redemption and the like) through the scene primary key, and establishing the time when the scene primary key is used as the actual content of the scene primary key. When one application server sends a token request for a certain flow control scene, the local component may overwrite the content of the scene primary key, for example, refresh the time value recorded in the scene primary key, and use the content of the overwritten scene primary key as a sufficient condition for processing the next application server request, thereby avoiding the problem of request confusion received by the local component when multiple application servers send requests at the same time. With each overwrite, the time point on the second time axis can be approximated to the real current time with a smaller value until equal to or later than the current time. Such as: the current time is 1:10:10:10 (in units of time: minutes: seconds: millisecond, that is, the precision is at least millisecond), the scene primary key of each sub-item in the flow control item is generated at 1:10:10:00, and each time the local component receives a request sent by one application server, the time value recorded in the primary key is overwritten, each overwriting may be increased by 2 milliseconds, for example, the application servers 1, 2, and 3 respectively send out a request within the 10 milliseconds, for example:
when the current time reaches 1:10:10:01, the application servers 1, 2 and 3 respectively send out a request, and the content overwriting sequence of the scene primary key is as follows: 1:10:10:02 → 1:10:10:04 → 1:10:10: 06;
the application server 2 sends a request again when the current time reaches 1:10:10:07, and the content of the scene primary key is overwritten to be 1:10:10: 08;
the application server 3 sends a request again when the current time reaches 1:10:10:08, and the content of the scene primary key is overwritten to be 1:10:10: 10;
the application server 1 sends a request again when the current time goes to 1:10:10:10, the content of the scene primary key is overwritten to 1:10:10:12, and since 1:10:10:12 exceeds the current time 1:10:10:00, the overwriting is not carried out at this time, a return message is sent to the application server 1, or the next cycle is waited for counting again. That is, every time the timing overwriting of the application server is mutually exclusive, only accumulation can be carried out, if there are simultaneously received requests, all the requests are accumulated
S22, allocating a time slice for each received token request and moving the time points forward on the second time axis until the value of the time points on the second time axis reaches the current time value of the first time axis.
The amount of forward movement of the time point is equal to the amount of the allocated time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one subentry. And the time point of the second time axis is continuously stepped forward according to the distributed time slices, and the first time axis is the natural time of the global system. And the time point on the second time axis continuously advances until the natural time point on the first time axis is tracked, namely the current time is tracked.
And S23, summing the time slices allocated to each subentry to obtain the total time, acquiring the number of tokens of each subentry in the flow control item according to the total time and the flow control value per second, and allocating the tokens to the local component according to the number.
In this embodiment. The flow control value per second is: the number of tokens allocated per unit time by the central controller.
Specifically, the obtaining the number of tokens of each sub-item in the flow control item according to the total time and the flow control value per second includes:
receiving all token requests issued by the local component to the central controller before the time threshold is exceeded.
A time period requested for each of the items is obtained based on the received token request.
The requested time periods for each of the fractions are summed to obtain a summed time for each of the fractions.
And multiplying the total time of each subentry with the flow control value per second to obtain the number of tokens of each subentry in the flow control item. I.e. the total token count is the total time per second flow control value.
For example: in the process of catching up the current time of the first time axis at the time point of the second time axis,
the total 90 application servers request tokens through the local components, the local components report flow control items to the central controller in 3 times, the central controller allocates time slices of 10ms, 2ms and 3ms to each reporting, so that the total time is 15ms, the flow control value per second is 10000/s, namely 10/ms, and the number of tokens to be fed back by the central controller is 15ms x 10/ms, namely 150 tokens.
The local component continuously sends the flow control item to the central controller in each time interval. The two layers of the central controller and the local component are matched, so that the central controller can uniformly and streaming inject the token. When the token is distributed: it is ensured that the tokens distributed to the requesters are statistically accurate and average.
The embodiment provides a flow control system combining local control and central control, which comprises the following steps: and loading a corresponding rule engine on the local component so as to judge the scene needing flow control, wherein the rule engine can adopt the existing technology and algorithm. The central controller calculates the number of tokens to be allocated at the flow control value per second and the summed time, thereby achieving a token generation quantity that is completely measured in time. And, since direct communication of the application server and the central controller is isolated by the local component, the communication pressure of the central controller is reduced.
The embodiment is particularly suitable for a large-scale and distributed real-time processing system, and can realize a flow control mechanism which is quickly configured, changed and validated for the large-scale and distributed real-time processing system by changing the time threshold value and the flow control value per second, and can adapt to almost all flow control scenes in practical application. For example: it can be configured according to the scene, like a typical mutual-fund system, and can control the account payment processing flow of user A to be 5 times per second at 10 to 12 points per week. And through the flow control value per second which can be adjusted in real time, a token generation and acquisition mechanism is improved, the in-out tokens can be smoothly and continuously, and the problem that the counting before and after the token bucket switching point is inaccurate is solved.
An embodiment of the present invention further provides a local component for global flow control, including:
the system comprises a preprocessing module, a flow control item and a flow control module, wherein the preprocessing module is used for determining the flow control item corresponding to a request message after receiving the request message sent by an application server, and the flow control item comprises at least one sub-item;
the interaction module is used for requesting a central controller to acquire a token according to the flow control item;
the processing module is used for acquiring tokens distributed by the central controller and feeding back the tokens to the application server sending the request, wherein the central controller acquires the quantity of the tokens distributed by one subentry according to the total time and the flow control value per second; the central controller allocates a time slice for each received token request and moves the time point forward on a second time axis until the value of the time point on the second time axis reaches the current time value of a first time axis, the amount of forward movement of the time point is equal to the amount of allocated time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one subentry; the flow control value per second is: the number of tokens allocated per unit time by the central controller.
An embodiment of the present invention further provides a central controller for global flow control, including:
the system comprises a receiving module, a processing module and a sending module, wherein the receiving module is used for receiving a token request sent by a local component, a flow control item is recorded in the token request, and the flow control item comprises at least one subentry;
the management module is used for allocating time slices for each received token request and moving the time point forwards on a second time axis until the value of the time point on the second time axis reaches the current time value of a first time axis, wherein the quantity of the forward movement of the time point is equal to the quantity of the allocated time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one subentry;
and the flow control module is used for summing the time slices allocated to each subentry to obtain the summed time, acquiring the number of tokens of each subentry in the flow control subentry according to the summed time and the flow control value per second, and allocating the tokens to the local assembly according to the number.
Specifically, the flow control module is specifically configured to:
receiving all token requests issued by the local component to the central controller before the time threshold is exceeded; acquiring a time period requested for each item according to the received token request, wherein the time threshold is the last moment of a time interval, and the time interval is divided into at least 2 time periods; summing the requested time periods for each of the subentries to obtain a summed time for each of the subentries; and multiplying the total time of each subentry with the flow control value per second to obtain the number of tokens of each subentry in the flow control item.
The embodiment provides a flow control system combining local control and central control, which comprises the following steps: and loading a corresponding rule engine on the local component so as to judge the scene needing flow control, wherein the rule engine can adopt the existing technology and algorithm. The central controller calculates the number of tokens to be allocated at the flow control value per second and the summed time, thereby achieving a token generation quantity that is completely measured in time. And, since direct communication of the application server and the central controller is isolated by the local component, the communication pressure of the central controller is reduced. For example: the local component decision flow is shown in fig. 4.
The embodiment is particularly suitable for a large-scale and distributed real-time processing system, and can realize a flow control mechanism which is quickly configured, changed and validated for the large-scale and distributed real-time processing system by changing the time threshold value and the flow control value per second, and can adapt to almost all flow control scenes in practical application. For example: it can be configured according to the scene, like a typical mutual-fund system, and can control the account payment processing flow of user A to be 5 times per second at 10 to 12 points per week. And through the flow control value per second which can be adjusted in real time, a token generation and acquisition mechanism is improved, the in-out tokens can be smoothly and continuously, and the problem that the counting before and after the token bucket switching point is inaccurate is solved.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A global flow control method, comprising:
after receiving a request message sent by an application server, determining a flow control item corresponding to the request message, wherein the flow control item comprises at least one subentry;
requesting a central controller to acquire a token according to the flow control item;
obtaining tokens distributed by the central controller and feeding back the tokens to a requesting application server, wherein the quantity of the tokens distributed for one subentry is obtained by the central controller according to the total time and the flow control value per second; the central controller allocates a time slice for each received token request and moves the time point forward on a second time axis until the value of the time point on the second time axis reaches the current time value of a first time axis, the amount of forward movement of the time point is equal to the amount of allocated time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one subentry; the flow control value per second is: the number of tokens allocated per unit time by the central controller.
2. The method of claim 1, wherein requesting a central controller to obtain a token according to the flow control item comprises:
judging whether tokens corresponding to all the sub-items in the flow control item are cached locally or not, and screening out the sub-items which do not cache the tokens locally;
and requesting to acquire the token from the central controller according to the screened items.
3. The method of claim 1, further comprising:
when the request for obtaining the token from the central controller fails, the local component generates the token;
and screening application servers from the application servers sending the requests, and feeding back tokens to the screened application servers, wherein the number of the tokens generated by the local component is less than that of the tokens requested by all the application servers.
4. A global flow control method, comprising:
receiving a token request sent by a local component, wherein a flow control item is recorded in the token request, and the flow control item comprises at least one subentry;
allocating a time slice for each received token request, and moving a time point forwards on a second time axis until the value of the time point on the second time axis reaches the current time value of a first time axis, wherein the forward moving amount of the time point is equal to the allocated time slice amount, the first time axis corresponds to natural time, and each allocated time slice corresponds to one subentry;
the time slices allocated to each subentry are summed to obtain the summed time, the number of tokens of each subentry in the flow control item is obtained according to the summed time and the flow control value per second, and the tokens are allocated to the local component according to the number.
5. The method of claim 4, wherein one sub item corresponds to one scene primary key;
and after distributing the token to the local component, overwriting the scene primary key corresponding to each sub-item.
6. The method of claim 4, wherein; the flow control value per second is: the number of tokens allocated per unit time by the central controller.
7. The method of claim 6, wherein obtaining the number of tokens for each of the flow control entries based on the summed time and flow control per second values comprises:
receiving all token requests issued by the local component to the central controller before a time threshold is exceeded;
acquiring a time period requested for each item according to the received token request, wherein the time threshold is the last moment of a time interval, and the time interval is divided into at least 2 time periods;
summing the requested time periods for each of the subentries to obtain a summed time for each of the subentries;
and multiplying the total time of each subentry with the flow control value per second to obtain the number of tokens of each subentry in the flow control item.
8. A local component for global flow control, comprising:
the system comprises a preprocessing module, a flow control item and a flow control module, wherein the preprocessing module is used for determining the flow control item corresponding to a request message after receiving the request message sent by an application server, and the flow control item comprises at least one sub-item;
the interaction module is used for requesting the central controller to acquire the token according to the flow control item;
the processing module is used for acquiring the tokens distributed by the central controller and feeding the tokens back to the application server sending the request, wherein the quantity of the tokens distributed for one subentry is acquired by the central controller according to the total time and the flow control value per second; the central controller allocates a time slice for each received token request and moves the time point forward on a second time axis until the value of the time point on the second time axis reaches the current time value of a first time axis, the amount of forward movement of the time point is equal to the amount of allocated time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one subentry; the flow control value per second is: the number of tokens allocated per unit time by the central controller.
9. A central controller for global flow control, comprising:
the flow control system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving a token request sent by a local component, wherein a flow control item is recorded in the token request, and the flow control item comprises at least one subentry;
the management module is used for allocating time slices for each received token request and moving a time point forwards on a second time axis until a value of the time point on the second time axis reaches a current time value of a first time axis, wherein the forward moving amount of the time point is equal to the allocated amount of the time slices, the first time axis corresponds to natural time, and each allocated time slice corresponds to one subentry;
and the flow control module is used for summing the time slices allocated to each subentry to obtain the summed time, acquiring the number of tokens of each subentry in the flow control subentry according to the summed time and the flow control value per second, and allocating the tokens to the local assembly according to the number.
10. Central controller according to claim 9, characterized in that the flow control module is in particular intended for
Receiving all token requests issued by the local component to the central controller before a time threshold is exceeded; acquiring a time period requested for each item according to the received token request, wherein the time threshold is the last moment of a time interval, and the time interval is divided into at least 2 time periods; summing the requested time periods for each of the subentries to obtain a summed time for each of the subentries; and multiplying the total time of each subentry with the flow control value per second to obtain the number of tokens of each subentry in the flow control item.
CN201810735932.9A 2018-07-06 2018-07-06 Global flow control method and device Active CN109150746B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810735932.9A CN109150746B (en) 2018-07-06 2018-07-06 Global flow control method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810735932.9A CN109150746B (en) 2018-07-06 2018-07-06 Global flow control method and device

Publications (2)

Publication Number Publication Date
CN109150746A CN109150746A (en) 2019-01-04
CN109150746B true CN109150746B (en) 2022-08-30

Family

ID=64799806

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810735932.9A Active CN109150746B (en) 2018-07-06 2018-07-06 Global flow control method and device

Country Status (1)

Country Link
CN (1) CN109150746B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112350953B (en) * 2019-08-07 2022-07-01 亿度慧达教育科技(北京)有限公司 Flow limiting method and device, electronic equipment and computer readable storage medium
CN110554918B (en) * 2019-08-09 2022-09-09 北京字节跳动网络技术有限公司 Current limiting method, current limiting device, electronic equipment and computer readable storage medium
CN110708258B (en) * 2019-09-29 2023-04-07 Oppo广东移动通信有限公司 Flow control method, device, server and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013143285A1 (en) * 2012-03-28 2013-10-03 华为技术有限公司 Flow control method and device as well as clustering system
WO2016188377A1 (en) * 2015-05-22 2016-12-01 中兴通讯股份有限公司 Method for implementing traffic control, server and terminal
CN106843170A (en) * 2016-11-30 2017-06-13 浙江中控软件技术有限公司 Method for scheduling task based on token

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013143285A1 (en) * 2012-03-28 2013-10-03 华为技术有限公司 Flow control method and device as well as clustering system
WO2016188377A1 (en) * 2015-05-22 2016-12-01 中兴通讯股份有限公司 Method for implementing traffic control, server and terminal
CN106843170A (en) * 2016-11-30 2017-06-13 浙江中控软件技术有限公司 Method for scheduling task based on token

Also Published As

Publication number Publication date
CN109150746A (en) 2019-01-04

Similar Documents

Publication Publication Date Title
CN108494703B (en) Access frequency control method, device and storage medium
CN109150746B (en) Global flow control method and device
EP3857381B1 (en) Collecting samples hierarchically in a datacenter
US8386512B2 (en) System for managing data collection processes
US9858124B1 (en) Dynamic management of data stream processing
US20060277295A1 (en) Monitoring system and monitoring method
EP2590113B1 (en) On demand multi-objective network optimization
US20180032387A1 (en) Predictive Analytics on Database Wait Events
US10944581B2 (en) Increasing processing capacity of processor cores during initial program load processing
CN108512768B (en) Access amount control method and device
CN108471385B (en) Flow control method and device for distributed system
CN110048907B (en) Global flow control method and device in cluster environment
CN109981702A (en) File storage method and system
CN111343102A (en) Flow rate control method, server-side server, client-side server and system
US11487588B2 (en) Auto-sizing for stream processing applications
US20200220910A1 (en) Idempotent processing of data streams
US8725868B2 (en) Interactive service management
US8407336B2 (en) Supporting apparatus for analyzing computer operation status
US9584379B2 (en) Sorted event monitoring by context partition
CN110807058B (en) Method and system for exporting data
US10067778B2 (en) Management system, recording medium and method for managing virtual machines
CN109783499A (en) A kind of data cache method, device and server
CN117478600B (en) Flow control method and system for serving high concurrency multi-center business center
US12061607B2 (en) Method and system for high-throughput distributed computing of computational jobs
US11687269B2 (en) Determining data copy resources

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210726

Address after: Room 834, Yingying building, 99 Tuanjie Road, yanchuangyuan, Jiangbei new district, Nanjing, Jiangsu 210000

Applicant after: Nanjing Xingyun Digital Technology Co.,Ltd.

Address before: 210042 No.1, Suning Avenue, Xuanwu District, Nanjing City, Jiangsu Province

Applicant before: SUNING.COM Co.,Ltd.

GR01 Patent grant
GR01 Patent grant