CN113726885A - Method and device for adjusting flow quota - Google Patents

Method and device for adjusting flow quota Download PDF

Info

Publication number
CN113726885A
CN113726885A CN202111005526.5A CN202111005526A CN113726885A CN 113726885 A CN113726885 A CN 113726885A CN 202111005526 A CN202111005526 A CN 202111005526A CN 113726885 A CN113726885 A CN 113726885A
Authority
CN
China
Prior art keywords
data object
flow
traffic
object set
quota
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
CN202111005526.5A
Other languages
Chinese (zh)
Inventor
刘中砥
柴社荣
徐超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Skyguard Network Security Technology Co ltd
Original Assignee
Beijing Skyguard Network Security Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Skyguard Network Security Technology Co ltd filed Critical Beijing Skyguard Network Security Technology Co ltd
Priority to CN202111005526.5A priority Critical patent/CN113726885A/en
Publication of CN113726885A publication Critical patent/CN113726885A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/566Grouping or aggregating service requests, e.g. for unified processing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/06Generation of reports
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control

Abstract

The invention discloses a method and a device for adjusting a flow quota, and relates to the technical field of computers. One embodiment of the method comprises: receiving one or more flow transmission requests, and respectively determining a user identifier according to request information in the flow transmission requests aiming at each flow transmission request; searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set; and adjusting the flow quota corresponding to each data object according to the flow quota strategy and the flow value of each data object in the data object set. According to the embodiment, the flow counting efficiency and the flow quota adjusting efficiency are improved, and the accuracy of the adjusted flow quota is guaranteed.

Description

