question

ReniK-9973 avatar image
0 Votes"
ReniK-9973 asked saldana-msft edited

MS Graph SDK Teams request limit

I am using graph sdk for integrating to Teams.
I had a couple of questions with regards to throttling and chat creation

1) I see there is in built throttling handling per your docs for graph sdk and I am using the sdk and the default retry handler.
There doesn't seem to be much info about throttling for POST /chats/{chat-id}/messages, but I do see POST /chats/{chat-id}/sendActivityNotification is 20 rps Assuming this is same, I am getting throttled and my retries are failing when I even try 2 chats per second.
https://docs.microsoft.com/en-us/graph/throttling#microsoft-teams-service-limits
This below error is what I got when I removed the default retry handler.
Code: TooManyRequests
Message: UnknownError
Inner error:
AdditionalData:
date: 2022-04-15T15:00:34
request-id: 7d95abb9-9260-4a68-8f77-3e62632638b2
client-request-id: 7d95abb9-9260-4a68-8f77-3e62632638b2
ClientRequestId: 7d95abb9-9260-4a68-8f77-3e62632638b2
With Retry handler it fails with Service Exception occurred while sending direct IM. Details: Code: tooManyRetries
Message: More than 1 retries encountered while sending the request.
Is there a specific limit I should keep to for this from not happening? I think 2 ims per second is an okay limit. I am not sure what I may be doing wrong.
2)For single chats, should there be reuse of chati ds? There is no guidance in weather or not creating a new chat Id when trying to send an IM is a bad practise. If I wanted to send an IM to a person 10 times, should I do that with same chat id? Is there a benefit in using a single chat Id for these 10 IMS. Or rather it doesn't matter if there are 10 new chats created? Could you add guidance on this in your documentation as well?

microsoft-graph-sdkmicrosoft-graph-throttling
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sheena-MSFT avatar image
0 Votes"
Sheena-MSFT answered

Hi @ReniK-9973,

When it comes to MS Graph API throttling we suggest:

  • Reduce the number of operations per request.

  • Reduce the frequency of calls.

  • Avoid immediate retries, because all requests accrue against your usage limits.

There are some best practices to avoid the throttling while using the Graph API requests.

  • Wait the number of seconds specified in the Retry-After header.

  • Retry the request.
    -If the request fails again with a 429 error code, you are still being throttled. Continue to use the recommended Retry-After delay and retry the request until it succeeds.

If noRetry-After header is provided by the response, we recommend implementing an exponential backoff retry policy. You can also implement more advanced patterns when building large-scale applications.

Refer this document for more information throttling

Also, we have some service specific limits in regards with different O365 workloads. Please refer this Microsoft document for this throttling

JSON batching allows you to optimize your application by combining multiple requests into a single JSON object. Please refer this documentation for more information on batching throttling

If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ReniK-9973 avatar image
0 Votes"
ReniK-9973 answered ReniK-9973 commented

Hi Sheena,
Thanks for the info and I do see there are these guidelines, but we use the graph sdk and these are handled by MS Graph sdk per your documentation.
https://docs.microsoft.com/en-us/graph/throttling
"Note

If no Retry-After header is provided by the response, we recommend implementing an exponential backoff retry policy. You can also implement more advanced patterns when building large-scale applications.

Microsoft Graph SDKs already implement handlers that rely on the Retry-After header or default to an exponential backoff retry policy."

I am looking for a bit more in depth help specifically for Teams rather than the generic api throttling guidance.
Could you advise on MSTeams throttling especially when there seems to be a 20rps for a single application?

Also could you kindly address this one as well?
2)For single chats, should there be reuse of chat ids? There is no guidance in whether or not creating a new chat Id when trying to send an IM is a bad practice. If I wanted to send an IM to a person 10 times, should I do that with same chat id? Is there a benefit in using a single chat Id for these 10 IMs. Or rather it doesn't matter if there are 10 new chats created for the one-onone chats? Could you add guidance on this in your documentation as well?
Thank you
Reni

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Just checking back in to see if you have any further suggestions for this. @Sheena-MSFT

0 Votes 0 ·