CN109818992A - Video cloud platform API Access frequency control method - Google Patents
Video cloud platform API Access frequency control method Download PDFInfo
- Publication number
- CN109818992A CN109818992A CN201711154541.XA CN201711154541A CN109818992A CN 109818992 A CN109818992 A CN 109818992A CN 201711154541 A CN201711154541 A CN 201711154541A CN 109818992 A CN109818992 A CN 109818992A
- Authority
- CN
- China
- Prior art keywords
- user
- access
- frequency
- request
- cloud platform
- 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
Links
Landscapes
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
Abstract
The present invention provides a kind of video cloud platform API Access frequency control methods, it is the following steps are included: step 1, flexible control based on different user account, it needs the core logic of control being transferred to Business Logic, user each time can be introduced into Filter the request of API, first be accessed frequency authorization according to User ID;Step 2 judges whether user's access is more than the frequency, if user alreadys exceed the visitation frequency of restriction, directly returns or directly refuse;Step 3, if user is not above the visitation frequency of restriction, user's access count+1, the business logic processing unit for passing the requests to rear end is handled.The present invention can flexibly control the frequency of each user, and it can be arranged into cluster in extension at any time, video cloud API system can be supported to expand to cluster, increase node as needed, the frequency configuration of each user can be modified at any time after deployment is completed, characteristic easy to maintain can flexibly be expanded by reaching.
Description
Technical field
The present invention relates to a kind of video cloud platform fields, and in particular, to a kind of video cloud platform API Access frequency control
Method.
Background technique
In the cloud platform for providing video Saas (software is to service) service, many users are required through platform offer
API (application programming interface) completes the integrated of same Saas (software services) service, such as the upload of video, management,
The functions such as inquiry.It is used since video cloud platform is usually associated with a large amount of user, API Access amount is very huge, can be to platform
No small resource loss is caused, such as: control is inflexible, and the visitation frequency control method based on Nginx is calculated based on IP
Access times return to mistake to it that is, if access times have been more than n times in an IP unit time.But for video
Cloud service generally requires to control its visitation frequency for single user, reaches the flexible allocation of resource;Collection can not be expanded to
The visitation frequency of single machine may only be arranged in group, and video cloud service faces huge access pressure, often using extension
Mode to cluster is come for access, but can not be shared using the access times data between Nginx multiple servers;It is not easy
Modification configuration, the configuration of Nginx require to modify into configuration file, and need to restart service after having modified, and repair
The cost changed is larger.
Summary of the invention
For the defects in the prior art, the object of the present invention is to provide a kind of video cloud platform API Access frequency controls
Method can flexibly control the frequency of each user, and can be arranged into cluster in extension at any time, can support to regard
Frequency cloud API system expands to cluster, increases node as needed, can modify the frequency of each user at any time after deployment is completed
Configuration, characteristic easy to maintain can flexibly be expanded by reaching.
According to an aspect of the present invention, a kind of video cloud platform API Access frequency control method is provided, feature exists
In comprising following steps:
Step 1, the flexible control based on different user account need the core logic of control being transferred to service logic
Layer, request filter element intercept the HTTP API Access request of all users;
Step 2, request filter element obtain the User ID in HTTP request parameter, carry out parameter and deliver for a check, if do not met
Then direct denied access;
Step 3 judges whether user's access is more than visitation frequency, if user alreadys exceed the visitation frequency of restriction,
It directly returns or directly refuses;If user is not above the visitation frequency of restriction, which passes request
The business logic processing unit for passing rear end is handled;
Step 4, the current accessed for obtaining user into distributed caching according to User ID counts, if the value is not present,
The value is then denoted as 1;
Step 5 directly allows this if the value is not present according to the maximum access times that User ID gets user
Access passes through;
Current accessed is counted and carries out numeric ratio pair with maximum access count by step 6;
The request is then forwarded the request to Service Processing Unit and carried out by step 7 if access is not up to the upper limit
Processing;
Step 8 requests the direct denied access of filter element if the access reaches the upper limit;
Step 9, after the unit time, current request technology can be zeroed out by request control unit.
Preferably, the business logic processing unit of the rear end includes video management unit so that it is convenient to manage video.
Preferably, the visitation frequency is needed to access times in each request video management API Subscriber Unit time
Counted with access times maximum in each Subscriber Unit time so that it is convenient to.
Preferably, access times and each Subscriber Unit in each request video management API Subscriber Unit time
Maximum access times are used to store so that it is convenient to storage and management by Hash dictionary in time.
Compared with prior art, the present invention is with following the utility model has the advantages that the present invention can flexibly control each user
The frequency, and can at any time extension be arranged into cluster, video cloud API system can be supported to expand to cluster, as needed
Increase node, deployment complete after can modify at any time each user the frequency configuration, reach can flexibly expand it is easy to maintain
Characteristic.
Detailed description of the invention
Upon reading the detailed description of non-limiting embodiments with reference to the following drawings, other feature of the invention,
Objects and advantages will become more apparent upon:
Fig. 1 is the flow diagram of video cloud platform API Access frequency control method of the present invention.
Fig. 2 is the flow diagram counted using Hash dictionary access visit.
Fig. 3 is the flow diagram counted using Redis access visit.
Fig. 4 is the working principle diagram with the automatic expiration mechanism of redis key.
Specific embodiment
The present invention is described in detail combined with specific embodiments below.Following embodiment will be helpful to the technology of this field
Personnel further understand the present invention, but the invention is not limited in any way.It should be pointed out that the ordinary skill of this field
For personnel, without departing from the inventive concept of the premise, various modifications and improvements can be made.These belong to the present invention
Protection scope.
As shown in Figure 1, video cloud platform API Access frequency control method of the present invention the following steps are included:
Step 1, the flexible control based on different user account need the core logic of control being transferred to service logic
Layer, request filter element intercept the HTTP API Access request of all users;
Step 2, request filter element obtain the User ID in HTTP request parameter, carry out parameter and deliver for a check, if do not met
Then direct denied access;
Step 3 judges whether user's access is more than visitation frequency, if user alreadys exceed the visitation frequency of restriction,
It directly returns or directly refuses;If user is not above the visitation frequency of restriction, which passes request
The business logic processing unit for passing rear end is handled;
Step 4, the current accessed for obtaining user into distributed caching according to User ID counts, if the value is not present,
The value is then denoted as 1;
Step 5 directly allows this if the value is not present according to the maximum access times that User ID gets user
Access passes through;
Current accessed is counted and carries out numeric ratio pair with maximum access count by step 6;
The request is then forwarded the request to Service Processing Unit and carried out by step 7 if access is not up to the upper limit
Processing;
Step 8 requests the direct denied access of filter element if the access reaches the upper limit;
Step 9, after the unit time, current request technology can be zeroed out by request control unit.
As shown in Fig. 2, when visitation frequency Fi lter (filter) is needed to each request video management API Subscriber Unit
In access times and maximum access times are counted in each Subscriber Unit time, since video cloud platform accesses user
It is numerous, it needs quickly accurately to find the current count value needs of some access user and is ensured by special mechanism,
It will use two Hash dictionaries difference storage cell times access times and maximum access times in the present embodiment.Hash dictionary
It is to look for fastest data structure, is well suited for being used in finding from a large amount of key values to some key and corresponds to numerical value.At this
In embodiment, we use key of the video cloud platform for unique ID of each user distribution as Hash dictionary, access count work
For the value of Hash dictionary, so that it may quickly find the current access count of some User ID.Such as: user A accesses API,
Filter can search the corresponding current count key count_key_A of ID ID_A of user A, be that key is being worked as by count_key_A
Current accessed is found in preceding access count Hash dictionary counts count_A.Maximum access count is calculated by identical method
Key max_count_key_A and value max_count_A.
Referring finally to count_A whether more than max_count_A, if it does, not allowing then to access, returned to client wrong
Accidentally.
In the case where allowing access in the case where count_A is less than max_count_A, system is needed A pairs of user
The current accessed answered, which counts, adds one, and the value added is newly stored into Hash table.
When being carried out to count_A plus a deposit, it should be noted that the user may also exist there are also other requests at this time
API is accessed, if other in the dictionary may be override if putting back to again out from value in Hash dictionary and requested
Change to the value.So system needs to guarantee the atomicity of count_A, guarantee that it is thread-safe;It herein can be by
The characteristic of high-level language, such as count_A is declared as the AtomicInteger in Java, call its getAndIncrease
Method can add one to it in the case where guaranteeing thread-safe.
What system needed to control is the video management API Access frequency in the unit time, and it is fixed that this means that we need
Phase is zeroed out the access times of statistics.Video cloud platform API system will start a timer in this embodiment, every
The operation of unit time t is primary, empties all current accesseds in Hash dictionary and counts.So just can guarantee can control the unit time
Interior visitation frequency.
As shown in figure 3, in actual use situation, platform generally requires to service due to the publicly-owned characteristic of video cloud platform
Mass users have to be the distributed request to cope with magnanimity this requires video cloud platform API.Divide by API system
After cloth, because multiple programs need share and access to count, current accessed was counted into Hash dictionary and maximum access meter originally
Number Hash dictionary is stored in the mode in local memory and is just no longer applicable in.In distributed environment, the present embodiment will be used
Redis (reaffirming) stores access count, key assignments class storing data library redis (reaffirming) outstanding as one, have it is high simultaneously
Hair and distributed characteristic.Also, the characteristic of automatic expired (expire) can be set using redi s (reaffirming) all keys,
It can not have to periodically empty access count in program again, more accurate access control can be reached.
As shown in figure 4, needing to provide using redis (reaffirming) when (reaffirming) that access count increases to redis
Incr operation, just can guarantee the atomicity of the data manipulation in multithreading.
Redis has been applied among these and (has reaffirmed) the automatic expiration mechanism of key to guarantee emptying automatically for access count, has been come
Achieving the purpose that frequency control, the maximum visitation frequency of each video cloud platform user is recorded in redi s (reaffirming),
It can modify in video cloud platform management system, change each user's maximum limitation in real time, achieve the purpose that flexibly to control.
In conclusion the present invention can flexibly control the frequency of each user, and can be arranged into extension at any time
In cluster, video cloud API system can be supported to expand to cluster, increase node as needed, it can be at any time after deployment is completed
The frequency configuration of each user is modified, characteristic easy to maintain can flexibly be expanded by reaching.
Specific embodiments of the present invention are described above.It is to be appreciated that the invention is not limited to above-mentioned
Particular implementation, those skilled in the art can make various deformations or amendments within the scope of the claims, this not shadow
Ring substantive content of the invention.
Claims (4)
1. a kind of video cloud platform API Access frequency control method, which is characterized in that itself the following steps are included:
Step 1, the flexible control based on different user account are needed the core logic of control being transferred to Business Logic, be asked
Filter element is asked to intercept the HTTP API Access request of all users;
Step 2, request filter element obtain the User ID in HTTP request parameter, carry out parameter and deliver for a check, straight if not meeting
Connect denied access;
Step 3 judges whether user's access is more than visitation frequency, if user alreadys exceed the visitation frequency of restriction, directly
It returns or directly refuses;If user is not above the visitation frequency of restriction, which is passed the requests to
The business logic processing unit of rear end is handled;
Step 4, the current accessed for obtaining user into distributed caching according to User ID counts, will if the value is not present
The value is denoted as 1;
Step 5 gets the maximum access times of user according to User ID, if the value is not present, this is directly allowed to access
Pass through;
Current accessed is counted and carries out numeric ratio pair with maximum access count by step 6;
The request is then forwarded the request to Service Processing Unit and handled by step 7 if access is not up to the upper limit;
Step 8 requests the direct denied access of filter element if the access reaches the upper limit;
Step 9, after the unit time, current request technology can be zeroed out by request control unit.
2. video cloud platform API Access frequency control method according to claim 1, which is characterized in that the rear end
Business logic processing unit includes video management unit.
3. video cloud platform API Access frequency control method according to claim 1, which is characterized in that the access frequency
It is secondary to need to access times and maximum visit in each Subscriber Unit time in each request video management API Subscriber Unit time
Ask that number is counted.
4. video cloud platform API Access frequency control method according to claim 3, which is characterized in that described each to ask
Ask in the video management API Subscriber Unit time access times and in each Subscriber Unit time maximum access times by Hash word
Allusion quotation is used to store.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711154541.XA CN109818992A (en) | 2017-11-20 | 2017-11-20 | Video cloud platform API Access frequency control method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711154541.XA CN109818992A (en) | 2017-11-20 | 2017-11-20 | Video cloud platform API Access frequency control method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109818992A true CN109818992A (en) | 2019-05-28 |
Family
ID=66599304
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711154541.XA Pending CN109818992A (en) | 2017-11-20 | 2017-11-20 | Video cloud platform API Access frequency control method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109818992A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115334321A (en) * | 2022-08-10 | 2022-11-11 | 北京百度网讯科技有限公司 | Method and device for acquiring access heat of video stream, electronic equipment and medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103379090A (en) * | 2012-04-12 | 2013-10-30 | 腾讯科技(北京)有限公司 | Open platform access frequency control method and system and frequency server |
CN103379000A (en) * | 2012-04-28 | 2013-10-30 | 阿里巴巴集团控股有限公司 | Concurrent testing method and testing server |
CN103475637A (en) * | 2013-04-24 | 2013-12-25 | 携程计算机技术(上海)有限公司 | Network access control method and system based on IP access behaviors |
US9317820B1 (en) * | 2010-03-31 | 2016-04-19 | Emc Corporation | System and method for configuring a cloud computing space |
CN107196811A (en) * | 2017-07-13 | 2017-09-22 | 上海幻电信息科技有限公司 | Video website door chain control system and method |
-
2017
- 2017-11-20 CN CN201711154541.XA patent/CN109818992A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9317820B1 (en) * | 2010-03-31 | 2016-04-19 | Emc Corporation | System and method for configuring a cloud computing space |
CN103379090A (en) * | 2012-04-12 | 2013-10-30 | 腾讯科技(北京)有限公司 | Open platform access frequency control method and system and frequency server |
CN103379000A (en) * | 2012-04-28 | 2013-10-30 | 阿里巴巴集团控股有限公司 | Concurrent testing method and testing server |
CN103475637A (en) * | 2013-04-24 | 2013-12-25 | 携程计算机技术(上海)有限公司 | Network access control method and system based on IP access behaviors |
CN107196811A (en) * | 2017-07-13 | 2017-09-22 | 上海幻电信息科技有限公司 | Video website door chain control system and method |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115334321A (en) * | 2022-08-10 | 2022-11-11 | 北京百度网讯科技有限公司 | Method and device for acquiring access heat of video stream, electronic equipment and medium |
CN115334321B (en) * | 2022-08-10 | 2024-04-09 | 北京百度网讯科技有限公司 | Method and device for acquiring access heat of video stream, electronic equipment and medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11789925B2 (en) | System and method for conditionally updating an item with attribute granularity | |
US9754009B2 (en) | System and method for implementing a scalable data storage service | |
US9372911B2 (en) | System and method for performing replica copying using a physical copy mechanism | |
CN107766129A (en) | A kind of task processing method, apparatus and system | |
CN107688500A (en) | A kind of distributed task scheduling processing method, device, system and equipment | |
CN108132830A (en) | A kind of method for scheduling task, apparatus and system | |
CN106357778A (en) | Session information sharing method, device and system | |
CN106886371B (en) | Caching data processing method and device | |
CN101771723A (en) | Data synchronization method | |
US11126460B2 (en) | Limiting folder and link sharing | |
CN107766378A (en) | Sending method and device, the distributed data base system of solicited message | |
CN101583160A (en) | Device for realizing hierarchical quality of service business and method | |
CN109951541A (en) | A kind of serial number generation method and server | |
CN107306247B (en) | Resource access control method and device | |
CN110417777B (en) | Optimized method and device for communication between microservices | |
CN105320676A (en) | Customer data query service method and device | |
CN101778131A (en) | Data synchronization system | |
US8224933B2 (en) | Method and apparatus for case-based service composition | |
CN109818992A (en) | Video cloud platform API Access frequency control method | |
CN101789963A (en) | Data synchronization system | |
CN110457307A (en) | Metadata management system, user's cluster creation method, device, equipment and medium | |
CN111861357B (en) | Authority information processing method and system, computer equipment and storage medium | |
CN114090969B (en) | Multilevel multi-tenant cross authorization management method | |
KR101888131B1 (en) | Method for Performing Real-Time Changed Data Publish Service of DDS-DBMS Integration Tool | |
CN111782634B (en) | Data distributed storage method, device, electronic equipment and storage 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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190528 |