CN113242184A - Flow control method of distributed architecture and related equipment - Google Patents

Flow control method of distributed architecture and related equipment Download PDF

Info

Publication number
CN113242184A
CN113242184A CN202110647160.5A CN202110647160A CN113242184A CN 113242184 A CN113242184 A CN 113242184A CN 202110647160 A CN202110647160 A CN 202110647160A CN 113242184 A CN113242184 A CN 113242184A
Authority
CN
China
Prior art keywords
access
traffic threshold
server
time period
equipment
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.)
Pending
Application number
CN202110647160.5A
Other languages
Chinese (zh)
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.)
Jingdong Technology Holding Co Ltd
Original Assignee
Jingdong Technology Holding 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 Jingdong Technology Holding Co Ltd filed Critical Jingdong Technology Holding Co Ltd
Priority to CN202110647160.5A priority Critical patent/CN113242184A/en
Publication of CN113242184A publication Critical patent/CN113242184A/en
Pending legal-status Critical Current

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
    • 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/29Flow control; Congestion control using a combination of thresholds
    • 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)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the disclosure provides a flow control method and device of a distributed architecture, a computer readable storage medium and electronic equipment, and belongs to the technical field of computers and communication. The method comprises the following steps: when a first device accesses, obtaining a traffic threshold of the first device, wherein the traffic threshold of the first device is the maximum number of times that the first device is allowed to access in a first time period; generating a first starting key according to the number of the first device and the current time; acquiring the access times of the first equipment by using a cached increment register according to the first starting key; and in the first time period, if the access times of the first equipment are greater than the flow threshold of the first equipment, rejecting the access request of the first equipment. The method disclosed by the invention can realize flow control under a distributed architecture.

Description

