CN108573013A - Request processing method, device, electronic equipment and computer readable storage medium - Google Patents

Request processing method, device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN108573013A
CN108573013A CN201711295208.0A CN201711295208A CN108573013A CN 108573013 A CN108573013 A CN 108573013A CN 201711295208 A CN201711295208 A CN 201711295208A CN 108573013 A CN108573013 A CN 108573013A
Authority
CN
China
Prior art keywords
value
count value
default
default value
access request
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
CN201711295208.0A
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 Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud 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 Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN201711295208.0A priority Critical patent/CN108573013A/en
Publication of CN108573013A publication Critical patent/CN108573013A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

An embodiment of the present invention provides a kind of request processing method, device, electronic equipment and computer readable storage mediums, in this method, after receiving target database access request, first determine whether the first count value is less than 1, if being not less than 1, the target database access request is handled, and updates the first count value and is:Current first count value with 1 difference.Wherein, the first count value is for the count value set by the corresponding target user of the target database access request, and the first count value is arranged to the first default value at interval of the first preset duration.Compared with prior art, in scheme provided in an embodiment of the present invention, the average speed of the database access request of database server processes target user is:The ratio of first default value and the first preset duration meets the demand for the different user setting different Q PS limitations that database service enterprise is serviced for it.

Description

Request processing method, device, electronic equipment and computer readable storage medium
Technical field
The present invention relates to field of computer technology, more particularly to a kind of request processing method, device, electronic equipment and meter Calculation machine readable storage medium storing program for executing.
Background technology
Database (Database) is to come tissue, storage and the warehouse for managing data according to data structure, with informationization The continuous development of technology, database technology are more and more extensive in the application of every field.In order to avoid expensive data management expense With the expense with engagement expert data administrative staff, there is the enterprise of data management demand that can hand over the data administration tasks of itself It goes to complete by database service enterprise, i.e., database service enterprise can provide data to the above-mentioned enterprise for having data management demand Library services.
In the prior art, the above-mentioned enterprise for having data management demand can be arranged by terminal to database service enterprise Database server transmission data library access request, to achieve the purpose that increase data, delete, check and change. For example, the above-mentioned redis databases for having the enterprise of data management demand to store data in the setting of database service enterprise are (a kind of The Key-Value databases increased income) in, it, can be to the redis data when it needs to check the data in redis databases The corresponding database server transmission data in library checks request.
For database service enterprise, each user (such as above-mentioned enterprise for having data management demand for being serviced Industry) the grade of service, expenses standard of services etc. be different, so having different QPS (Query Per for different users Second, query rate per second) limitation demand.But for the above-mentioned database server of the prior art, when it receives number When according to library access request, the database access request can be directly handled, cannot be satisfied the above-mentioned different user that is directed to there are different Q PS limits The demand of system.
Invention content
The embodiment of the present invention is designed to provide a kind of request processing method, device, electronic equipment and computer-readable Storage medium has the demand that different Q PS is limited to meet database service enterprise for its different user serviced.Specific skill Art scheme is as follows:
In order to achieve the above object, in a first aspect, an embodiment of the present invention provides a kind of request processing methods, including:
Receive target database access request;
Judge whether the first count value is less than 1, wherein the first count value is to be corresponded to for the target database access request Target user set by count value, the first count value is arranged to the first default value at interval of the first preset duration;
If being not less than 1, the target database access request is handled;
Updating the first count value is:Current first count value with 1 difference.
Optionally, in the case where the first count value is less than 1, the above method further includes:
It is spaced the second preset duration, returns to execution is above-mentioned to judge the step of whether the first count value is less than 1.
Optionally, in the case where the first count value is less than 1, the above method further includes:
Before statistics current time in third preset duration, the total degree that the first count value is less than 1 is judged;
Judge whether the total degree reaches the first predetermined threshold value;
If reaching the first predetermined threshold value, the first default value of update is:Current first default value and the second present count Be worth and value.
Optionally, it is in the first default value of above-mentioned update:Current first default value and the second default value and value The step of before, the above method further includes:
Judge current first default value and the second default value and value whether be less than the second predetermined threshold value;
If it is less than the second predetermined threshold value, executing the first default value of above-mentioned update is:Current first default value and Two default values and value the step of.
Optionally, in the case where the total degree reaches the first predetermined threshold value, the above method further includes:
Prompt messages are generated, and the prompt messages generated are fed back into above-mentioned target database access request Corresponding terminal.
Optionally, in the case where the first count value is less than 1, the above method further includes:
It updates and is for the second count value set by target user:Current second count value with 1 and value;
Judge whether updated second count value reaches third predetermined threshold value;
If reaching third predetermined threshold value, the first default value of update is:Current first default value and the second present count Be worth and value.
Second aspect, an embodiment of the present invention provides a kind of request processing units, including:
Receiving module, for receiving target database access request;
First judgment module, for judging whether the first count value is less than 1, wherein the first count value is for the target Count value set by the corresponding target user of database access request, the first count value are set at interval of the first preset duration For the first default value;
Processing module, in the case where the judging result of the first judgment module is no, handling target database visit Ask request;
First update module, for update the first count value be:Current first count value with 1 difference.
Optionally, above-mentioned first judgment module is additionally operable in the case where the first count value is less than 1, and interval second is default Duration returns to execute the step of whether the first count value is less than 1 judged.
Optionally, above-mentioned apparatus further includes:
Statistical module, in the case where the judging result of the first judgment module is to be, counting third before current time In preset duration, the total degree that the first count value is less than 1 is judged;
Second judgment module, for judging whether the total degree reaches the first predetermined threshold value;
Second update module, in the case where the judging result of the second judgment module is to be, updating the first present count Value is:Current first default value and the second default value and value.
Optionally, above-mentioned apparatus further includes:
Third judgment module, in the case where the judging result of the second judgment module is to be, judging that current first is pre- If numerical value and the second default value and value whether be less than the second predetermined threshold value;
Correspondingly, above-mentioned second update module, in the case of specifically for being in the judging result of third judgment module, Updating the first default value is:Current first default value and the second default value and value.
Optionally, above-mentioned apparatus further includes:
Feedback module, in the case where the judging result of the second judgment module is to be, generating prompt messages, and Prompt messages are fed back into the terminal corresponding to target database access request.
Optionally, above-mentioned apparatus further includes:
Third update module, in the case where the judging result of the first judgment module is to be, update to be used for target The second count value set by family is:Current second count value with 1 and value;
4th judgment module, for judging whether updated second count value reaches third predetermined threshold value;
4th update module, in the case where the judging result of the 4th judgment module is to be, updating the first present count Value is:Current first default value and the second default value and value.
Face, an embodiment of the present invention provides a kind of electronic equipment, including processor and memory, wherein;
Memory, for storing computer program;
Processor when for executing the program stored on memory, is realized described in any of the above-described request processing method Method and step.
Fourth aspect, an embodiment of the present invention provides a kind of computer readable storage medium, the computer-readable storage mediums Computer program is stored in matter, which realizes when being executed by processor described in any of the above-described request processing method Method and step.
5th aspect, an embodiment of the present invention provides a kind of computer program products including instruction, when it is in computer When upper operation so that computer executes the method and step described in any of the above-described request processing method.
6th aspect, an embodiment of the present invention provides a kind of computer programs, when run on a computer so that meter Calculation machine executes the method and step described in any of the above-described request processing method.
As known from the above, in scheme provided in an embodiment of the present invention, after receiving target database access request, first Judge whether the first count value is less than 1, if being not less than 1, handles the target database access request, and update the first count value For:Current first count value with 1 difference.Wherein, the first count value is for the corresponding mesh of target database access request The count value set by user is marked, the first count value is arranged to the first default value at interval of the first preset duration.With it is existing Technology is compared, and in scheme provided in an embodiment of the present invention, database server is only the case where the first count value is not less than 1 Under, it can just handle above-mentioned target database access request, and since the first count value is arranged at interval of the first preset duration First default value, and the database access request of a target user is often handled, can update the first count value is:Current first Count value and 1 difference, therefore the average speed of the database access request of database server processes target user is:First is pre- If the ratio of numerical value and the first preset duration, it is different to meet the different user setting that database service enterprise is serviced for it The demand of QPS limitations.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with Obtain other attached drawings according to these attached drawings.
Fig. 1 is a kind of flow diagram for request processing method that one embodiment of the invention provides;
Fig. 2 is a kind of flow diagram for request processing method that another embodiment of the present invention provides;
Fig. 3 is a kind of flow diagram for request processing method that further embodiment of this invention provides;
Fig. 4 is a kind of structural schematic diagram for request processing unit that one embodiment of the invention provides;
Fig. 5 is a kind of structural schematic diagram for request processing unit that another embodiment of the present invention provides;
Fig. 6 is a kind of structural schematic diagram for request processing unit that further embodiment of this invention provides;
Fig. 7 is the structural schematic diagram of a kind of electronic equipment provided in an embodiment of the present invention.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
First below be directed to this specification relates to technical term simply introduced.
Database access request has the enterprise of data management demand to be stored in the data of itself as stated in the background art In the equipment that database service enterprise provides, so when thering is the enterprise of data management demand to access the data of its own, first The database server transmission data access request to database service enterprise is needed, the data of its own can just be accessed.
Data access request can be data read request, can be according to after database server receives data read request Data read request, by the data-pushing corresponding to data read request to the terminal of transmission data read request so that terminal user The corresponding data of data read request can be checked by terminal.For example, terminal A is sent to database server for data x's Data read request, then database server can find data x, and data x is pushed to terminal A.
Data access request can also be data write request, can be by after database server receives data write request According to data write request, corresponding data write operation, such as increase, deletion, the modification of data are executed.Illustratively, terminal B is to number The data write request for deleting data y is sent according to library server, then database server can find data y, and by data y from It is deleted in database.
QPS, Chinese are known as query rate per second, can be understood as in present specification:It is looked forward to for each database service Each user of industry, the database server quantity per second for handling the corresponding database access request of the user.For example, for using The quantity of the corresponding database access request of family X, database server processing user X per second is M, then the user couple within the second The QPS answered is M.
The different user setting difference that database service enterprise is serviced for it is cannot be satisfied in order to solve the prior art The problem of demand of QPS limitations, an embodiment of the present invention provides a kind of request processing method, device, electronic equipment and storages to be situated between Matter.
A kind of request processing method is provided for the embodiments of the invention first below to describe in detail.
Firstly the need of explanation, a kind of request processing method that the embodiment of the present invention is provided can be applied to data Library service equipment, i.e., above-mentioned database server.In the case of one kind, which is setting for storing data It is standby.In another case, can be the control server in data base cluster system, or agency's clothes in the database server Business device (proxy), database server itself does not store data, but it can be communicated with the database node of storage data Letter;For example, above-mentioned database is redis databases, data base cluster system includes control server and multiple redis sections Point, control server are communicated with each redis nodes, and control server can be used for receiving database access request, and can Received data library access request is transmitted to corresponding redis nodes.
As shown in Figure 1, a kind of request processing method provided in an embodiment of the present invention, including:
S101:Receive target database access request.
It is understood that the sender of target database access request is database server corresponding end herein End, it is clear that, which belongs to the aforementioned enterprise for having data management demand, also, each received by database server A database access request can be so-called target database access request in the embodiment of the present invention.In addition, as previously mentioned, Target database access request herein can be database read request, can also be database write request, be even other The request of classification, the embodiment of the present invention do not limit the concrete type of target database access request herein.
S102:Judge whether the first count value is less than 1;Wherein, the first count value is to be asked for target database access The count value set by corresponding target user, the first count value is asked to be arranged to the first present count at interval of the first preset duration Value.
It should be noted that target user belongs to the object that database service enterprise is serviced, and in the case of a kind of, database The object that service enterprise is serviced is individual, then the target user is the terminal use for sending the target database access request Person;In another case, the object that database service enterprise is serviced is enterprise, mechanism etc., then the target user is enterprise's machine Structure etc., target user is not equivalent to the terminal user for sending the target database access request in the case of this, for example, the mesh Mark user is company A, and the employee a under company A is by terminal to database server transmission data library access request.
In the embodiment of the present invention, the first count value that target user is configured is a variable, the first count value at interval of First preset duration will be arranged to the first default value, wherein first default value is the positive number more than 1, in addition, should First preset duration and the first default value can be arranged according to actual conditions, and it is first pre- that the embodiment of the present invention does not limit this If the concrete numerical value of duration and the first default value, for example, the first default value of setting is 50, the first preset duration is 1s (second).
In practical applications, can according to corresponding to target user the grade of service and/or charge setting above-mentioned first it is pre- If duration and the first default value, the grade of service and/or charge corresponding to target user are higher, and the first preset duration is arranged Shorter and/or the first default value is bigger.It, then can be with for example, the grade of service corresponding to target user A is higher than target user B It sets corresponding first default values of target user B to the 50, first preset duration and is set as 1s, target user A is corresponding First default value is set as the 80, first preset duration and is set as 1s.
If the judging result of step S102 is no, step S103 is executed:Handle the target database access request.
In embodiments of the present invention, only in the case where the judging result of step S102 is no, database server is It can go to handle the target database access request, and in the case where the judging result of step S102 is to be, database server The target database access request will not be handled, for example, database server can refuse the target database access request.
It is appreciated that in the case where the judging result of step S102 is to be, if database server directly refuses mesh Database access request is marked, that is, shows that the target database access request cannot respond, in the embodiment of the present invention, in order to enable Each database access request can be handled by database server, i.e., each database access request can be rung It answers, as a kind of optional realization method of the embodiment of the present invention, in the case where the judging result of step S102 is to be, above-mentioned side Method can also include:
It is spaced the second preset duration, returns to execution is above-mentioned to judge the step of whether the first count value is less than 1 (S102).
The specific size of second preset duration can be based on actual demand and set, and the embodiment of the present invention does not limit second The specific size of preset duration.
The judging result of step S102 is yes, shows that current first count value is less than 1, but the first count value is at interval of the One preset duration can be arranged to the first default value, so the first count value after current time when the second preset duration differs Surely it is less than 1, if first count value of moment is not less than 1, server can handle the target data in the time data library Library access request.
Illustratively, it is assumed that at the first moment, the first count value is 0, then determines step S102's at the first moment Judging result is yes;A length of 1s when preset second level, 1s was referred to as the second moment after the first moment, at the first moment to second Certain moment between moment, the first count value are reset as 50.So database server executes step again at the second moment Rapid S102, the result that judges to be likely to of step S102 is no at this time, then the target data access request can be by database service Handled by device.
It, can be with although some database access requests cannot be by timely processing it is appreciated that in this realization method Ensure that each database access request can be handled by database server.
As previously mentioned, in the case of one kind, which is equipment for storing data, in this case, data The server process target database access request in library can be understood as:Database server is according to target database access request Corresponding database manipulation is executed, for example, the target database access request is to be directed to the write request of data a, then database Server executes the operation that data a is written to database.
In another case, can be the control server in data base cluster system, data in the database server Library group system includes control server and multiple database nodes for storing data, in this case, database service Device handles the target database access request and can be understood as:The target database access request that database server will be received It is transmitted to corresponding database node.For example, control server communication is connected with 10 redis nodes, target database accesses Request is checks that the data of data a check request, then database server processes target database access request is:It finds out The redis nodes that data a is stored, and target database access request is transmitted to found redis nodes.
S104:Updating the first count value is:Current first count value with 1 difference.
In embodiments of the present invention, the first count value at interval of the first preset duration in addition to being arranged to the first default value Outside, database server processes are crossed after the corresponding database access request of target user and can also update the first count value and be: Current first count value with 1 difference.
For example, current first count value is 45, database server is after performing step S103, by the first count value It is updated to 44.
It should be noted that in actual use, the first count value in the embodiment of the present invention can be default enables Token quantity in board bucket.In the case, database service enterprise is respectively provided with a token for its each user serviced Barrel, the token quantity in token bucket is above-mentioned first count value.
Correspondingly, above-mentioned first default value is to be directed in the default target spoke bucket of target user at most accommodate Token quantity, also, step S104 at this time can be:
It updates and is for the token quantity in the default target spoke bucket of target user:Order in current goal token bucket Board quantity with 1 difference.
It is appreciated that in embodiments of the present invention, the first count value is arranged to first in advance at interval of the first preset duration If numerical value, i.e. database server periodically resets to first using the first preset duration as a cycle, by the first count value Default value.Again since database server often handles the database access request corresponding to a target user, will update First count value is:Current first count value with 1 difference, so for the database access request corresponding to target user, Database server can at most handle the first default value within the said one period, to achieve the purpose that QPS is limited.
Can with understanding, in embodiments of the present invention, the QPS values corresponding to target user be above-mentioned first default value with The ratio of first preset duration.And identical in the first preset duration, the first default value is bigger, and QPS values are higher; Likewise, identical in the first default value, the first preset duration is smaller, and QPS values are higher.
Illustratively, for target user, the first default value is 40, and the first preset duration is 1s.Then in a cycle Interior, data server can at most handle 40 corresponding database access requests of target user.
From the foregoing, it will be observed that compared with prior art, in scheme provided in this embodiment, database server is only in the first meter In the case that numerical value is not less than 1, above-mentioned target database access request can be just handled, and since the first count value is at interval of first Preset duration is arranged to the first default value, and often handles the database access request of a target user, can update first Count value is:Current first count value and 1 difference, therefore the database access request of database server processes target user Average speed is:The ratio of first default value and the first preset duration meets database service enterprise and is serviced for it Different user setting different Q PS limitation demand.
In embodiments of the present invention, on the basis of embodiment of the method shown in Fig. 1, as shown in Fig. 2, sentencing in step S102 Disconnected result is in the case of being, the above method can also include:
S105:Before statistics current time in third preset duration, the total degree that the first count value is less than 1 is judged.
Likewise, the specific size of third preset duration may be set according to actual conditions, the embodiment of the present invention is simultaneously unlimited Determine the specific size of third preset duration.
For step S105, illustratively, database server, can be with when determining the first count value less than 1 every time Do primary record;Assuming that third preset duration is 1 hour, then when executing step S105, statistics is found database server In first 1 hour of current time, the total degree of above-mentioned record is 100 times, i.e., judged in third preset duration before current time Total degree of first count value less than 1 is 100 times.
S106:Judge whether the total degree reaches the first predetermined threshold value.
Likewise, the specific size of the first predetermined threshold value may be set according to actual conditions, the embodiment of the present invention is simultaneously unlimited The specific size of fixed first predetermined threshold value.
If the judging result of step S106 is yes, step S107 is executed:Updating the first default value is:Current first is pre- If numerical value and the second default value and value.
It is appreciated that in embodiments of the present invention, the first default value is also not fixed value, in the judgement of step S106 As a result it is in the case of being, can update the first default value is:Current first default value and the second default value and value. Certainly, the specific size of the second default value may be set according to actual conditions, and it is default that the embodiment of the present invention does not limit second The specific size of numerical value.
For step S106 and step S107, illustratively, it is assumed that the first predetermined threshold value is 40, and step S105 is counted Total degree be 50 times, the first current default value is 50, and the second default value is 10.Obvious, the judgement of step S106 As a result be yes, need at this time execute step S107, i.e., by the first default value be updated to 50 and 10 and value 60.
In the case where the first preset duration is constant, the first default value increases, then increases the corresponding QPS of target user Value, as previously mentioned, the corresponding QPS values of target user are corresponding with the grade of service of target user, tollbooth, so in reality In application process, after executing the step S107, database server can also generate new charge for current QPS values and order It is single, and according to new order charging.Certainly, the specific mode for generating charge order and charging is referred to the prior art, this Inventive embodiments are not described in detail herein.
Compared with embodiment of the method shown in Fig. 1, in the embodiment of the present invention, target use can be increased automatically according to actual conditions The QPS values at family, it is ensured that database access request corresponding to target user can by database server timely processing, It is excessively high to ensure that the QPS values of target user will not be set to simultaneously.
As a kind of optional realization method of the embodiment of the present invention, the case where the judging result of above-mentioned steps S106 is to be Under, for database server other than executing step S107, the above method can also include the following steps S1:
Step S1:Prompt messages are generated, and the prompt messages generated are fed back into above-mentioned target database Terminal corresponding to access request.
The prompt messages are that the QPS to prompt target user current is too low, cannot be satisfied the reality of target user The information of use demand, the embodiment of the present invention do not limit the form of the prompt messages.It is appreciated that prompt messages After feeding back to the terminal corresponding to above-mentioned target database access request, which can be shown to itself by prompt messages Display interface on or voice broadcast come out so that target user can grasp the too low problem of current QPS values in time.
For example, carry current QPS values in the prompt messages generated, i.e. the first default value and first it is default when Long ratio, specifically such as:Current QPS values are 50, then the terminal corresponding to above-mentioned target database access request is receiving report It, can the display reminding information " alarm on the display interface of itself after alert prompt message:Current QPS values are 50, QPS value mistakes It is low ".
It should be noted that in practical applications, in the case where the judging result of above-mentioned steps S106 is to be, database Server can only execute step S1, without executing step S107.In the case, target user is learning current QPS values mistake When low problem, the request for changing current QPS can be sent to database server by terminal.For example, change QPS's asks Asking to be:In the case where keeping first to preset constant, the first current default value is increased to current 2 times.
As previously mentioned, after the corresponding QPS values of target user are raised, the corresponding charge of target user also can accordingly rise Height, in the embodiment of the present invention, in order to ensure that QPS values are improved automatically in the range that target user is subjected to, as this hair A kind of optional realization method of bright embodiment is in the first default value of above-mentioned update:Current first default value and second is in advance If numerical value and value (S107) the step of before, the above method can also include:
Judge current first default value and the second default value and value whether be less than the second predetermined threshold value;
If it is less than the second predetermined threshold value, executing the first default value of above-mentioned update is:Current first default value and Two default values and value the step of.
I.e. in the present embodiment, on the basis of embodiment of the method shown in Fig. 2, as shown in figure 3, above-mentioned request processing method Including:
S201:Receive target database access request.
S202:Judge whether the first count value is less than 1;Wherein, the first count value is to be asked for target database access The count value set by corresponding target user, the first count value is asked to be arranged to the first present count at interval of the first preset duration Value.
If the judging result of step S202 is no, step S203 is executed:Handle the target database access request.
S204:Updating the first count value is:Current first count value with 1 difference.
If the judging result of step S202 is yes, S205 is executed:Before statistics current time in third preset duration, judge Go out the total degree that the first count value is less than 1.
S206:Judge whether the total degree reaches the first predetermined threshold value.
If the judging result of step S206 is yes, step S207 is executed:Judge current first default value and second in advance If whether numerical value is less than the second predetermined threshold value with value.
Likewise, the specific size of the second predetermined threshold value may be set according to actual conditions, the embodiment of the present invention is simultaneously unlimited The specific size of fixed second predetermined threshold value.In actual use, which can be preset by target user, example Such as, it is 100 that target user first passes through terminal profile second predetermined threshold value in advance, and the second set predetermined threshold value is sent to Database server.
If the judging result of step S207 is yes, step S208 is executed:Updating the first default value is:Current first is pre- If numerical value and the second default value and value.
Certainly, in the case where the judging result of step S207 is no, step S208 is not carried out in database server.
It should be noted that the step S201~S206 and S208 in embodiment of the method shown in Fig. 3 are corresponded to and Fig. 2 institutes respectively Show that the S101~S106 and S107 in embodiment of the method is identical, the explanation and specific implementation of step S201~S206 and S208 It is referred to embodiment of the method shown in Fig. 2, details are not described herein for the present embodiment.
For step S207 and S208, illustratively, the second predetermined threshold value is 80, and the second default value is 20, it is assumed that when Preceding first default value is 50, then when executing step S207, current first default value and the second default value and value be 70, since this and value 70 are less than the second predetermined threshold value 80, then database server executes step S208, that is, updates the first present count Value is:Current first default value and the second default value and value 70;Assuming that current first default value is 70, then executing When step S207, current first default value and the second default value and value be 90, in advance not less than second due to this and value 90 If threshold value 80, then step S208 is not carried out in database server.
Described in embodiment of the method shown in Fig. 2 and Fig. 3 is how to increase the realization method of the QPS values of target user; Corresponding, in some cases, the QPS values being initially set corresponding to target user may be excessive, so in order to avoid this Class situation, in the embodiment of the present invention, database server by the first count value at interval of the first preset duration in addition to resetting to Outside one default value, it can also judge whether the first current count value is more than or equal to 1 in the first count value of resetting every time, When continuously judging to reset the first count value, number of first count value more than or equal to 1 is more than pre-determined number, it can update First default value is:The difference of current first default value and numerical value 1.It is appreciated that the QPS values of target user subtract at this time It is small.
In this regard, illustrative, above-mentioned pre-determined number is 200 times, and the first current default value is 45, the first preset duration For 1s, then the corresponding QPS values of target customer are 45 at this time, and database server can be held in the first count value of resetting every time Row judges the step of whether the first current count value is more than or equal to 1, database server in certain first count value of resetting, It determines the first current count value and is more than or equal to 1, and it was found that is corresponding when continuously having occurred 200 the first count values of resetting First count value at moment is more than or equal to 1, then updating the first default value at this time is:Current first default value and numerical value 1 Difference, that is, it is 44 to update the first default value.
As a kind of embodiment arranged side by side with embodiment of the method shown in Fig. 2, in the embodiment of the present invention, method shown in Fig. 1 On the basis of embodiment, in the case where the judging result of above-mentioned steps S102 is to be, the above method can also include following steps Rapid a1~a3:
Step a1:It updates and is for the second count value set by target user:Current second count value with 1 and value.
It is appreciated that in embodiments of the present invention, for target user except configuring there are one in addition to the first count value, also configuring There are one the second count values, it is generally the case that it is 0 that second count value, which obtains initial value,.Database server is being judged every time When first count value is less than 1, can update second count value is:Current second count value with 1 and value.
Illustratively, which is 0, and the result that database server executes step S102 is when being, Updating second count value is:Current second count value with 1 and value, that is, update the second count value be 1.
Step a2:Judge whether updated second count value reaches third predetermined threshold value.
Likewise, the specific size of third predetermined threshold value may be set according to actual conditions, the embodiment of the present invention is simultaneously unlimited Determine the specific size of third predetermined threshold value.
If the judging result of step a2 is yes, a3 is thened follow the steps:Updating the first default value is:Current first is default Numerical value and the second default value and value.
It is appreciated that in embodiments of the present invention, the first default value is not fixed value, in the judging result of step a2 In the case of being, can update the first default value is:Current first default value and the second default value and value.Obviously , the specific size of the second default value may be set according to actual conditions, and the embodiment of the present invention does not limit the second present count The specific size of value.
For step a2 and a3, illustratively, it is assumed that third predetermined threshold value 40, the second meter that step a1 updates Numerical value is 40, and the first current default value is 50, and the second default value is 10.It is obvious, the judging result of step a2 be it is yes, Need at this time execute step a3, i.e., by the first default value be updated to 50 and 10 and value 60.
It is appreciated that in the embodiment of the present invention, step a3 and the step S107 in embodiment of the method shown in earlier figures 2 are complete Identical, the related content of step a3 and explanation are referred to state embodiment of the method shown in Fig. 2, and the embodiment of the present invention is herein not It is described in detail.
In addition, a kind of optional realization method as the embodiment of the present invention, is yes in the judging result of above-mentioned steps a2 In the case of, for database server other than executing step a3, the above method can also include the following steps S2:
Step S2:Prompt messages are generated, and the prompt messages generated are fed back into above-mentioned target database Terminal corresponding to access request.
Further more, a kind of optional realization method as the embodiment of the present invention, is in the first default value of above-mentioned update:Currently First default value and the second default value and the step of value (a3) before, the above method can also include step b:
Judge current first default value and the second default value and value whether be less than the second predetermined threshold value;
If the judging result of step b is yes, executing the first default value of above-mentioned update is:Current first default value with Second default value and value (a3) the step of.
It is also understood that in the embodiment of the present invention, step S2 and step b respectively with embodiment of the method shown in earlier figures 2 In step S1 and Fig. 3 shown in step S207 in embodiment of the method it is identical, the related content of step S2 and step b and Explanation is referred to state embodiment of the method shown in Fig. 2 and Fig. 3, and the embodiment of the present invention is not described in detail herein.
In the following, simply being introduced the present invention by a specific example again.
For target customer A, pre-set there are one token bucket, which can at most place 40 tokens, database Server is set as 40 at interval of 1 second, by the token in token bucket, i.e. QPS values current target customer A are 40.In addition, number It is the control server in data base cluster system according to library server, control server is communicated with multiple redis nodes, above-mentioned Third preset duration is 10 minutes, and the first predetermined threshold value is 40, and the first default value is 50, and the second default value is 10, second Predetermined threshold value is 80.
Assuming that at the p moment, database server receives a target database access request, first determines whether the first counting Whether value is less than 1, it is assumed that current first count value is 24, that is, shows that the first count value is not less than 1, database server is looked at this time The redis nodes corresponding to the target database access request are looked for, and the target database access request is transmitted to and is searched The redis nodes arrived.
Assuming that at the q moment, database server receives another target database access request, first determines whether the first meter Whether numerical value is less than 1, it is assumed that current first count value is 0, that is, shows that the first count value is less than 1.At this point, database server is united Before meter current time in third preset duration, judge that total degree of first count value less than 1 is 42.
Due to 42 be more than above-mentioned first predetermined threshold value 40, so database server judge again current first default value with Second default value and value whether be less than the second predetermined threshold value, at this point, the first default value and the second default value and be worth It is 60, is less than the second predetermined threshold value.So database server the first default value of update is:Current first default value and Two default values and value 60.
Corresponding to embodiment of the method shown in Fig. 1, as shown in figure 4, an embodiment of the present invention provides a kind of request processing unit, Including:
Receiving module 110, for receiving target database access request;
First judgment module 120, for judging whether the first count value is less than 1, wherein the first count value is for the mesh The count value set by the corresponding target user of database access request is marked, the first count value is set at interval of the first preset duration It is set to the first default value;
Processing module 130, in the case where the judging result of the first judgment module 120 is no, handling the number of targets According to library access request;
First update module 140, for update the first count value be:Current first count value with 1 difference.
A kind of as the embodiment of the present invention selects realization method, above-mentioned first judgment module 120 to can be also used for first In the case that count value is less than 1, it is spaced the second preset duration, returns to execute the step of whether the first count value is less than 1 judged.
Corresponding to embodiment of the method shown in Fig. 2, as shown in figure 5, above-mentioned apparatus can also include:
Statistical module 150, in the case where the judging result of the first judgment module 120 is to be, counting current time In preceding third preset duration, the total degree that the first count value is less than 1 is judged;
Second judgment module 160, for judging whether the total degree reaches the first predetermined threshold value;
Second update module 170, in the case where the judging result of the second judgment module 160 is to be, updating first Default value is:Current first default value and the second default value and value.
Corresponding to embodiment of the method shown in Fig. 3, as shown in fig. 6, above-mentioned apparatus can also include:
Third judgment module 180, in the case where the judging result of the second judgment module 160 is to be, judging current First default value and the second default value and value whether be less than the second predetermined threshold value;
Correspondingly, above-mentioned second update module 170, is specifically used in the judging result of third judgment module 180 being yes In the case of, the first default value of update is:Current first default value and the second default value and value.
Specifically, above-mentioned apparatus can also include:
Feedback module, in the case where the judging result of the second judgment module is to be, generating prompt messages, and Prompt messages are fed back into the terminal corresponding to target database access request.
As a kind of realization method arranged side by side with Fig. 5 shown devices embodiment, in the embodiment of the present invention, above-mentioned apparatus may be used also To include:
Third update module, in the case where the judging result of the first judgment module is to be, update to be used for target The second count value set by family is:Current second count value with 1 and value;
4th judgment module, for judging whether updated second count value reaches third predetermined threshold value;
4th update module, in the case where the judging result of the 4th judgment module is to be, updating the first present count Value is:Current first default value and the second default value and value.
From the foregoing, it will be observed that compared with prior art, in scheme provided in this embodiment, database server is only in the first meter In the case that numerical value is not less than 1, above-mentioned target database access request can be just handled, and since the first count value is at interval of first Preset duration is arranged to the first default value, and often handles the database access request of a target user, can update first Count value is:Current first count value and 1 difference, therefore the database access request of database server processes target user Average speed is:The ratio of first default value and the first preset duration meets database service enterprise and is serviced for it Different user setting different Q PS limitation demand.
The embodiment of the present invention additionally provides a kind of electronic equipment, as shown in fig. 7, comprises processor 210 and memory 220, Wherein,
Memory 220, for storing computer program;
Processor 210 when for executing the program stored on memory 220, realizes following steps:
Receive target database access request;
Judge whether the first count value is less than 1, wherein the first count value is to be corresponded to for the target database access request Target user set by count value, the first count value is arranged to the first default value at interval of the first preset duration;
If being not less than 1, the target database access request is handled;
Updating the first count value is:Current first count value with 1 difference.
Specific implementation and relevant explanation content about each step of this method may refer to shown in above-mentioned Fig. 1~3 Embodiment of the method, this will not be repeated here.
Above-mentioned electronic equipment can have the communication interface realized and communicated between above-mentioned electronic equipment and other equipment.
Above-mentioned processor 210, communication interface, memory 220 complete mutual communication by communication bus, this place The communication bus mentioned can be that Peripheral Component Interconnect standard (Peripheral Component Interconnect, PCI) is total Line or expanding the industrial standard structure (Extended Industry Standard Architecture, EISA) bus etc..This is logical Letter bus can be divided into address bus, data/address bus, controlling bus etc..
Memory 220 may include random access memory (Random Access Memory, RAM), can also include Nonvolatile memory (Non-Volatile Memory, NVM), for example, at least a magnetic disk storage.Optionally, memory It can also be at least one storage device for being located remotely from aforementioned processor.
Above-mentioned processor 210 can be general processor, including central processing unit (Central Processing Unit, CPU), network processing unit (Network Processor, NP) etc.;It can also be digital signal processor (Digital Signal Processing, DSP), application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic Device, discrete gate or transistor logic, discrete hardware components.
From the foregoing, it will be observed that compared with prior art, in scheme provided in this embodiment, database server is only in the first meter In the case that numerical value is not less than 1, above-mentioned target database access request can be just handled, and since the first count value is at interval of first Preset duration is arranged to the first default value, and often handles the database access request of a target user, can update first Count value is:Current first count value and 1 difference, therefore the database access request of database server processes target user Average speed is:The ratio of first default value and the first preset duration meets database service enterprise and is serviced for it Different user setting different Q PS limitation demand.
In another embodiment provided by the invention, a kind of computer readable storage medium is additionally provided, which can It reads to be stored with instruction in storage medium, when run on a computer so that computer executes any institute in above-described embodiment The request processing method stated.
From the foregoing, it will be observed that compared with prior art, in scheme provided in this embodiment, database server is only in the first meter In the case that numerical value is not less than 1, above-mentioned target database access request can be just handled, and since the first count value is at interval of first Preset duration is arranged to the first default value, and often handles the database access request of a target user, can update first Count value is:Current first count value and 1 difference, therefore the database access request of database server processes target user Average speed is:The ratio of first default value and the first preset duration meets database service enterprise and is serviced for it Different user setting different Q PS limitation demand.
In another embodiment provided by the invention, a kind of computer program product including instruction is additionally provided, when it When running on computers so that computer executes the method and step described in any of the above-described request processing method.
From the foregoing, it will be observed that compared with prior art, in scheme provided in this embodiment, database server is only in the first meter In the case that numerical value is not less than 1, above-mentioned target database access request can be just handled, and since the first count value is at interval of first Preset duration is arranged to the first default value, and often handles the database access request of a target user, can update first Count value is:Current first count value and 1 difference, therefore the database access request of database server processes target user Average speed is:The ratio of first default value and the first preset duration meets database service enterprise and is serviced for it Different user setting different Q PS limitation demand.
In another embodiment provided by the invention, a kind of computer program is additionally provided, when it runs on computers When so that computer executes the method and step described in any of the above-described request processing method.
From the foregoing, it will be observed that compared with prior art, in scheme provided in this embodiment, database server is only in the first meter In the case that numerical value is not less than 1, above-mentioned target database access request can be just handled, and since the first count value is at interval of first Preset duration is arranged to the first default value, and often handles the database access request of a target user, can update first Count value is:Current first count value and 1 difference, therefore the database access request of database server processes target user Average speed is:The ratio of first default value and the first preset duration meets database service enterprise and is serviced for it Different user setting different Q PS limitation demand.
It should be noted that herein, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also include other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that There is also other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is all made of relevant mode and describes, identical similar portion between each embodiment Point just to refer each other, and each embodiment focuses on the differences from other embodiments.Especially for device, For electronic equipment, computer readable storage medium, computer program product and computer program embodiments, since it is basic It is similar to embodiment of the method, so description is fairly simple, the relevent part can refer to the partial explaination of embodiments of method.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention It is interior.

