CN114710450A - Flow control method, device, equipment and computer storage medium - Google Patents
Flow control method, device, equipment and computer storage medium Download PDFInfo
- Publication number
- CN114710450A CN114710450A CN202210334148.3A CN202210334148A CN114710450A CN 114710450 A CN114710450 A CN 114710450A CN 202210334148 A CN202210334148 A CN 202210334148A CN 114710450 A CN114710450 A CN 114710450A
- Authority
- CN
- China
- Prior art keywords
- flow control
- server
- request
- transaction requests
- database
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 57
- 238000004590 computer program Methods 0.000 claims description 18
- 238000010586 diagram Methods 0.000 description 11
- 238000007726 management method Methods 0.000 description 11
- 230000008569 process Effects 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000012545 processing Methods 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 238000007792 addition Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000005055 memory storage Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/24—Traffic characterised by specific attributes, e.g. priority or QoS
- H04L47/2416—Real-time traffic
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/29—Flow control; Congestion control using a combination of thresholds
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
- H04L67/1044—Group management mechanisms
- H04L67/1053—Group management mechanisms with pre-configuration of logical or physical connections with a determined number of other peers
- H04L67/1055—Group management mechanisms with pre-configuration of logical or physical connections with a determined number of other peers involving connection limits
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/146—Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Physics & Mathematics (AREA)
- Finance (AREA)
- Theoretical Computer Science (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the application provides a flow control method, a flow control device, flow control equipment and a computer storage medium, wherein the flow control method comprises the steps of receiving a target transaction request, wherein the target transaction request comprises an identifier of request equipment; acquiring the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment from a database, wherein the quantity and the total quantity of the transaction requests are pre-loaded to the database from a flow control configuration module; when the number of the transaction requests is smaller than the total number, recording and updating the current transaction request number of the request equipment to be the number of the transaction requests plus one, and acquiring a server initial value from a database; determining a server identifier for providing service for the target transaction request according to the initial value of the server, and sending the target transaction request to a server corresponding to the server identifier; and in the case that the number of the transaction requests is greater than or equal to the total number, sending the excess flow control information to the request equipment. According to the embodiment of the application, the accurate control of the flow control data can be realized.
Description
Technical Field
The present application belongs to the field of big data technologies, and in particular, to a method, an apparatus, a device, and a computer storage medium for flow control.
Background
"flow control" is short for flow control, and is used to control the number of requests for simultaneous access to a specific Application Program Interface (API).
In the prior art, flow control is mainly performed in a manner of loading flow control parameters into a memory for use when an application is started, or a service method pointed by a service request is determined after the service request is received, and a flow control decision is performed according to different service method requirements. However, although the time consumption can be reduced by loading the flow control parameters into the memory for use, the memory is realized by a single machine, and accurate control of the flow in the cluster cannot be realized, and the manner of performing flow control decision for different service method requirements can only perform flow control for service requests of the same type of service, and cannot perform flow control for different requesters, so that the above manners cannot realize accurate control of the flow in the cluster of different requesters.
Disclosure of Invention
Embodiments of the present application provide a flow control method, an apparatus, a device, and a computer storage medium, which can solve the problem in the prior art that accurate control of flows in clusters of different requesters cannot be achieved.
In a first aspect, an embodiment of the present application provides a flow control method, where the method includes:
receiving a target transaction request, the target transaction request including an identification of a requesting device;
acquiring the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment from a database, wherein the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment are pre-loaded to the database from a flow control configuration module;
under the condition that the number of the transaction requests is smaller than the total number, recording and updating the current number of the transaction requests of the request equipment to be the number of the transaction requests plus one, and acquiring a server initial value from the database;
determining the server identifier for providing service for the target transaction request according to the initial value of the server, and sending the target transaction request to a server corresponding to the server identifier;
and in the case that the number of the transaction requests is greater than or equal to the total number, sending excess flow control information to the request equipment.
In one embodiment, the database comprises a clustered database; the determining the server identifier serving the target transaction request according to the server initial value includes:
and determining the sum of the initial value of the server and a preset numerical value, and the remainder of division of the sum of the initial value of the server and the total number of the servers in the cluster database as the server identification.
In one embodiment, the method further comprises:
and storing the remainder as an updated server initial value to the cluster database.
In one embodiment, the database includes flow control configuration information; after the sending of the target transaction request to the server corresponding to the server identification, the method further comprises: inquiring the number of current transaction requests in the flow control configuration information of the request device;
subtracting one from the number of the current transaction requests of the request equipment to obtain the updated number of the current transaction requests;
and storing the updated number of the current transaction requests to the flow control configuration information.
In a second aspect, an embodiment of the present application provides a flow control device, including:
a receiving module for receiving a target transaction request, the target transaction request including an identification of a requesting device;
the acquisition module is used for acquiring the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment from a database, wherein the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment are pre-loaded to the database from the flow control configuration module;
the updating module is used for recording and updating the current transaction request quantity of the request equipment to be the quantity of the transaction requests plus one when the quantity of the transaction requests is smaller than the total quantity, and acquiring a server initial value from the database;
the sending module is used for determining the server identifier for providing service for the target transaction request according to the initial value of the server and sending the target transaction request to a server corresponding to the server identifier;
the sending module is further configured to send excess flow control information to the requesting device when the number of transaction requests is greater than or equal to the total number.
In one embodiment, the database comprises a clustered database; the flow control device further comprises a determination module;
the determining module is configured to determine a sum of the server initial value and a preset numerical value, and a remainder obtained by dividing the sum by the total number of servers in the database is the server identifier.
In one embodiment, the flow control device further comprises a memory module;
and the storage module is used for storing the remainder as an updated server initial value to the cluster database.
In one embodiment, the database includes flow control configuration information; the flow control device also comprises a query module;
the query module is configured to query the number of current transaction requests in the flow control configuration information of the request device after the target transaction request is sent to the server corresponding to the server identifier;
the updating module is further configured to reduce the number of the current transaction requests of the requesting device by one to obtain an updated number of the current transaction requests;
the storage module is further configured to store the updated number of the current transaction requests to the flow control configuration information.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory storing computer program instructions;
the processor, when executing the computer program instructions, implements a flow control method as described in any of the embodiments of the first aspect.
In a fourth aspect, the present application provides a computer storage medium having computer program instructions stored thereon, where the computer program instructions, when executed by a processor, implement the flow control method as described in any one of the embodiments of the first aspect.
In a fifth aspect, the present application provides a computer program product, and when executed by a processor of an electronic device, the instructions of the computer program product cause the electronic device to execute the flow control method as described in any one of the embodiments of the first aspect.
According to the traffic control method, the traffic control device, the traffic control equipment and the computer storage medium, the target transaction requests including the identification of the request equipment are received, the number of the transaction requests of the request equipment and the total number of the transaction requests allowed by the request equipment are obtained from the database, and the number of the transaction requests of the request equipment and the total number of the transaction requests allowed by the request equipment are pre-loaded into the database from the flow control configuration module, so that the efficiency of subsequently inquiring the number of the transaction requests is improved. And then, under the condition that the number of the transaction requests is smaller than the total number, recording and updating the current transaction request number of the request equipment to be the number of the transaction requests plus one, acquiring a server initial value from a database, determining a server identifier for providing service for the target transaction request according to the server initial value, and sending the target transaction request to a server corresponding to the server identifier. And sending the exceeding flow control information to the request equipment under the condition that the number of the transaction requests is greater than or equal to the total number. In the embodiment of the application, the flow control information of the request equipment is configured into the database through unified logic control, cluster sharing is achieved, cluster flow control can be performed on different request equipment, and when each transaction request arrives, the flow control data in the database is updated, so that accurate control of the flow control data is achieved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments of the present application will be briefly described below, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a flow control architecture provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of a flow control method according to an embodiment of the present application;
FIG. 3 is a schematic view of a flow control device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Features and exemplary embodiments of various aspects of the present application will be described in detail below, and in order to make objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are intended to be illustrative only and are not intended to be limiting. It will be apparent to one skilled in the art that the present application may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present application by illustrating examples thereof.
It should be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
According to the technical scheme, the data acquisition, storage, use, processing and the like meet relevant regulations of national laws and regulations.
As described in the background art, there is a problem in the prior art that accurate control of traffic in a cluster of different requesters cannot be achieved. In order to solve the above problem, embodiments of the present application provide a flow control method, an apparatus, a device, and a computer storage medium, where the flow control method may improve efficiency of subsequently querying a transaction request quantity by receiving a target transaction request including an identifier of a requesting device, obtaining, from a database, a quantity of transaction requests of the requesting device and a total quantity of transaction requests allowed by the requesting device, where the quantity of transaction requests of the requesting device and the total quantity of transaction requests allowed by the requesting device are preloaded from a flow control configuration module to the database. And then, under the condition that the number of the transaction requests is smaller than the total number, recording and updating the current transaction request number of the request equipment to be the number of the transaction requests plus one, acquiring a server initial value from a database, determining a server identifier for providing service for the target transaction request according to the server initial value, and sending the target transaction request to a server corresponding to the server identifier. And sending the exceeding flow control information to the request equipment under the condition that the number of the transaction requests is greater than or equal to the total number. In the embodiment of the application, the flow control information of the request equipment is configured into the database through unified logic control, cluster sharing is achieved, cluster flow control can be performed on different request equipment, and when each transaction request arrives, the flow control data in the database is updated, so that accurate control of the flow control data is achieved.
Based on this, the flow control method provided in the embodiment of the present application may be implemented based on a flow control architecture, and the flow control architecture provided in the embodiment of the present application is described in detail below with reference to fig. 1.
As shown in fig. 1, a flow control architecture proposed in the embodiment of the present application may include a server cluster 10, a client 11, and a flow control management system 12.
The client 11 sends a transaction request to the flow control management system 12. The flow control management system 12 receives the transaction requests sent by the client 11, and obtains flow control configuration information of the client 11 according to the identification information of the client 11 in the transaction requests, including the number of the transaction requests and the total number of the transaction requests allowed by the client 11, and then records and updates the current number of the transaction requests of the client 11 as the sum of the number of the transaction requests when it is determined that the number of the transaction requests is smaller than the total number. The flow control management system 12 further obtains the server initial value, determines a server identifier for providing a service for the target transaction request according to the server initial value, and sends the transaction request to a server corresponding to the server identifier in the server cluster 10. In the case where the number of transaction requests is equal to or greater than the total number, the excess flow control information is sent to the client 11. In this way, the flow control in the cluster can be performed for the client 11, and when the transaction request arrives, the flow control configuration information in the flow control management system 12 is updated, so that accurate control of the flow control data is realized.
In some embodiments, as shown in fig. 1, the server cluster 10 may include at least one server, such as server 1, server 2, … …, server N, N being an integer greater than 1. The server cluster 10 may be a cluster including a plurality of servers providing the same service, and may provide an Application Program Interface (API) to the outside.
Client 11 may include at least one requesting device, such as requesting device 1, requesting device 2, … …, requesting device M, M being an integer greater than 1.
The flow control management system 12 further includes a server management module, a flow control configuration module, a database access module, and a database.
The server management module is configured to receive a transaction request sent by at least one requesting device in the client 11, access the database access module to query the information of the clustered database in the database, the number of transaction requests of the requesting device, and the total number of transaction requests allowed by the requesting device, record and update the current number of transaction requests of the requesting device to be the number of transaction requests plus one when it is determined that the number of transaction requests is smaller than the total number, and store the updated current number of transaction requests in the flow control configuration module. Then, the server in the server cluster 10 is called to forward the transaction request to the corresponding server. The server may be a machine that deploys a certain service, and provides an API or an interface for calling to the outside.
The flow control configuration module is configured to initialize a flow control parameter according to configuration when an application is started, where the flow control parameter is flow control configuration information, and is used to control the number of requests for simultaneous access to the API or interface of each request device in the client 11. The flow control configuration module is further configured to update the flow control configuration information of each requesting device, so as to implement cluster sharing.
The database access module is used for preloading the flow control configuration information into a database from the flow control configuration module, and preloading the cluster database information into the database from the server cluster 10 for subsequent quick query, wherein the database can be a memory database, and the flow control data storage is performed by utilizing the characteristic of quick data writing and reading of the memory database.
Therefore, in the embodiment of the application, the flow control management system receives the target transaction request sent by the request device based on the server management module, and obtains the flow control configuration information of the request device from the database based on the database access module according to the identifier of the request device, wherein the flow control configuration information includes the number of the transaction requests and the total number of the transaction requests allowed by the request device, and the flow control configuration information is preloaded to the database from the flow control configuration module, so that the efficiency of subsequently inquiring the number of the transaction requests is improved. And then, under the condition that the number of the transaction requests is judged to be smaller than the total number, recording and updating the current number of the transaction requests of the request equipment to be the number of the transaction requests plus one, and storing the updated current number of the transaction requests to the flow control configuration module. And then, acquiring a server initial value from the database, determining a server identifier for providing service for the target transaction request according to the server initial value, and sending the target transaction request to a server corresponding to the server identifier in the server cluster. And in the case that the number of the transaction requests is greater than or equal to the total number, sending the excess flow control information to the request equipment. Therefore, the flow control information of the request equipment is configured in the database through unified logic control, cluster sharing is realized, cluster internal flow control can be performed on different request equipment, when each transaction request arrives, the flow control data in the database is updated, and accurate control of the flow control data is realized.
In addition, the flow control architecture provided by the embodiment of the application can be applied to a low flow control scene in which the numerical value of the flow control parameter is smaller than the number of servers, and can realize accurate control of flow control.
According to the above flow control architecture, the flow control method provided in the embodiment of the present application is described in detail below with reference to fig. 2.
Fig. 2 is a flowchart illustrating a flow control method according to an embodiment of the present application, where the flow control method may be applied to a flow control management module in the flow control architecture.
As shown in fig. 2, the flow control method may specifically include the following steps:
s110, a target transaction request is received, where the target transaction request may include an identification of the requesting device.
The target transaction request may be a transaction request sent by any requesting device and may include an identification of the requesting device, where the identification of the requesting device may be a character capable of uniquely identifying the requesting device and may include numbers, letters, symbols, and the like.
In one embodiment, the flow control field value in the target transaction request is obtained, resulting in the identification of the requesting device.
S120, obtaining the number of the transaction requests of the requesting device and the total number of the transaction requests allowed by the requesting device from the database, where the number of the transaction requests of the requesting device and the total number of the transaction requests allowed by the requesting device may be pre-loaded into the database from the flow control configuration module.
The number of transaction requests of the requesting device and the total number of transaction requests allowed by the requesting device may be preset numbers of the database based on the flow control configuration module, where the database may be an in-memory database.
As an example, at the time of service start, the configuration information of the requesting device 1, including the total number of transaction requests allowed, i.e. the maximum request number, and the number of current transaction requests of the requesting device 1, i.e. the current request number, are first preconfigured in the memory database from the flow control configuration module for use in subsequent quick query. When the flow control for the requesting device 1 is 3, the initialized data according to the requirement of the requesting device 1 may be: the request device 1: { current request number: 0, maximum number of requests: 3}. Next, the number 0 of transaction requests of the requesting device 1 and the total number 3 of transaction requests allowed by the requesting device 1 are obtained from the memory database.
And S130, under the condition that the number of the transaction requests is smaller than the total number, recording and updating the current transaction request number of the request equipment to be the number of the transaction requests plus one, and acquiring a server initial value from the database.
As an example, after configuring that the number of the current transaction requests of the requesting device 1 is 0 and the total number of the transaction requests allowed by the requesting device 1 is 3 in the database, when receiving the transaction request a, querying the current configuration information in the database, and determining whether the transaction request a is in a flow control range, that is, the total number of the transaction requests allowed 3 — the number of the current transaction requests 0 is 3>0, and if the number of the transaction requests is less than the total number, the transaction request a is determined to pass, and the transaction request a is in the flow control range. Next, a server initial value, which may be-1, for example, pre-configured in the database is obtained for subsequent determination of the server serving the transaction request a. In addition, the number of the current transaction requests is added by 1 and written back to the database as the updated number of the current transaction requests of the requesting device 1.
S140, determining a server identifier for providing service for the target transaction request according to the initial value of the server, and sending the target transaction request to the server corresponding to the server identifier.
The server initial value may be a server index value used to select the calling server, for example, when the server initial value is-1, the server index is stored in the database: -1.
As an example, when a service is started, a server information array is preconfigured in an in-memory database, for example, a cluster includes 12 servers, and the data initialized according to the requirement may be: server information array [ { server 1}, { server 2}, { … 12} ], server subscript: -1. And then, receiving a transaction request A, acquiring a server subscript value-1 from the cluster database when judging that the transaction request A is in the flow control range, determining a server identifier for providing service for the transaction request A according to the server subscript value-1, and sending the transaction request A to a server corresponding to the server identifier.
And S150, sending the excess flow control information to the request equipment under the condition that the number of the transaction requests is larger than or equal to the total number.
The excess flow control information may be feedback information for prompting the requesting device for a transaction request for excess flow control.
As an example, when the flow control is 3 for the requesting device 1, when receiving the transaction request B of the requesting device 1, the current configuration information in the database is queried, and it is determined whether the transaction request B is within the flow control range, that is, the total number of the transaction requests allowed by the requesting device 1 is 3 — the number of the current transaction requests is 3 — 0, and the number of the transaction requests is equal to the total number, then the transaction request B does not pass through, and the information exceeding the flow control is not sent to the requesting device 1 within the flow control range.
In the embodiment of the application, the target transaction requests including the identification of the request device are received, the number of the transaction requests of the request device and the total number of the transaction requests allowed by the request device are obtained from the database, and the number of the transaction requests of the request device and the total number of the transaction requests allowed by the request device are pre-loaded to the database from the flow control configuration module, so that the efficiency of subsequently inquiring the number of the transaction requests is improved. And then, under the condition that the number of the transaction requests is smaller than the total number, recording and updating the current transaction request number of the request equipment to be the number of the transaction requests plus one, acquiring a server initial value from a database, determining a server identifier for providing service for the target transaction request according to the server initial value, and sending the target transaction request to a server corresponding to the server identifier. And in the case that the number of the transaction requests is greater than or equal to the total number, sending the excess flow control information to the request equipment. In the embodiment of the application, the flow control information of the request equipment is configured into the database through unified logic control, cluster sharing is achieved, cluster flow control can be performed on different request equipment, and when each transaction request arrives, the flow control data in the database is updated, so that accurate control of the flow control data is achieved.
In the embodiment of the application, the initial value of the server is obtained from the cluster database, and the server identifier for providing service for the target transaction request is determined according to the initial value of the server, so that the server in the cluster database can be accurately selected for calling, and the accurate control of the server in the cluster is realized.
In some embodiments, the database may comprise a clustered database; s140: determining a server identifier for providing service for the target transaction request according to the server initial value may specifically include:
and determining the remainder of the sum of the initial value of the server and the preset numerical value and the division of the sum and the total number of the servers in the database as the server identification.
The cluster database may be used to store the server cluster, the cluster database may store the server identifier and the initial value of the server, and the preset value may be a value arbitrarily set by the user according to needs, for example, 0 or 1, and is not limited herein.
As an example, the cluster includes 12 servers, and at the time of service startup, the data initialized in the cluster database may be: server information array [ { server 1}, { server 2}, { … 12} ], server subscript: -1. When a transaction request A is received and is judged to be in a flow control range, a server subscript value of-1 is obtained from a cluster database, one server in a server information array is selected to provide service according to the server subscript value, the server subscript is used for calculating to obtain a remainder of 0 (namely the calculated server subscript is 0) by using the server subscript which is equal to (server subscript + 1)% of the total number of the servers, and the server with the subscript value of 0 is called to provide service for the transaction request A.
In the embodiment of the application, the remainder obtained by dividing the sum of the initial value of the server and the preset numerical value by the total number of the servers in the database is calculated and is used as the server identifier, so that the selection of the servers in the cluster can be more accurate, and the calling accuracy of the servers in the cluster is further improved.
In some embodiments, the flow control method may further include:
and storing the remainder as an updated initial value of the server to a cluster database.
As an example, after receiving the transaction request a and calculating the remainder to be 0 by using the server index to be (server index + 1)% of the total number of servers, the calculated index is returned to the server information array of the cluster database, and the server index in the cluster database is updated to be 0, that is, the server information array is [ { server 1}, { server 2}, { … 12} ], the server index: 0.
in the embodiment of the application, the remainder is stored in the cluster database as the updated initial value of the server, so that the server can be conveniently called for the received transaction request in the follow-up process.
In some embodiments, the database may include flow control configuration information; at S140: after sending the target transaction request to the server corresponding to the server identifier, the traffic control method may further include:
inquiring the number of current transaction requests in the flow control configuration information of the request device;
subtracting one from the number of the current transaction requests of the request device to obtain the updated number of the current transaction requests;
and storing the updated number of the current transaction requests to the flow control configuration information.
The flow control configuration information may be information pre-configured in a database, and may include, for example, the number of current transaction requests of the requesting device and the total number of transaction requests allowed by the requesting device.
As an example, after the transaction request a of the request device 1 is forwarded to the corresponding server, that is, after the transaction request is ended, the number of current requests in the flow control configuration information of the request device 1 is queried, the number of current requests is subtracted by 1 and written back to the database as the updated number of current transaction requests, and then the processing of single transaction request is ended.
In the embodiment of the application, the number of the current transaction requests of the request device is reduced by one by inquiring the number of the current transaction requests in the flow control configuration information of the request device, so that the updated number of the current transaction requests is obtained, and the updated number of the current transaction requests is stored in the flow control configuration information, so that whether the received transaction requests of the request device are in a flow control range or not is conveniently judged subsequently, the flow control configuration information in the database is updated, and cluster sharing and accurate control can be realized.
Fig. 3 is a schematic diagram illustrating a flow control device 300 according to an exemplary embodiment.
As shown in fig. 3, the flow control device 300 may include:
a receiving module 301, configured to receive a target transaction request, where the target transaction request includes an identifier of a requesting device;
an obtaining module 302, configured to obtain, from the database, the number of transaction requests of the requesting device and the total number of transaction requests allowed by the requesting device, where the number of transaction requests of the requesting device and the total number of transaction requests allowed by the requesting device are preloaded in the database from the flow control configuration module;
the updating module 303 is configured to record and update the current transaction request quantity of the requesting device as the quantity of the transaction requests plus one when the quantity of the transaction requests is smaller than the total quantity, and obtain an initial value of the server from the database;
a sending module 304, configured to determine, according to the initial value of the server, a server identifier for providing a service for the target transaction request, and send the target transaction request to a server corresponding to the server identifier;
the sending module 304 is further configured to send the excess flow control information to the requesting device if the number of transaction requests is greater than or equal to the total number.
In one embodiment, the database comprises a clustered database; the flow control apparatus 300 may further include a determination module;
and the determining module is used for determining the sum of the initial value of the server and a preset numerical value, and the remainder of division of the sum and the total number of the servers in the database is the server identification.
In one embodiment, the flow control device 300 may further include a memory module;
and the storage module is used for storing the remainder as an updated server initial value to the cluster database.
In one embodiment, the database includes flow control configuration information; the flow control device 300 may also include a query module;
the query module is used for querying the number of the current transaction requests in the flow control configuration information of the request device after sending the target transaction requests to the server corresponding to the server identifier;
the updating module 303 is further configured to reduce the number of the current transaction requests of the requesting device by one, so as to obtain an updated number of the current transaction requests;
and the storage module is also used for storing the updated number of the current transaction requests to the flow control configuration information.
Therefore, by receiving the target transaction request comprising the identification of the request equipment, acquiring the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment from the database, wherein the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment are pre-loaded to the database from the flow control configuration module, and the efficiency of subsequently inquiring the quantity of the transaction requests is improved. And then, under the condition that the number of the transaction requests is smaller than the total number, recording and updating the current transaction request number of the request equipment to be the number of the transaction requests plus one, acquiring a server initial value from a database, determining a server identifier for providing service for the target transaction request according to the server initial value, and sending the target transaction request to a server corresponding to the server identifier. And sending the exceeding flow control information to the request equipment under the condition that the number of the transaction requests is greater than or equal to the total number. In the embodiment of the application, the flow control information of the request equipment is configured into the database through unified logic control, cluster sharing is achieved, cluster flow control can be performed on different request equipment, and when each transaction request arrives, the flow control data in the database is updated, so that accurate control of the flow control data is achieved.
Fig. 4 shows a hardware schematic diagram of an electronic device provided in an embodiment of the present application.
The electronic device may include a processor 401 and a memory 402 storing computer program instructions.
Specifically, the processor 401 may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or may be configured to implement one or more Integrated circuits of the embodiments of the present Application.
The memory may include Read Only Memory (ROM), Random Access Memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical/tangible memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software comprising computer-executable instructions and when the software is executed (e.g., by one or more processors), it is operable to perform operations described with reference to the methods according to an aspect of the present disclosure.
The processor 401 reads and executes the computer program instructions stored in the memory 402 to implement any of the flow control methods in the above embodiments.
In one example, the electronic device may also include a communication interface 403 and a bus 410. As shown in fig. 4, the processor 401, the memory 402, and the communication interface 403 are connected via a bus 410 to complete communication therebetween.
The communication interface 403 is mainly used for implementing communication between modules, apparatuses, units and/or devices in the embodiments of the present application.
The electronic device may execute the traffic control method in the embodiment of the present application based on the identification of the requesting device in the target transaction request, the number of transaction requests of the requesting device in the database, and the total number of transaction requests allowed by the requesting device, thereby implementing the traffic control method described in conjunction with fig. 2.
In addition, in combination with the flow control method in the foregoing embodiment, the embodiment of the present application may provide a computer storage medium to implement the method. The computer storage medium having computer program instructions stored thereon; the computer program instructions, when executed by a processor, implement any of the flow control methods in the above embodiments.
It is to be understood that the present application is not limited to the particular arrangements and instrumentality described above and shown in the attached drawings. A detailed description of known methods is omitted herein for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present application are not limited to the specific steps described and illustrated, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps, after comprehending the spirit of the present application.
The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, plug-in, function card, or the like. When implemented in software, the elements of the present application are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted by a data signal carried in a carrier wave over a transmission medium or a communication link. A "machine-readable medium" may include any medium that can store or transfer information. Examples of a machine-readable medium include electronic circuits, semiconductor memory devices, ROM, flash memory, Erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, Radio Frequency (RF) links, and so forth. The code segments may be downloaded via computer networks such as the internet, intranet, etc.
It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, may be performed in an order different from the order in the embodiments, or may be performed simultaneously.
Aspects of the present disclosure are described above with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions/acts specified in the flowchart and/or block diagram block or blocks. Such a processor may be, but is not limited to, a general purpose processor, a special purpose processor, an application specific processor, or a field programmable logic circuit. It will also be understood that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware for performing the specified functions or acts, or combinations of special purpose hardware and computer instructions.
As described above, only the specific embodiments of the present application are provided, and it can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working processes of the system, the module and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. It should be understood that the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the present application, and these modifications or substitutions should be covered within the scope of the present application.
Claims (10)
1. A method of flow control, comprising:
receiving a target transaction request, the target transaction request including an identification of a requesting device;
acquiring the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment from a database, wherein the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment are pre-loaded to the database from a flow control configuration module;
under the condition that the quantity of the transaction requests is smaller than the total quantity, recording and updating the current quantity of the transaction requests of the request equipment to be the quantity of the transaction requests plus one, and acquiring a server initial value from the database;
determining the server identifier for providing service for the target transaction request according to the initial value of the server, and sending the target transaction request to a server corresponding to the server identifier;
and in the case that the number of the transaction requests is greater than or equal to the total number, sending excess flow control information to the request equipment.
2. The method of claim 1, wherein the database comprises a clustered database; the determining the server identifier serving the target transaction request according to the server initial value includes:
and determining the sum of the initial value of the server and a preset numerical value, and the remainder of division of the sum of the initial value of the server and the total number of the servers in the cluster database as the server identification.
3. The method of claim 2, further comprising:
and storing the remainder as an updated server initial value to the cluster database.
4. The method of claim 1, wherein the database comprises flow control configuration information; after the sending of the target transaction request to the server corresponding to the server identification, the method further comprises:
inquiring the number of current transaction requests in the flow control configuration information of the request device;
subtracting one from the number of the current transaction requests of the request equipment to obtain the updated number of the current transaction requests;
and storing the updated number of the current transaction requests to the flow control configuration information.
5. A flow control device, the device comprising:
a receiving module for receiving a target transaction request, the target transaction request including an identification of a requesting device;
the acquisition module is used for acquiring the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment from a database, wherein the quantity of the transaction requests of the request equipment and the total quantity of the transaction requests allowed by the request equipment are pre-loaded to the database from the flow control configuration module;
the updating module is used for recording and updating the current transaction request quantity of the request equipment to be the quantity of the transaction requests plus one when the quantity of the transaction requests is smaller than the total quantity, and acquiring a server initial value from the database;
the sending module is used for determining the server identifier for providing service for the target transaction request according to the initial value of the server and sending the target transaction request to a server corresponding to the server identifier;
the sending module is further configured to send excess flow control information to the requesting device when the number of the transaction requests is greater than or equal to the total number.
6. The apparatus of claim 5, wherein the database comprises a clustered database; the flow control device further comprises a determination module;
the determining module is configured to determine a sum of the server initial value and a preset numerical value, and a remainder of division of a total number of servers in the cluster database is the server identifier.
7. The apparatus of claim 6, further comprising a storage module;
and the storage module is used for storing the remainder as an updated server initial value to the cluster database.
8. An electronic device, characterized in that the device comprises: a processor, and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the flow control method of any one of claims 1-4.
9. A computer storage medium having computer program instructions stored thereon which, when executed by a processor, implement the flow control method of any one of claims 1 to 4.
10. A computer program product, wherein instructions in the computer program product, when executed by a processor of an electronic device, cause the electronic device to perform the flow control method of any one of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210334148.3A CN114710450B (en) | 2022-03-31 | 2022-03-31 | Flow control method, device, equipment and computer storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210334148.3A CN114710450B (en) | 2022-03-31 | 2022-03-31 | Flow control method, device, equipment and computer storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114710450A true CN114710450A (en) | 2022-07-05 |
CN114710450B CN114710450B (en) | 2024-04-09 |
Family
ID=82169934
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210334148.3A Active CN114710450B (en) | 2022-03-31 | 2022-03-31 | Flow control method, device, equipment and computer storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114710450B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170220624A1 (en) * | 2016-02-01 | 2017-08-03 | International Business Machines Corporation | Transaction processor |
CN107707488A (en) * | 2017-10-25 | 2018-02-16 | 北京数码视讯支付技术有限公司 | Payment online transaction flow control method, flow limiting server and client |
CN110198275A (en) * | 2018-03-28 | 2019-09-03 | 腾讯科技(深圳)有限公司 | A kind of flow control methods, system, server and storage medium |
CN114244624A (en) * | 2021-12-31 | 2022-03-25 | 北京市商汤科技开发有限公司 | Flow control method and device, equipment and storage medium |
-
2022
- 2022-03-31 CN CN202210334148.3A patent/CN114710450B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170220624A1 (en) * | 2016-02-01 | 2017-08-03 | International Business Machines Corporation | Transaction processor |
CN107707488A (en) * | 2017-10-25 | 2018-02-16 | 北京数码视讯支付技术有限公司 | Payment online transaction flow control method, flow limiting server and client |
CN110198275A (en) * | 2018-03-28 | 2019-09-03 | 腾讯科技(深圳)有限公司 | A kind of flow control methods, system, server and storage medium |
CN114244624A (en) * | 2021-12-31 | 2022-03-25 | 北京市商汤科技开发有限公司 | Flow control method and device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN114710450B (en) | 2024-04-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111143371B (en) | Data query method, device, equipment, system and medium | |
CN110856126B (en) | Information reporting and receiving method, terminal equipment and storage medium | |
CN115345646A (en) | Information sending method, device, equipment and computer readable storage medium | |
CN112995909B (en) | SIM card distribution method, device, server and computer readable storage medium | |
CN111385256A (en) | Method, device, equipment and medium for migrating batch applications | |
CN116775110A (en) | Data synchronization method, device, equipment, medium and product | |
CN114710450B (en) | Flow control method, device, equipment and computer storage medium | |
CN112995900B (en) | SIM card distribution method, device, server and computer readable storage medium | |
CN115567448A (en) | Flow control method, flow control device, flow control apparatus, flow control medium, and program product | |
CN115913625A (en) | Information processing method, device, equipment, medium and product | |
CN114372072A (en) | Data storage method, device, equipment, computer storage medium and program product | |
CN114945038A (en) | Communication method, system, equipment and readable storage medium based on SOA architecture | |
CN118069452A (en) | Filling method, device, equipment and storage medium for buried point event | |
CN114169917B (en) | Information sending method, platform, system, electronic equipment and storage medium | |
CN114675970A (en) | Information determination method, device, equipment, storage medium and computer program product | |
CN113139170B (en) | Method, device and equipment for generating authentication credentials and authentication | |
CN115514820A (en) | Data calling method, device, equipment, storage medium and program product | |
CN108965214B (en) | Data processing method, device and computer storage medium | |
CN118132655A (en) | Information synchronization method, apparatus, device, storage medium, and program product | |
CN114693417A (en) | Automatic data processing method, device and equipment for interest bearing and computer storage medium | |
CN115543594A (en) | Storage resource allocation method, device, equipment and storage medium | |
CN117786655A (en) | Identification code generation method, device, equipment and medium | |
CN115525601A (en) | Data storage and query method, device, equipment and computer storage medium | |
CN115544077A (en) | Data determination method, device, equipment and computer storage medium | |
CN116938964A (en) | Method, device, equipment and storage medium for determining resource position |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |