Skip to content

How is the Resource Unit normalization for CSOM requests calculated to determine when app should be throttled? #10213

Open
@digiofficerobin

Description

@digiofficerobin

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

SharePoint online CSOM / REST API

Issue description

In chapter Application Throttling there is the following text:

SharePoint provides various APIs. Different APIs have different costs depending on the complexity of the API. The cost of APIs is normalized by SharePoint and expressed by resource units. Application’s limits are also defined using resource units.

We want to rate limit on the client side to avoid throttling by the server. Therefore we need to know how much each request will cost or has cost.

In particular we want to know Resource Unit of the following CSOM queries/actions:

  1. Context.Load(siteUsers, us => us.Include(u => u.Title, u => u.Id, u => u.LoginName, u => u.PrincipalType, u => u.Email, u => u.UserPrincipalName, u => u.AadObjectId));
  2. var refUserAsPrincipal = rootWeb.EnsureUser(logOnName);
  3. SecurableObjectSharePoint.Context.Load(refUserAsPrincipal, _user => _user.Email, _user => _user.LoginName);
  4. SecurableObjectSharePoint.ResetRoleInheritance();
  5. SecurableObjectSharePoint.BreakRoleInheritance(true, true);
  6. SecurableObjectSharePoint.Context.Load(SecurableObjectSharePoint, s => s.HasUniqueRoleAssignments);
  7. _spfile = ClientContext.Web.GetFileByUrl(AbsoluteUrl);
  8. ClientContext.Load(SPFile, f => f.TimeLastModified, f => f.Exists);
  9. ClientContext.Load(SPFile, f => f.Exists);
  10. ClientContext.Load(SPFile, f => f.Exists, f => f.TimeLastModified, f => f.MajorVersion, f => f.MinorVersion, f => f.Length, f => f.ListItemAllFields.Id, f => f.ListItemAllFields.ParentList.ForceCheckout, f => f.CheckOutType, f => f.CheckedOutByUser.UserPrincipalName, f => f.LockedByUser.UserPrincipalName, f => f.ListItemAllFields.HasUniqueRoleAssignments);
  11. ClientContext.Load(SPFile, f => f.ListItemAllFields.RoleAssignments.Include(rs => rs.Member, rs => rs.RoleDefinitionBindings.Include(rdb => rdb.RoleTypeKind, rdb => rdb.Name)));
  12. ClientContext.Load(member, u => u.AadObjectId);
  13. ClientContext.Load(SPFile, f => f.Exists, f => f.ListItemAllFields.ParentList.Fields.Include(fld => fld.InternalName, fld => fld.FieldTypeKind), f => f.ListItemAllFields);
  14. ClientContext.Load(web, s => s.ServerRelativeUrl);
  15. ClientContext.Load(checkedoutedFile, f => f.Where(fi => fi.ServerRelativePath.DecodedUrl == fileRelativeUrl).Include(fi => fi.CheckedOutBy.Email));
  16. SPFile.CheckIn(comment, (CheckinType)checkinType);
  17. SPFile.CheckOut();
  18. SPFile.UndoCheckOut();
  19. SPFile.DeleteObject();
  20. var mstream = SPFile.OpenBinaryStream();
  21. ClientContext.Load(SPFile, r => r.ListItemAllFields.HasUniqueRoleAssignments);
  22. ClientContext.Load(SPFile, r => r.ListItemAllFields.ParentList.ParentWeb.RoleDefinitions.Where(rd => !(rd.RoleTypeKind == RoleType.Guest || rd.RoleTypeKind == RoleType.RestrictedGuest)).Include(rd => rd.Name, rd => rd.BasePermissions, rd => rd.RoleTypeKind));
  23. ClientContext.Load(SPFile, r => r.ListItemAllFields.RoleAssignments.Include(ra => ra.Member.LoginName, ra => ra.Member.PrincipalType, ra => ra.Member.Id, ra => ra.RoleDefinitionBindings.Include(rdb => rdb.Id, rdb => rdb.RoleTypeKind, rdb => rdb.Name)));
  24. ClientContext.Load(SPFile, _file => _file.Exists, _file => _file.ListItemAllFields.ParentList.Fields.Include(_field => _field.InternalName, _field => _field.ReadOnlyField, _field => _field.FieldTypeKind), _file => _file.ListItemAllFields.ContentType.Name);
  25. var uploadFile = folder.Files.Add(newfile); ClientContext.Load(uploadFile);
  26. bytesUploaded = uploadFile.StartUpload(uploadId, startStream);
  27. uploadFile = uploadFile.FinishUpload(uploadId, fileoffset, finishStream);
  28. bytesUploaded = uploadFile.ContinueUpload(uploadId, fileoffset, continueStream);
  29. uploadFile.CancelUpload(uploadId);
  30. site.Context.Load(oWeb, w => w.Title, w => w.Language, w => w.Url, w => w.Navigation.UseShared, w => w.Description, w => w.AllProperties, w => w.HasUniqueRoleAssignments, w => w.ServerRelativeUrl, w => w.Id);
  31. site.Context.Load(oWeb, w => w.RoleAssignments.Include(ra => ra.Member.LoginName, ra => ra.Member.Id, ra => ra.RoleDefinitionBindings.Include(rdb => rdb.Id, rdb => rdb.RoleTypeKind, rdb => rdb.Name)));
  32. site.Context.Load(oWeb, r => r.RoleDefinitions.Where(rd => !(rd.RoleTypeKind == RoleType.Guest || rd.RoleTypeKind == RoleType.RestrictedGuest)).Include(rd => rd.Id, rd => rd.Name, rd => rd.BasePermissions, rd => rd.RoleTypeKind));

We want also know the points for more complex calls/actions, such as creating or updating lists, contenttypes, lists, site columns.

We now have made estimations what each call will probably costs based on the Graph API call costs table with values 1,2 or 5

If there is a way to return the actual resource unit costs of each action/query in the response headers, that would be awesome. We then can implement rate limiting on the client side with actual values.

The Metered API charges on price per 1000 requests (thus not on points). We therefore cannot use the metered (pay-per-use) API to determine the points per request.

Can you assist us to clarify the Resource Unit costs of the CSOM operations/queries?

Metadata

Metadata

Assignees

Labels

area:throttlingCategory: SharePoint Online throttling (HTTP status 429)feature-requestRequest for a new feature.sharepoint-developer-supportsharepoint-developer-supporttype:uservoice-requestEnhancements & feature requests should be posted: http://aka.ms/sp-dev-uservoice

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions