21

What constitutes abuse?

Making an undue number of requests in a short span of time, or regularly exceeding a request quota during "normal" use.

Guidelines for polling

We realize that a great many applications will need to regularly make calls to see if some event has occurred on one of the Trilogy sites.

Examples:

  • A user gained/lost reputation
  • A question was answered
  • New questions - in general, or within a tag or a search query - were posted
  • ... and many more

However, polling can incur considerable overhead especially if done too aggressively. So, to lay down some hard guidelines...

If you're application is making identical requests more than once a minute it is probably going to be considered abusive.

Another way to think of it, if you're using more than 15% of your daily request quota simply polling for new activity you're being needlessly aggressive.

What constitutes an "identical" request?

Exactly the same method and query parameters. You don't need to wait a minute before fetching the 2nd page of a request, for example, but you do need to wait a minute between calls to say the /questions method.

Glorfindel
  • 6,772
  • 3
  • 20
  • 46
Kevin Montrose
  • 18,660
  • 6
  • 34
  • 62
  • 1
    What if the requests are only triggered by user activity? For example: a refresh button for /questions results. Is allowing a manual refresh considered abusive? I can imagine some users tapping it way more than once per minute. Do we need to put a throttle on these types of things? – TM. Jun 27 '10 at 22:14
  • @T M - yes, you should throttle those requests. If a user is going out of there way to defeat your throttling, that's a different matter. – Kevin Montrose Jun 27 '10 at 23:01
  • @T M - perhaps a caching buffer proxy class in between the generation of the URL and the actual request would help. when a request is made it is passed to the buffer, buffer checks the cached for a similar request less than 1 minute old and returns it if found, otherwise make the request and cache the results before returning it. – Sky Sanders Jun 29 '10 at 01:25
  • any considering for adding webhooks to avoid polling? – Eric Bloch Dec 01 '10 at 01:57

5 Answers5

11

Another scenario to consider is testing. Granted tests shouldn't really be hitting the service that hard but I know for my library I have at least 50 integration test that when run all at once would it the /questions method with the same parameters many times in a minute. These requests are done anonymously (with no api key) so I am not sure if you treat those differently.

One thing you didn't cover in your post is what the penalty is for being too aggressive or if any action is taken at all against such apps.

lfoust
  • 6,075
  • 3
  • 17
  • 15
  • Well, I ran into the problem tonight of having my IP run out of anonymous request due to integration testing with my library. The only solution I have is to include an API key as part of my libraries tests. – lfoust Jun 17 '10 at 04:07
5

Another good way to be conscientious to the API is think about timing. If your app has certain peaks hours, slow down on the calls after hours (If 75% of users are US, run at 1 call/min from 9-5, and 1 call/5 min the rest of the time)

The same goes vice-versa. If your application isn't completely reliant on up-to-minute data during the day, slow down on the requests during the day and then do your heavy lifting during off-hours. That way it leaves room for applications that are reliant on up-to-minute data. (Statistics Applications, as well as other apps that generalize data come to mind)

As Code Poet pointed out, technically users are using the site 24/7 because the site is fairly global, but realistically speaking, there are definitely off-peak hours. Maybe at some point the devs can share those off-hours with us so we can adjust accordingly to spread out the load.

Tyler Carter
  • 5,054
  • 1
  • 14
  • 11
  • even back when I was screen scraping user pages for indexing purposes, I did it @ 3am my time, which, granted is an arbitrary time considering the global nature of the sites, but I suspect the majority of users are on my continent. ;-)
  • – Sky Sanders Jun 06 '10 at 06:53