CN114513469A - Traffic shaping method and device for distributed system and storage medium - Google Patents

Traffic shaping method and device for distributed system and storage medium Download PDF

Info

Publication number
CN114513469A
CN114513469A CN202210143459.1A CN202210143459A CN114513469A CN 114513469 A CN114513469 A CN 114513469A CN 202210143459 A CN202210143459 A CN 202210143459A CN 114513469 A CN114513469 A CN 114513469A
Authority
CN
China
Prior art keywords
data
access request
request message
interface access
service 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.)
Pending
Application number
CN202210143459.1A
Other languages
Chinese (zh)
Inventor
何雨伦
姚积全
唐世昊
唐斐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210143459.1A priority Critical patent/CN114513469A/en
Publication of CN114513469A publication Critical patent/CN114513469A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/22Traffic shaping
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The present application relates to the field of finance, and in particular, to a method, an apparatus, and a storage medium for traffic shaping in a distributed system. In the traffic shaping method, a first service server receives a first interface access request message, wherein the first interface access request message is used for requesting data to be inquired, and the first service server is any one of a plurality of service servers; the first business server sends a first instruction to a remote dictionary service database based on the first interface access request message, wherein the first instruction is used for indicating the remote dictionary service database to add one to the total times recorded in the first data; and if the total number of times after the one adding operation is carried out is less than or equal to the total access number threshold of the plurality of service servers in one traffic shaping period, the first service server executes the operation requested by the first interface access request message. The traffic shaping method realizes efficient traffic shaping available in a distributed scene, and ensures the availability of temporary service when a large amount of burst traffic comes.

Description

