0

I tried to make multiple subscriptions to a single user, to test out how many subscription requests i can send until throttling occurs. I used the following code:

for (int i = 0; i < 10000; i++)
{
      try
      {
            var request = graphClient.Subscriptions.Request();

            var result = await request.AddAsync(
            new Subscription
            {
                ChangeType = "created,updated,deleted",
                NotificationUrl = notificationUrl,
                Resource = "/users/" + userId + "/" + resource,
                ExpirationDateTime = DateTimeOffset.UtcNow.AddMinutes(4230),
                ClientState = "my-subscription-identifier"
            }
            );

            AddOutputMessage((i + 1) + " Created Webhook", Color.Blue);
      }
      catch (ServiceException serviceException)
      {
           AddOutputErrorMessage(serviceException);
      }
}

The throttling limit per user per app is 10000 in 10 minutes (as described in another stackoverflow post). I already tested this limit by making some requests to a single users calendar and contacts where it seems to work.

I was able to make 220 subscriptions until throttling occured (tested it three times). Even though that seems to be a little low, my end goal is to make multiple subscription requests for multiple users (for example 1000 subscriptions to a 1000 users), so it wouldn't be a problem if this throttling limit is for a single user only.

The throttling (HttpStatusCode 429) service exception for the subscriptions request also contained the error code 'ExtensionError' which i couldn't really find in the doc.ExtensionError

What i want to know is:

  • What are the throttling limits for the '/subscription endpoint'?
  • Especially after how many requests does throttling occur? (per user and overall per app) e.g. if i want to make subscriptions to 1000 users will i be throttled after 220?
  • What is an 'ExtensionError'?
Michael Hufnagel
  • 537
  • 1
  • 3
  • 13
  • What is the value of `resource` in this example? Some resources (i.e. AAD) have subscription limits: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/webhooks#azure-ad-resource-limitations – Marc LaFleur Jun 06 '18 at 14:26
  • The value of resource is events. – Michael Hufnagel Jun 06 '18 at 15:00

1 Answers1

1

ExtensionError is actually an OAuth error category. Expand the Message string to see if it has more info.

I'm checking with the code owners to see what the subscription limits for REST are.

  • Sry for the late response. The message string doesn't have a lot of additional info (see picture **Code: ExtensionError Message: Operation: Create; Exception: [Status Code: 429; Reason: ]Inner error**). The Reason is empty. Thank you for checking the limit. – Michael Hufnagel Jun 06 '18 at 06:49
  • I chatted with the team that owns the subscription foo in REST. CURRENTLY, callers are limited to 1000 active subscriptions *and* there is a rate limit for creating subscriptions. It seems you are hitting the latter. As with any other 429 you receive, check the Retry-After HTTP response header to see when you should retry your request. Note that the team indicated that they reserve the right to change those throttling limits depending on how much coffee they have had, so it is best to just honor the response headers rather than hardcode expectations in your app. – David Sterling - MSFT Jun 07 '18 at 16:31
  • Thank you for asking. Unfortunately the Retry-After header in the response always has the value 0 so i can't really use it. The [documentation](https://developer.microsoft.com/en-us/graph/docs/concepts/throttling) didn't list the "Subscription endpoint" when mentioning the endpoints which implement the Retry-After header so i thought it just wasn't implemented yet. – Michael Hufnagel Jun 08 '18 at 07:27
  • 1
    I will open up bug on our side for that. I know that the exception that is thrown by the notifications team has a back off time on it, so it seems that the rest team simply didn't forward that into the retry after header. Thank you for letting us know. – David Sterling - MSFT Jun 09 '18 at 15:19
  • I have a follow up question. Is caller in my case the app (since i use client credential authentication)? I just realised that the [graph doc](https://developer.microsoft.com/en-us/graph/docs/concepts/webhooks) mentions a limit of 50,000 subscriptions per app so i am kind of confused about which limit is correct. – Michael Hufnagel Jun 13 '18 at 10:34
  • The section you are referring to deal with limits around Azure AD. In this case, you are dealing with Exchange online which has the limits I mentioned above. – David Sterling - MSFT Jun 26 '18 at 21:47