Query optimization and API throttling

2020-05-28 11:10发布

问题:

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.

回答1:

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?