Claims (14)

1. a kind of request processing method, which is characterized in that including:
Receive target database access request;
Judge whether the first count value is less than 1, wherein first count value is for the target database access request pair The count value set by target user answered, first count value are arranged to the first present count at interval of the first preset duration Value;
If being not less than 1, the target database access request is handled;
Updating first count value is:Presently described first count value with 1 difference.
2. according to the method described in claim 1, it is characterized in that, first count value be less than 1 in the case of, the side Method further includes:
It is spaced the second preset duration, returns to execution is described to judge the step of whether the first count value is less than 1.
3. method according to claim 1 or 2, which is characterized in that in the case where first count value is less than 1, institute The method of stating further includes:
Before statistics current time in third preset duration, the total degree that first count value is less than 1 is judged;
Judge whether the total degree reaches the first predetermined threshold value;
If reaching the first predetermined threshold value, updating first default value is:Presently described first default value and second is in advance If numerical value and value.
4. according to the method described in claim 3, it is characterized in that, being in update first default value:Current institute State the first default value and the second default value and the step of value before, the method further includes:
Judge presently described first default value and the second default value and value whether be less than the second predetermined threshold value;
If it is less than second predetermined threshold value, executing update first default value is:Presently described first is default Numerical value and the second default value and the step of value.
5. according to the method described in claim 3, it is characterized in that, the case where the total degree reaches the first predetermined threshold value Under, the method further includes:
Prompt messages are generated, and the prompt messages are fed back to corresponding to the target database access request Terminal.
6. method according to claim 1 or 2, which is characterized in that in the case where first count value is less than 1, institute The method of stating further includes:
It updates and is for the second count value set by the target user:Presently described second count value with 1 and value;
Judge whether updated second count value reaches third predetermined threshold value;
If reaching third predetermined threshold value, updating first default value is:Presently described first default value and second is in advance If numerical value and value.
7. a kind of request processing unit, which is characterized in that including:
Receiving module, for receiving target database access request;
First judgment module, for judging whether the first count value is less than 1, wherein first count value is for the mesh The count value set by the corresponding target user of database access request is marked, first count value is at interval of the first preset duration It is arranged to the first default value;
Processing module, in the case where the judging result of first judgment module is no, handling the target database Access request;
First update module is for updating first count value:Presently described first count value with 1 difference.
8. device according to claim 7, which is characterized in that first judgment module is additionally operable in first meter In the case that numerical value is less than 1, it is spaced the second preset duration, returns to execution is described to judge the step of whether the first count value is less than 1.
9. device according to claim 7 or 8, which is characterized in that described device further includes:
Statistical module, in the case where the judging result of first judgment module is to be, counting third before current time In preset duration, the total degree that first count value is less than 1 is judged;
Second judgment module, for judging whether the total degree reaches the first predetermined threshold value;
Second update module, in the case where the judging result of second judgment module is to be, update described first to be pre- If numerical value is:Presently described first default value and the second default value and value.
10. device according to claim 9, which is characterized in that described device further includes:
Third judgment module, in the case where the judging result of second judgment module is to be, judging presently described the One default value and the second default value and value whether be less than the second predetermined threshold value;
Second update module, specifically in the case where the judging result of the third judgment module is to be, updating institute Stating the first default value is:Presently described first default value and the second default value and value.
11. device according to claim 9, which is characterized in that described device further includes:
Feedback module, in the case where the judging result of second judgment module is to be, generating prompt messages, and The prompt messages are fed back into the terminal corresponding to the target database access request.
12. device according to claim 7 or 8, which is characterized in that described device further includes:
Third update module, in the case where the judging result of first judgment module is to be, update to be directed to the mesh Marking the second count value set by user is:Presently described second count value with 1 and value;
4th judgment module, for judging whether updated second count value reaches third predetermined threshold value;
4th update module, in the case where the judging result of the 4th judgment module is to be, update described first to be pre- If numerical value is:Presently described first default value and the second default value and value.
13. a kind of electronic equipment, which is characterized in that including processor and memory, wherein;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes any method and steps of claim 1-6.
14. a kind of computer readable storage medium, which is characterized in that be stored with computer in the computer readable storage medium Program realizes claim 1-6 any method and steps when the computer program is executed by processor.
CN201711295208.0A 2017-12-08 2017-12-08 Request processing method, device, electronic equipment and computer readable storage medium Pending CN108573013A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711295208.0A CN108573013A (en) 2017-12-08 2017-12-08 Request processing method, device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711295208.0A CN108573013A (en) 2017-12-08 2017-12-08 Request processing method, device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN108573013A true CN108573013A (en) 2018-09-25