Method and device for adjusting flow quota
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for adjusting a traffic quota.
Background
As a bridge for connecting a network terminal (e.g., a client) and another network terminal (e.g., a target server), the proxy server needs to not only ensure privacy and security of the network terminal, but also count a traffic value corresponding to the network terminal in a traffic transmission process, adjust a traffic quota (remaining traffic quota) corresponding to the network terminal in combination with a traffic quota policy, and perform corresponding operations (e.g., warning, current limiting, etc.).
The prior art has at least the following problems:
when the external database is adopted to count the flow value in the existing method, the performance of the external database needs to be relied on, and the database needs to be regularly maintained; when the flow value is counted in a log recording mode, because real-time counting is difficult to realize, the counted flow value has certain hysteresis, and the accuracy of the adjusted flow quota is low; and a single-process multi-thread mode is adopted, and the flow values which are respectively counted are inserted into values, so that locking and unlocking operations need to be executed, the counting time of the flow values is prolonged, and the adjustment efficiency is low.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for adjusting a traffic quota, which can construct a data object for each client in a proxy server, and when a traffic transmission request is initiated each time, only a corresponding data object needs to be searched, so that a traffic value corresponding to the client in a traffic transmission process can be counted in real time, thereby improving traffic counting efficiency, further improving efficiency of adjusting the traffic quota, and ensuring accuracy of the adjusted traffic quota.
In order to achieve the above object, according to a first aspect of the embodiments of the present invention, a method for adjusting a traffic quota is provided, including:
receiving one or more flow transmission requests, and respectively determining a user identifier according to request information in the flow transmission requests aiming at each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server;
searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification;
carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set;
and adjusting the flow quota corresponding to each data object according to the flow quota strategy and the flow value of each data object in the data object set.
Further, if it is determined that the first data object corresponding to the user identifier does not exist in the process of searching the data object set, the method further includes:
creating a second data object according to the user identification;
and performing statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the second data object, and writing the statistical operation result into the second data object.
Further, after the step of writing the result of the statistical operation to the second data object, the method further comprises:
judging whether a data object corresponding to the user identifier exists in the data object set or not;
if so, acquiring an address corresponding to the data object corresponding to the user identifier in the data object set, and writing the flow value counted in the second data object into the address;
and if not, locking the data object set, and inserting the second data object into the data object set successfully subjected to locking.
Further, the locking processing is performed on the data object set, and the inserting of the second data object into the data object set which is successfully locked includes:
locking the data object set, and judging whether the locking is successful;
and if the locking processing fails, placing the second data object in the candidate queue, so that the candidate queue performs locking processing on the data object set again until the locking processing is successful.
Further, if the locking process is successful, the method further comprises:
judging whether a data object corresponding to the user identifier exists in the data object set which is successfully locked again according to the user identifier;
if the traffic value exists, taking a data object corresponding to the user identifier in the data object set as a target data object, and writing the traffic value counted in the second data object into the target data object;
and if not, inserting the second data object into the data object set.
Further, performing a statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object includes:
and counting the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object in an atomic operation mode.
According to a second aspect of the embodiments of the present invention, there is provided a device for adjusting a traffic quota, including:
the receiving module is used for receiving one or more flow transmission requests, and for each flow transmission request, the user identification is determined according to the request information in the flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server;
the first data object determining module is used for searching from the data object set according to the user identification to determine a first data object and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification;
the statistical module is used for performing statistical operation on a traffic value transmitted corresponding to a traffic transmission request corresponding to the first data object and writing a statistical operation result into an address of the first data object corresponding to the data object set;
and the adjusting module is used for adjusting the flow quota corresponding to each data object according to the flow quota strategy and the flow value of each data object in the data object set.
Further, the system also comprises a second data object creating module, and if the first data object corresponding to the user identifier does not exist in the searching process of the data object set, the second data object creating module determines that the first data object corresponding to the user identifier does not exist; a second data object creation module to:
creating a second data object according to the user identification;
and performing statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the second data object, and writing the statistical operation result into the second data object.
According to a third aspect of embodiments of the present invention, there is provided an electronic apparatus, including:
one or more processors;
a storage device for storing one or more programs,
when executed by one or more processors, the one or more programs cause the one or more processors to implement any of the methods for adjusting traffic quotas described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer-readable medium, on which a computer program is stored, which when executed by a processor, implements any one of the above-mentioned methods for adjusting a traffic quota.
One embodiment of the above invention has the following advantages or benefits: because one or more flow transmission requests are received, and the user identifier is determined according to the request information in the flow transmission request aiming at each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server; searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification; carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set; the technical means of adjusting the flow quota corresponding to each data object according to the flow quota policy and the flow value of each data object in the data object set overcome the technical problems of dependence on the performance of an external database, low adjustment efficiency and low accuracy of the adjusted flow quota in the existing method, and further achieve the technical effects of improving the flow statistical efficiency, improving the efficiency of adjusting the flow quota and ensuring the accuracy of the adjusted flow quota.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a method for adjusting a traffic quota according to a first embodiment of the present invention;
fig. 2 is a schematic diagram of a main flow of a method for adjusting a traffic quota according to a second embodiment of the present invention;
fig. 3 is a schematic diagram of main modules of an apparatus for adjusting a traffic quota, according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of a method for adjusting a traffic quota according to a first embodiment of the present invention; as shown in fig. 1, a method for adjusting a traffic quota according to an embodiment of the present invention mainly includes:
step S101, receiving one or more flow transmission requests, and determining a user identifier according to request information in the flow transmission requests for each flow transmission request; the traffic transmission request comprises an access request sent by a client in the current traffic transmission request and a response request returned by the target server.
Specifically, according to the embodiment of the present invention, for the multiple traffic transmission requests, the multiple traffic transmission requests may be sent by one network terminal, or may be sent by multiple network terminals, and one network terminal (e.g., a client) may initiate multiple traffic transmission requests at the same time.
Further, according to the embodiment of the present invention, an interaction between the client and the target server is involved in one traffic transmission process, and the traffic value in the subsequent determination of the current traffic transmission process is also referred to as a traffic value generated in one interaction process (request and response).
Illustratively, the request information includes information such as a user number, an IP address, and a port number, and a unique user identifier is determined according to the request information, which is helpful for subsequently determining a data object corresponding to the user identifier, so as to perform statistics on a traffic value in a traffic transmission process.
Step S102, searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification.
Through the setting, the first data object is determined from the data object set according to the unique user identifier corresponding to the flow transmission request, the flow value in the flow transmission request is counted on the basis of the flow value counted by the data object, the total flow value corresponding to the user in the process of multiple flow transmission requests is determined conveniently, and the flow quota is adjusted conveniently subsequently. On the other hand, the address of the first data object corresponding to the data object set is obtained, which is helpful for directly writing the traffic value counted in the current traffic transmission process into the address, namely directly writing the traffic value into the first data object corresponding to the user identifier in the data object set, so that the real-time counting of the traffic value is realized, the counting efficiency of the traffic value is improved, and the adjustment efficiency of the traffic quota is further improved.
Further, according to the embodiment of the present invention, if it is determined that the first data object corresponding to the user identifier does not exist in the process of searching the data object set, the method further includes:
creating a second data object according to the user identification;
and performing statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the second data object, and writing the statistical operation result into the second data object.
In the actual implementation process, after the user identifier is determined, firstly, whether a first data object corresponding to the user identifier exists in a data object set is inquired and judged, and if the first data object exists, a corresponding address of the first data object in the data object set is obtained; if not, the first data object corresponding to the user identifier is not existed in the data object set, that is, the client corresponding to the user identifier has not initiated the request for the excessive flow transmission and has not generated the excessive flow value, at this time, the second data object is reconstructed according to the user identifier and is used as the data object for the flow value statistics in the current transmission process. Through the arrangement, even if the client initiating the flow transmission request does not have a corresponding data object in the data object set, the flow value statistics can be carried out by establishing the data object, and then the data object set is updated according to the second data object, so that the statistical efficiency and the statistical accuracy of the flow value are ensured, and meanwhile, even if a plurality of flow transmission requests initiated by the client corresponding to the user identification are received, the flow value corresponding to each flow transmission request can be simultaneously counted, the iterative statistics is carried out on the total flow value, the statistical efficiency is improved, and the statistical error is avoided.
Preferably, according to an embodiment of the present invention, after the step of writing the result of the statistical operation into the second data object, the method further includes:
judging whether a data object corresponding to the user identifier exists in the data object set or not;
if so, acquiring an address corresponding to the data object corresponding to the user identifier in the data object set, and writing the flow value counted in the second data object into the address;
and if not, locking the data object set, and inserting the second data object into the data object set successfully subjected to locking.
In a specific embodiment, in the process of constructing a new data object (i.e., a second data object) according to a user identifier, a data object corresponding to the user identifier may have been inserted into a data object set by other statistical units, and in order to avoid that multiple data objects exist in the data object set for the same user identifier, before inserting a newly constructed target data object into the data object set, it is necessary to determine again whether a data object corresponding to the user identifier exists in the data object set.
According to another specific implementation manner of the embodiment of the present invention, since the same client may initiate multiple traffic transmission requests simultaneously, at this time, second data objects are respectively constructed for the user identifier corresponding to each traffic transmission request, that is, before inserting a data object set, multiple second data objects may have been constructed for the same user identifier, if a second data object is directly inserted into the data object set, after the client initiates a traffic transmission request again, multiple data objects corresponding to the user identifier may be queried in the data object set, so that complexity of determining a target data object is increased, a difficulty coefficient is further added to summarization of a total traffic value corresponding to the user identifier, and more statistical time of the traffic value is consumed. Therefore, when the newly constructed second data object is inserted into the data object set, the data object set needs to be locked, and after the locking is successful, the newly constructed second data object is inserted into the data object set.
Through the setting, before the flow value statistics is executed, the data object corresponding to the user identifier is effectively ensured to exist, and the flow value generated by the client corresponding to the user identifier in the flow transmission process is counted (if the data set has the first data correspondence, the flow value counted in the current flow transmission process is directly summarized to the original flow value counted according to the address of the first data object), so that the real-time performance of the flow statistics is ensured, and the adjustment efficiency of the flow quota is improved.
Illustratively, according to the embodiment of the present invention, the locking processing on the data object set and the inserting the second data object into the data object set successfully subjected to the locking processing include:
locking the data object set, and judging whether the locking is successful;
and if the locking processing fails, placing the second data object in the candidate queue, so that the candidate queue performs locking processing on the data object set again until the locking processing is successful.
Specifically, when the locking fails, the target data object to be inserted into the data object set is placed in the candidate queue, so that the locking processing is performed subsequently.
Further, according to the embodiment of the present invention, if the locking process is successful, the method further includes:
judging whether a data object corresponding to the user identifier exists in the data object set which is successfully locked again according to the user identifier;
if the traffic value exists, taking a data object corresponding to the user identifier in the data object set as a target data object, and writing the traffic value counted in the second data object into the target data object;
and if not, inserting the second data object into the data object set.
In specific implementation, when the locking process may be performed last time, corresponding data objects are inserted for the same user identifier, and in order to ensure that only the uniquely corresponding data object exists for the same user identifier in the data object set, it is necessary to query and determine whether the data object corresponding to the user identifier exists in the data object set again. If the data object exists, taking the data object corresponding to the user identifier in the data object set as a target data object corresponding to the user identifier, namely updating the target data object and acquiring the address of the target data object; and if the flow value does not exist, inserting a second data object which is newly created and completes the flow value statistics in the current flow transmission process into the data object set, and updating the data object set.
Step S103, performing a statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing a statistical operation result into an address of the first data object in the data object set.
Specifically, according to the embodiment of the present invention, the performing a statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object includes:
and counting the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object in an atomic operation mode.
Atomic operations refer to operations that are not interrupted by a thread scheduling mechanism, and once started, run to the end without switching to another thread in the middle. Counting in an atomic operation mode: when multiple threads add operations to the same counter (the traffic values counted by multiple traffic transmission requests initiated by the same client are superimposed on the original statistical value of the same data object), if the locking is not performed, the counter value (the superimposed total statistical value) is inaccurate, and if the locking operation is performed to the same counter value, multiple threads compete for the same lock, so that the calculation efficiency is reduced. By using the atomic operation, an operation lock is not needed, the calculation operation is completed by the compiler and the hardware, the calculation performance is improved, and the realization of the logic is simpler.
According to the embodiment of the present invention, in a specific implementation, the same client may initiate multiple traffic transmission requests at the same time, that is, multiple statistical units all obtain data object addresses corresponding to the same user identifier from a data object set, and write corresponding traffic values into the corresponding addresses in the traffic transmission process of each statistical unit. Through atomic operation, multiple writing of the same data object is realized, and errors in writing (summarizing, and overlaying of newly written data to the original statistical flow value) of multiple statistical values are avoided.
And step S104, adjusting the flow quota corresponding to each data object according to the flow quota strategy and the flow value of each data object in the data object set.
The proxy server establishes a flow quota policy according to network bandwidth, data of a network terminal (client) initiating access and the like, adjusts a flow quota (residual flow quota) corresponding to each data object in a data object set by combining flow values (a total flow value updated in real time and including a flow value generated in each flow transmission process) corresponding to each data object, and executes corresponding operations (such as warning, current limiting and the like) according to the flow quota of each data object.
According to the technical scheme of the embodiment of the invention, one or more flow transmission requests are received, and the user identification is determined according to the request information in the flow transmission request aiming at each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server; searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification; carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set; the technical means of adjusting the flow quota corresponding to each data object according to the flow quota policy and the flow value of each data object in the data object set overcome the technical problems of dependence on the performance of an external database, low adjustment efficiency and low accuracy of the adjusted flow quota in the existing method, and further achieve the technical effects of improving the flow statistical efficiency, improving the efficiency of adjusting the flow quota and ensuring the accuracy of the adjusted flow quota.
Fig. 2 is a schematic diagram of a main flow of a method for adjusting a traffic quota according to a second embodiment of the present invention; as shown in fig. 2, a method for adjusting a traffic quota according to an embodiment of the present invention mainly includes:
step S201, receiving one or more traffic transmission requests, and determining a user identifier according to request information in the traffic transmission request for each traffic transmission request. The traffic transmission request comprises an access request sent by a client in the current traffic transmission request and a response request returned by the target server.
Specifically, according to the embodiment of the present invention, for the multiple traffic transmission requests, the multiple traffic transmission requests may be sent by one network terminal, or may be sent by multiple network terminals, and one network terminal (e.g., a client) may initiate multiple traffic transmission requests at the same time.
Illustratively, the request information includes information such as a user number, an IP address, and a port number, and a unique user identifier is determined according to the request information, which is helpful for subsequently determining a data object corresponding to the user identifier, so as to perform statistics on a traffic value in a traffic transmission process.
Further, according to a specific implementation manner of the embodiment of the present invention, a state machine in the proxy server may be used to receive the traffic transmission request, and a traffic value generated by an interaction (including a request of the client and a response of the server) between the client and the server is counted by the state machine.
Step S202, searching from the data object set according to the user identification, and judging whether a first data object corresponding to the user identification exists. If yes, go to step S203; if not, go to step S204.
Specifically, the data object is used to indicate the correspondence between the user identifier and the traffic value correspondingly transmitted by the user identifier.
Step S203, acquiring the corresponding address of the first data object in the data object set, performing a statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the corresponding address of the first data object in the data object set.
Through the setting, the first data object is determined from the data object set according to the unique user identifier corresponding to the flow transmission request, the flow value in the flow transmission request is counted on the basis of the flow value counted by the data object, the total flow value corresponding to the user in the process of multiple flow transmission requests is determined conveniently, and the flow quota is adjusted conveniently subsequently. On the other hand, the address of the first data object corresponding to the data object set is obtained, which is helpful for directly writing the traffic value counted in the current traffic transmission process into the address, namely directly writing the traffic value into the first data object corresponding to the user identifier in the data object set, so that the real-time counting of the traffic value is realized, the counting efficiency of the traffic value is improved, and the adjustment efficiency of the traffic quota is further improved.
Step S204, creating a second data object according to the user identification; and performing statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the second data object, and writing the statistical operation result into the second data object.
In the actual implementation process, after the user identifier is determined, firstly, whether a first data object corresponding to the user identifier exists in a data object set is inquired and judged, and if the first data object exists, a corresponding address of the first data object in the data object set is obtained; if not, the first data object corresponding to the user identifier is not existed in the data object set, that is, the client corresponding to the user identifier has not initiated the request for the excessive flow transmission and has not generated the excessive flow value, at this time, the second data object is reconstructed according to the user identifier and is used as the data object for the flow value statistics in the current transmission process. Through the arrangement, even if the client initiating the flow transmission request does not have a corresponding data object in the data object set, the flow value statistics can be carried out by establishing the data object, and then the data object set is updated according to the second data object, so that the statistical efficiency and the statistical accuracy of the flow value are ensured, and meanwhile, even if a plurality of flow transmission requests initiated by the client corresponding to the user identification are received, the flow value corresponding to each flow transmission request can be simultaneously counted, the iterative statistics is carried out on the total flow value, the statistical efficiency is improved, and the statistical error is avoided.
According to a specific implementation manner of the embodiment of the present invention, in order to distinguish between a first data object (already stored in the data object set) and a second data object (newly created and not yet inserted into the data object set), the first data object and the second data object may be distinguished according to a parameter in db of the data object, and for the data object already stored in the data object set, an in db parameter is true; if not already stored in the set of data objects (e.g., the newly created second data object), the in db parameter is false.
Step S205, judging whether a data object corresponding to the user identification exists in the data object set; if so, acquiring an address corresponding to the data object corresponding to the user identifier in the data object set, and writing the flow value counted in the second data object into the address; and if not, locking the data object set, and inserting the second data object into the data object set successfully subjected to locking.
In a specific embodiment, in the process of constructing a new data object (i.e., a second data object) according to a user identifier, a data object corresponding to the user identifier may have been inserted into a data object set by other statistical units, and in order to avoid that multiple data objects exist in the data object set for the same user identifier, before inserting a newly constructed target data object into the data object set, it is necessary to determine again whether a data object corresponding to the user identifier exists in the data object set.
According to another specific implementation manner of the embodiment of the present invention, since the same client may initiate multiple traffic transmission requests simultaneously, at this time, second data objects are respectively constructed for the user identifier corresponding to each traffic transmission request, that is, before inserting a data object set, multiple second data objects may have been constructed for the same user identifier, if a second data object is directly inserted into the data object set, after the client initiates a traffic transmission request again, multiple data objects corresponding to the user identifier may be queried in the data object set, so that complexity of determining a target data object is increased, a difficulty coefficient is further added to summarization of a total traffic value corresponding to the user identifier, and more statistical time of the traffic value is consumed. Therefore, when the newly constructed second data object is inserted into the data object set, the data object set needs to be locked, and after the locking is successful, the newly constructed second data object is inserted into the data object set.
Through the setting, before the flow value statistics is executed, the data object corresponding to the user identifier is effectively ensured to exist, and the flow value generated by the client corresponding to the user identifier in the flow transmission process is counted (if the data set has the first data correspondence, the flow value counted in the current flow transmission process is directly summarized to the original flow value counted according to the address of the first data object), so that the real-time performance of the flow statistics is ensured, and the adjustment efficiency of the flow quota is improved.
Illustratively, according to the embodiment of the present invention, the locking processing on the data object set and the inserting the second data object into the data object set successfully subjected to the locking processing include:
locking the data object set, and judging whether the locking is successful;
and if the locking processing fails, placing the second data object in the candidate queue, so that the candidate queue performs locking processing on the data object set again until the locking processing is successful.
Specifically, when the locking fails, the target data object to be inserted into the data object set is placed in the candidate queue, so that the locking processing is performed subsequently.
Further, according to the embodiment of the present invention, if the locking process is successful, the method further includes:
judging whether a data object corresponding to the user identifier exists in the data object set which is successfully locked again according to the user identifier;
if the traffic value exists, taking a data object corresponding to the user identifier in the data object set as a target data object, and writing the traffic value counted in the second data object into the target data object;
and if not, inserting the second data object into the data object set.
In specific implementation, when the locking process may be performed last time, corresponding data objects are inserted for the same user identifier, and in order to ensure that only the uniquely corresponding data object exists for the same user identifier in the data object set, it is necessary to query and determine whether the data object corresponding to the user identifier exists in the data object set again. If the data object exists, taking the data object corresponding to the user identifier in the data object set as a target data object corresponding to the user identifier, namely updating the target data object and acquiring the address of the target data object; and if the flow value does not exist, inserting a second data object which is newly created and completes the flow value statistics in the current flow transmission process into the data object set, and updating the data object set.
Specifically, according to the embodiment of the present invention, the statistical operation on the traffic value transmitted corresponding to the traffic transmission request is performed in an atomic operation manner.
Atomic operations refer to operations that are not interrupted by a thread scheduling mechanism, and once started, run to the end without switching to another thread in the middle. Counting in an atomic operation mode: when multiple threads add operations to the same counter (the traffic values counted by multiple traffic transmission requests initiated by the same client are superimposed on the original statistical value of the same data object), if the locking is not performed, the counter value (the superimposed total statistical value) is inaccurate, and if the locking operation is performed to the same counter value, multiple threads compete for the same lock, so that the calculation efficiency is reduced. By using the atomic operation, an operation lock is not needed, the calculation operation is completed by the compiler and the hardware, the calculation performance is improved, and the realization of the logic is simpler.
According to the embodiment of the present invention, in a specific implementation, the same client may initiate multiple traffic transmission requests at the same time, that is, multiple statistical units all obtain data object addresses corresponding to the same user identifier from a data object set, and write corresponding traffic values into the corresponding addresses in the traffic transmission process of each statistical unit. Through atomic operation, multiple writing of the same data object is realized, and errors in writing (summarizing, and overlaying of newly written data to the original statistical flow value) of multiple statistical values are avoided.
Step S206, adjusting the flow quota corresponding to each data object according to the flow quota policy and the flow value of each data object in the data object set.
The proxy server establishes a flow quota policy according to network bandwidth, data of a network terminal (client) initiating access and the like, adjusts a flow quota (residual flow quota) corresponding to each data object in a data object set by combining flow values (a total flow value updated in real time and including a flow value generated in each flow transmission process) corresponding to each data object, and executes corresponding operations (such as warning, current limiting and the like) according to the flow quota of each data object.
According to the technical scheme of the embodiment of the invention, one or more flow transmission requests are received, and the user identification is determined according to the request information in the flow transmission request aiming at each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server; searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification; carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set; the technical means of adjusting the flow quota corresponding to each data object according to the flow quota policy and the flow value of each data object in the data object set overcome the technical problems of dependence on the performance of an external database, low adjustment efficiency and low accuracy of the adjusted flow quota in the existing method, and further achieve the technical effects of improving the flow statistical efficiency, improving the efficiency of adjusting the flow quota and ensuring the accuracy of the adjusted flow quota.
Fig. 3 is a schematic diagram of main modules of an apparatus for adjusting a traffic quota, according to an embodiment of the present invention; as shown in fig. 3, an apparatus 300 for adjusting a traffic quota according to an embodiment of the present invention mainly includes:
a receiving module 301, configured to receive one or more traffic transmission requests, and determine, for each traffic transmission request, a user identifier according to request information in the traffic transmission request; the traffic transmission request comprises an access request sent by a client in the current traffic transmission request and a response request returned by the target server.
Specifically, according to the embodiment of the present invention, for the multiple traffic transmission requests, the multiple traffic transmission requests may be sent by one network terminal, or may be sent by multiple network terminals, and one network terminal (e.g., a client) may initiate multiple traffic transmission requests at the same time.
Further, according to the embodiment of the present invention, an interaction between the client and the target server is involved in one traffic transmission process, and the traffic value in the subsequent determination of the current traffic transmission process is also referred to as a traffic value generated in one interaction process (request and response).
Illustratively, the request information includes information such as a user number, an IP address, and a port number, and the user identifier is determined according to the request information, which is helpful for subsequently determining a data object corresponding to the user identifier, so as to count a traffic value in a traffic transmission process.
The first data object determining module 302 is configured to search from the data object set according to the user identifier to determine a first data object, and obtain an address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification.
Through the setting, the first data object is determined from the data object set according to the unique user identifier corresponding to the flow transmission request, the flow value in the flow transmission request is counted on the basis of the flow value counted by the data object, the total flow value corresponding to the user in the process of multiple flow transmission requests is determined conveniently, and the flow quota is adjusted conveniently subsequently. On the other hand, the address of the first data object corresponding to the data object set is obtained, which is helpful for directly writing the traffic value counted in the current traffic transmission process into the address, namely directly writing the traffic value into the first data object corresponding to the user identifier in the data object set, so that the real-time counting of the traffic value is realized, the counting efficiency of the traffic value is improved, and the adjustment efficiency of the traffic quota is further improved.
Further, according to the embodiment of the present invention, the apparatus 300 for adjusting a traffic quota further includes a second data object determining module, where if it is determined that there is no first data object corresponding to the user identifier in the process of searching the data object set; a second data object creation module to:
creating a second data object according to the user identification;
and performing statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the second data object, and writing the statistical operation result into the second data object.
In the actual implementation process, after the user identifier is determined, firstly, whether a first data object corresponding to the user identifier exists in a data object set is inquired and judged, and if the first data object exists, a corresponding address of the first data object in the data object set is obtained; if not, the first data object corresponding to the user identifier is not existed in the data object set, that is, the client corresponding to the user identifier has not initiated the request for the excessive flow transmission and has not generated the excessive flow value, at this time, the second data object is reconstructed according to the user identifier and is used as the data object for the flow value statistics in the current transmission process. Through the arrangement, even if the client initiating the flow transmission request does not have a corresponding data object in the data object set, the flow value statistics can be carried out by establishing the data object, and then the data object set is updated according to the second data object, so that the statistical efficiency and the statistical accuracy of the flow value are ensured, and meanwhile, even if a plurality of flow transmission requests initiated by the client corresponding to the user identification are received, the flow value corresponding to each flow transmission request can be simultaneously counted, the iterative statistics is carried out on the total flow value, the statistical efficiency is improved, and the statistical error is avoided.
The counting module 303 is configured to perform a counting operation on a traffic value transmitted by the target data object in the current traffic transmission process, and write a result of the counting operation into a corresponding address of the target data object in the data object set.
Specifically, according to the embodiment of the present invention, after the step of writing the result of the statistical operation into the second data object, the statistical module 303 is further configured to:
judging whether a data object corresponding to the user identifier exists in the data object set or not;
if so, acquiring an address corresponding to the data object corresponding to the user identifier in the data object set, and writing the flow value counted in the second data object into the address;
and if not, locking the data object set, and inserting the second data object into the data object set successfully subjected to locking.
In a specific embodiment, in the process of constructing a new data object (i.e., a second data object) according to a user identifier, a data object corresponding to the user identifier may have been inserted into a data object set by other statistical units, and in order to avoid that multiple data objects exist in the data object set for the same user identifier, before inserting a newly constructed target data object into the data object set, it is necessary to determine again whether a data object corresponding to the user identifier exists in the data object set.
According to another specific implementation manner of the embodiment of the present invention, since the same client may initiate multiple traffic transmission requests simultaneously, at this time, second data objects are respectively constructed for the user identifier corresponding to each traffic transmission request, that is, before inserting a data object set, multiple second data objects may have been constructed for the same user identifier, if a second data object is directly inserted into the data object set, after the client initiates a traffic transmission request again, multiple data objects corresponding to the user identifier may be queried in the data object set, so that complexity of determining a target data object is increased, a difficulty coefficient is further added to summarization of a total traffic value corresponding to the user identifier, and more statistical time of the traffic value is consumed. Therefore, when the newly constructed second data object is inserted into the data object set, the data object set needs to be locked, and after the locking is successful, the newly constructed second data object is inserted into the data object set.
Through the setting, before the flow value statistics is executed, the data object corresponding to the user identifier is effectively ensured to exist, and the flow value generated by the client corresponding to the user identifier in the flow transmission process is counted (if the data set has the first data correspondence, the flow value counted in the current flow transmission process is directly summarized to the original flow value counted according to the address of the first data object), so that the real-time performance of the flow statistics is ensured, and the adjustment efficiency of the flow quota is improved.
Illustratively, according to an embodiment of the present invention, the statistic module 303 is further configured to:
locking the data object set, and judging whether the locking is successful;
and if the locking processing fails, placing the second data object in the candidate queue, so that the candidate queue performs locking processing on the data object set again until the locking processing is successful.
Specifically, when the locking fails, the target data object to be inserted into the data object set is placed in the candidate queue, so that the locking processing is performed subsequently.
Further, according to an embodiment of the present invention, if the locking process is successful, the statistical module 303 is further configured to:
judging whether a data object corresponding to the user identifier exists in the data object set which is successfully locked again according to the user identifier;
if the traffic value exists, taking a data object corresponding to the user identifier in the data object set as a target data object, and writing the traffic value counted in the second data object into the target data object;
and if not, inserting the second data object into the data object set.
In specific implementation, when the locking process may be performed last time, corresponding data objects are inserted for the same user identifier, and in order to ensure that only the uniquely corresponding data object exists for the same user identifier in the data object set, it is necessary to query and determine whether the data object corresponding to the user identifier exists in the data object set again. If the data object exists, taking the data object corresponding to the user identifier in the data object set as a target data object corresponding to the user identifier, namely updating the target data object and acquiring the address of the target data object; and if the flow value does not exist, inserting a second data object which is newly created and completes the flow value statistics in the current flow transmission process into the data object set, and updating the data object set.
Specifically, according to an embodiment of the present invention, the statistical module 303 is further configured to:
and counting the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object in an atomic operation mode.
Atomic operations refer to operations that are not interrupted by a thread scheduling mechanism, and once started, run to the end without switching to another thread in the middle. Counting in an atomic operation mode: when multiple threads add operations to the same counter (the traffic values counted by multiple traffic transmission requests initiated by the same client are superimposed on the original statistical value of the same data object), if the locking is not performed, the counter value (the superimposed total statistical value) is inaccurate, and if the locking operation is performed to the same counter value, multiple threads compete for the same lock, so that the calculation efficiency is reduced. By using the atomic operation, an operation lock is not needed, the calculation operation is completed by the compiler and the hardware, the calculation performance is improved, and the realization of the logic is simpler.
According to the embodiment of the present invention, in a specific implementation, the same client may initiate multiple traffic transmission requests at the same time, that is, multiple statistical units all obtain data object addresses corresponding to the same user identifier from a data object set, and write corresponding traffic values into the corresponding addresses in the traffic transmission process of each statistical unit. Through atomic operation, multiple writing of the same data object is realized, and errors in writing (summarizing, and overlaying of newly written data to the original statistical flow value) of multiple statistical values are avoided.
The adjusting module 304 is configured to adjust a traffic quota corresponding to each data object according to the traffic quota policy and the traffic value of each data object in the data object set.
The proxy server establishes a flow quota policy according to network bandwidth, data of a network terminal (client) initiating access and the like, adjusts a flow quota (residual flow quota) corresponding to each data object in a data object set by combining flow values (a total flow value updated in real time and including a flow value generated in each flow transmission process) corresponding to each data object, and executes corresponding operations (such as warning, current limiting and the like) according to the flow quota of each data object.
According to the technical scheme of the embodiment of the invention, one or more flow transmission requests are received, and the user identification is determined according to the request information in the flow transmission request aiming at each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server; searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification; carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set; the technical means of adjusting the flow quota corresponding to each data object according to the flow quota policy and the flow value of each data object in the data object set overcome the technical problems of dependence on the performance of an external database, low adjustment efficiency and low accuracy of the adjusted flow quota in the existing method, and further achieve the technical effects of improving the flow statistical efficiency, improving the efficiency of adjusting the flow quota and ensuring the accuracy of the adjusted flow quota.
Fig. 4 illustrates an exemplary system architecture 400 to which the method for adjusting a traffic quota or the apparatus for adjusting a traffic quota according to the embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405 (this architecture is merely an example, and the components included in a particular architecture may be adapted according to application specific circumstances). The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as a data processing-type application, a web browser application, a search-type application, an instant messaging tool, a mailbox client, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server that provides various services, such as a server (for example only) for users to (perform data processing with) the terminal devices 401, 402, 403. The server may analyze and/or otherwise process the received data, such as the traffic transmission request, and feed back the processing results (e.g., statistical operation results, target data objects, just examples) to the terminal device.
It should be noted that the method for adjusting the traffic quota provided in the embodiment of the present invention is generally executed by the server 405, and accordingly, the apparatus for adjusting the traffic quota is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, a block diagram of a computer system 500 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a receiving module, a first data object determination module, a statistics module, and an adjustment module. The names of the modules do not form a limitation on the modules themselves in some cases, for example, the receiving module may also be described as "receiving one or more traffic transmission requests, and for each traffic transmission request, determining a user identifier according to request information in the traffic transmission request; the traffic transmission request comprises an access request sent by the client in the current traffic transmission request and a unit of a response request returned by the target server ".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: receiving one or more flow transmission requests, and respectively determining a user identifier according to request information in the flow transmission requests aiming at each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server; searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification; carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set; and adjusting the flow quota corresponding to each data object according to the flow quota strategy and the flow value of each data object in the data object set.
According to the technical scheme of the embodiment of the invention, one or more flow transmission requests are received, and the user identification is determined according to the request information in the flow transmission request aiming at each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server; searching from the data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification; carrying out statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing the statistical operation result into the address of the first data object corresponding to the data object set; the technical means of adjusting the flow quota corresponding to each data object according to the flow quota policy and the flow value of each data object in the data object set overcome the technical problems of dependence on the performance of an external database, low adjustment efficiency and low accuracy of the adjusted flow quota in the existing method, and further achieve the technical effects of improving the flow statistical efficiency, improving the efficiency of adjusting the flow quota and ensuring the accuracy of the adjusted flow quota.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for adjusting a traffic quota, comprising:
receiving one or more flow transmission requests, and determining a user identifier according to request information in each flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server;
searching from a data object set according to the user identification to determine a first data object, and acquiring a corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification;
performing a statistical operation on a traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and writing a statistical operation result into an address of the first data object corresponding to the data object set;
and adjusting the flow quota corresponding to each data object according to the flow quota strategy and the flow value of each data object in the data object set.
2. The method for adjusting traffic quota according to claim 1, wherein if it is determined that there is no first data object corresponding to the user identifier in the process of searching the data object set, the method further comprises:
creating a second data object according to the user identification;
and performing statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the second data object, and writing the statistical operation result into the second data object.
3. The method for adjusting traffic quota according to claim 2, further comprising, after the step of writing the result of the statistical operation into the second data object:
judging whether a data object corresponding to the user identifier exists in the data object set or not;
if so, acquiring an address corresponding to the data object corresponding to the user identifier in the data object set, and writing the flow value counted in the second data object into the address;
and if not, locking the data object set, and inserting the second data object into the data object set successfully subjected to locking.
4. The method for adjusting traffic quota according to claim 3, wherein the locking the data object set and inserting the second data object into the data object set successfully subjected to locking processing comprises:
locking the data object set, and judging whether the locking is successful;
and if the locking processing fails, placing the second data object in a candidate queue, so that the candidate queue performs locking processing on the data object set again until the locking processing is successful.
5. The method for adjusting traffic quota according to claim 4, further comprising, if the locking process is successful:
judging whether a data object corresponding to the user identifier exists in the data object set which is successfully locked again according to the user identifier;
if the traffic value exists, taking a data object corresponding to the user identifier in the data object set as a target data object, and writing the traffic value counted in the second data object into the target data object;
and if not, inserting the second data object into the data object set.
6. The method for adjusting traffic quota according to claim 1, wherein the performing a statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object includes:
and counting the traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object in an atomic operation mode.
7. An apparatus for adjusting a traffic quota, comprising:
the receiving module is used for receiving one or more flow transmission requests, and for each flow transmission request, determining a user identifier according to request information in the flow transmission request; the flow transmission request comprises an access request sent by a client in the current flow transmission request and a response request returned by a target server;
the first data object determining module is used for searching from the data object set according to the user identification to determine a first data object and acquiring the corresponding address of the first data object in the data object set; the data object is used for indicating the corresponding relation between the user identification and the flow value correspondingly transmitted by the user identification;
a counting module, configured to perform a counting operation on a traffic value transmitted corresponding to the traffic transmission request corresponding to the first data object, and write a result of the counting operation into an address of the first data object corresponding to the data object set;
and the adjusting module is used for adjusting the flow quota corresponding to each data object according to the flow quota strategy and the flow value of each data object in the data object set.
8. The apparatus according to claim 7, further comprising a second data object creating module, configured to determine that there is no first data object corresponding to the user identifier in the process of searching the data object set; the second data object creation module to:
creating a second data object according to the user identification;
and performing statistical operation on the traffic value transmitted corresponding to the traffic transmission request corresponding to the second data object, and writing the statistical operation result into the second data object.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202111005526.5A 2021-08-30 2021-08-30 Method and device for adjusting flow quota Pending CN113726885A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111005526.5A CN113726885A (en) 2021-08-30 2021-08-30 Method and device for adjusting flow quota

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111005526.5A CN113726885A (en) 2021-08-30 2021-08-30 Method and device for adjusting flow quota

