Query optimization and API throttling
Asked Answered
T

1

6

We are tracking Facebook Page and Post metrics for a number of clients, and we have some questions regarding high CPU intensity and too many calls for Post/comments - according to what is being reported by the developer insights console (Insights -> Developer -> Activity & Errors). The documentation is somewhat unclear on the limits and restrictions for the Graph API, and we'd simply like to make sure we have the correct understanding of what resources we have available.

We are working on optimizing our software and queries to decrease the error rate and number of requests. Related to this work we have a few questions:

  1. We have changed to use FQL queries instead of regular Graph API requests for fetching Post comments, which enables us to fetch comments for several posts per request. This have lead to a significant decrease in number of requests. We use a query with page_id IN (PAGE_ID_1, PAGE_ID_2, ....). Will this increase the CPU intensity compared with a regular Graph API request?

  2. We have also implemented throttling of requests on our end to make sure we distribute our requests evenly over time and not in big bursts. For Page comments, we make sure the maximum number of request do not exceed 300 over a 10 minute period. In other words, we are limiting the number of Page comment requests to 0.5 per second or 30 per minute. Is this still to high?

  3. Once request limits are exceeded, we assume this is for an access token, not APP ID? So if one of our clients has been over-using resources, our APP will still continue working on behalf of our other clients which have different access tokens?

  4. In the developer console, under the Insights -> Developer -> Activity & Errors page for our app, the API Throttling table have a time above it. As an example 1 hour, 14 minutes. What does this time indicate, how often is this table updated, and how old are the numbers?

  5. We are getting a small amount of errors with response code 500. Are these errors typically a result of exceeding request and/or CPU limits? If not, are there any ways to determine what is actually causing them, and if there is something we can do on our end to fix it?

We'd appreciate any input on and confirmation of our assumptions.

Treasonous answered 18/12, 2012 at 12:11 Comment(1)
Consider updating your title to be framed as a question, and the body to contain a single question. Those changes could help attract an answer.Antonio
W
2

Some answers to your questions :

  • Facebook limit to graph API request is 600 request per 600 secondes... BUT batch requests are counted as ONE REQUEST per request in the batch... I think that FQL limits are the same...
  • This limit is for one IP and one access token, if you have many token and / or IP you can adjust this limit
  • I have no example actualy, but when you broke the speed limit the error message is something like 'too many request', not an error 500... no idea about whas can cause this in your case

Some questions I don't understand : - When you speak about "CPU intensity", do you mean on your side or FB side? On FB side I never see such a limit, the only one is 600 req / 600 sec...

For more informations : Facebook graph API rate limit and batch requests What's the Facebook's Graph API call limit?

Westernize answered 7/3, 2013 at 8:35 Comment(4)
If you look at Apps > YOUR APP > Insights > Activity & Errors under developers.facebook.com/apps, you will get API Throttling Errors and Warnings if you push your boundaries to much. The 3 types I have seen so far is: 'Too Many Calls', 'Calls Are Too CPU Intensive' and 'Calls Access Too Much Data'.Treasonous
I also had such messages, but in my case only 'warnings' no errors (at this time)... In our case we have a "speed regulator" locked at 300 request/600 seconds, so maybe it's why we don't have such messages as error, but just warning ?Westernize
CPU intensive is happening for APP Token only apparently. If you can, use Page Token or User Token as much as possible to spread the love :)Cosmonaut
the 600 requests / 600 seconds is not per token and per IP address. If you exceed this windowed rate limit, you will not be able to make more requests with the same token from a different IP address (I've tested this).Hugo

© 2022 - 2024 — McMap. All rights reserved.