Dealing with Rate Limits
If an API change doesn't get you, rate limits will. You'll probably only notice them if you're getting or sending any sort of traffic to or from Facebook.
A rate limit is a cap on the number of requests you can make to an API within a given time frame. For instance, depending on how often your app hits Facebook's API, they might keep you from accessing it very often. As I write this, Facebook returns a 600-transactions-per-600-seconds limit. You can't post any more than 600 requests in a 600-second time frame, per this rate limit. Rate limits keep developers from causing too much strain on Facebook's servers, and avoid spam among the Facebook user base. Unfortunately, Facebook doesn't publish the exact method of how it limits API calls. This is something you have to detect by reading the errors Facebook sends back to your application and handling them accordingly. You may also want to do some logging, so you can log the various rate limits your application may be hitting in order to adapt your application to meet those limits.
It is best to set some hard limits on your own and ensure that you don't exceed those limits. You could set it so that your application only posts to Facebook Platform 500 times in every 600-second time frame, for instance. It will be up to you to detect how often your application makes API calls and throttle that to a reasonable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access