You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Find out about throttling in SharePoint Online, and learn how to avoid being throttled or blocked. Includes sample CSOM and REST code you can use to make your task easier.
11
11
12
12
-[What is throttling?](how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online.md#BKMK_Whatisthrottling)
13
-
14
-
13
+
15
14
-[Common throttling scenarios in SharePoint Online](how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online.md#BKMK_Commonthrottlingscenarios)
16
-
17
-
15
+
18
16
-[Why can't you just tell me the exact throttling limits?](how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online.md#BKMK_Whycantyoujusttellmetheexactthrottlinglimits)
19
-
20
-
17
+
21
18
-[Best practices to handle throttling](how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online.md#BKMK_Bestpracticestohandlethrottling)
22
19
20
+
-[How to decorate your traffic to avoid getting throttled?](how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online.md#BKMK_DecorateSharePointOnlineThrottling)
Does this sound familiar? You're running a CSOM process - for example, to migrate files in SharePoint Online - but you keep getting throttled. Or even worse, you get completely blocked. What's going on and what can you do to make it stop?
35
31
36
-
37
-
38
-
39
-
40
32
## What is throttling?
41
33
<aname="BKMK_Whatisthrottling"> </a>
42
34
43
35
SharePoint Online uses throttling to maintain optimal performance and reliability of the SharePoint Online service. Throttling limits the number of user actions or concurrent calls (by script or code) to prevent overuse of resources.
44
36
45
-
46
-
47
37
That said, it is extremely rare for a user to get throttled in SharePoint Online. The service is robust, and it is designed to handle very high volume. If you do get throttled, 99% of the time it is because of custom code. That doesn't mean that there aren't other ways to get throttled, just that they are less common. For example you spin up 10 machines and have a sync client going on all 10. On each sync 1TB of content. This would likely get you throttled.
### What happens when you get throttled in SharePoint Online?
61
43
62
44
When a user exceeds usage limits, SharePoint Online throttles any further requests from that user account for a short period. All user actions are throttled while the throttle is in effect.
63
45
64
-
65
-
66
-
67
46
- For requests that a user performs directly in the browser, SharePoint Online redirects you to the throttling information page, and the requests fail.
68
-
69
47
70
48
- For all other requests, including CSOM or REST calls, SharePoint Online returns HTTP status code 429 ("Too many requests"), and the requests fail.
71
-
72
49
73
50
If the offending process continues to exceed usage limits, SharePoint Online might completely block the process; in this case, you may see HTTP status code 503 ("Service unavailable"), and we'll notify you of the block in the Office 365 Message Center. The error message is shown below:
74
-
75
-
76
-
77
-
78
-
79
-
80
-
51
+
81
52

82
-
83
-
84
-
53
+
85
54
503 Server unavailable message.
86
-
87
-
88
-
89
55
90
56
## Common throttling scenarios in SharePoint Online
91
57
<aname="BKMK_Commonthrottlingscenarios"> </a>
92
58
93
59
The most common causes of per-user throttling in SharePoint Online are client-side object model (CSOM) or Representational State Transfer (REST) code that performs too many actions too frequently.
94
-
95
-
96
60
97
61
98
62
-**Sporadic traffic**
@@ -103,50 +67,32 @@ The most common causes of per-user throttling in SharePoint Online are client-si
A single process dramatically exceeds throttling limits, continually, over a long time period.
113
73
114
74
- You used web services to build a tool to synchronize user profile properties. The tool updates user profile properties based on information from your line-of-business (LOB) human resources (HR) system. The tool makes calls at too high a frequency.
115
-
116
75
117
76
- You're running a load-testing script on SharePoint Online and you get throttled. Load testing is not allowed on SharePoint Online.
118
-
119
77
120
78
- You customized your team site on SharePoint Online, for example, by adding a status indicator on the Home page. This status indicator updates frequently, which causes the page to make too many calls to the SharePoint Online service - this triggered throttling.
Setting and publishing exact throttling limits sounds very straightforward, but in fact, it's not the best way to go. We continually monitor resource usage on SharePoint Online. Depending on usage, we fine-tune thresholds so users can consume the maximum number of resources without degrading the reliability and performance of SharePoint Online. That's why it's so important for your CSOM or REST code to include incremental back off to handle throttling; this lets your code run as fast as possible on any given day, and it lets your code back off "just enough" if it hits throttling limits. The code samples later in this article show you how to use incremental back off.
- Decorate your traffic so we know who you are (see section on traffic decoration best practice more on that below)
148
95
149
-
150
96
If you do run into throttling, we recommend incremental back off to reduce the number and frequency of calls until no more throttling occurs.
151
97
152
98
Incremental back off uses progressively longer waits between retries before trying again to run the code that was throttled. You can use the GitHub code samples, later in this article, written as extension methods, to add incremental back off to your code.
@@ -158,6 +104,7 @@ For information about ways to monitor your SharePoint Online activity, see [Dia
158
104
For a broader discussion of throttling on the Microsoft Cloud, see [Throttling Pattern](http://msdn.microsoft.com/library/4baf5af2-32fc-47ab-8569-3e5c59a5ebd5.aspx).
159
105
160
106
## How to decorate your http traffic to avoid throttling?
To ensure and maintain high-availability, some traffic may be throttled. Throttling happens when system health is at stake and one of the criteria used for throttling is traffic decoration, which impacts directly on the prioritization of the traffic. Well decorated traffic will be prioritized over traffic which is not properly decorated.
163
110
@@ -244,29 +191,19 @@ Before you run this code sample:
244
191
245
192
**Core.Throttling** runs as a console application using a user-only authorization policy, which means this code sample uses the permissions of the current user. In the **Main** method in Program.cs, a while loop repeatedly creates new folders in the test document library. A call is then made to **ctx.ExecuteQueryWithExponentialRetry**, which uses CSOM to perform the **ExecuteQuery** method. **ExecuteQueryWithExponentialRetry** is an extension method on the [ClientContext](https://msdn.microsoft.com/library/office/microsoft.sharepoint.client.clientcontext%28v=office.15%29.aspx) object, and is defined in **ClientContextExtension.cs**.
246
193
247
-
248
-
194
+
249
195
If SharePoint Online throttles the **ExecuteQuery** statement, **ExecuteQueryWithIncrementalRetry** starts the incremental back off technique by:
250
-
251
-
252
-
253
196
254
197
- Catching a **WebException** and checking the **HttpWebResponse.StatusCode**. If SharePoint Online throttled the **ExecuteQuery** statement, the **HttpWebResponse.StatusCode** is 429.
255
-
256
-
198
+
257
199
- The current thread is suspended for the period specified in **backoffInterval**.
258
-
259
-
200
+
260
201
- When the current thread resumes, the **backoffInterval** is doubled and the number of retries performed ( **retryAttempts** ) is incremented. By doubling **backoffInterval** your code suspends activity for a longer period of time before retrying the code that was throttled by SharePoint Online.
261
-
262
-
202
+
263
203
- The process is repeated until either the **ExecuteQuery** statement is successful, or the number of allowed retries ( **retryCount** ) is exceeded.
264
-
265
-
266
204
267
205
### CSOM Code sample: Incremental back off and retry (calls ExecuteQueryWithIncrementalRetry method, later in this article)
268
206
269
-
270
207
```
271
208
272
209
using (var ctx = new ClientContext(serverUrl))
@@ -352,24 +289,13 @@ public static void ExecuteQueryWithIncrementalRetry(this ClientContext context,
352
289
353
290
Blocking is the most extreme form of throttling. We rarely ever block a tenant, unless we detect long-term, extremely excessive traffic that may threaten the overall health of the SharePoint Online service. We apply blocks to prevent excessive traffic from degrading the performance and reliability of SharePoint Online. A block - which is usually placed at the tenancy level - prevents the offending process from running until you fix the problem. If we block your subscription, you must take action to modify the offending processes before the block can be removed.
354
291
355
-
356
-
357
292
If we block your subscription, you'll see HTTP status code 503, and we'll notify you of the block in the Office 365 Message Center. The message describes what caused the block, provides guidance on how to resolve the offending issue, and tells you who to contact to get the block removed.
358
293
359
-
360
-
361
-
362
294
## Additional resources
363
295
<aname="BKMK_Additionalresources"> </a>
364
296
365
-
366
297
-[Diagnosing performance issues with SharePoint Online](https://support.office.com/en-us/article/3c364f9e-b9f6-4da4-a792-c8e8c8cd2e86)
367
-
368
298
369
299
-[Capacity planning and load testing SharePoint Online](http://msdn.microsoft.com/library/22fa7e7e-7554-4987-b56f-b39bbf303a0a.aspx)
0 commit comments