Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph API rate limit and batch requests

I've seen the 600 calls / 600 seconds rate limit mentioned by some (e.g. on quora).

What I want to know is whether I am allowed to do 600 batch requests in 600 secs (a batch request consists of up to 50 requests).

like image 981
daremon Avatar asked Jan 10 '12 14:01

daremon


4 Answers

You should handle the rate limiting programmatically by checking for the following error message. You should then put in a time-wait loop before your next call if you encounter the error. One of my high traffic applications accounts watches for this error and will slow down.

From: https://developers.facebook.com/docs/bestpractices/

Rate limited (API_EC_TOO_MANY_CALLS) If your application is making too many calls, the API server might rate limit you automatically, returning an "API_EC_TOO_MANY_CALLS" error. Generally, this should not happen. If it does, it is because your application has been determined to be making too many API calls. Iterate on your code so you're making as few calls as possible in order to maintain the user experience needed. You should also avoid complicated FQL queries. To understand if your application is being throttled, go to Insights and click "Throttling".

edit

As reported by Igy in the comment thread, each request in that batch counts as 1. For your example of 600 being the max limit, that means you can fire off 15 batch requests containing 50 calls each.

like image 142
DMCS Avatar answered Nov 08 '22 00:11

DMCS


According to FB docs, each element in a batch counts as a separate call.

We currently limit the number of requests which can be in a batch to 50, but each call within the batch is counted separately for the purposes of calculating API call limits and resource limits. For example, a batch of 10 API calls will count as 10 calls and each call within the batch contributes to CPU resource limits in the same manner.

Quoted from: https://developers.facebook.com/docs/reference/api/batch/

I don't have empirical evidence however.

David

like image 40
Marquez Avatar answered Nov 07 '22 23:11

Marquez


From my experience, they count individual requests regardless the way they were made (in batch or not).

For example, if I'm trying to do 1 batch/sec containing 10 requests each, I soon get 'TOO MANY CALLS'.

If I'm doing 1 batch/10 sec, each batch containg 10 requests, I never see TOO MANY CALLS.

I personally do not see any reason to prefer batches over regular API calls.

like image 6
Niki Tonsky Avatar answered Nov 08 '22 01:11

Niki Tonsky


I have quite a big and painful experience now with the Facebook API and I can state that :

  • If a batch request contains 50 requests, then it counts as 50 requests on Facebook
  • 1 request != 1 call. Facebook has its own definition of what a call is. If your request is big, return a lot of data or consume a lot of cpu then it will count as several calls.

The most frequent graph API call I am doing contains a lot of nested fields and I have noticed that I reached the "600 calls / 600 seconds" after doing it only 200 times. So basically this call count for 3 in my case...

You have a lot of other rate limits but none of of them are properly documented...

like image 5
tibo Avatar answered Nov 08 '22 01:11

tibo