Family

ID=63576483

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711295208.0A Pending CN108573013A (en) 2017-12-08 2017-12-08 Request processing method, device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN108573013A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342539A (en) * 2021-05-31 2021-09-03 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN114745329A (en) * 2022-03-30 2022-07-12 青岛海尔科技有限公司 Flow control method and apparatus, storage medium, and electronic apparatus

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8504691B1 (en) * 2010-12-29 2013-08-06 Amazon Technologies, Inc. System and method for allocating resources for heterogeneous service requests
CN105144161A (en) * 2013-03-13 2015-12-09 亚马逊科技公司 Token-based admission control for replicated writes
CN105409171A (en) * 2013-06-25 2016-03-16 亚马逊科技公司 Burst mode control
CN106202581A (en) * 2016-08-30 2016-12-07 北京奇艺世纪科技有限公司 A kind of data search method and device
CN106326340A (en) * 2016-08-01 2017-01-11 网易无尾熊(杭州)科技有限公司 Method and device for processing data
CN106612238A (en) * 2015-10-21 2017-05-03 阿里巴巴集团控股有限公司 Flow control method, device and system
CN106980687A (en) * 2017-03-31 2017-07-25 北京奇艺世纪科技有限公司 A kind of resource downloading system, method and reptile download system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8504691B1 (en) * 2010-12-29 2013-08-06 Amazon Technologies, Inc. System and method for allocating resources for heterogeneous service requests
CN105144161A (en) * 2013-03-13 2015-12-09 亚马逊科技公司 Token-based admission control for replicated writes
CN105409171A (en) * 2013-06-25 2016-03-16 亚马逊科技公司 Burst mode control
CN106612238A (en) * 2015-10-21 2017-05-03 阿里巴巴集团控股有限公司 Flow control method, device and system
CN106326340A (en) * 2016-08-01 2017-01-11 网易无尾熊(杭州)科技有限公司 Method and device for processing data
CN106202581A (en) * 2016-08-30 2016-12-07 北京奇艺世纪科技有限公司 A kind of data search method and device
CN106980687A (en) * 2017-03-31 2017-07-25 北京奇艺世纪科技有限公司 A kind of resource downloading system, method and reptile download system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342539A (en) * 2021-05-31 2021-09-03 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN114745329A (en) * 2022-03-30 2022-07-12 青岛海尔科技有限公司 Flow control method and apparatus, storage medium, and electronic apparatus
CN114745329B (en) * 2022-03-30 2024-03-22 青岛海尔科技有限公司 Flow control method and device, storage medium and electronic device