Traffic shaping method and device for distributed system and storage medium
Technical Field
The present application relates to the field of finance, and in particular, to a method, an apparatus, and a storage medium for traffic shaping in a distributed system.
Background
Distributed systems (distributed systems) are software systems built on top of a network, which are highly cohesive and transparent because of the nature of the software. In a distributed system, a set of independent computers appear to the user as a unified whole, as if it were a system. The system has various general physical and logical resources, can dynamically allocate tasks, and realizes information exchange by the dispersed physical and logical resources through a computer network.
Due to the rapid development of the internet, in the using process of the distributed system, traffic exceeding an expected traffic may be gushed at any time, and in order to ensure that limited system resources can provide a maximum service capability, the traffic (output or input) of the system needs to be limited according to a preset rule, so that the received traffic does not exceed an upper limit which can be borne by the system, and the system is ensured to run stably. For example, when dealing with scenes with high performance pressure such as killing, promotion, double 11 and the like in seconds, the query rate per second of the distributed system needs to be controlled through flow shaping, so that the purpose of protecting the system is achieved.
However, most of the existing traffic shaping methods are applicable to a single-machine scenario and cannot be directly applied to a distributed system, so how to solve traffic shaping in a distributed scenario becomes a technical problem to be solved urgently.
Disclosure of Invention
The application provides a traffic shaping method, a traffic shaping device and a storage medium of a distributed system, which are used for solving the traffic shaping problem in a distributed scene.
In a first aspect, the present application provides a traffic shaping method for a distributed system, where the distributed system includes a plurality of traffic servers and a remote dictionary service database, where the remote dictionary service database includes first data, and the first data is used to record a total number of times that the traffic servers are accessed in a current traffic shaping cycle, and the method includes: a first service server receives a first interface access request message, wherein the first interface access request message is used for requesting data to be inquired, and the first service server is any one of a plurality of service servers; the first business server sends a first instruction to the remote dictionary service database based on the first interface access request message, wherein the first instruction is used for instructing the remote dictionary service database to add one to the total times recorded in the first data; and if the total number of times after the adding operation is carried out is less than or equal to a total access number threshold value of the service servers in one traffic shaping period, the first service server executes the operation requested by the first interface access request message.
According to the method, the total access times and the total access time threshold of the access requests in the distributed system are judged, so that the available high-efficiency flow shaping in a distributed scene is realized, and the availability of temporary service in a large amount of burst flows is ensured.
With reference to the first aspect, in a possible implementation manner, the remote dictionary service database further includes M second data, where the M second data are in one-to-one correspondence with M interface access request messages received by the multiple service servers, each second data in the M second data is used to record access time of a corresponding interface access request message in the M interface access request messages, and M is a non-negative integer; accordingly, the method further comprises: the first business server sends a second instruction to the remote dictionary service database, wherein the second instruction is used for indicating that second data are added into the remote dictionary service database, and the added second data are used for recording first access time of the first interface access request message; if the total number of times after the adding operation is performed is greater than the total access number threshold, the first service server obtains a time difference between the first access time and second access time based on second data stored in the remote dictionary service database, where the second access time is access time of a second interface access request message in the plurality of interface access request messages, the access time of the second interface access request message is located before the first interface access request, and a preset number of interface access request messages exist between the second access time and the first access time, and the preset number is equal to the total access number threshold; and if the time difference is greater than the duration of the flow shaping period, the first service server executes the operation requested by the first interface access request message.
In the implementation mode, when the total number of times is greater than the total access number threshold, the judgment of whether the interface access request is in the range of current limit is realized through the access time and the current access time corresponding to the preset number of interface access request messages, and the available efficient flow shaping under the distributed scene is also ensured
With reference to the first aspect, in a possible implementation manner, the first data is specifically configured to record a total number of times that the plurality of service servers are accessed by a first user in a current traffic shaping period, the first interface access request message is specifically configured to request the data to be queried for the first user, each interface access request message in the M interface access request messages is configured to request the data to be queried for the first user, and the total access threshold is specifically a threshold of the total number of times that the plurality of service servers are accessed by the first user in one traffic shaping period.
In the implementation mode, the traffic shaping of the access data request by a single user in one traffic shaping period is realized through the limitation of the first interface access request message.
With reference to the first aspect, in a possible implementation manner, each second data in the remote dictionary service database is further configured to record an expiration duration of a corresponding interface access request message.
In the implementation mode, the expiration duration of the interface access request message is increased for the second data, and the second data is cleared after expiration, so that the waste of storage resources can be avoided.
With reference to the first aspect, in a possible implementation manner, the expiration duration is greater than a duration of a traffic shaping period of the distributed system; correspondingly, the obtaining, by the first business server, a time difference between the first access time and the second access time based on the second data stored in the remote dictionary service database further includes: the first business server judges whether the remote dictionary service database contains target second data, wherein the target second data is second data used for recording the access time of the second interface access request message; if the remote dictionary service database does not contain the target second data, the first business server executes the operation requested by the first interface access request message; and if the remote dictionary service database does not contain the target second data, the first service server acquires a time difference value between the first access time and the second access time based on the second data stored in the remote dictionary service database.
In the implementation mode, the target second data is searched in the remote dictionary service database to determine whether the first interface access request message is directly executed at the time, and when the first interface access request message cannot be executed at the time, the time difference between the first access time and the second access time is obtained, so that a judgment basis is provided for subsequently determining whether the first interface access request message can be continuously executed at the time.
With reference to the first aspect, in a possible implementation manner, the first data is further configured to record an initial generation time and an expiration time of the first data.
In the implementation mode, a reference basis is provided for releasing the occupied space of the storage resources in the remote dictionary service database from the initial generation time and the expiration time.
With reference to the first aspect, in a possible implementation manner, before the first service server sends the first instruction to the remote dictionary service database based on the first interface access request message, the method further includes: the first business server sends a third instruction to the remote dictionary service database in response to the first interface access request message, wherein the third instruction is used for instructing the remote dictionary service database to generate the first data under the condition that the first data is not contained, and the value of the total access times in the generated first data is 0.
In the implementation manner, starting from the third instruction, in order to realize that the first data is not found in the remote dictionary service database, the first interface access request message of the time is recorded as the first data, and the value of the total access times is recorded as 0, so that a basis is provided for implementing subsequent efficient traffic shaping.
In a second aspect, the present application provides a traffic shaping apparatus for a distributed system, where the distributed system includes a plurality of traffic servers and a remote dictionary service database, and the remote dictionary service database includes first data, where the first data is used to record the total number of times that the traffic servers are accessed in a current traffic shaping period, and the apparatus includes: a receiving module, configured to receive a first interface access request message, where the first interface access request message is used to request data to be queried, and a first service server is any one of the plurality of service servers; a sending module, configured to send a first instruction to the remote dictionary service database based on the first interface access request message, where the first instruction is used to instruct the remote dictionary service database to add one to the total number of times recorded in the first data; and the execution module is used for executing the operation requested by the first interface access request message if the total number of times after one adding operation is less than or equal to a total access number threshold of the service servers in one flow shaping period.
With reference to the second aspect, in a possible implementation manner, the remote dictionary service database further includes M second data, where the M second data are in one-to-one correspondence with M interface access request messages received by the multiple service servers, each second data in the M second data is used to record access time of a corresponding interface access request message in the M interface access request messages, and M is a non-negative integer; correspondingly, the sending module is further configured to send a second instruction to the remote dictionary service database, where the second instruction is used to instruct the remote dictionary service database to add second data, and the added second data is used to record a first access time of the first interface access request message; the receiving module is further configured to, if the total number of times after the adding operation is greater than the total access number threshold, obtain a time difference between the first access time and second access time based on second data stored in the remote dictionary service database, where the second access time is an access time of a second interface access request message in the plurality of interface access request messages, the access time of the second interface access request message is located before the first interface access request, and a preset number of interface access request messages exists between the second access time and the first access time, where the preset number is equal to the total access number threshold; the execution module is further configured to execute the operation requested by the first interface access request message if the time difference is greater than the duration of the traffic shaping period.
With reference to the second aspect, in a possible implementation manner, the first data is specifically configured to record a total number of times that the plurality of service servers are accessed by a first user in a current traffic shaping cycle, the first interface access request message is specifically configured to request the data to be queried for the first user, each interface access request message in the M interface access request messages is configured to request the data to be queried for the first user, and the total access threshold is specifically a threshold of the total number of times that the plurality of service servers are accessed by the first user in one traffic shaping cycle.
With reference to the second aspect, in a possible implementation manner, each second data in the remote dictionary service database is further used for recording an expiration duration of a corresponding interface access request message.
With reference to the second aspect, in a possible implementation manner, the expiration duration is greater than a duration of one traffic shaping period of the distributed system; correspondingly, the first service server obtains a time difference between the first access time and the second access time based on second data stored in the remote dictionary service database, and the execution module is further configured to determine whether the remote dictionary service database contains target second data, where the target second data is second data used for recording access time of the second interface access request message; the execution module is further configured to execute the operation requested by the first interface access request message if the remote dictionary service database does not contain the target second data; the obtaining module is further configured to obtain a time difference between the first access time and the second access time based on second data stored in the remote dictionary service database if the remote dictionary service database does not include the target second data.
With reference to the second aspect, in a possible implementation manner, the first data is further configured to record an initial generation time and an expiration time of the first data.
With reference to the second aspect, in a possible implementation manner, before the first service server sends the first instruction to the remote dictionary service database based on the first interface access request message, the sending module is further configured to send a third instruction to the remote dictionary service database in response to the first interface access request message, where the third instruction is used to instruct the remote dictionary service database to generate the first data without containing the first data, and a value of the total number of accesses in the generated first data is 0.
In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively coupled to the processor; the memory stores computer-executable instructions; the processor executes computer-executable instructions stored by the memory to implement the method of the first aspect or any one of its possible implementations.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing the method according to the first aspect or any one of the possible implementations thereof when executed by a processor.
In a fifth aspect, the present application provides a computer program product, which comprises a computer program that, when executed by a processor, implements the method of the first aspect or any one of the possible implementations thereof.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
fig. 2 is a flowchart of a traffic shaping method of a distributed system according to an embodiment of the present application;
fig. 3 is a flowchart of a traffic shaping method for a distributed system according to another embodiment of the present application;
FIG. 4 is a schematic block diagram of a traffic shaping device of a distributed system provided by one embodiment of the present application;
fig. 5 is a schematic view of an apparatus according to another embodiment of the present application.
With the above figures, there are shown specific embodiments of the present application, which will be described in more detail below. These drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the inventive concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
A specific application scenario of the present application is shown in fig. 1, and the scenario is based on a distributed system (distributed system), and may include a plurality of servers (e.g., server 101, server 102, and server 103).
A user may access a server in a distributed system through a client of one or more clients (e.g., client 104, client 105).
For example, user a accesses server 101 through client 104, requests server 101 to respond to the interface access request requested by user a, user B accesses server 103 through client 105, requests server 103 to respond to the interface access request requested by user B, and server 103 and server 101 respectively perform the operation requested by the respective interface access request message based on the two interface access requests.
Further, in the process of using the distributed system, there is a possibility that traffic exceeding an expected traffic may be flown in at any time, and in order to ensure that limited system resources can provide a maximum service capability, the traffic (output or input) of the system needs to be limited according to a preset rule, that is, traffic shaping is performed on the system, so that the received traffic does not exceed an upper limit that the system can carry, and the system is ensured to run stably.
In the related art at present, common traffic shaping methods include a counter algorithm, a leaky bucket algorithm, and a token bucket algorithm. The counter algorithm is simple to implement, but cannot deal with the phenomenon of thorny; although the bucket leakage algorithm eliminates the 'spurt phenomenon', the bucket leakage algorithm cannot cope with short-time burst flow; the token bucket algorithm bucket is a good algorithm in a single machine scene, but the mainstream technical architecture is built based on a distributed system at present, and the three algorithms cannot be directly applied to a distributed environment.
That is to say, most of the traffic shaping methods in the prior art are applicable to a single-machine scenario and cannot be directly applied to a distributed system, so how to solve the traffic shaping in the distributed scenario becomes an urgent technical problem to be solved.
In view of the above, the present application provides a traffic shaping method, apparatus and storage medium for a distributed system, which aim to solve the above technical problems in the prior art.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of a traffic shaping method of a distributed system according to an embodiment of the present application. As shown in fig. 2, the method provided in the embodiment of the present application includes S201, S202, and S203. The individual steps in the method shown in fig. 2 are explained in detail below.
S201, a first service server receives a first interface access request message, where the first interface access request message is used to request data to be queried, and the first service server is any one of a plurality of service servers.
In the scheme, the distributed system comprises a plurality of business servers and a remote dictionary service database, wherein the remote dictionary service database (Redis) is a key-value storage system, namely a cross-platform non-relational database.
The remote dictionary service database comprises first data, and the first data is used for recording the total times of the plurality of service servers accessed in the current flow shaping period.
As an example, the plurality of business servers may be the server 101, the server 102, and the server 103 in fig. 1, which are not limited in number, and the first data in the remote dictionary service database records the total number of times that the server 101, the server 102, and the server 103 are accessed by the clients in one traffic shaping period, which is not limited in number.
For example, the first data in the remote dictionary service database may be 25 times, that is, the total number of times that the plurality of traffic servers are accessed in the current traffic shaping period is 25 times.
As a possible implementation manner, the first interface access request message carries a first key (key) for obtaining first data in the remote dictionary service database, that is, the total number of times (value corresponding to the first key) that the first data in the remote dictionary service database is accessed.
Illustratively, the first key may be a custom name, such as zhang san; and the first key can also write the Identity (ID) of the user.
Optionally, the first data is specifically configured to record a total number of times that the plurality of service servers are accessed by the first user in the current traffic shaping period, the first interface access request message is specifically configured to request data to be queried for the first user, each interface access request message in the M interface access request messages is configured to request data to be queried for the first user, and the total access threshold is specifically a threshold of the total number of times that the plurality of service servers are accessed by the first user in one traffic shaping period.
For example, when the first interface access request message is specifically used for requesting data to be queried for the first user, the first key may be a user identifier.
As an example, a total number of times (e.g., 30 times) that the plurality of traffic servers are accessed by the first user over a period of time (i.e., one traffic shaping period, e.g., 30 minutes), i.e., a total access threshold. And each of the M interface access request messages of the first user (e.g., a request message corresponding to each of 25 accesses) is used to request data to be queried (e.g., query data a) for the first user.
Optionally, the client sends a first interface access request message to the server, and the server receives the first interface access request message, where the server is any one of a plurality of service servers in the distributed system.
The first user may refer to a user corresponding to a different client, or may be a unique user, and therefore, in different scenarios, the traffic shaping may refer to all users accessing the data to be queried, or may refer to one user.
S202, the first business server sends a first instruction to the remote dictionary service database based on the first interface access request message, wherein the first instruction is used for indicating the remote dictionary service database to add one to the total times recorded in the first data.
In the scheme, each operation in the remote dictionary service database is an atomic operation, that is, only one operation can be supported at a certain time point, that is, the first interface access request messages received by different service servers are subjected to subsequent processing according to the sequence of the receiving time.
In this step, after receiving the first interface access request message, the first service server needs to add one to the total number of times accessed in the current traffic shaping period in the remote dictionary service database according to the first interface access request message, where the one added is used to determine whether the first interface access request message belongs to the traffic shaping period.
As an example, a first instruction may be sent to the remote dictionary service database, adding 1 to the total number of times recorded in the first data in the remote dictionary service database.
For example, the total number of times may be added by 1 by the "INCR" command, and the return value "INDEX" of "INCR" (the total number of times after adding 1) is obtained as the basis for the determination of the subsequent processing step.
Optionally, the first data is also used for recording the time of the first generation and the time of expiration of the first data. Before this step, the first business server sends a third instruction to the remote dictionary service database in response to the first interface access request message, the third instruction being used for instructing the remote dictionary service database to generate the first data without containing the first data, and the value of the total access times in the generated first data is 0.
For example, a record may be inserted into the remote dictionary service database in an "SETNX" manner, that is, a third instruction is sent, when first data does not exist in the remote dictionary service database, the value of the total number of accesses for generating the first data is 0 (that is, the value corresponding to the first key is 0), at this time, the time of acquiring the third instruction is recorded in the first data, and is recorded as the initial generation time, and at the same time, the expiration time is also recorded.
For example, when the first data does not exist, the remote dictionary service database receives a third instruction sent by the first service server, at this time, the first data is created, and the creation time (initial generation time) is recorded as 2 months, 2 days, 2 o 'clock 2 minutes, and the expiration time is recorded as 2 months, 2 days, 6 o' clock 2 minutes, wherein the expiration time is set by the user and may be any time length longer than one traffic shaping period.
S203, if the total number of times after the adding operation is less than or equal to the total access number threshold of the multiple service servers in one traffic shaping period, the first service server executes the operation requested by the first interface access request message.
In this step, after the total number of times after an operation is added is returned from the remote dictionary service database, the total number of times is compared with a total access number threshold in a traffic shaping period, and it is determined whether the first service server can perform the operation requested by the first interface access request message.
As an example, the number of times after the adding operation is performed is the sum of the number of times of the first interface access request message and the previous request, and if the sum is within the total access number threshold in the traffic shaping period compared with the total access number threshold in the traffic shaping period, the first interface access request message is considered to be executable; if the first interface access request message is not within the total access time threshold value in the traffic shaping period, the first interface access request message is considered to be not executable, and degradation processing and abnormal error reporting can be performed.
For example, the total number of times in the first data in the remote dictionary service database is 25, and after an adding operation, the total number of times is 26, then the total access number threshold in the traffic shaping period is 30, then 26 times is less than 30, that is, the first interface access request message of the time is considered to be within the total access number threshold in the traffic shaping period, that is, the first interface access request message of the time can be executed by the first service server.
For another example, if the total number of times in the first data in the remote dictionary service database is 30 times, and after an adding operation, the number of times is 31 times, then the total access number threshold in the traffic shaping period is 30 times, and 31 times is greater than 30 times, that is, the first interface access request message part is considered to be out of the total access number threshold in the traffic shaping period, that is, the first interface access request message part can be executed by the first service server, and degradation processing and abnormal error reporting should be performed.
In the traffic shaping method for the distributed system provided in the embodiment of the present application, a first service server receives a first interface access request message, where the first interface access request message is used to request data to be queried, the first service server is any one of a plurality of service servers, the first service server sends a first instruction to a remote dictionary service database based on the first interface access request message, where the first instruction is used to instruct the remote dictionary service database to add one to a total number of times recorded in first data, and if the total number of times after adding one is less than or equal to a total access number threshold of the plurality of service servers in one traffic shaping cycle, the first service server executes an operation requested by the first interface access request message. The traffic shaping method realizes efficient traffic shaping available in a distributed scene, and ensures the availability of temporary service when a large amount of burst traffic comes.
Based on fig. 2, fig. 3 is a flowchart of a traffic shaping method of a distributed system according to another embodiment of the present application. As shown in fig. 3, the method provided in the embodiment of the present application further includes S301, S302, and S303. The individual steps in the method shown in fig. 3 are explained in detail below.
In the scheme, the remote dictionary service database further includes M second data, the M second data correspond to M interface access request messages received by the multiple service servers one to one, each second data in the M second data is used for recording access time of a corresponding interface access request message in the M interface access request messages, and M is a non-negative integer, that is, each interface access request message corresponds to time when the interface access request message is received, that is, access time.
S301, the first service server sends a second instruction to the remote dictionary service database, wherein the second instruction is used for indicating that second data are added to the remote dictionary service database, and the added second data are used for recording first access time of the first interface access request message.
In this step, after the first service server receives the first interface access request message, the first service server needs to record the access time of the first interface access request message in the remote dictionary service database, so as to provide a basis for determining whether the first interface access request message needs to respond to the request under the judgment of traffic shaping.
Optionally, the first service server sends a second instruction to the remote dictionary service database, where the second instruction carries a time corresponding to the first interface access request message, and records the time in the remote dictionary service database as the first access time.
In one possible implementation, the access time may be a record inserted into the remote dictionary service database in a "SET" manner, and the value is a current timestamp, i.e., a first access time corresponding to the interface access request message.
For example, the first access time corresponding to the interface access request message may be 2 months, 2 days, 3 points and 2 minutes.
For another example, the second instruction carries a second key, which is used to insert second data into the remote dictionary service database, that is, the first access time (value corresponding to the second key) of the first interface access request message in the remote dictionary service database.
S302, if the total times after the adding operation is larger than the total access time threshold, the first business server obtains a time difference value between the first access time and the second access time based on the second data stored in the remote dictionary service database.
The second access time is the access time of a second interface access request message in the plurality of interface access request messages, the access time of the second interface access request message is located before the first interface access request, a preset number of interface access request messages exist between the second access time and the first access time, and the preset number is equal to the total access time threshold.
In this step, that is, in the judgment of the foregoing embodiment, when the total number of times after the adding operation is greater than the total access number threshold, the first service server obtains the first access time, that is, the current time corresponding to the interface access request message, from the second data stored in the remote dictionary service database, obtains, from the remote dictionary service database, the access time corresponding to the interface access request message (the second interface access request message) having the preset number of times between the first access time and the first access time, and records the access time as the second access time, and then determines the difference between the first access time and the second access time based on the first access time and the second access time.
In a possible implementation, the preset number is equal to the total access time threshold, that is, may be set to 30 times, when the total number after adding one operation is greater than the total access time threshold, the first access time is obtained as 2 months, 2 days, 3 points and 2 minutes, at this time, the access time of the second interface access request message corresponding to 30 times ahead is obtained in the remote dictionary service database, the second access time is obtained as 2 months, 2 days, 2 points and 31 minutes, and at this time, the difference between the first access time and the second access time is 31 minutes.
In another possible implementation, the preset number is equal to the total access time threshold, that is, may be set to 30 times, when the total number after adding one operation is greater than the total access time threshold, the first access time is acquired as 2 months, 2 days, 3 points and 2 minutes, at this time, the access time of the second interface access request message corresponding to 30 times ahead is acquired in the remote dictionary service database, the second access time is acquired as 2 months, 2 days, 2 points and 33 minutes, and at this time, the difference between the first access time and the second access time is 29 minutes.
The preset number may be any number, and the total access time threshold is the maximum access time corresponding to one traffic shaping period.
Further, when the expiration time is longer than the time of a traffic shaping period of the distributed system, the step includes the following 3 sub-steps:
1. and the first business server judges whether the remote dictionary service database contains target second data, wherein the target second data is second data used for recording the access time of the second interface access request message.
Optionally, it is determined whether the target second data exists in the remote dictionary service database, that is, the access time corresponding to the interface access request message (second interface access request message) having the total access time threshold between the first access times is searched in the remote dictionary service database.
As a possible implementation manner, the index bit in the current second key is pushed forward to a position corresponding to the total access time threshold, that is, to be a third key (i.e., the target second data), and at this time, an "EXISTS" command is used to query whether the third key EXISTS (i.e., whether the remote dictionary service database includes the target second data).
2. And if the remote dictionary service database does not contain the target second data, the first business server executes the operation requested by the first interface access request message.
Optionally, if the remote dictionary service database does not include the target second data, that is, the second data corresponding to the first interface access request message is the initial generation time, or the total access time has not reached the total time threshold in a traffic shaping period, the first interface access request message may be allowed to perform the requested operation.
3. And if the remote dictionary service database contains the target second data, the first business server acquires a time difference value between the first access time and the second access time based on the second data stored in the remote dictionary service database.
Optionally, if the remote dictionary service database includes the target second data, that is, the second data corresponding to the first interface access request message is the access time corresponding to the interface access request message (second interface access request message) having the total access time threshold between the first access times.
Further, a time difference between the first access time and the second access time is calculated.
Optionally, each second data in the remote dictionary service database is further used for recording an expiration time of the corresponding interface access request message.
For example, the remote dictionary service database may periodically check the access time and the expiration time of each second data, and if the time between the access time corresponding to a certain second data so far exceeds the expiration time, the information is cleared to avoid wasting storage resources.
S303, if the time difference is greater than the duration of the traffic shaping period, the first service server executes the operation requested by the first interface access request message.
In this step, a time difference between the first access time and the second access time is greater than a duration of the traffic shaping period, that is, a time length between the first interface access request message and the second interface access request message is greater than the duration of the traffic shaping period, that is, a forward total access number threshold of the first interface access request message is received before the traffic shaping period, and then the first interface access request message is an access corresponding to a new traffic shaping period, that is, the first service server is allowed to execute an operation requested by the first interface access request message.
Optionally, following the example in step S302:
in one possible implementation, when the difference between the first access time and the second access time is 31 minutes and the traffic shaping period is 30 minutes, the first service server performs the operation requested by the first interface access request message.
In another possible implementation, when the difference between the first access time and the second access time is 29 minutes and the traffic shaping period is 30 minutes, the first service server may not perform the operation requested by the first interface access request message for a while.
Fig. 4 illustrates a traffic shaping apparatus 400 of a distributed system according to an embodiment of the present application, where the apparatus 400 includes: a receiving module 401, a sending module 402 and an executing module 403.
The receiving module 401 is configured to receive a first interface access request message, where the first interface access request message is used to request data to be queried, and the first service server is any one of multiple service servers; a sending module 402, configured to send a first instruction to the remote dictionary service database based on the first interface access request message, where the first instruction is used to instruct the remote dictionary service database to add one to the total number of times recorded in the first data; an executing module 403, configured to execute the operation requested by the first interface access request message if the total number of times after performing the add operation is less than or equal to a total access number threshold of the multiple service servers in one traffic shaping period.
As an example, the apparatus 400 may be configured to perform the method shown in fig. 2, for example, the receiving module 401 is configured to perform S201, the sending module 402 is configured to perform S202, and the executing module 403 is configured to perform S203.
In a possible implementation manner, the remote dictionary service database further includes M second data, the M second data correspond to M interface access request messages received by the multiple service servers one to one, each second data in the M second data is used for recording access time of a corresponding interface access request message in the M interface access request messages, and M is a non-negative integer; correspondingly, the sending module 402 is further configured to send a second instruction to the remote dictionary service database, where the second instruction is used to instruct the remote dictionary service database to add second data, and the added second data is used to record a first access time of the first interface access request message; the receiving module 401 is further configured to, if the total number of times after the adding operation is greater than the total access number threshold, obtain a time difference between first access time and second access time based on second data stored in the remote dictionary service database, where the second access time is access time of a second interface access request message in the multiple interface access request messages, the access time of the second interface access request message is located before the first interface access request, and a preset number of interface access request messages exists between the second access time and the first access time, and the preset number is equal to the total access number threshold; the executing module 403 is further configured to execute the operation requested by the first interface access request message if the time difference is greater than the duration of the traffic shaping period.
In a possible implementation manner, the first data is specifically used to record the total number of times that the plurality of service servers are accessed by the first user in the current traffic shaping period, the first interface access request message is specifically used to request the data to be queried for the first user, each interface access request message in the M interface access request messages is used to request the data to be queried for the first user, and the total access threshold is specifically a threshold of the total number of times that the plurality of service servers are accessed by the first user in one traffic shaping period.
In one possible implementation, each second data in the remote dictionary service database is further used for recording an expiration time of the corresponding interface access request message.
In one possible implementation, the expiration duration is greater than the duration of one traffic shaping period of the distributed system; correspondingly, the first service server obtains a time difference between the first access time and the second access time based on second data stored in the remote dictionary service database, and the execution module 403 is further configured to determine whether the remote dictionary service database contains target second data, where the target second data is second data used for recording access time of the second interface access request message; the executing module 403 is further configured to execute the operation requested by the first interface access request message if the remote dictionary service database does not contain the target second data; the receiving module 401 is further configured to, if the remote dictionary service database does not include the target second data, obtain a time difference between the first access time and the second access time based on the second data stored in the remote dictionary service database.
In one possible implementation, the first data is further used to record an initial generation time and an expiration time of the first data.
In a possible implementation manner, before the first service server sends the first instruction to the remote dictionary service database based on the first interface access request message, the sending module 402 is further configured to send a third instruction to the remote dictionary service database in response to the first interface access request message, where the third instruction is used to instruct the remote dictionary service database to generate the first data without containing the first data, and a value of a total access number in the generated first data is 0.
Fig. 5 is a schematic view of an apparatus according to another embodiment of the present application. The apparatus shown in fig. 5 may be used to perform the method described in any of the previous embodiments.
As shown in fig. 5, the apparatus 500 of the present embodiment includes: memory 501, processor 502, communication interface 503, and bus 504. The memory 501, the processor 502 and the communication interface 503 are connected to each other by a bus 504.
The memory 501 may be a Read Only Memory (ROM), a static memory device, a dynamic memory device, or a Random Access Memory (RAM). The memory 501 may store a program and the processor 502 is adapted to perform the steps of the method shown in the above embodiments when the program stored in the memory 501 is executed by the processor 502.
The processor 502 may be a general-purpose Central Processing Unit (CPU), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits, and is configured to execute related programs to implement the methods shown in the embodiments of the present application.
The processor 502 may also be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the method of the embodiment of the present application may be implemented by integrated logic circuits of hardware or instructions in the form of software in the processor 502.
The processor 502 may also be a general purpose processor, a Digital Signal Processor (DSP), an ASIC, an FPGA (field programmable gate array) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 501, and the processor 502 reads the information in the memory 501, and in combination with the hardware thereof, performs the functions that the unit included in the apparatus of the present application needs to perform.
The communication interface 503 may enable communication between the apparatus 500 and other devices or communication networks using, but not limited to, transceiver means such as transceivers.
Bus 504 may include a path that transfers information between various components of apparatus 500 (e.g., memory 501, processor 502, communication interface 503).
It should be understood that the apparatus 500 shown in the embodiments of the present application may be an electronic device, or may also be a chip configured in the electronic device.
It should be noted that the traffic shaping method, apparatus, and storage medium of the distributed system provided in the present application may be used in the financial field, and may also be used in any field other than the financial field. The application of the method, the device and the storage medium for traffic shaping of the distributed system is not limited.
It should be understood that the term "and/or" herein is merely one type of association relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. In addition, the "/" in this document generally indicates that the former and latter associated objects are in an "or" relationship, but may also indicate an "and/or" relationship, which may be understood with particular reference to the former and latter text.
In the present application, "at least one" means one or more, "a plurality" means two or more. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of the singular or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, a-b, a-c, b-c or a-b-c, wherein a, b and c can be single or multiple.
It should be understood that, in the various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: u disk, removable hard disk, read only memory, random access memory, magnetic or optical disk, etc. for storing program codes.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (11)

