What is the best way to deal with HTTP 429 - Throttled - requests with PnP ? #62
-
I have a script where I iterate through 22k items in a CSV file and update document sets for each item. So I'm basically repeatedly calling
However, every now and then the operation fails with HTTP 429 - Too Many Requests. Is there a standard way of capturing this and identifying the Wait/Retry time which I understand would be in the response header. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 24 replies
-
In principle there is nothing you need to do to handle 429s. PnP PowerShell makes use of the PnP Framework behind the scenes where we override way CSOM work with it comes to executing requests. We implemented an incremental backoff flow which means that if a 429 comes in we initially wait 0.5 seconds. Then we try again. If it still fails, we wait 2x0.5 seconds, then 2, then 4, then 8, then 16, 32, 64, 128, 256 seconds. We try up to a maximum of 10 times before giving up. That means that maximum wait time before we give up is 512 seconds, meaning more than 8 minutes. This delay has shown to handle the throttling errors is almost every case. We have seen that this covers throttling nicely. Do you by any change in your script run other cmdlets not coming from PnP PowerShell, as all PnP PowerShell cmdlets use the throttling handling mechanism I just described? |
Beta Was this translation helpful? Give feedback.
-
Literally just "Set-PnPListItem" over and over .. I randomly get 429 errors ... |
Beta Was this translation helpful? Give feedback.
-
How do you connect to your tenant (e.g. what connection method/parameters do you use)? And which version of PnP PowerShell do you use? The 'legacy' version (SharePointPnPPowerShellOnline) or the new PnP.PowerShell version? |
Beta Was this translation helpful? Give feedback.
-
Apologize for opening an old thread :)
|
Beta Was this translation helpful? Give feedback.
In principle there is nothing you need to do to handle 429s. PnP PowerShell makes use of the PnP Framework behind the scenes where we override way CSOM work with it comes to executing requests. We implemented an incremental backoff flow which means that if a 429 comes in we initially wait 0.5 seconds. Then we try again. If it still fails, we wait 2x0.5 seconds, then 2, then 4, then 8, then 16, 32, 64, 128, 256 seconds. We try up to a maximum of 10 times before giving up. That means that maximum wait time before we give up is 512 seconds, meaning more than 8 minutes. This delay has shown to handle the throttling errors is almost every case. We have seen that this covers throttling nicely.
D…