Similar Documents

Publication Publication Date Title
CN109936511A (en) A kind of token acquisition methods, device, server, terminal device and medium
CN106548402A (en) Resource transfers monitoring method and device
US7840576B1 (en) Flexible rule-based infrastructure for discussion board maintenance
CN105095393A (en) Method and device for data storage
CN102468982B (en) Element terminal and communication system
CN107656807A (en) The automatic elastic telescopic method and device of a kind of virtual resource
CN109800204A (en) Data distributing method and Related product
CN108573013A (en) Request processing method, device, electronic equipment and computer readable storage medium
CN110011843A (en) Alarm information processing method, electronic equipment and storage medium
CN112016030A (en) Message pushing method, device, server and computer storage medium
CN102315955A (en) Control method for setting obstruction for junk information and corresponding control device
CN113591068A (en) Online login equipment management method and device and electronic equipment
CN104348905B (en) A kind of method and device of off-line PUSH message
CN108646987B (en) File volume management method and device, storage medium and terminal
CN114357085A (en) Financial data storage method and device based on block chain and storage medium
CN112052399B (en) Data processing method, device and computer readable storage medium
CN107483310B (en) Method and system for networking between terminal and forwarding node
CN106933673A (en) Adjust the method and device of component logic number of threads
CN103414756A (en) Task distributing method and distributing node and system
CN110389876A (en) Basic resource capacity monitoring and managing method, device, equipment and storage medium
CN111475223B (en) Management method and device for information reminding
CN110223132A (en) Order processing method, apparatus, terminal and storage medium based on more authorization roles
CN115660344A (en) User scheduling method and device, electronic equipment and storage medium
CN107766086A (en) Function option display method and device, electronic equipment and readable storage medium
CN114490406A (en) Test coverage item management method, device, equipment and medium

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