1. A traffic shaping method for a distributed system, wherein the distributed system includes a plurality of traffic servers and a remote dictionary service database, the remote dictionary service database includes first data, and the first data is used to record the total number of times that the plurality of traffic servers are accessed in a current traffic shaping period, and the method includes:
a first service server receives a first interface access request message, wherein the first interface access request message is used for requesting data to be inquired, and the first service server is any one of a plurality of service servers;
the first business server sends a first instruction to the remote dictionary service database based on the first interface access request message, wherein the first instruction is used for instructing the remote dictionary service database to add one to the total times recorded in the first data;
and if the total number of times after the adding operation is carried out is less than or equal to a total access number threshold value of the service servers in one traffic shaping period, the first service server executes the operation requested by the first interface access request message.
2. The method according to claim 1, wherein the remote dictionary service database further includes M second data, the M second data corresponds to M interface access request messages received by the plurality of service servers in a one-to-one manner, each second data in the M second data is used for recording an access time of a corresponding interface access request message in the M interface access request messages, and M is a non-negative integer;
accordingly, the method further comprises:
the first business server sends a second instruction to the remote dictionary service database, wherein the second instruction is used for indicating that second data are added into the remote dictionary service database, and the added second data are used for recording first access time of the first interface access request message;
if the total number of times after the adding operation is greater than the total access number threshold, the first service server obtains a time difference between the first access time and second access time based on second data stored in the remote dictionary service database, where the second access time is access time of a second interface access request message in the plurality of interface access request messages, the access time of the second interface access request message is located before the first interface access request, a preset number of interface access request messages exists between the second access time and the first access time, and the preset number is equal to the total access number threshold;
and if the time difference is greater than the duration of the flow shaping period, the first service server executes the operation requested by the first interface access request message.
3. The method according to claim 2, wherein the first data is specifically configured to record a total number of times that the plurality of traffic servers are accessed by a first user in a current traffic shaping cycle, the first interface access request message is specifically configured to request the data to be queried for the first user, each interface access request message in the M interface access request messages is configured to request the data to be queried for the first user, and the total access threshold is specifically a threshold of the total number of times that the plurality of traffic servers are accessed by the first user in one traffic shaping cycle.
4. A method according to claim 2 or 3, wherein each second datum in the remote dictionary service database is also used to record the expiry date of the corresponding interface access request message.
5. The method of claim 4, wherein the expiration time period is greater than a time period of a traffic shaping period of the distributed system;
correspondingly, the obtaining, by the first business server, a time difference between the first access time and the second access time based on the second data stored in the remote dictionary service database further includes:
the first business server judges whether the remote dictionary service database contains target second data, wherein the target second data is second data used for recording the access time of the second interface access request message;
if the remote dictionary service database does not contain the target second data, the first business server executes the operation requested by the first interface access request message;
and if the remote dictionary service database does not contain the target second data, the first service server acquires a time difference value between the first access time and the second access time based on the second data stored in the remote dictionary service database.
6. The method of claim 1, wherein the first data is further used to record an initial generation time and an expiration time of the first data.
7. The method of claim 1, wherein prior to the first traffic server sending a first instruction to the remote dictionary service database based on the first interface access request message, the method further comprises:
the first business server sends a third instruction to the remote dictionary service database in response to the first interface access request message, wherein the third instruction is used for instructing the remote dictionary service database to generate the first data under the condition that the first data is not contained, and the value of the total access times in the generated first data is 0.
8. A traffic shaping apparatus for a distributed system, wherein the distributed system includes a plurality of traffic servers and a remote dictionary service database, the remote dictionary service database includes first data, and the first data is used to record the total number of times that the plurality of traffic servers are accessed in a current traffic shaping period, the apparatus comprising:
the device comprises a receiving module, a query module and a query module, wherein the receiving module is used for receiving a first interface access request message which is used for requesting data to be queried;
a sending module, configured to send a first instruction to the remote dictionary service database based on the first interface access request message, where the first instruction is used to instruct the remote dictionary service database to add one to the total number of times recorded in the first data;
and the execution module is used for executing the operation requested by the first interface access request message if the total number of times after one adding operation is less than or equal to a total access number threshold of the service servers in one flow shaping period.
9. An electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored by the memory to implement the method of any of claims 1 to 7.
10. A computer-readable storage medium having computer-executable instructions stored therein, which when executed by a processor, are configured to implement the method of any one of claims 1 to 7.
11. A computer program product, characterized in that a computer program is included in the computer program product, which computer program, when being executed by a processor, is adapted to carry out the method of any one of claims 1 to 7.
CN202210143459.1A 2022-02-16 2022-02-16 Traffic shaping method and device for distributed system and storage medium Pending CN114513469A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210143459.1A CN114513469A (en) 2022-02-16 2022-02-16 Traffic shaping method and device for distributed system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210143459.1A CN114513469A (en) 2022-02-16 2022-02-16 Traffic shaping method and device for distributed system and storage medium

Publications (1)

Publication Number Publication Date
CN114513469A true CN114513469A (en) 2022-05-17

Family

ID=81550802

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210143459.1A Pending CN114513469A (en) 2022-02-16 2022-02-16 Traffic shaping method and device for distributed system and storage medium

Country Status (1)

Country Link
CN (1) CN114513469A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115442307A (en) * 2022-07-27 2022-12-06 交通银行股份有限公司 Distributed key-based current limiting method, system and computer-readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109194584A (en) * 2018-08-13 2019-01-11 中国平安人寿保险股份有限公司 A kind of flux monitoring method, device, computer equipment and storage medium
CN112671897A (en) * 2020-12-22 2021-04-16 北京达佳互联信息技术有限公司 Access method, device, storage medium, equipment and product of distributed system
CN113010818A (en) * 2021-02-23 2021-06-22 腾讯科技(深圳)有限公司 Access current limiting method and device, electronic equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109194584A (en) * 2018-08-13 2019-01-11 中国平安人寿保险股份有限公司 A kind of flux monitoring method, device, computer equipment and storage medium
CN112671897A (en) * 2020-12-22 2021-04-16 北京达佳互联信息技术有限公司 Access method, device, storage medium, equipment and product of distributed system
CN113010818A (en) * 2021-02-23 2021-06-22 腾讯科技(深圳)有限公司 Access current limiting method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115442307A (en) * 2022-07-27 2022-12-06 交通银行股份有限公司 Distributed key-based current limiting method, system and computer-readable storage medium

