CN114710450B - Flow control method, device, equipment and computer storage medium - Google Patents
Flow control method, device, equipment and computer storage medium Download PDFInfo
- Publication number
- CN114710450B CN114710450B CN202210334148.3A CN202210334148A CN114710450B CN 114710450 B CN114710450 B CN 114710450B CN 202210334148 A CN202210334148 A CN 202210334148A CN 114710450 B CN114710450 B CN 114710450B
- Authority
- CN
- China
- Prior art keywords
- flow control
- server
- request
- database
- transaction requests
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 60
- 238000004590 computer program Methods 0.000 claims description 16
- 238000010586 diagram Methods 0.000 description 12
- 238000007726 management method Methods 0.000 description 11
- 230000008569 process Effects 0.000 description 10
- 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 2
- 230000004048 modification Effects 0.000 description 2
- 230000036316 preload Effects 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
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000004519 manufacturing process Methods 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
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
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 a request equipment; obtaining the number of transaction requests of the requesting device from a database, and the total number of transaction requests allowed by the requesting device, wherein the number and the total number of the transaction requests are preloaded into the database from the 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 one more than the number of the transaction requests, 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 sending the excess flow control information to the requesting device when the number of transaction requests is greater than or equal to the total number. According to the embodiment of the application, the accurate control of the flow control data can be realized.
Description
Technical Field
The application belongs to the technical field of big data, and particularly relates to a flow control method, a flow control device, flow control equipment and a computer storage medium.
Background
"flow control" is an abbreviation for flow control, which is used to control the number of requests for simultaneous access to a specific application program interface (Application Program Interface, API).
In the prior art, flow control is performed mainly by loading flow control parameters into a memory for use when an application is started, or after a service request is received, a service method pointed by the service request is determined, and flow control decisions are performed according to different service method requirements. However, although the method of loading the flow control parameters into the memory can reduce the time consumption, because the memory is realized by a single machine, the precise control of the flow in the cluster cannot be realized, and the method of making the flow control decision according to the requirements of different service methods can only perform the flow control according to the service requests of the same type of service, and cannot realize the flow control according to different requesters, therefore, the method cannot realize the precise control of the flow in the cluster of different requesters.
Disclosure of Invention
The embodiment of the application provides a flow control method, a flow control device, flow control equipment and a computer storage medium, which can solve the problem that the accurate control of the flow in clusters of different requesters cannot be realized in the prior art.
In a first aspect, an embodiment of the present application provides a flow control method, including:
receiving a target transaction request, wherein the target transaction request comprises an identification of a request device;
obtaining the number of the request device transaction requests from a database, and the total number of the request device permission transaction requests, wherein the number of the request device transaction requests and the total number of the request device permission transaction requests are preloaded to the database from a flow control configuration module;
recording and updating the current transaction request number of the request equipment to be one more than the transaction request number under the condition that the transaction request number is smaller than the total number, 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 sending the 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 determining the server identifier for providing service for the target transaction request according to the initial value of the server includes:
and determining the sum of the initial value of the server and a preset value, and taking the remainder of the division 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 initial value of the server to the cluster database.
In one embodiment, the database includes flow control configuration information; after the sending the target transaction request to the server corresponding to the server identifier, the method further includes: inquiring the number of current transaction requests in the flow control configuration information of the request equipment;
subtracting one from the number of the current transaction requests of the request equipment to obtain the number of updated current transaction requests;
and storing the updated number of the current transaction requests to the flow control configuration information.
In a second aspect, embodiments of the present application provide a flow control device, including:
a receiving module, configured to receive a target transaction request, where the target transaction request includes an identifier of a requesting device;
an acquisition module, configured to acquire, from a database, a number of transaction requests of the requesting device, and a total number of allowed transaction requests of the requesting device, where the number of transaction requests of the requesting device and the total number of allowed transaction requests of the requesting device are preloaded from a flow control configuration module to the database;
the updating module is used for recording and updating the current transaction request number of the request equipment to be one when the number of the transaction requests is smaller than the total number, 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, to the requesting device, excess flow control information 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;
and the determining module is used for determining the sum of the initial value and the preset value of the server, and the remainder of the division of the initial value and the total number of the servers in the database is the server identification.
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 initial value of the server 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 subtract one from the number of current transaction requests of the requesting device to obtain an updated number of current transaction requests;
the storage module is further configured to store the updated number of 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 the flow control method as described in any of the embodiments of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer storage medium having stored thereon computer program instructions which, when executed by a processor, implement a flow control method as in any of the embodiments of the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product, instructions in which, when executed by a processor of an electronic device, cause the electronic device to perform a flow control method as described in any one of the embodiments of the first aspect.
According to the flow control method, the flow control device, the flow control equipment and the flow control computer storage medium, the number of the transaction requests of the request equipment is obtained from the database by receiving the target transaction requests comprising the identification of the request equipment, and the total number of the transaction requests allowed by the request equipment, wherein the number of the transaction requests of the request equipment and the total number of the transaction requests allowed by the request equipment are preloaded from the flow control configuration module to the database, so that the efficiency of inquiring the number of the transaction requests in the follow-up process 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 one, obtaining 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 excess flow control information to the requesting device when the number of transaction requests is greater than or equal to the total number. According to 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, flow control can be conducted on different request equipment in the clusters, when each transaction request arrives, flow control data in the database are updated, and 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 that are needed in the embodiments of the present application will be briefly described, and it is possible for a person skilled in the art to obtain other drawings according to these drawings without inventive effort.
FIG. 1 is a schematic diagram of a flow control architecture provided in one embodiment of the present application;
FIG. 2 is a flow diagram of a flow control method provided in one embodiment of the present application;
FIG. 3 is a schematic view of a flow control device according to one embodiment of the present disclosure;
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 are described in detail below to make the objects, technical solutions and advantages of the present application more apparent, and to further describe the present application in conjunction with the accompanying drawings and the detailed embodiments. It should be understood that the specific embodiments described herein are intended to be illustrative of the application 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 showing examples of the present application.
It is noted that 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. Moreover, 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 like elements in a process, method, article or apparatus that comprises the element.
The data acquisition, storage, use, processing and the like in the technical scheme meet the relevant regulations of national laws and regulations.
As described in the background art, in the prior art, there is a problem that accurate control of intra-cluster traffic of different requesters cannot be achieved. In order to solve the above-mentioned problems, embodiments of the present application provide a flow control method, apparatus, device, and computer storage medium, where the flow control method may obtain, from a database, the number of transaction requests of a requesting device, and the total number of transaction requests allowed by the requesting device, by receiving a target transaction request including an identifier of 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 from a flow control configuration module to the database, thereby improving efficiency of querying the number of transaction requests subsequently. 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 one, obtaining 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 excess flow control information to the requesting device when the number of transaction requests is greater than or equal to the total number. According to 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, flow control can be conducted on different request equipment in the clusters, when each transaction request arrives, flow control data in the database are updated, and 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, the 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 clients 11, obtains flow control configuration information of the clients 11 according to the identification information of the clients 11 in the transaction requests, wherein the flow control configuration information comprises the number of the transaction requests and the total number of the transaction requests allowed by the clients 11, and then records and updates the current transaction request number of the clients 11 to be one plus the number of the transaction requests under the condition that the number of the transaction requests is judged to be smaller than the total number. Further, the flow control management system 12 obtains a server initial value, determines a server identifier for providing a service for the target transaction request according to the server initial value, and transmits 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, excess flow control information is transmitted 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 the 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, servers 2, … …, server N, N being an integer greater than 1. The server cluster 10 may be a cluster composed of a plurality of servers providing the same service, and externally provides an application program interface (Application Program Interface, API).
The client 11 may comprise at least one requesting device, e.g. requesting device 1, requesting device 2, … …, requesting device M, M being an integer greater than 1.
The flow control management system 12 also 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 request device in the client 11, access the database access module, query cluster database information in the database, the number of transaction requests of the request device, and the total number of allowed transaction requests of the request device, record and update the current transaction request number of the request device to be one more than the number of transaction requests if the number of transaction requests is determined to be less than the total number, and store the updated current transaction request number to the flow control configuration module. The servers in the server cluster 10 are then invoked and the transaction request is forwarded to the corresponding server. The server may be a machine in which a certain service is deployed, and provides an API or an interface for calling.
The flow control configuration module is used for initializing flow control parameters according to configuration when the application is started, wherein the flow control parameters are flow control configuration information, and are used for controlling the number of requests for simultaneously accessing the API or the interface of each request device in the client 11. The flow control configuration module is also used for updating the flow control configuration information of each request device to realize cluster sharing.
The database access module is configured to pre-load the flow control configuration information from the flow control configuration module into a database, pre-load cluster database information from the server cluster 10 into the database for subsequent quick query, where the database may be, for example, an in-memory database, and perform flow control data storage by using the characteristic that the in-memory database is fast in writing and reading data.
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 identification of the request device, wherein the flow control configuration information comprises the number of the transaction requests and the total number of the transaction requests allowed by the request device, and is preloaded from the flow control configuration module to the database, so that the efficiency of inquiring the number of the transaction requests in the follow-up process 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 transaction request number of the request equipment to be one, and storing the updated current transaction request number into 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 sending the excess flow control information to the requesting device when the number of transaction requests is greater than or equal to the total number. Thus, the flow control information of the request equipment is configured into the database through unified logic control, cluster sharing is realized, flow control can be carried out on different request equipment in the cluster, when each transaction request arrives, 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 that the number of flow control parameters is smaller than the number of servers, and can realize accurate control of flow control.
In view of the foregoing flow control architecture, a flow control method according to an embodiment of the present application is described in detail below with reference to fig. 2.
Fig. 2 is a flow chart illustrating a flow control method according to an embodiment of the present application, where the flow control method may be applied to the flow control management module in the flow control architecture.
As shown in fig. 2, the flow control method specifically includes the following steps:
s110, receiving a target transaction request, wherein the target transaction request can include an identification of a 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 a number, letter, symbol, and the like.
In one embodiment, a flow control field value in the target transaction request is obtained to obtain an identification of the requesting device.
S120, obtaining, from the database, the number of request device transaction requests and the total number of request device permission transaction requests, where the number of request device transaction requests and the total number of request device permission transaction requests may be preloaded from the flow control configuration module to the database.
The number of requesting device transaction requests and the total number of requesting device allowed transaction requests may be a number that is pre-configured by a database based on a flow control configuration module, wherein the database may be an in-memory database.
As an example, at service start-up, configuration information of the requesting device 1 is first pre-configured in the in-memory database from the flow control configuration module, including the total number of allowed transaction requests, i.e. the maximum number of requests, and the number of current transaction requests of the requesting device 1, i.e. the current number of requests, for subsequent fast query use. When the flow control is 3 for the requesting device 1, the data initialized according to the demand of the requesting device 1 may be: requesting device 1: { number of current requests: 0, maximum number of requests: 3}. Next, the number of transaction requests 0 of the requesting device 1 is obtained from the in-memory database, and the total number of transaction requests 3 allowed by the requesting device 1.
And S130, recording and updating the current transaction request number of the request equipment to be one more than the number of the transaction requests under the condition that the number of the transaction requests is smaller than the total number, and acquiring the initial value of the server from the database.
As an example, after the number of current transaction requests of the requesting device 1 is configured in the database to be 0, and the total number of allowed transaction requests of the requesting device 1 is 3, when the transaction request a is received, the current configuration information in the database is queried, whether the transaction request a is within the flow control range is judged, that is, the total number of allowed transaction requests is 3-the number of current transaction requests is 0= 3>0, the number of transaction requests is smaller than the total number, and the transaction request a is judged to pass. The pre-configured server initial value in the database is then obtained, which may be-1, for example, for subsequent determination of the server that serves the transaction request a. In addition, the number of the current transaction requests is added by 1 and the database is written back as the updated number of the current transaction requests of the requesting device 1.
And 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 a server corresponding to the server identifier.
The server initial value may be a server subscript value for selecting to invoke the server, for example, when the server initial value is-1, the server subscript is stored in the database: -1.
As an example, at the time of service start, an array of server information is preconfigured in the stored database, for example, the cluster includes 12 servers, and the initialized data according to the requirement may be: server information array= [ { server 1}, { server 2}, { … } ], server subscript: -1. And then, when the transaction request A is received and judged to be in the flow control range, a server index value-1 is obtained from the cluster database, a server identifier for providing service for the transaction request A is determined according to the server index value-1, and the transaction request A is sent to a server corresponding to the server identifier.
And S150, when the number of the transaction requests is greater than or equal to the total number, sending the excess flow control information to the requesting equipment.
The excess flow control information may be feedback information for prompting the requesting device that the transaction request exceeds flow control.
As an example, when the flow control is 3 for the requesting device 1, upon 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 allowed transaction requests 3 of the requesting device 1—the number of current transaction requests 3=0, and the number of transaction requests is equal to the total number, then the transaction request B does not pass, and no information exceeding the flow control is transmitted to the requesting device 1 within the flow control range.
In the embodiment of the application, the target transaction request comprising the identification of the request device is received, the number of the transaction requests of the request device is obtained from the database, and the total number of the transaction requests allowed by the request device is preloaded from the flow control configuration module to the database, so that the efficiency of inquiring the number of the transaction requests in the follow-up process 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 one, obtaining 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 excess flow control information to the requesting device when the number of transaction requests is greater than or equal to the total number. According to 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, flow control can be conducted on different request equipment in the clusters, when each transaction request arrives, flow control data in the database are updated, and accurate control of the flow control data is achieved.
According to the method and the device for controlling the server, the server initial value is obtained from the cluster database, the server identifier for providing service for the target transaction request is determined according to the server initial value, and the server in the cluster database can be accurately selected for calling, so that accurate control of the servers in the cluster is achieved.
In some embodiments, the database may comprise a clustered database; s140: the determining, according to the initial value of the server, a server identifier for providing service for the target transaction request may specifically include:
and determining the sum of the initial value of the server and the preset value, and taking the remainder of dividing the sum of the initial value of the server and the total number of the servers in the database as the server identification.
The cluster database may be used to store a server cluster, where a server identifier and a server initial value may be stored in the cluster database, and the preset value may be a value arbitrarily set by a user according to needs, for example, may be 0 or 1, which is not limited herein.
As an example, a cluster includes 12 servers, and at service start-up, initialized data in the cluster database may be: server information array= [ { server 1}, { server 2}, { … } ], server subscript: -1. When a transaction request A is received and the transaction request A is judged to be in a flow control range, a server index 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 index value, the server index= (server index+1)% total number of servers is utilized, the remainder is calculated to be 0, namely the calculated server index is 0, and a server with the index value of 0 is called to provide service for the transaction request A.
In the embodiment of the application, the remainder of the sum of the initial value of the server and the preset value is calculated and divided with the total number of the servers in the database, and the remainder is used as the server identification, 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 the cluster database.
As an example, after receiving the transaction request a and calculating to obtain the remainder as 0 using the server index= (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 0, that is, the server information array= [ { server 1}, { server 2}, { … } ], the server index: 0.
in the embodiment of the application, the remainder is stored as the updated initial value of the server to the cluster database, so that the server is conveniently called by the received transaction request.
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 flow control method may further include:
inquiring the number of current transaction requests in the flow control configuration information of the request equipment;
subtracting one from the number of the current transaction requests of the requesting device to obtain the number of updated 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 by the requesting device, and the total number of allowed transaction requests by the requesting device.
As an example, after forwarding the transaction request a of the requesting device 1 to the corresponding server, i.e. after the transaction request ends, the number of current requests in the flow control configuration information of the requesting device 1 is queried, the number of current requests is subtracted by 1 and written back to the database as the number of updated current transaction requests, at which point the single transaction request processing ends.
In the embodiment of the application, the number of the current transaction requests of the request equipment is reduced by one by inquiring the number of the current transaction requests in the flow control configuration information of the request equipment, the updated number of the current transaction requests is obtained, the updated number of the current transaction requests is stored in the flow control configuration information, whether the received transaction requests of the request equipment are in the 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 a database, a number of transaction requests of the requesting device, and a 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 from the flow control configuration module to the database;
an updating module 303, configured to record and update, when the number of transaction requests is less than the total number, the current number of transaction requests of the requesting device by one, and obtain a server initial value from the database;
a sending module 304, configured to determine, according to the initial value of the server, a server identifier that provides 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 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 300 may also include a determination module;
and the determining module is used for determining the sum of the initial value of the server and the preset value, and the remainder of the division of the initial value of the server 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 initial value of the server 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 current transaction requests in the flow control configuration information of the request equipment after sending the target transaction request to the server corresponding to the server identifier;
the updating module 303 is further configured to subtract one from the number of current transaction requests of the requesting device to obtain an updated number of current transaction requests;
and the storage module is also used for storing the updated quantity of the current transaction requests to the flow control configuration information.
Thus, by receiving the target transaction request including the identification of the requesting device, obtaining the number of requesting device transaction requests from the database, and the total number of requesting device allowed transaction requests, the number of requesting device transaction requests and the total number of requesting device allowed transaction requests are preloaded from the flow control configuration module to the database, improving the efficiency of subsequent querying of the number of transaction requests. 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 one, obtaining 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 excess flow control information to the requesting device when the number of transaction requests is greater than or equal to the total number. According to 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, flow control can be conducted on different request equipment in the clusters, when each transaction request arrives, flow control data in the database are updated, and accurate control of the flow control data is achieved.
Fig. 4 shows a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application.
A processor 401 may be included in an electronic device as well as a memory 402 in which computer program instructions are stored.
In particular, the processor 401 described above may include a Central Processing Unit (CPU), or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or may be configured to implement one or more integrated circuits of embodiments of the present application.
Memory 402 may include mass storage for data or instructions. By way of example, and not limitation, memory 402 may comprise a Hard Disk Drive (HDD), floppy Disk Drive, flash memory, optical Disk, magneto-optical Disk, magnetic tape, or universal serial bus (Universal Serial Bus, USB) Drive, or a combination of two or more of the foregoing. Memory 402 may include removable or non-removable (or fixed) media, where appropriate. Memory 402 may be internal or external to the integrated gateway disaster recovery device, where appropriate. In a particular embodiment, the memory 402 is a non-volatile solid state memory.
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 the operations described with reference to methods in accordance with aspects of the present disclosure.
The processor 401 implements any of the flow control methods of the above embodiments by reading and executing computer program instructions stored in the memory 402.
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 by a bus 410 and perform communication with each other.
The communication interface 403 is mainly used to implement communication between each module, device, unit and/or apparatus in the embodiments of the present application.
Bus 410 includes hardware, software, or both, coupling components of the flow control device to one another. By way of example, and not limitation, the buses may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an infiniband interconnect, a Low Pin Count (LPC) bus, a memory bus, a micro channel architecture (MCa) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a video electronics standards association local (VLB) bus, or other suitable bus, or a combination of two or more of the above. Bus 410 may include one or more buses, where appropriate. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
The electronic device may execute the flow 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 allowed transaction requests of the requesting device, thereby implementing the flow control method described in connection with fig. 2.
In addition, in combination with the flow control method in the above embodiment, the embodiment of the application may be implemented by providing a computer storage medium. The computer storage medium has stored thereon computer program instructions; the computer program instructions, when executed by a processor, implement any of the flow control methods of the above embodiments.
It should be clear that the present application is not limited to the particular arrangements and processes described above and illustrated in the drawings. For the sake of brevity, a detailed description of known methods is omitted here. 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 steps, after appreciating the spirit of the present application.
The functional blocks shown in the above-described structural block diagrams may be implemented in 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, a plug-in, a 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 over transmission media or communication links by a data signal carried in a carrier wave. A "machine-readable medium" may include any medium that can store or transfer information. Examples of machine-readable media include electronic circuitry, 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 the like. The code segments may be downloaded via computer networks such as the internet, intranets, 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 different from the order in the embodiments, or several steps 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 being, 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 which performs the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In the foregoing, only the specific embodiments of the present application are described, and it will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the systems, modules and units described above may refer to the corresponding processes in the foregoing method embodiments, which are not repeated herein. 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, which are intended to be included in the scope of the present application.
Claims (6)
1. A flow control method, comprising:
receiving a target transaction request, wherein the target transaction request comprises an identification of a request device;
obtaining the number of the request device transaction requests from a database, and the total number of the request device permission transaction requests, wherein the number of the request device transaction requests and the total number of the request device permission transaction requests are preloaded to the database from a flow control configuration module;
recording and updating the current transaction request number of the request equipment to be one more than the transaction request number under the condition that the transaction request number is smaller than the total number, and acquiring a server initial value from the 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;
transmitting excess flow control information to the requesting device if the number of transaction requests is greater than or equal to the total number;
the database comprises a cluster database; the determining the server identifier for providing service for the target transaction request according to the initial value of the server includes:
determining the sum of the initial value and a preset value of the server, and taking the remainder of the division of the initial value and the total number of the servers in the cluster database as the server identification;
the method further comprises the steps of:
and storing the remainder as an updated initial value of the server to the cluster database.
2. The method of claim 1, wherein the database comprises flow control configuration information; after the sending the target transaction request to the server corresponding to the server identifier, the method further includes:
inquiring the number of current transaction requests in the flow control configuration information of the request equipment;
subtracting one from the number of the current transaction requests of the request equipment to obtain the number of updated current transaction requests;
and storing the updated number of the current transaction requests to the flow control configuration information.
3. A flow control device, the device comprising:
a receiving module, configured to receive a target transaction request, where the target transaction request includes an identifier of a requesting device;
an acquisition module, configured to acquire, from a database, a number of transaction requests of the requesting device, and a total number of allowed transaction requests of the requesting device, where the number of transaction requests of the requesting device and the total number of allowed transaction requests of the requesting device are preloaded from a flow control configuration module to the database;
the updating module is used for recording and updating the current transaction request number of the request equipment to be one when the number of the transaction requests is smaller than the total number, and acquiring a server initial value from the database;
the sending module is used for 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;
the sending module is further configured to send, to the requesting device, excess flow control information when the number of transaction requests is greater than or equal to the total number;
the database comprises a cluster database; the flow control device further comprises a determination module;
the determining module is used for determining the sum of the initial value and a preset value of the server, and the remainder of the division of the initial value and the total number of the servers in the cluster database is the server identification;
the device also comprises a storage module;
and the storage module is used for storing the remainder as an updated initial value of the server to the cluster database.
4. An electronic device, the device comprising: a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the flow control method according to any of claims 1-2.
5. A computer storage medium having stored thereon computer program instructions which, when executed by a processor, implement a flow control method according to any of claims 1-2.
6. A computer program product, characterized in that 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 according to any of claims 1-2.
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 CN114710450A (en) | 2022-07-05 |
CN114710450B true 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 (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
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 |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10372701B2 (en) * | 2016-02-01 | 2019-08-06 | International Business Machines Corporation | Transaction processor |
-
2022
- 2022-03-31 CN CN202210334148.3A patent/CN114710450B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
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 |
---|---|
CN114710450A (en) | 2022-07-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111143371A (en) | Data query method, device, equipment, system and medium | |
CN112039861A (en) | Risk identification method and device, electronic equipment and computer readable storage medium | |
CN111328067B (en) | User information checking method, device, system, equipment and medium | |
CN114710450B (en) | Flow control method, device, equipment and computer storage medium | |
CN116775110A (en) | Data synchronization method, device, equipment, medium and product | |
CN111414528B (en) | Method and device for determining equipment identification, storage medium and electronic equipment | |
CN112995909B (en) | SIM card distribution method, device, server and computer readable storage medium | |
CN116708576A (en) | Service providing method, device, equipment and computer readable storage medium | |
CN112995900B (en) | SIM card distribution method, device, server and computer readable storage medium | |
CN111461118B (en) | Interest feature determining method, device, equipment and storage medium | |
CN118069452A (en) | Filling method, device, equipment and storage medium for buried point event | |
CN113139170B (en) | Method, device and equipment for generating authentication credentials and authentication | |
CN116049911B (en) | Method, device, equipment and computer storage medium for generating equipment identifier | |
CN116527758B (en) | Method, device, equipment, storage medium and product for generating universal identifier | |
CN117786655A (en) | Identification code generation method, device, equipment and medium | |
CN118132655A (en) | Information synchronization method, apparatus, device, storage medium, and program product | |
CN117749671A (en) | Data packet query method, device, equipment, storage medium and vehicle | |
CN116383197A (en) | Intelligent contract processing method, device, equipment and computer readable storage medium | |
CN116016495A (en) | File downloading method, device, equipment, storage medium and product | |
CN115543594A (en) | Storage resource allocation method, device, equipment and storage medium | |
CN118170496A (en) | Service discovery method, device, system, equipment, medium and product | |
CN116775673A (en) | Data integration method of multiple data sources and device, equipment, medium and product thereof | |
CN116433374A (en) | Intelligent contract deployment method, device, equipment, storage medium and program product | |
CN116938964A (en) | Method, device, equipment and storage medium for determining resource position | |
CN116028521A (en) | Data processing method, device, equipment, medium and product |
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 |