Flow control method of distributed architecture and related equipment
Technical Field
The present disclosure relates to the field of computer and communication technologies, and in particular, to a flow control method and apparatus for a distributed architecture, a computer-readable storage medium, and an electronic device.
Background
The existing mainstream flow limiting algorithms are various, and typically include a counter mode, a token bucket mode, and the like, but all of the schemes involve a process on a "control quantity", including counting operations such as initialization, increase and decrease, and the like, which increase the scheme maintenance cost, and also introduce a part of externally dependent algorithms, such as adjustment of tokens involving reloading, and the like. Although some gateways provide richer current limiting schemes, for many small systems or application services without some gateway introduction conditions, a light-weight, simple and low-maintenance scheme is very needed to meet a certain scenario of concurrent traffic limitation.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The embodiment of the disclosure provides a flow control method and device for a distributed architecture, a computer-readable storage medium and an electronic device, which can implement flow control under the distributed architecture.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
According to an aspect of the present disclosure, there is provided a traffic control method for a distributed architecture, including:
when a first device accesses, obtaining a traffic threshold of the first device, wherein the traffic threshold of the first device is the maximum number of times that the first device is allowed to access in a first time period;
generating a first starting key according to the number of the first device and the current time;
acquiring the access times of the first equipment by using a cached increment register according to the first starting key;
and in the first time period, if the access times of the first equipment are greater than the flow threshold of the first equipment, rejecting the access request of the first equipment.
In one embodiment, obtaining the traffic threshold of the first device when the first device accesses comprises:
when the first device accesses, a database is queried to obtain a traffic threshold of the first device.
In one embodiment, the method further comprises:
and informing the first equipment that the access times reach the maximum value, and asking the first equipment to access after a second time period.
In one embodiment, the method further comprises:
after the first starting key is generated until the first time period passes, setting a storage time limit for the first starting key of the first device and the access times of the first device in the first time period, which are stored in the cache, so that the first starting key and the access times of the first device in the first time period are automatically deleted by the cache when the storage time limit is reached.
In one embodiment, the first device accesses a server cluster, and the cache is a cache of the server cluster, the method further comprising:
when the first device accesses a first server in the server cluster, the first server in the server cluster stores the traffic threshold of the first device into a local cache of the first server after querying the database to obtain the traffic threshold of the first device, wherein the first server is any one server in the server cluster.
In one embodiment, the method further comprises:
and setting an update time for a local cache of the first server, and if the first server needs to use the traffic threshold of the first device after the update time is reached, re-querying the database to obtain the traffic threshold of the first device.
In one embodiment, the method further comprises:
when a second device accesses, obtaining a traffic threshold of the second device, wherein the traffic threshold of the second device is the maximum number of times that the second device is allowed to access in a first time period;
generating a second starting key according to the number of the second device and the current time;
acquiring the access times of the second equipment by using the cached increment register according to the second starting key;
rejecting an access request of the second device when the first time period is not full and the number of accesses of the second device is greater than a traffic threshold of the second device;
the traffic threshold of the first device is different from or the same as the traffic threshold of the second device, and the first device and the second device access at the same time or at different times.
According to an aspect of the present disclosure, there is provided a flow control apparatus of a distributed architecture, including:
the device comprises a first obtaining module, a second obtaining module and a third obtaining module, wherein the first obtaining module is configured to obtain a traffic threshold of a first device when the first device accesses, and the traffic threshold of the first device is the maximum number of times that the first device is allowed to access in a first time period;
a generating module configured to generate a first start key according to the number of the first device and a current time;
the second acquisition module is configured to acquire the access times of the first device by using a cached increment register according to the first starting key;
and the execution module is configured to reject the access request of the first device if the access times of the first device are greater than the traffic threshold of the first device in the first time period.
According to an aspect of the present disclosure, there is provided an electronic device including:
one or more processors;
a storage device configured to store one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the method of any of the above embodiments.
According to an aspect of the present disclosure, there is provided a computer readable storage medium storing a computer program which, when executed by a processor, implements the method of any one of the above embodiments
The flow control method of the distributed architecture is simple to implement and low in code coupling degree; the logic is simple, and the stability is strong; the counter reset or update logic is not required to be added, and the maintenance cost is low; the adaptive distributed architecture supports differentiated current limiting control.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The following figures depict certain illustrative embodiments of the invention in which like reference numerals refer to like elements. These described embodiments are to be considered as exemplary embodiments of the disclosure and not limiting in any way.
Fig. 1 shows a schematic diagram of an exemplary system architecture to which the flow control method of the distributed architecture of the disclosed embodiments may be applied;
FIG. 2 illustrates a schematic structural diagram of a computer system suitable for use with the electronic device implementing embodiments of the present disclosure;
FIG. 3 schematically illustrates a flow diagram of a flow control method of a distributed architecture according to an embodiment of the present disclosure;
FIG. 4 is a structural diagram illustrating a concurrent (multiple concurrent) traffic control scheme in a distributed architecture according to an embodiment of the present disclosure;
FIG. 5 schematically illustrates a block diagram of a flow control device of a distributed architecture, according to an embodiment of the present disclosure;
FIG. 6 schematically illustrates a block diagram of a flow control device of a distributed architecture according to another embodiment of the present invention;
fig. 7 schematically illustrates a block diagram of a flow control device of a distributed architecture according to another embodiment of the present invention.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
Fig. 1 shows a schematic diagram of an exemplary system architecture 100 to which the flow control method of the distributed architecture of the disclosed embodiments may be applied.
As shown in fig. 1, the system architecture 100 may include one or more of terminals 101, 102, 103, a network 104, and a server 105. The network 104 is a medium to provide communication links between the terminals 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
It should be understood that the number of terminals, networks, and servers in fig. 1 are merely illustrative. There may be any number of terminals, networks, and servers, as desired for an implementation. For example, server 105 may be a server cluster comprised of multiple servers, or the like.
A staff member or user may use the terminals 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminals 101, 102, 103 may be various electronic devices having display screens including, but not limited to, smart phones, tablets, portable and desktop computers, digital cinema projectors, and the like.
The server 105 may be a server that provides various services. For example, when a worker or a user accesses the server 105 through the terminal 103 (which may also be the terminal 101 or 102), the server 105 obtains a traffic threshold of a first device (for example, the terminal 103) when the first device accesses, where the traffic threshold of the first device is a maximum number of times that the first device is allowed to access in a first time period; generating a first starting key according to the number of the first device and the current time; acquiring the access times of the first equipment by using a cached increment register according to the first starting key; and in the first time period, if the access times of the first equipment are greater than the flow threshold of the first equipment, rejecting the access request of the first equipment. The server 105 may display the result of the rejection of the first device on the terminal 103 or other terminal, and a worker or other person (e.g., a user) may view the result of the rejection of the first device by the server based on the content displayed on the terminal.
Also, for example, the terminal 103 (also may be the terminal 101 or 102) may be a smart tv, a VR (Virtual Reality)/AR (Augmented Reality) helmet display, or a mobile terminal such as a smart phone, a tablet computer, etc. on which a navigation, a network appointment, an instant messaging, a video Application (APP), etc. are installed, and a worker or a user may access the server 105 through the smart tv, the VR/AR helmet display, or the navigation, the network appointment, the instant messaging, the video APP, etc. and the server 105 may perform corresponding processing according to the access of the terminal 103. The server 105 may return the result of denying the access of the terminal 103 to the or another smart tv, VR/AR head mounted display, or the navigation, network appointment, instant messaging, and video APP, and then display the result of denying the access of the terminal 103 through the smart tv, VR/AR head mounted display, or the navigation, network appointment, instant messaging, and video APP.
FIG. 2 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present disclosure.
It should be noted that the computer system 200 of the electronic device shown in fig. 2 is only an example, and should not bring any limitation to the functions and the scope of the application of the embodiments of the present disclosure.
As shown in fig. 2, the computer system 200 includes a Central Processing Unit (CPU)201 that can perform various appropriate actions and processes in accordance with a program stored in a Read-Only Memory (ROM) 202 or a program loaded from a storage section 208 into a Random Access Memory (RAM) 203. In the RAM 203, various programs and data necessary for system operation are also stored. The CPU 201, ROM 202, and RAM 203 are connected to each other via a bus 204. An input/output (I/O) interface 205 is also connected to bus 204.
The following components are connected to the I/O interface 205: an input portion 206 including a keyboard, a mouse, and the like; an output section 207 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 208 including a hard disk and the like; and a communication section 209 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 209 performs communication processing via a network such as the internet. A drive 210 is also connected to the I/O interface 205 as needed. A removable medium 211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is mounted on the drive 210 as necessary, so that a computer program read out therefrom is installed into the storage section 208 as necessary.
In particular, the processes described below with reference to the flowcharts may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication section 209 and/or installed from the removable medium 211. The computer program, when executed by a Central Processing Unit (CPU)201, performs various functions defined in the methods and/or apparatus of the present application.
It should be noted that the computer readable storage medium shown in the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM) or flash Memory), an optical fiber, a portable compact disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer-readable signal medium may include a propagated data signal with computer-readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable storage medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF (Radio Frequency), etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of methods, apparatus, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules and/or units and/or sub-units described in the embodiments of the present disclosure may be implemented by software, or may be implemented by hardware, and the described modules and/or units and/or sub-units may also be disposed in a processor. Wherein the names of such modules and/or units and/or sub-units in some cases do not constitute a limitation on the modules and/or units and/or sub-units themselves.
As another aspect, the present application also provides a computer-readable storage medium, which may be contained in the electronic device described in the above embodiment; or may exist separately without being assembled into the electronic device. The computer-readable storage medium carries one or more programs which, when executed by an electronic device, cause the electronic device to implement the method described in the embodiments below. For example, the electronic device may implement the steps as shown in fig. 3.
In the related art, for example, a machine learning method, a deep learning method, or the like may be used to perform flow control in a distributed architecture, and the application range of different methods is different.
Fig. 3 schematically shows a flow chart of a flow control method of a distributed architecture according to an embodiment of the present disclosure. The method steps of the embodiments of the present disclosure may be performed by a server or a server cluster, for example, by the server 105 in fig. 1, but the present disclosure is not limited thereto.
In step S310, when a first device accesses, a traffic threshold of the first device is obtained, where the traffic threshold of the first device is a maximum number of times that the first device is allowed to access in a first time period.
In this step, the server obtains a traffic threshold of the first device when the first device accesses, where the traffic threshold of the first device is a maximum number of times that the first device is allowed to access in a first time period. In one embodiment, the first period of time is, for example, 1 second, 1 minute, or 1 hour, although the disclosure is not so limited; the first time period may be a monitoring period of the server, i.e. the number of times the first device is allowed to access is defined within the first time period. For example, if a first device (e.g., terminal 103) is allowed to access the server no more than 100 times in 1 second, then the traffic threshold for the first device is 100 times per second. In one embodiment, obtaining the traffic threshold of the first device when the first device accesses comprises: when the first device accesses, a database is queried to obtain a traffic threshold of the first device.
In the embodiments of the present disclosure, a terminal may be implemented in various forms. For example, the terminal described in the present disclosure may include mobile terminals such as a mobile phone, a tablet computer, a notebook computer, a palmtop computer, a Personal Digital Assistant (PDA), a Portable Media Player (PMP), a wearable device, a smart band, a pedometer, a robot, an unmanned vehicle, and the like, and fixed terminals such as a digital TV (television), a desktop computer, and the like.
In step S320, a first start key is generated according to the number of the first device and the current time.
In this step, the server generates a first start key based on the number of the first device and the current time.
In one embodiment, the first start key may be understood as a starting point and a marking point for monitoring the access of the first device.
In step S330, the number of accesses to the first device is obtained by using the cached increment register according to the first start key.
In this step, the server obtains the number of accesses of the first device using the cached increment register according to the first start key.
In one embodiment, the method further comprises setting a storage time limit for the first start key of the first device stored in the cache and the number of accesses of the first device within the first time period after the first time period has elapsed since the first start key was generated, so that the first start key is automatically deleted by the cache when the storage time limit is reached. For example, after the first time period elapses since the first start key is generated, a storage time limit (for example, 5 seconds) is set for the first start key in the cache and the number of accesses of the first device within the first time period (for example, 1 second) counted in the first time period, and after the counting of the number of accesses is completed, a deletion operation is performed on the first start key of the first device and the number of accesses of the first device within the first time period after the storage time limit elapses (for example, 5 seconds).
In one embodiment, the first device accesses a server cluster, and the cache is a cache of the server cluster, the method further comprising:
when the first device accesses a first server in the server cluster, the first server in the server cluster stores the traffic threshold of the first device in a local cache of the first server after querying the database to obtain the traffic threshold of the first device, wherein the first server may be any one server in the server cluster.
In one embodiment, the method further comprises: and setting an update time for the local cache of the first server, and if the first server needs to continue to use the traffic threshold of the first device after the update time is reached, re-querying the database to obtain the traffic threshold of the first device. When the first period of time is 1 second, the update time may be 1 minute or 2 minutes, for example.
In step S340, in the first time period, if the number of access times of the first device is greater than the traffic threshold of the first device, the access request of the first device is rejected.
In this step, the server rejects the access request of the first device if the access frequency of the first device is greater than the traffic threshold of the first device within the first time period. For example, 0.5 seconds (the first time period is 1 second) from the time when the first start key is generated, the number of times of access of the first device has reached 100 times (the threshold value is 100 times per second), and the server rejects the access request of the first device.
In one embodiment, the method further comprises: and informing the first equipment that the access times reach the maximum value, and asking the first equipment to access after a second time period. For example, 0.5 seconds (the first time period is 1 second), the number of times of access of the first device reaches 100 times (the threshold value is 100 times per second), and the server notifies the first device that the number of times of access reaches the maximum value, please access after 0.5 seconds. In one embodiment, the second time period may be any value greater than or equal to the remaining time of one monitoring period.
In one embodiment, the method further comprises:
when a second device accesses, obtaining a traffic threshold of the second device, wherein the traffic threshold of the second device is the maximum number of times that the second device is allowed to access in a first time period;
generating a second starting key according to the number of the second device and the current time;
acquiring the access times of the second equipment by using the cached increment register according to the second starting key;
rejecting an access request of the second device when the first time period is not full and the number of accesses of the second device is greater than a traffic threshold of the second device;
the traffic threshold of the first device is different from or the same as the traffic threshold of the second device, and the first device and the second device access at the same time or at different times.
The flow control method of the distributed architecture is simple to implement and low in code coupling degree; the logic is simple, and the stability is strong; the counter reset or update logic is not required to be added, and the maintenance cost is low; the adaptive distributed architecture supports differentiated current limiting control.
Fig. 4 shows a structural diagram of a concurrent (simultaneous multiple) flow control scheme under a distributed architecture according to an embodiment of the present disclosure.
Referring to fig. 4, the design concept and processing scheme at the core of the present disclosure are as follows:
(1) the service cluster of a certain interface I (entrance/exit) is provided with N servers, namely a server 1, a server 2 … and a service N;
(2) external invocation of interface I has multiple mechanisms (first devices), such as mechanism a, mechanism B (or more);
(3) configuring a concurrent current limit threshold C (the current limit threshold of a mechanism may be differentiated) for an interface I by a mechanism (such as mechanism a or mechanism B) through a data store (database in fig. 4);
(4) when the organization concurrently calls the interface I, any server (which may be the server 1 or the server N) that accepts the request obtains the mechanism-by-mechanism control current limiting configuration in (3), operates the auto-increment 1(1 second, i.e., the first time period) according to the "mechanism number + second-level character string YYYYMMDDHHMMSS of the current server time" as a KEY (first start KEY) using an atomic auto-increment interface incr (increment register, in this scheme, a java version client of redis) provided by a redis (cache), compares the value (value, the number of times of access of the organization) after the auto-increment success returned by the incr operation with the threshold value configured in the data storage of the corresponding organization, interrupts the request if the threshold value is exceeded, and returns the call sending flow rate to the corresponding organization to exceed the standard.
(5) Since the local time of the server of the interface is changed along with the system clock, the corresponding key is changed according to the second of the clock, and the starting point of the time period for flow control is switched.
(6) In order to automatically clear the key-value of the expired control period from the redis, after the incr operation is performed in the step (4), when the return value is equal to 1 (that is, the first time period has elapsed), the expiration time of the corresponding key is set by using an expiration method of expiration setting in the redis, because the flow control time period given by the scheme is 1 second, the expiration time can be set to be longer than the time interval of the flow control period, for example, 5 seconds or 10 seconds, so that the self-owned clearing mechanism of the redis can clear useless flow control record data in time, and unnecessary space occupation is reduced.
(7) In the scheme of fig. 4, an optimization processing scheme can be supplemented to improve the response speed of the system. For example, for the query of the mechanism flow control configuration, the data storage service may be searched, or a local cache may be made in each server after the query, so as to reduce the time consumption of the query interaction process, but the update time of the local cache needs to be specified (when the flow control time period is 1 second, the update time may be, for example, 1 minute or 2 minutes), so as to update the threshold data of the control configuration in time.
(8) In the above scheme, the time period unit of the flow control may be seconds or minutes, and the like, and the corresponding character string for changing the local time of the server may be, for example, YYYYMMDDHHMMSS (second level), YYYYMMDDHHMM (minute level), and YYYYMMDDHH (hour level).
Fig. 5 schematically illustrates a block diagram of a flow control device of a distributed architecture according to an embodiment of the present disclosure. The flow control device 500 of the distributed architecture provided by the embodiments of the present disclosure may be disposed on a server side, for example, may be disposed in the server 105 in fig. 1, but the present disclosure is not limited thereto.
The flow control apparatus 500 of the distributed architecture provided by the embodiments of the present disclosure may include a first obtaining module 510, a generating module 520, a second obtaining module 530, and an executing module 540.
The first obtaining module is configured to obtain a traffic threshold of a first device when the first device accesses, wherein the traffic threshold of the first device is a maximum number of times that the first device is allowed to access within a first time period;
a generating module configured to generate a first start key according to the number of the first device and a current time;
the second acquisition module is configured to acquire the access times of the first device by using a cached increment register according to the first starting key;
and the execution module is configured to reject the access request of the first device if the access times of the first device are greater than the traffic threshold of the first device in the first time period.
According to the embodiment of the present disclosure, the code coupling degree of the flow control device 500 of the distributed architecture is low; the logic is simple, and the stability is strong; the counter reset or update logic is not required to be added, and the maintenance cost is low; the adaptive distributed architecture supports differentiated current limiting control.
According to the embodiment of the present disclosure, the flow control apparatus 500 of the distributed architecture may be used to implement the flow control method of the distributed architecture described in the embodiment of fig. 3.
Fig. 6 schematically shows a block diagram of a flow control device 600 of a distributed architecture according to another embodiment of the present invention.
As shown in fig. 6, the flow control apparatus 600 of the distributed architecture further includes a display module 610 in addition to the first obtaining module 510, the generating module 520, the second obtaining module 530 and the executing module 540 described in the embodiment of fig. 5.
Specifically, the display module 610 displays the number of times of access of the first device to a client or a worker after the second obtaining module 530 obtains the number of times of access of the first device.
In the flow control apparatus 600 with the distributed architecture, the number of accesses of the first device may be displayed by the display module 910.
Fig. 7 schematically shows a block diagram of a flow control device 700 of a distributed architecture according to another embodiment of the present invention.
As shown in fig. 7, the flow control apparatus 700 of the distributed architecture further includes a storage module 710 in addition to the first obtaining module 510, the generating module 520, the second obtaining module 530 and the executing module 540 described in the embodiment of fig. 5.
Specifically, the storage module 710 is configured to store data in a flow control process of the distributed architecture, so as to facilitate subsequent invocation and reference.
It is understood that the first obtaining module 510, the generating module 520, the second obtaining module 530, the executing module 540, the displaying module 610 and the storing module 710 may be combined into one module to be implemented, or any one of them may be split into a plurality of modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of the other modules and implemented in one module. According to an embodiment of the present invention, at least one of the first obtaining module 510, the generating module 520, the second obtaining module 530, the executing module 540, the displaying module 610 and the storing module 710 may be at least partially implemented as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or in a suitable combination of three implementations of software, hardware and firmware. Alternatively, at least one of the first acquiring module 510, the generating module 520, the second acquiring module 530, the executing module 540, the displaying module 610 and the storing module 710 may be at least partially implemented as a computer program module, which may perform the functions of the respective modules when the program is executed by a computer.
For details that are not disclosed in the embodiment of the apparatus of the present invention, reference is made to the above-mentioned embodiment of the flow control method of the distributed architecture of the present invention for the details that are not disclosed in the embodiment of the apparatus of the present invention, because each module of the flow control apparatus of the distributed architecture of the present invention can be used to implement the steps of the above-mentioned example embodiment of the flow control method of the distributed architecture described in fig. 3.
The specific implementation of each module, unit and subunit in the flow control device with a distributed architecture provided in the embodiments of the present disclosure may refer to the content in the flow control method with a distributed architecture, and is not described herein again.
It should be noted that although several modules, units and sub-units of the apparatus for action execution are mentioned in the above detailed description, such division is not mandatory. Indeed, the features and functionality of two or more modules, units and sub-units described above may be embodied in one module, unit and sub-unit, in accordance with embodiments of the present disclosure. Conversely, the features and functions of one module, unit and sub-unit described above may be further divided into embodiments by a plurality of modules, units and sub-units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A flow control method of a distributed architecture is characterized by comprising the following steps:
when a first device accesses, obtaining a traffic threshold of the first device, wherein the traffic threshold of the first device is the maximum number of times that the first device is allowed to access in a first time period;
generating a first starting key according to the number of the first device and the current time;
acquiring the access times of the first equipment by using a cached increment register according to the first starting key;
and in the first time period, if the access times of the first equipment are greater than the flow threshold of the first equipment, rejecting the access request of the first equipment.
2. The method of claim 1, wherein obtaining the traffic threshold of the first device upon access by the first device comprises:
when the first device accesses, a database is queried to obtain a traffic threshold of the first device.
3. The method of claim 1, further comprising:
and informing the first equipment that the access times reach the maximum value, and asking the first equipment to access after a second time period.
4. The method of claim 1, further comprising:
after the first starting key is generated until the first time period passes, setting a storage time limit for the first starting key of the first device and the access times of the first device in the first time period, which are stored in the cache, so that the first starting key and the access times of the first device in the first time period are automatically deleted by the cache when the storage time limit is reached.
5. The method of claim 2, wherein the first device accesses a server cluster, wherein the cache is a cache of the server cluster, and wherein the method further comprises:
when the first device accesses a first server in the server cluster, the first server in the server cluster stores the traffic threshold of the first device into a local cache of the first server after querying the database to obtain the traffic threshold of the first device, wherein the first server is any one server in the server cluster.
6. The method of claim 5, further comprising:
and setting an update time for a local cache of the first server, and if the first server needs to use the traffic threshold of the first device after the update time is reached, re-querying the database to obtain the traffic threshold of the first device.
7. The method of claim 1, further comprising:
when a second device accesses, obtaining a traffic threshold of the second device, wherein the traffic threshold of the second device is the maximum number of times that the second device is allowed to access in a first time period;
generating a second starting key according to the number of the second device and the current time;
acquiring the access times of the second equipment by using the cached increment register according to the second starting key;
rejecting an access request of the second device when the first time period is not full and the number of accesses of the second device is greater than a traffic threshold of the second device;
the traffic threshold of the first device is different from or the same as the traffic threshold of the second device, and the first device and the second device access at the same time or at different times.
8. A distributed architecture flow control apparatus, comprising:
the device comprises a first obtaining module, a second obtaining module and a third obtaining module, wherein the first obtaining module is configured to obtain a traffic threshold of a first device when the first device accesses, and the traffic threshold of the first device is the maximum number of times that the first device is allowed to access in a first time period;
a generating module configured to generate a first start key according to the number of the first device and a current time;
the second acquisition module is configured to acquire the access times of the first device by using a cached increment register according to the first starting key;
and the execution module is configured to reject the access request of the first device if the access times of the first device are greater than the traffic threshold of the first device in the first time period.
9. An electronic device, comprising:
one or more processors;
a storage device configured to store one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-7.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN202110647160.5A 2021-06-10 2021-06-10 Flow control method of distributed architecture and related equipment Pending CN113242184A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110647160.5A CN113242184A (en) 2021-06-10 2021-06-10 Flow control method of distributed architecture and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110647160.5A CN113242184A (en) 2021-06-10 2021-06-10 Flow control method of distributed architecture and related equipment

