throttling

javascript/jquery - add debounce to a button

£可爱£侵袭症+ 提交于 2019-11-27 12:55:36
I want to add a debounce to a button, but i want to perform some actions each time user clicks button, but only after 5 second after user hits button, then perform SQL update. Usually the throttle seems to be applied directly to the listener. Here I want some actions performed each time the button is clicked, and then an update after a reasonable waiting period. I am not sure how to use the function in this case... reference: http://code.google.com/p/jquery-debounce/ $('#myButton').click(function() { // do a date calculation // show user changes to screen // wait until user has has stopped

Bandwidth throttling in C#

懵懂的女人 提交于 2019-11-27 12:49:37
I am developing a program that continually sends a stream of data in the background and I want to allow the user to set a cap for both upload and download limit. I have read up on the token bucket and leaky bucket alghorhithms, and seemingly the latter seems to fit the description since this is not a matter of maximizing the network bandwidth but rather being as unobtrusive as possible. I am however a bit unsure on how I would implement this. A natural approach is to extend the abstract Stream class to make it simple to extend existing traffic, but would this not require the involvement of

How can I debounce a method call?

社会主义新天地 提交于 2019-11-27 11:58:14
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 unnecessary network traffic. I'd rather not write this functionality myself, but I will if I need to. I found: https://gist.github.com/ShamylZakariya/54ee03228d955f458389 , but I'm not quite sure how to use it: func debounce( delay:NSTimeInterval, #queue:dispatch_queue_t, action: (()->()) ) -> ()->() { var lastFireTime:dispatch_time_t = 0 let

WCF Service Throttling

血红的双手。 提交于 2019-11-27 07:28:12
I have a WCF service deployed in a console app with BasicHTTPBinding and SSL enabled. The following attribute is set as well: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] I have also set the throttling behavior to <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" /> On the other hand I have created a test client (for load test) that initiates multiple clients simultaneously (multiple threads) and performs transactions on the server. Everything seems fine but on server

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

白昼怎懂夜的黑 提交于 2019-11-27 06:19:25
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 = "HTTP/1.1 200 OK\r\n" + "Connection: close\r\n" + "\r\n" + "\r\n" buffer = "" server = TCPServer.new("127.0.0.1", 3000) # Create TCP server at port 3000. server.listen(1024) # Set backlog to 1024. while true client = server.accept # Accept new client. client.write(RESPONSE) # Write a stock "HTTP" response. client.close_write # Shutdown write part of the

How to throttle requests in a Web Api?

假如想象 提交于 2019-11-27 06:05:24
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: [Route("api/dothis/{id}")] [AcceptVerbs("POST")] [Throttle(Name = "TestThrottle", Message = "You must wait {n} seconds before accessing this url again.", Seconds = 5)] [Authorize] public HttpResponseMessage DoThis(int id) {...} This compiles but the attribute's code doesn't get hit, and the throttling doesn't work. I don't get any errors though. What am I missing? Darin Dimitrov

How to programmatically limit bandwidth usage of my c# application?

一曲冷凌霜 提交于 2019-11-27 03:36:18
I've got a backup application here which connects to various webservices and downloads/uploads files from ftp or http servers. What is the easiest way to limit the bandwidth usage of my application? I need to do that because the application once installed and running will be slowing down internet access for all office people, which eventually will get me into hell. So I'd like to implement a speed-limit which is active during the work-hours and gets disabled at night. What you are looking for is called Bandwidth throttling And here is a good example how is this done, also review the comments

How do I throttle my site's API users?

霸气de小男生 提交于 2019-11-27 02:35:32
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 yet). I could obviously log every API call in a DB and do the calculation on every request to see if they're over the limit, but all this extra overhead on EVERY request would be defeating the purpose. What are other less resource-intensive methods I could use to institute a limit? I'm using PHP/Apache/Linux, for what it's worth. scotts Ok, there's

Throttling login attempts

走远了吗. 提交于 2019-11-27 00:38:08
问题 (This is in principal a language-agnostic question, though in my case I am using ASP.NET 3.5) I am using the standard ASP.NET login control and would like to implement the following failed login attempt throttling logic. Handle the OnLoginError event and maintain, in Session, a count of failed login attempts When this count gets to [some configurable value] block further login attempts from the originating IP address or for that user / those users for 1 hour Does this sound like a sensible

Throttling Async Functions in Python Asyncio

☆樱花仙子☆ 提交于 2019-11-27 00:24:32
问题 I have a list of awaitables that I want to pass to the asyncio.AbstractEventLoop but I need to throttle the requests to a third party API. I would like to avoid something that waits to pass the future to the loop because in the meantime I block my loop waiting. What options do I have? Semaphores and ThreadPools will limit how many are running concurrently, but that's not my problem. I need to throttle my requests to 100/sec, but it doesn't matter how long it takes to complete the request.