Questions tagged [throttling]

Throttling is a mechanism to regulate the rate at which processing is performed

1092 questions
289
votes
6 answers

Simulate delayed and dropped packets on Linux

I would like to simulate packet delay and loss for UDP and TCP on Linux to measure the performance of an application. Is there a simple way to do this?
Alec
228
votes
6 answers

Best way to implement request throttling in ASP.NET MVC?

We're experimenting with various ways to throttle user actions in a given time period: Limit question/answer posts Limit edits Limit feed retrievals For the time being, we're using the Cache to simply insert a record of user activity - if that…
Jarrod Dixon
  • 15,727
  • 9
  • 60
  • 72
167
votes
15 answers

Throttling method calls to M requests in N seconds

I need a component/class that throttles execution of some method to maximum M calls in N seconds (or ms or nanos, does not matter). In other words I need to make sure that my method is executed no more than M times in a sliding window of N…
vtrubnikov
  • 2,045
  • 3
  • 14
  • 10
139
votes
28 answers

How to use throttle or debounce with React Hook?

I'm trying to use the throttle method from lodash in a functional component, e.g.: const App = () => { const [value, setValue] = useState(0) useEffect(throttle(() => console.log(value), 1000), [value]) return (
Alexandre Annic
  • 9,942
  • 5
  • 36
  • 50
120
votes
24 answers

Simple throttle in JavaScript

I am looking for a simple throttle in JavaScript. I know libraries like lodash and underscore have it, but only for one function it will be overkill to include any of those libraries. I was also checking if jQuery has a similar function - could not…
Mia
  • 6,220
  • 12
  • 47
  • 81
74
votes
10 answers

Throttle and queue up API requests due to per second cap

I'm use mikeal/request to make API calls. One of the API's I use most frequently (the Shopify API). Recently put out a new call limit, I'm seeing errors like: Exceeded 6.0 calls per second for api client. Slow your requests or contact support for…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
67
votes
3 answers

Throttling asynchronous tasks

I would like to run a bunch of async tasks, with a limit on how many tasks may be pending completion at any given time. Say you have 1000 URLs, and you only want to have 50 requests open at a time; but as soon as one request completes, you open up a…
Josh Wyant
  • 1,177
  • 1
  • 8
  • 13
61
votes
11 answers

How can I throttle user login attempts in PHP

I was just reading this post The definitive guide to form-based website authentication on Preventing Rapid-Fire Login Attempts. Best practice #1: A short time delay that increases with the number of failed attempts, like: 1 failed attempt = no…
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
60
votes
11 answers

How to throttle requests in a Web Api?

I'm trying to implement request throttling via the following: Best way to implement request throttling in ASP.NET MVC? I've pulled that code into my solution and decorated an API controller endpoint with the attribute:…
RobVious
  • 12,685
  • 25
  • 99
  • 181
54
votes
8 answers

How do I throttle my site's API users?

The legitimate users of my site occasionally hammer the server with API requests that cause undesirable results. I want to institute a limit of no more than say one API call every 5 seconds or n calls per minute (haven't figured out the exact limit…
scotts
  • 4,027
  • 3
  • 29
  • 26
50
votes
15 answers

How can I debounce a method call?

I'm trying to use a UISearchView to query google places. In doing so, on text change calls for my UISearchBar, I'm making a request to google places. The problem is I'd rather debounce this call to only request once per 250 ms in order to avoid…
Parris
  • 17,833
  • 17
  • 90
  • 133
49
votes
5 answers

CPU throttling in C++

I was just wondering if there is an elegant way to set the maximum CPU load for a particular thread doing intensive calculations. Right now I have located the most time-consuming loop in the thread (it does only compression) and use GetTickCount()…
Piotr Tyburski
  • 651
  • 6
  • 11
44
votes
9 answers

Throttling CPU/Memory usage of a Thread in Java?

I'm writing an application that will have multiple threads running, and want to throttle the CPU/memory usage of those threads. There is a similar question for C++, but I want to try and avoid using C++ and JNI if possible. I realize this might not…
Alex Beardsley
  • 20,988
  • 15
  • 52
  • 67
40
votes
6 answers

WCF stops responding after about 10 or so calls (throttling)

I have a WCF Service and an application with a Service Reference to it, and with the application I have a loop and in each iteration it's making a call to a method in this wcf web-service. The problem is that after about 9 calls or so, it just…
Andreas Grech
  • 105,982
  • 98
  • 297
  • 360
40
votes
3 answers

'ab' program freezes after lots of requests, why?

Whenever I use 'ab' to benchmark a web server, it will freeze for a while after having sent lots of requests, only to continue after 20 seconds or so. Consider the following HTTP server simulator, written in Ruby: require 'socket' RESPONSE =…
Hongli
  • 18,682
  • 15
  • 79
  • 107
1
2 3
72 73