Similar Documents

Publication Publication Date Title
US11755530B2 (en) Method and system for applying data retention policies in a computing platform
CN110188096B (en) Index creating method, device and equipment for data record
US11379836B2 (en) Methods and systems for recording data based on plurality of blockchain networks
CN110162526B (en) Method, device and equipment for inquiring data records in block chain type account book
WO2019041738A1 (en) Client resource obtaining method and apparatus, terminal device, and storage medium
US11050550B2 (en) Methods and systems for reading data based on plurality of blockchain networks
CN104601696A (en) Service processing method and service invoking frame, device and architecture
US11500861B2 (en) Methods and systems for recording data based on plurality of blockchain networks
CN110474775B (en) User creating method, device and equipment in block chain type account book
CN111815454A (en) Data uplink method and device, electronic equipment and storage medium
CN110597461B (en) Data storage method, device and equipment in block chain type account book
CN115756955A (en) Data backup and data recovery method and device and computer equipment
CN111444216A (en) Data block deleting method based on centralized block chain type account book
CN106570005A (en) Database cleaning method and device
CN114513469A (en) Traffic shaping method and device for distributed system and storage medium
CN115242872B (en) Data processing method, device, computer equipment and readable storage medium
US11086849B2 (en) Methods and systems for reading data based on plurality of blockchain networks
CN110059081A (en) Data output method, device and the computer equipment shown based on data
CN110874268B (en) Data processing method, device and equipment
CN111161019B (en) Data processing system and method
CN110874486A (en) Data reading method, device and equipment in block chain type account book
CN111291296A (en) Content issuing method and device
CN115858423A (en) Switching method and device of cache elimination strategies, electronic equipment and storage medium
CN111831519A (en) Data acquisition method, device and equipment
CN110209679A (en) A kind of date storage method for promoting access efficiency, terminal device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20220517

RJ01 Rejection of invention patent application after publication