Publications (1)

Publication Number Publication Date
CN113726885A true CN113726885A (en) 2021-11-30

Family

ID=78679150

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111005526.5A Pending CN113726885A (en) 2021-08-30 2021-08-30 Method and device for adjusting flow quota

Country Status (1)

Country Link
CN (1) CN113726885A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114615073A (en) * 2022-03-22 2022-06-10 广州方硅信息技术有限公司 Access flow control method, device, equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104967624A (en) * 2015-06-30 2015-10-07 北京奇虎科技有限公司 Flow-free platform based network accessing method, mobile terminal and system
CN106101025A (en) * 2016-05-19 2016-11-09 北京小米移动软件有限公司 Flow allocation method and device
CN108259207A (en) * 2016-12-29 2018-07-06 北京国双科技有限公司 Flow statistical method, client, server and system
CN110708258A (en) * 2019-09-29 2020-01-17 Oppo广东移动通信有限公司 Flow control method, flow control device, server and storage medium
CN113285884A (en) * 2021-07-19 2021-08-20 阿里云计算有限公司 Flow control method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104967624A (en) * 2015-06-30 2015-10-07 北京奇虎科技有限公司 Flow-free platform based network accessing method, mobile terminal and system
CN106101025A (en) * 2016-05-19 2016-11-09 北京小米移动软件有限公司 Flow allocation method and device
CN108259207A (en) * 2016-12-29 2018-07-06 北京国双科技有限公司 Flow statistical method, client, server and system
CN110708258A (en) * 2019-09-29 2020-01-17 Oppo广东移动通信有限公司 Flow control method, flow control device, server and storage medium
CN113285884A (en) * 2021-07-19 2021-08-20 阿里云计算有限公司 Flow control method and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114615073A (en) * 2022-03-22 2022-06-10 广州方硅信息技术有限公司 Access flow control method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN111277639B (en) Method and device for maintaining data consistency
CN111460129A (en) Method and device for generating identification, electronic equipment and storage medium
CN110909022A (en) Data query method and device
CN111782502A (en) Automatic testing method and device
CN113726885A (en) Method and device for adjusting flow quota
CN113364887A (en) File downloading method based on FTP, proxy server and system
CN112948138A (en) Method and device for processing message
CN112052152A (en) Simulation test method and device
CN114070889B (en) Configuration method, traffic forwarding device, storage medium, and program product
CN115421922A (en) Current limiting method, device, equipment, medium and product of distributed system
CN113722113A (en) Traffic statistic method and device
CN114064803A (en) Data synchronization method and device
CN109087097B (en) Method and device for updating same identifier of chain code
CN113760876A (en) Data filtering method and device
CN110019671B (en) Method and system for processing real-time message
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN113541987A (en) Method and device for updating configuration data
CN111858586A (en) Data processing method and device
CN110262756B (en) Method and device for caching data
CN115309612B (en) Method and device for monitoring data
CN110896391A (en) Message processing method and device
CN114449031B (en) Information acquisition method, device, equipment and storage medium
CN110784479B (en) Data verification method and device, electronic equipment and storage medium
CN111179097B (en) Method, device, electronic equipment and storage medium for modifying warranty
CN113421163A (en) Account checking method, account checking application cluster and related client

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
CB03 Change of inventor or designer information

Inventor after: Liu Zhongdi

Inventor after: Liu Lin

Inventor after: Chai Sherong

Inventor after: Xu Chao

Inventor before: Liu Zhongdi

Inventor before: Chai Sherong

Inventor before: Xu Chao

CB03 Change of inventor or designer information