Messenger Platform Limit Error (#613) Calls to this api have exceeded the rate limit
Asked Answered
A

2

7

I'm having trouble stress testing my app with the Messenger Platform to send the same message to several users in a small timeframe. I'm getting a Limit Error: (#613) Calls to this api have exceeded the rate limit.

Currently I'm testing this by sending the same message several times to the same user (me); in a real world scenario, the same message would be sent to several different users of course.

Also, I'm using a test application of a live app to perform these tests. Is this supposed to drastically improve in the live app?

I really need a nice throughput broadcasting messages, so currently my setup has several threads spawn (50) sending messages in parallel, some of them already hit this limit and error out. Also, I tried the Batch Requests to improve the speed of the delivery process, and at that point it really becomes unbearable, with a success rate of less than 50%.

I've read about general Graph API rate limits (https://developers.facebook.com/docs/graph-api/advanced/rate-limiting), and to send a message you provide a Page Access Token, so I would expect my app to fall into the "Page-Level Rate Limiting" category, if I was sending too many messages. However, in the error responses there are no X-Page-Usage headers (neither X-App-Usage, by the way).

In the Messenger Platform documentation (https://developers.facebook.com/docs/messenger-platform/send-api-reference#limits) the following is stated:

Messenger Platform supports a high rate of calls to the Send API.

However, you should architect your system such that you distribute any sudden high amounts of load over time and are able to control your throughput should you hit our rate limits.

Rate limits are in place to prevent malicious behavior and poor user experiences.

Be sure to catch any errors returned by the Send API including the one indicating that you've reached the rate limit.

These are not particularly helpful either, since they don't explicitly refer to the general Graph API limits neither specify a different amount of requests you're allowed to perform.

Is there anything that I might be missing?

Anatase answered 13/6, 2017 at 11:50 Comment(5)
"you should architect your system such that you distribute any sudden high amounts of load over time and are able to control your throughput should you hit our rate limits" - what exactly is the problem with that? You realize you are hitting the limits, because the API is returning this error message ... so it is time to set the $slowThisShitDown flag in your application.Orlosky
Yes, but that is still vary vague. The headers I mentioned are in place exactly so that your app can adjust itself based on the current usage of the sliding window that Facebook uses to limit your Graph API requests. So if the send API does not provide it, you won't be able to nicely distribute your workload based on real usage. I'm afraid that this API is not using the same rate limiting concept, but it would be nice to have a value other than "a high rate of calls".Anatase
You can always file a documentation bug, and ask them to clarify if something is unclear or missing. I am not sure whether the Send API is supposed to send those response headers as well, but agree it would only make sense. So I’d ask them whether it is supposed to do that, and if not that the documentation should at least explicitly mention that. developers.facebook.com/bugsOrlosky
Yes, did that in the meantime. I think that either the limit should be public or the headers should be provided according to the remaining endpoints of the Graph API. Thank you.Anatase
I am also encountering this error even if I've already distributed the bot messaging to 500 users per 3 minutes. I am sending an article to subscribed users every morning but some users could not receive the article because of this limit. I also could not find a particular number to meet to not hit this limit (e.g. 10 request / second). That simple number explanation will do.Grilled
K
0

The latest document from Facebook clearly lists out 250 calls per second for the SendAPI.

The Send API does not have a fixed rate limit, but you can safely send 250 requests per second.

More info here: https://developers.facebook.com/docs/messenger-platform/send-messages#limits

Kahler answered 6/4, 2018 at 9:46 Comment(0)
G
0

To answer your question, "Is this supposed to drastically improve in the live app?"

No, there's not a difference between the test app and live app for this case. My application is already live and I'm also encountering this error.

And I agree that our case should've fallen to "Page-Level Rate Limiting" because we are using a Page Access Token. But then, I'm not receiving any error related to Page-Level Limiting. And my app dashboard doesn't show API Limit hit either. So it's just really the 613 - Custom Level Throttling that's all I have and FB just says "Contact your Partner Manager"

=========================================================================

I have solved this. Based from what the FB support said, "You are being rate-limited for calling the Send API too fast", I set a delay on the Send API requests to 200ms using setTimeout(). At the rate of 10 messages / second, I am not hitting the limit anymore. No error 613 at all. I will gradually increase this rate to find the ideal scenario since Facebook won't formally document it. Will keep you posted of the experiments.

Grilled answered 23/8, 2017 at 12:52 Comment(2)
Actually, since the initial post I opened a bug in Facebook's issue tracker: developers.facebook.com/bugs/379288625806177. Not very much information to add from there. However, we have now some live clients with big pages (~10M likes) and with less than 10k bot users right now, we are able to send about 100 messages/sec. So I would risk saying that engagement % also influences this custom level throttling.Anatase
Our page have 15M likes and 90k subscribers. 100 messages / second is hitting the limit. I know it is based on the Page Engaged Users and I believe we have a high number on that.Grilled
K
0

The latest document from Facebook clearly lists out 250 calls per second for the SendAPI.

The Send API does not have a fixed rate limit, but you can safely send 250 requests per second.

More info here: https://developers.facebook.com/docs/messenger-platform/send-messages#limits

Kahler answered 6/4, 2018 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.