Publications (1)

Publication Number Publication Date
CN113242184A true CN113242184A (en) 2021-08-10

Family

ID=77139474

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110647160.5A Pending CN113242184A (en) 2021-06-10 2021-06-10 Flow control method of distributed architecture and related equipment

Country Status (1)

Country Link
CN (1) CN113242184A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113641505A (en) * 2021-10-14 2021-11-12 阿里云计算有限公司 Resource allocation control method and device for server cluster
CN114531377A (en) * 2022-01-19 2022-05-24 重庆川仪自动化股份有限公司 Flow control method, system, equipment and medium for process industrial equipment data

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109194584A (en) * 2018-08-13 2019-01-11 中国平安人寿保险股份有限公司 A kind of flux monitoring method, device, computer equipment and storage medium
US20190097984A1 (en) * 2017-09-26 2019-03-28 Intel Corporation Techniques for flow control packet processing
CN110401720A (en) * 2019-07-31 2019-11-01 中国工商银行股份有限公司 Information processing method, device, system, application server and medium
CN110417671A (en) * 2019-07-31 2019-11-05 中国工商银行股份有限公司 The current-limiting method and server of data transmission
CN111262795A (en) * 2020-01-08 2020-06-09 京东数字科技控股有限公司 Service interface-based current limiting method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190097984A1 (en) * 2017-09-26 2019-03-28 Intel Corporation Techniques for flow control packet processing
CN109194584A (en) * 2018-08-13 2019-01-11 中国平安人寿保险股份有限公司 A kind of flux monitoring method, device, computer equipment and storage medium
CN110401720A (en) * 2019-07-31 2019-11-01 中国工商银行股份有限公司 Information processing method, device, system, application server and medium
CN110417671A (en) * 2019-07-31 2019-11-05 中国工商银行股份有限公司 The current-limiting method and server of data transmission
CN111262795A (en) * 2020-01-08 2020-06-09 京东数字科技控股有限公司 Service interface-based current limiting method and device, electronic equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113641505A (en) * 2021-10-14 2021-11-12 阿里云计算有限公司 Resource allocation control method and device for server cluster
CN113641505B (en) * 2021-10-14 2022-01-04 阿里云计算有限公司 Resource allocation control method and device for server cluster
CN114531377A (en) * 2022-01-19 2022-05-24 重庆川仪自动化股份有限公司 Flow control method, system, equipment and medium for process industrial equipment data
CN114531377B (en) * 2022-01-19 2024-04-02 重庆川仪自动化股份有限公司 Flow control method, system, equipment and medium for flow industrial equipment data

