当前位置:网站首页>Current limiting and download interface request number control
Current limiting and download interface request number control
2022-06-11 01:17:00 【Programmer vegetables】
The cash register system is much more stable than the Internet application traffic , The peak flow is three times as much as usual , It is completely controllable , We use the current limit here to control the background downloading at the same time XLS Number of requests for the table , Because the background system needs to provide a large number of exports XLS Table function , Cashiers and managers need to use the data we export to do various analyses ( It should be because our report function is not perfect ).
Let's sort it out Guaua Current limiting tools provided and our own practices .
One 、 Use LoadCaching Realize interface current limitation
Ideas : establish LoadCaching object , Set the validity period to 1 second , cache Key For timestamps ( The current number of seconds ), Value is a counter ( The number of calls is accumulated ), If the query hit counter is incremented , Do not process when the counter value is greater than the limit value , If there is no command , Create a new timestamp cache and initialize the value to 0, To achieve the purpose of current limitation .

Two 、 Use RateLimter Current limiting
RateLimter Limit the rate of access to resources , There are two interfaces for obtaining tokens , One is non blocking , If you can't get the token, you can return directly false, The other is blocking , Can't get a token wait for a token .
RateLimiter rateLimiter = RateLimiter.create(10)
Number of tokens created per second 
3、 ... and 、 The number of download interface requests is limited
Ideas : Create an interceptor , Use redis Store the currently downloaded request ( Generate a unique string ), Judge the present redis The key Of size size , If the limit is exceeded , Just return the message you need to wait for , When the download is complete , The unique string of the request is separated from redis Delete in .

边栏推荐
- The file "setup" does not exist. What should I do?
- 北京朝阳区专精特新制造业企业支持标准介绍,补贴100万
- 北京门头沟区高新技术企业培育支持标准,补贴10万
- Viewpager and dot of bottom wireless loop
- Merge sort and cardinality sort
- 北京中国专利奖申报流程介绍,补贴100万
- table_exists_action=append和table_exists_action=truncate
- SSH远程登陆配置sshd_config文件详解
- A/B机器正常连接后, B机器突然重启, 问A此时处于TCP的 什么状态?如何消除服务器程序中的这个状态?
- Introduction to the application process of China Patent Award, with a subsidy of 1million yuan
猜你喜欢

About log traffic monitoring and early warning small project | Kafka vs redis

CentOS实战部署redis

pytorch分类问题总结

文件“Setup”不存在,怎么办?

Teach you the front and back separation architecture (V) system authentication implementation

Direct insert sort and shell sort

对多线程的理解
【ROS入门教程】---- 02 ROS安装

ZABBIX offline installation

最好的創意鼓工具:Groove Agent 5
随机推荐
记录oracle的几个参数 db_files,Cursor_sharing ,open_cursor
網絡基礎(1)-----認識網絡
async await
Array simulation [queue] and [ring queue]_ code implementation
Network foundation (1) -- understanding the network
Merge sort and cardinality sort
[introduction to ROS] - 01 introduction to ROS
2022北京怀柔区新技术新产品(服务)认定要求
简述自定义注解
Store binary tree in sequence [store tree in array]
库存管理与策略模式
Shenzhen Nanshan District specialized special new enterprise application process, with a subsidy of RMB 100000-500000
Introduction to the application process of Beijing China Patent Award, with a subsidy of 1million yuan
ion_mmap
Basic introduction of graph and depth first traversal and breadth first traversal
最好的創意鼓工具:Groove Agent 5
复利的保险理财产品怎么样?可以买吗?
Time dependent - format, operation, comparison, conversion
北京朝阳区专精特新制造业企业支持标准介绍,补贴100万
No module named CV2