Similar Documents

Publication Publication Date Title
CN110362266B (en) Prompt information display method, system, electronic equipment and computer readable medium
CN110516159B (en) Information recommendation method and device, electronic equipment and storage medium
CN113242184A (en) Flow control method of distributed architecture and related equipment
CN111709732A (en) Display method and device and electronic equipment
CN113741756A (en) Information processing method, device, terminal and storage medium
CN112379982B (en) Task processing method, device, electronic equipment and computer readable storage medium
CN110781373A (en) List updating method and device, readable medium and electronic equipment
CN110704833A (en) Data permission configuration method, device, electronic device and storage medium
CN110795446A (en) List updating method and device, readable medium and electronic equipment
CN110866040A (en) User portrait generation method, device and system
CN111881329A (en) Account balance management method and system
CN113760991A (en) Data operation method and device, electronic equipment and computer readable medium
CN110856004B (en) Message processing method and device, readable storage medium and electronic equipment
CN110852720A (en) Document processing method, device, equipment and storage medium
CN112884181A (en) Quota information processing method and device
CN110768861B (en) Method, device, medium and electronic equipment for obtaining overtime threshold
CN110992011A (en) Data splitting method and device, electronic equipment and storage medium
CN111949678A (en) Method and device for processing non-accumulation indexes across time windows
CN115378878B (en) CDN scheduling method, device, equipment and storage medium
CN112182400B (en) Message processing method, message processing device, electronic equipment and storage medium
CN113850685A (en) Method, apparatus, server and medium for real-time tally
CN113537893A (en) Order processing method, device, equipment and computer readable medium
CN112767036A (en) Service processing method and device
CN112288520A (en) Article information card pushing method and device, electronic equipment and computer readable medium
CN110119364B (en) Method and system for input/output batch submission

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210810